Index: lang/english.txt =================================================================== --- lang/english.txt (revision 5934) +++ lang/english.txt (working copy) @@ -1006,6 +1006,7 @@ STR_CONFIG_PATCHES_JOINSTATIONS :{LTBLUE}Join train stations built next to each other: {ORANGE}{STRING1} STR_CONFIG_PATCHES_FULLLOADANY :{LTBLUE}Leave station when any cargo is full, if 'full load': {ORANGE}{STRING1} STR_CONFIG_PATCHES_IMPROVEDLOAD :{LTBLUE}Use improved loading algorithm: {ORANGE}{STRING1} +STR_CONFIG_PATCHES_GRADUAL_LOADING :{LTBLUE}Load vehicles gradually: {ORANGE}{STRING1} STR_CONFIG_PATCHES_INFLATION :{LTBLUE}Inflation: {ORANGE}{STRING1} STR_CONFIG_PATCHES_SELECTGOODS :{LTBLUE}Deliver cargo to a station only when there is a demand: {ORANGE}{STRING1} STR_CONFIG_PATCHES_LONGBRIDGES :{LTBLUE}Allow building very long bridges: {ORANGE}{STRING1} Index: table/engines.h =================================================================== --- table/engines.h (revision 5934) +++ table/engines.h (working copy) @@ -15,7 +15,7 @@ * @param e Rail Type of the vehicle * @param f Bitmask of the climates */ -#define MK(a, b, c, d, e, f) { a, b, c, d, e, f, 0, 8, 0, 0 } +#define MK(a, b, c, d, e, f) { a, b, c, 5, d, e, f, 0, 8, 0, 0 } /** Writes the properties of a train carriage into the EngineInfo struct. * @see EngineInfo * @param a Introduction date @@ -23,7 +23,11 @@ * @param f Bitmask of the climates * @note the 0x80 in parameter b sets the "is carriage bit" */ -#define MW(a, b, c, d, e, f) { a, b | 0x80, c, d, e, f, 0, 8, 0, 0 } +#define MW(a, b, c, d, e, f) { a, b | 0x80, c, 5, d, e, f, 0, 8, 0, 0 } +/** Writes the properties of a ship into the EngineInfo struct. */ +#define MS(a, b, c, d, e, f) { a, b, c, 10, d, e, f, 0, 8, 0, 0 } +/** Writes the properties of an aeroplane into the EngineInfo struct. */ +#define MA(a, b, c, d, e, f) { a, b, c, 20, d, e, f, 0, 8, 0, 0 } // Rail types // R = Conventional railway @@ -248,57 +252,57 @@ MK( 5479, 20, 15, 55, 0, Y), /* 201 MightyMover Bubble Truck */ MK( 20970, 20, 15, 55, 0, Y), /* 202 Powernaught Bubble Truck */ MK( 33023, 20, 15, 85, 0, Y), /* 203 Wizzowow Bubble Truck */ - MK( 2922, 5, 30, 50, 0, T|A|S ), /* 204 MPS Oil Tanker */ - MK( 17167, 5, 30, 90, 0, T|A|S ), /* 205 CS-Inc. Oil Tanker */ - MK( 2192, 5, 30, 55, 0, T|A|S ), /* 206 MPS Passenger Ferry */ - MK( 18628, 5, 30, 90, 0, T|A|S ), /* 207 FFP Passenger Ferry */ - MK( 17257, 10, 25, 90, 0, T|A|S ), /* 208 Bakewell 300 Hovercraft */ - MK( 9587, 5, 30, 40, 0, Y), /* 209 Chugger-Chug Passenger Ferry */ - MK( 20544, 5, 30, 90, 0, Y), /* 210 Shivershake Passenger Ferry */ - MK( 2557, 5, 30, 55, 0, T|A|S ), /* 211 Yate Cargo ship */ - MK( 19724, 5, 30, 98, 0, T|A|S ), /* 212 Bakewell Cargo ship */ - MK( 9587, 5, 30, 45, 0, Y), /* 213 Mightymover Cargo ship */ - MK( 22371, 5, 30, 90, 0, Y), /* 214 Powernaut Cargo ship */ - MK( 2922, 20, 20, 20, 0, T|A|S ), /* 215 Sampson U52 */ - MK( 9922, 20, 24, 20, 0, T|A|S ), /* 216 Coleman Count */ - MK( 12659, 20, 18, 20, 0, T|A|S ), /* 217 FFP Dart */ - MK( 17652, 20, 25, 35, 0, T|A|S ), /* 218 Yate Haugan */ - MK( 4929, 20, 30, 30, 0, T|A|S ), /* 219 Bakewell Cotswald LB-3 */ - MK( 13695, 20, 23, 25, 0, T|A|S ), /* 220 Bakewell Luckett LB-8 */ - MK( 16341, 20, 26, 30, 0, T|A|S ), /* 221 Bakewell Luckett LB-9 */ - MK( 21395, 20, 25, 30, 0, T|A|S ), /* 222 Bakewell Luckett LB80 */ - MK( 18263, 20, 20, 30, 0, T|A|S ), /* 223 Bakewell Luckett LB-10 */ - MK( 25233, 20, 25, 30, 0, T|A|S ), /* 224 Bakewell Luckett LB-11 */ - MK( 15371, 20, 22, 25, 0, T|A|S ), /* 225 Yate Aerospace YAC 1-11 */ - MK( 15461, 20, 25, 25, 0, T|A|S ), /* 226 Darwin 100 */ - MK( 16952, 20, 22, 25, 0, T|A|S ), /* 227 Darwin 200 */ - MK( 17227, 20, 25, 30, 0, T|A|S ), /* 228 Darwin 300 */ - MK( 22371, 20, 25, 35, 0, T|A|S ), /* 229 Darwin 400 */ - MK( 22341, 20, 25, 30, 0, T|A|S ), /* 230 Darwin 500 */ - MK( 27209, 20, 25, 30, 0, T|A|S ), /* 231 Darwin 600 */ - MK( 17988, 20, 20, 30, 0, T|A|S ), /* 232 Guru Galaxy */ - MK( 18993, 20, 24, 35, 0, T|A|S ), /* 233 Airtaxi A21 */ - MK( 22401, 20, 24, 30, 0, T|A|S ), /* 234 Airtaxi A31 */ - MK( 24472, 20, 24, 30, 0, T|A|S ), /* 235 Airtaxi A32 */ - MK( 26724, 20, 24, 30, 0, T|A|S ), /* 236 Airtaxi A33 */ - MK( 22005, 20, 25, 30, 0, T|A|S ), /* 237 Yate Aerospace YAe46 */ - MK( 24107, 20, 20, 35, 0, T|A|S ), /* 238 Dinger 100 */ - MK( 29310, 20, 25, 60, 0, T|A|S ), /* 239 AirTaxi A34-1000 */ - MK( 35520, 20, 22, 30, 0, T|A|S ), /* 240 Yate Z-Shuttle */ - MK( 36981, 20, 22, 30, 0, T|A|S ), /* 241 Kelling K1 */ - MK( 38807, 20, 22, 50, 0, T|A|S ), /* 242 Kelling K6 */ - MK( 42094, 20, 25, 30, 0, T|A|S ), /* 243 Kelling K7 */ - MK( 44651, 20, 23, 30, 0, T|A|S ), /* 244 Darwin 700 */ - MK( 40268, 20, 25, 30, 0, T|A|S ), /* 245 FFP Hyperdart 2 */ - MK( 33693, 20, 25, 50, 0, T|A|S ), /* 246 Dinger 200 */ - MK( 32963, 20, 20, 60, 0, T|A|S ), /* 247 Dinger 1000 */ - MK( 9222, 20, 20, 35, 0, Y), /* 248 Ploddyphut 100 */ - MK( 12874, 20, 20, 35, 0, Y), /* 249 Ploddyphut 500 */ - MK( 16892, 20, 20, 35, 0, Y), /* 250 Flashbang X1 */ - MK( 21275, 20, 20, 99, 0, Y), /* 251 Juggerplane M1 */ - MK( 23832, 20, 20, 99, 0, Y), /* 252 Flashbang Wizzer */ - MK( 13575, 20, 20, 40, 0, T|A|S ), /* 253 Tricario Helicopter */ - MK( 28215, 20, 20, 30, 0, T|A|S ), /* 254 Guru X2 Helicopter */ + MS( 2922, 5, 30, 50, 0, T|A|S ), /* 204 MPS Oil Tanker */ + MS( 17167, 5, 30, 90, 0, T|A|S ), /* 205 CS-Inc. Oil Tanker */ + MS( 2192, 5, 30, 55, 0, T|A|S ), /* 206 MPS Passenger Ferry */ + MS( 18628, 5, 30, 90, 0, T|A|S ), /* 207 FFP Passenger Ferry */ + MS( 17257, 10, 25, 90, 0, T|A|S ), /* 208 Bakewell 300 Hovercraft */ + MS( 9587, 5, 30, 40, 0, Y), /* 209 Chugger-Chug Passenger Ferry */ + MS( 20544, 5, 30, 90, 0, Y), /* 210 Shivershake Passenger Ferry */ + MS( 2557, 5, 30, 55, 0, T|A|S ), /* 211 Yate Cargo ship */ + MS( 19724, 5, 30, 98, 0, T|A|S ), /* 212 Bakewell Cargo ship */ + MS( 9587, 5, 30, 45, 0, Y), /* 213 Mightymover Cargo ship */ + MS( 22371, 5, 30, 90, 0, Y), /* 214 Powernaut Cargo ship */ + MA( 2922, 20, 20, 20, 0, T|A|S ), /* 215 Sampson U52 */ + MA( 9922, 20, 24, 20, 0, T|A|S ), /* 216 Coleman Count */ + MA( 12659, 20, 18, 20, 0, T|A|S ), /* 217 FFP Dart */ + MA( 17652, 20, 25, 35, 0, T|A|S ), /* 218 Yate Haugan */ + MA( 4929, 20, 30, 30, 0, T|A|S ), /* 219 Bakewell Cotswald LB-3 */ + MA( 13695, 20, 23, 25, 0, T|A|S ), /* 220 Bakewell Luckett LB-8 */ + MA( 16341, 20, 26, 30, 0, T|A|S ), /* 221 Bakewell Luckett LB-9 */ + MA( 21395, 20, 25, 30, 0, T|A|S ), /* 222 Bakewell Luckett LB80 */ + MA( 18263, 20, 20, 30, 0, T|A|S ), /* 223 Bakewell Luckett LB-10 */ + MA( 25233, 20, 25, 30, 0, T|A|S ), /* 224 Bakewell Luckett LB-11 */ + MA( 15371, 20, 22, 25, 0, T|A|S ), /* 225 Yate Aerospace YAC 1-11 */ + MA( 15461, 20, 25, 25, 0, T|A|S ), /* 226 Darwin 100 */ + MA( 16952, 20, 22, 25, 0, T|A|S ), /* 227 Darwin 200 */ + MA( 17227, 20, 25, 30, 0, T|A|S ), /* 228 Darwin 300 */ + MA( 22371, 20, 25, 35, 0, T|A|S ), /* 229 Darwin 400 */ + MA( 22341, 20, 25, 30, 0, T|A|S ), /* 230 Darwin 500 */ + MA( 27209, 20, 25, 30, 0, T|A|S ), /* 231 Darwin 600 */ + MA( 17988, 20, 20, 30, 0, T|A|S ), /* 232 Guru Galaxy */ + MA( 18993, 20, 24, 35, 0, T|A|S ), /* 233 Airtaxi A21 */ + MA( 22401, 20, 24, 30, 0, T|A|S ), /* 234 Airtaxi A31 */ + MA( 24472, 20, 24, 30, 0, T|A|S ), /* 235 Airtaxi A32 */ + MA( 26724, 20, 24, 30, 0, T|A|S ), /* 236 Airtaxi A33 */ + MA( 22005, 20, 25, 30, 0, T|A|S ), /* 237 Yate Aerospace YAe46 */ + MA( 24107, 20, 20, 35, 0, T|A|S ), /* 238 Dinger 100 */ + MA( 29310, 20, 25, 60, 0, T|A|S ), /* 239 AirTaxi A34-1000 */ + MA( 35520, 20, 22, 30, 0, T|A|S ), /* 240 Yate Z-Shuttle */ + MA( 36981, 20, 22, 30, 0, T|A|S ), /* 241 Kelling K1 */ + MA( 38807, 20, 22, 50, 0, T|A|S ), /* 242 Kelling K6 */ + MA( 42094, 20, 25, 30, 0, T|A|S ), /* 243 Kelling K7 */ + MA( 44651, 20, 23, 30, 0, T|A|S ), /* 244 Darwin 700 */ + MA( 40268, 20, 25, 30, 0, T|A|S ), /* 245 FFP Hyperdart 2 */ + MA( 33693, 20, 25, 50, 0, T|A|S ), /* 246 Dinger 200 */ + MA( 32963, 20, 20, 60, 0, T|A|S ), /* 247 Dinger 1000 */ + MA( 9222, 20, 20, 35, 0, Y), /* 248 Ploddyphut 100 */ + MA( 12874, 20, 20, 35, 0, Y), /* 249 Ploddyphut 500 */ + MA( 16892, 20, 20, 35, 0, Y), /* 250 Flashbang X1 */ + MA( 21275, 20, 20, 99, 0, Y), /* 251 Juggerplane M1 */ + MA( 23832, 20, 20, 99, 0, Y), /* 252 Flashbang Wizzer */ + MA( 13575, 20, 20, 40, 0, T|A|S ), /* 253 Tricario Helicopter */ + MA( 28215, 20, 20, 30, 0, T|A|S ), /* 254 Guru X2 Helicopter */ MK( 13575, 20, 20, 99, 0, Y), /* 255 */ }; #undef Y Index: vehicle.c =================================================================== --- vehicle.c (revision 5934) +++ vehicle.c (working copy) @@ -683,7 +683,7 @@ ))) { // If patch is active, use alternative CanFillVehicle-function - if (_patches.full_load_any) return CanFillVehicle_FullLoadAny(v); + if (_patches.full_load_any && v->current_order.flags & OF_FULL_LOAD) return CanFillVehicle_FullLoadAny(v); do { if (v->cargo_count != v->cargo_cap) return true; Index: vehicle.h =================================================================== --- vehicle.h (revision 5934) +++ vehicle.h (working copy) @@ -223,6 +223,7 @@ bool leave_depot_instantly; // NOSAVE: stores if the vehicle needs to leave the depot it just entered. Used by autoreplace uint16 load_unload_time_rem; + bool loading_finished; int32 profit_this_year; int32 profit_last_year; @@ -305,7 +306,7 @@ UnitID GetFreeUnitNumber(byte type); -int LoadUnloadVehicle(Vehicle *v); +int LoadUnloadVehicle(Vehicle *v, bool calc_profit); void TrainConsistChanged(Vehicle *v); void TrainPowerChanged(Vehicle *v); Index: settings.c =================================================================== --- settings.c (revision 5934) +++ settings.c (working copy) @@ -1311,6 +1311,7 @@ SDT_VAR(Patches, station_spread,SLE_UINT8,0, 0, 12, 4,64,STR_CONFIG_PATCHES_STATION_SPREAD, InvalidateStationBuildWindow), SDT_BOOL(Patches, serviceathelipad, 0, 0, true, STR_CONFIG_PATCHES_SERVICEATHELIPAD, NULL), SDT_BOOL(Patches, modified_catchment, 0, 0, true, STR_CONFIG_PATCHES_CATCHMENT, NULL), + SDT_CONDBOOL(Patches, gradual_loading, 30, SL_MAX_VERSION, 0, 0, true, STR_CONFIG_PATCHES_GRADUAL_LOADING, NULL), /***************************************************************************/ /* Economy section of the GUI-configure patches window */ Index: newgrf_callbacks.h =================================================================== --- newgrf_callbacks.h (revision 5934) +++ newgrf_callbacks.h (working copy) @@ -19,6 +19,10 @@ // only for train vehicles CBID_TRAIN_VEHICLE_LENGTH = 0x11, + /* Called to determine the amount of cargo to load per unit of time when + * using gradual loading. */ + CBID_VEHICLE_LOAD_AMOUNT = 0x12, + /* Called (if appropriate bit in callback mask is set) to determine if a * newstation should be made available to build */ CBID_STATION_AVAILABILITY = 0x13, Index: newgrf.c =================================================================== --- newgrf.c (revision 5934) +++ newgrf.c (working copy) @@ -1203,8 +1203,7 @@ * credit ;-). --pasky */ /* TODO: This needs to be supported by * LoadUnloadVehicle() first. */ - FOR_EACH_OBJECT grf_load_byte(&buf); - ignoring = true; + FOR_EACH_OBJECT ei[i].load_amount = grf_load_byte(&buf); break; default: Index: engine.h =================================================================== --- engine.h (revision 5934) +++ engine.h (working copy) @@ -77,6 +77,7 @@ Date base_intro; byte unk2; ///< Carriages have the highest bit set in this one byte lifelength; + byte load_amount; byte base_life; byte railtype:4; byte climates:4; Index: aircraft_cmd.c =================================================================== --- aircraft_cmd.c (revision 5934) +++ aircraft_cmd.c (working copy) @@ -1232,9 +1232,10 @@ if (mode != 0) return; if (--v->load_unload_time_rem != 0) return; - if (v->current_order.flags & OF_FULL_LOAD && CanFillVehicle(v)) { + if (CanFillVehicle(v) && (v->current_order.flags & OF_FULL_LOAD || + (_patches.gradual_loading && ! v->loading_finished))) { SET_EXPENSES_TYPE(EXPENSES_AIRCRAFT_INC); - if (LoadUnloadVehicle(v)) { + if (LoadUnloadVehicle(v, false)) { InvalidateWindow(WC_AIRCRAFT_LIST, v->owner); MarkAircraftDirty(v); } @@ -1351,7 +1352,7 @@ } SET_EXPENSES_TYPE(EXPENSES_AIRCRAFT_INC); - LoadUnloadVehicle(v); + LoadUnloadVehicle(v, true); MarkAircraftDirty(v); InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); InvalidateWindowClasses(WC_AIRCRAFT_LIST); Index: variables.h =================================================================== --- variables.h (revision 5934) +++ variables.h (working copy) @@ -89,6 +89,7 @@ bool join_stations; // allow joining of train stations bool full_load_any; // new full load calculation, any cargo must be full bool improved_load; // improved loading algorithm + bool gradual_loading; // load vehicles gradually byte station_spread; // amount a station may spread bool inflation; // disable inflation bool selectgoods; // only send the goods to station if a train has been there Index: roadveh_cmd.c =================================================================== --- roadveh_cmd.c (revision 5934) +++ roadveh_cmd.c (working copy) @@ -707,9 +707,10 @@ if (--v->load_unload_time_rem != 0) return; - if (v->current_order.flags & OF_FULL_LOAD && CanFillVehicle(v)) { + if (CanFillVehicle(v) && (v->current_order.flags & OF_FULL_LOAD || + (_patches.gradual_loading && ! v->loading_finished))) { SET_EXPENSES_TYPE(EXPENSES_ROADVEH_INC); - if (LoadUnloadVehicle(v)) { + if (LoadUnloadVehicle(v, false)) { InvalidateWindow(WC_ROADVEH_LIST, v->owner); MarkRoadVehDirty(v); } @@ -1482,7 +1483,7 @@ } SET_EXPENSES_TYPE(EXPENSES_ROADVEH_INC); - if (LoadUnloadVehicle(v)) { + if (LoadUnloadVehicle(v, true)) { InvalidateWindow(WC_ROADVEH_LIST, v->owner); MarkRoadVehDirty(v); } Index: saveload.c =================================================================== --- saveload.c (revision 5934) +++ saveload.c (working copy) @@ -30,7 +30,7 @@ #include "variables.h" #include -const uint16 SAVEGAME_VERSION = 29; +const uint16 SAVEGAME_VERSION = 30; uint16 _sl_version; /// the major savegame version identifier byte _sl_minor_version; /// the minor savegame version, DO NOT USE! Index: train_cmd.c =================================================================== --- train_cmd.c (revision 5934) +++ train_cmd.c (working copy) @@ -2483,10 +2483,11 @@ if (--v->load_unload_time_rem) return; - if (v->current_order.flags & OF_FULL_LOAD && CanFillVehicle(v)) { + if (CanFillVehicle(v) && (v->current_order.flags & OF_FULL_LOAD || + (_patches.gradual_loading && ! v->loading_finished))) { v->u.rail.days_since_order_progr = 0; /* Prevent a train lost message for full loading trains */ SET_EXPENSES_TYPE(EXPENSES_TRAIN_INC); - if (LoadUnloadVehicle(v)) { + if (LoadUnloadVehicle(v, false)) { InvalidateWindow(WC_TRAINS_LIST, v->owner); MarkTrainDirty(v); @@ -2586,7 +2587,7 @@ v->current_order.station = 0; SET_EXPENSES_TYPE(EXPENSES_TRAIN_INC); - if (LoadUnloadVehicle(v) != 0) { + if (LoadUnloadVehicle(v, true) != 0) { InvalidateWindow(WC_TRAINS_LIST, v->owner); TrainCargoChanged(v); UpdateTrainAcceleration(v); Index: economy.c =================================================================== --- economy.c (revision 5934) +++ economy.c (working copy) @@ -28,6 +28,7 @@ #include "ai/ai.h" #include "train.h" #include "newgrf_engine.h" +#include "newgrf_callbacks.h" #include "unmovable.h" #include "date.h" @@ -1303,7 +1304,7 @@ return false; } -int LoadUnloadVehicle(Vehicle *v) +int LoadUnloadVehicle(Vehicle *v, bool calc_profit) { int profit = 0; int v_profit; //virtual profit for feeder systems @@ -1317,6 +1318,9 @@ uint count, cap; PlayerID old_player; bool completely_empty = true; + byte load_amount; + uint16 cb_load_amount; + bool station_empty = true; assert(v->current_order.type == OT_LOADING); @@ -1330,34 +1334,35 @@ for (; v != NULL; v = v->next) { GoodsEntry* ge; + load_amount = EngInfo(v->engine_type)->load_amount; + cb_load_amount = GetVehicleCallback(CBID_VEHICLE_LOAD_AMOUNT, 0, 0, v->engine_type, v); + if (cb_load_amount != CALLBACK_FAILED) load_amount = cb_load_amount & 0xFF; if (v->cargo_cap == 0) continue; ge = &st->goods[v->cargo_type]; + count = GB(ge->waiting_acceptance, 0, 12); /* unload? */ - if (v->cargo_count != 0) { + if (v->cargo_count != 0 && v->cargo_source != st->index) { if (v->cargo_source != last_visited && ge->waiting_acceptance & 0x8000 && !(u->current_order.flags & OF_TRANSFER)) { // deliver goods to the station - st->time_since_unload = 0; - - unloading_time += v->cargo_count; /* TTDBUG: bug in original TTD */ - profit += DeliverGoods(v->cargo_count, v->cargo_type, v->cargo_source, last_visited, v->cargo_days); + if (calc_profit) profit += DeliverGoods(v->cargo_count, v->cargo_type, v->cargo_source, last_visited, v->cargo_days); result |= 1; - v->cargo_count = 0; } else if (u->current_order.flags & (OF_UNLOAD | OF_TRANSFER)) { /* unload goods and let it wait at the station */ - st->time_since_unload = 0; + if (calc_profit) { + v_profit = GetTransportedGoodsIncome( + v->cargo_count, + DistanceManhattan(GetStation(v->cargo_source)->xy, GetStation(last_visited)->xy), + v->cargo_days, + v->cargo_type) * 3 / 2; - v_profit = GetTransportedGoodsIncome( - v->cargo_count, - DistanceManhattan(GetStation(v->cargo_source)->xy, GetStation(last_visited)->xy), - v->cargo_days, - v->cargo_type) * 3 / 2; + v_profit_total += v_profit; + ge->feeder_profit += v_profit; + u->profit_this_year += v_profit; + } - v_profit_total += v_profit; - - unloading_time += v->cargo_count; t = GB(ge->waiting_acceptance, 0, 12); if (t == 0) { // No goods waiting at station @@ -1371,10 +1376,16 @@ ge->enroute_from = v->cargo_source; } // Update amount of waiting cargo - SB(ge->waiting_acceptance, 0, 12, min(v->cargo_count + t, 0xFFF)); - ge->feeder_profit += v_profit; - u->profit_this_year += v_profit; + SB(ge->waiting_acceptance, 0, 12, min(min(load_amount, v->cargo_count) + t, 0xFFF)); result |= 2; + } + st->time_since_unload = 0; + unloading_time += v->cargo_count; /* TTDBUG: bug in original TTD */ + if (_patches.gradual_loading) { + v->cargo_count -= min(load_amount, v->cargo_count); + if (v->cargo_count != 0 || (count != 0 && !(u->current_order.flags & OF_UNLOAD))) station_empty = false; + continue; + } else { v->cargo_count = 0; } @@ -1398,7 +1409,6 @@ // If there's goods waiting at the station, and the vehicle // has capacity for it, load it on the vehicle. - count = GB(ge->waiting_acceptance, 0, 12); if (count != 0 && (cap = v->cargo_cap - v->cargo_count) != 0) { int cargoshare; @@ -1409,7 +1419,7 @@ /* Skip loading this vehicle if another train/vehicle is already handling * the same cargo type at this station */ - if (_patches.improved_load && LoadWait(v,u)) continue; + if (_patches.improved_load && (u->current_order.flags & OF_FULL_LOAD) && LoadWait(v,u)) continue; /* TODO: Regarding this, when we do gradual loading, we * should first unload all vehicles and then start @@ -1421,6 +1431,8 @@ completely_empty = false; if (cap > count) cap = count; + if (_patches.gradual_loading) cap = min(cap, load_amount); + if (cap < count) station_empty = false; cargoshare = cap * 10000 / ge->waiting_acceptance; feeder_profit_share = ge->feeder_profit * cargoshare / 10000; v->cargo_count += cap; @@ -1438,6 +1450,7 @@ } } + if (_patches.gradual_loading) unloading_time = (station_empty) ? 10 :25; v = u; @@ -1455,6 +1468,7 @@ } v->load_unload_time_rem = unloading_time; + v->loading_finished = station_empty; if (completely_empty) { TriggerVehicle(v, VEHICLE_TRIGGER_EMPTY); Index: ship_cmd.c =================================================================== --- ship_cmd.c (revision 5934) +++ ship_cmd.c (working copy) @@ -261,9 +261,10 @@ if (v->current_order.type != OT_LOADING) return; if (--v->load_unload_time_rem) return; - if (v->current_order.flags & OF_FULL_LOAD && CanFillVehicle(v)) { + if (CanFillVehicle(v) && (v->current_order.flags & OF_FULL_LOAD || + (_patches.gradual_loading && ! v->loading_finished))) { SET_EXPENSES_TYPE(EXPENSES_SHIP_INC); - if (LoadUnloadVehicle(v)) { + if (LoadUnloadVehicle(v, false)) { InvalidateWindow(WC_SHIPS_LIST, v->owner); MarkShipDirty(v); } @@ -731,7 +732,7 @@ ShipArrivesAt(v, st); SET_EXPENSES_TYPE(EXPENSES_SHIP_INC); - if (LoadUnloadVehicle(v)) { + if (LoadUnloadVehicle(v, true)) { InvalidateWindow(WC_SHIPS_LIST, v->owner); MarkShipDirty(v); } Index: settings_gui.c =================================================================== --- settings_gui.c (revision 5934) +++ settings_gui.c (working copy) @@ -592,6 +592,7 @@ "station_spread", "serviceathelipad", "modified_catchment", + "gradual_loading", }; static const char *_patches_economy[] = {