summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-12-02 16:56:32 +0000
committerpeter1138 <peter1138@openttd.org>2006-12-02 16:56:32 +0000
commit039794e83ca40717e0a5aff927f20e7a560ac7c5 (patch)
tree5e7abf3b12a62b206a4e2ea934e86e51e08cb91e
parent6a4d8fdd33de84ef691caa29ea77c21ff2b8d6c4 (diff)
downloadopenttd-039794e83ca40717e0a5aff927f20e7a560ac7c5.tar.xz
(svn r7326) -Feature: Add support for gradual (un)loading of vehicles (Maedhros)
-rw-r--r--aircraft_cmd.c7
-rw-r--r--economy.c57
-rw-r--r--engine.h1
-rw-r--r--lang/english.txt1
-rw-r--r--newgrf.c8
-rw-r--r--newgrf_callbacks.h4
-rw-r--r--roadveh_cmd.c7
-rw-r--r--saveload.c2
-rw-r--r--settings.c1
-rw-r--r--settings_gui.c1
-rw-r--r--ship_cmd.c7
-rw-r--r--table/engines.h126
-rw-r--r--train_cmd.c7
-rw-r--r--variables.h1
-rw-r--r--vehicle.c3
-rw-r--r--vehicle.h8
16 files changed, 155 insertions, 86 deletions
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index 1ed9962f1..46e06f417 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -1258,9 +1258,10 @@ static void HandleAircraftLoading(Vehicle *v, int mode)
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 && !HASBIT(v->load_status, LS_LOADING_FINISHED)))) {
SET_EXPENSES_TYPE(EXPENSES_AIRCRAFT_INC);
- if (LoadUnloadVehicle(v)) {
+ if (LoadUnloadVehicle(v, false)) {
InvalidateWindow(WC_AIRCRAFT_LIST, v->owner);
MarkAircraftDirty(v);
}
@@ -1377,7 +1378,7 @@ static void AircraftEntersTerminal(Vehicle *v)
}
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);
diff --git a/economy.c b/economy.c
index 37d0d2325..7c945fe00 100644
--- a/economy.c
+++ b/economy.c
@@ -29,6 +29,7 @@
#include "train.h"
#include "newgrf_engine.h"
#include "newgrf_sound.h"
+#include "newgrf_callbacks.h"
#include "unmovable.h"
#include "date.h"
@@ -1301,7 +1302,7 @@ static bool LoadWait(const Vehicle* v, const Vehicle* u)
return false;
}
-int LoadUnloadVehicle(Vehicle *v)
+int LoadUnloadVehicle(Vehicle *v, bool just_arrived)
{
int profit = 0;
int v_profit = 0; //virtual profit for feeder systems
@@ -1315,10 +1316,12 @@ int LoadUnloadVehicle(Vehicle *v)
uint count, cap;
PlayerID old_player;
bool completely_empty = true;
+ byte load_amount;
assert(v->current_order.type == OT_LOADING);
v->cur_speed = 0;
+ SETBIT(v->load_status, LS_LOADING_FINISHED);
old_player = _current_player;
_current_player = v->owner;
@@ -1328,26 +1331,41 @@ int LoadUnloadVehicle(Vehicle *v)
for (; v != NULL; v = v->next) {
GoodsEntry* ge;
+ load_amount = EngInfo(v->engine_type)->load_amount;
+ if (_patches.gradual_loading) {
+ uint16 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;
+ /* If the train has just arrived, set it to unload. */
+ if (just_arrived) SETBIT(v->load_status, LS_CARGO_UNLOADING);
+
ge = &st->goods[v->cargo_type];
+ count = GB(ge->waiting_acceptance, 0, 12);
/* unload? */
- if (v->cargo_count != 0) {
+ if (v->cargo_count != 0 && HASBIT(v->load_status, LS_CARGO_UNLOADING)) {
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 (just_arrived) profit += DeliverGoods(v->cargo_count, v->cargo_type, v->cargo_source, last_visited, v->cargo_days);
result |= 1;
- v->cargo_count = 0;
+ 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))) CLRBIT(u->load_status, LS_LOADING_FINISHED);
+ continue;
+ } else {
+ v->cargo_count = 0;
+ }
} else if (u->current_order.flags & (OF_UNLOAD | OF_TRANSFER)) {
+ uint16 amount_unloaded = _patches.gradual_loading ? min(v->cargo_count, load_amount) : v->cargo_count;
/* unload goods and let it wait at the station */
st->time_since_unload = 0;
-
- if (u->current_order.flags & OF_TRANSFER) {
+ if (just_arrived && (u->current_order.flags & OF_TRANSFER)) {
v_profit = GetTransportedGoodsIncome(
v->cargo_count,
DistanceManhattan(GetStation(v->cargo_source)->xy, GetStation(last_visited)->xy),
@@ -1371,14 +1389,18 @@ int LoadUnloadVehicle(Vehicle *v)
ge->enroute_from = v->cargo_source;
}
// Update amount of waiting cargo
- SB(ge->waiting_acceptance, 0, 12, min(v->cargo_count + t, 0xFFF));
+ SB(ge->waiting_acceptance, 0, 12, min(amount_unloaded + t, 0xFFF));
if (u->current_order.flags & OF_TRANSFER) {
ge->feeder_profit += v_profit;
u->profit_this_year += v_profit;
}
result |= 2;
- v->cargo_count = 0;
+ v->cargo_count -= amount_unloaded;
+ if (_patches.gradual_loading) {
+ if (v->cargo_count != 0 || (count != 0 && !(u->current_order.flags & OF_UNLOAD))) CLRBIT(u->load_status, LS_LOADING_FINISHED);
+ continue;
+ }
}
if (v->cargo_count != 0) completely_empty = false;
@@ -1387,6 +1409,10 @@ int LoadUnloadVehicle(Vehicle *v)
/* don't pick up goods that we unloaded */
if (u->current_order.flags & OF_UNLOAD) continue;
+ /* The vehicle must have been unloaded because it is either empty, or
+ * v->cargo_unloading is already false. */
+ CLRBIT(v->load_status, LS_CARGO_UNLOADING);
+
/* update stats */
ge->days_since_pickup = 0;
switch (u->type) {
@@ -1401,7 +1427,6 @@ int LoadUnloadVehicle(Vehicle *v)
// 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;
@@ -1412,7 +1437,7 @@ int LoadUnloadVehicle(Vehicle *v)
/* 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
@@ -1424,6 +1449,8 @@ int LoadUnloadVehicle(Vehicle *v)
completely_empty = false;
if (cap > count) cap = count;
+ if (_patches.gradual_loading) cap = min(cap, load_amount);
+ if (cap < count) CLRBIT(u->load_status, LS_LOADING_FINISHED);
cargoshare = cap * 10000 / ge->waiting_acceptance;
feeder_profit_share = ge->feeder_profit * cargoshare / 10000;
v->cargo_count += cap;
@@ -1441,9 +1468,17 @@ int LoadUnloadVehicle(Vehicle *v)
}
}
-
v = u;
+ if (_patches.gradual_loading) {
+ /* The time it takes to load one 'slice' of cargo or passengers depends
+ * on the vehicle type - the values here are those found in TTDPatch */
+ uint gradual_loading_wait_time[] = { 40, 20, 10, 20 };
+
+ unloading_time = gradual_loading_wait_time[v->type - VEH_Train];
+ if (HASBIT(v->load_status, LS_LOADING_FINISHED)) unloading_time += 20;
+ }
+
if (v_profit_total > 0) {
ShowFeederIncomeAnimation(v->x_pos, v->y_pos, v->z_pos, v_profit_total);
}
diff --git a/engine.h b/engine.h
index adb07cf44..ddf0abc95 100644
--- a/engine.h
+++ b/engine.h
@@ -77,6 +77,7 @@ typedef struct EngineInfo {
byte unk2; ///< Carriages have the highest bit set in this one
Year lifelength;
Year base_life;
+ byte load_amount;
byte railtype:4;
byte climates:4;
uint32 refit_mask;
diff --git a/lang/english.txt b/lang/english.txt
index 6e1374914..2e8369c66 100644
--- a/lang/english.txt
+++ b/lang/english.txt
@@ -1011,6 +1011,7 @@ STR_CONFIG_PATCHES_FORBID_90_DEG :{LTBLUE}Forbid
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}
diff --git a/newgrf.c b/newgrf.c
index fc0688ae3..70f816cf4 100644
--- a/newgrf.c
+++ b/newgrf.c
@@ -1416,14 +1416,10 @@ static void FeatureChangeInfo(byte *buf, int len)
break;
case 0x07: /* Loading speed */
- /* TODO */
/* Hyronymus explained me what does
* this mean and insists on having a
* 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:
@@ -3150,7 +3146,7 @@ static void InitializeGRFSpecial(void)
| ((_patches.mammoth_trains ? 1 : 0) << 0x08) // mammothtrains
| (1 << 0x09) // trainrefit
| (0 << 0x0B) // subsidiaries
- | (0 << 0x1C) // gradualloading
+ | ((_patches.gradual_loading ? 1 : 0) << 0x1C) // gradualloading
| (1 << 0x12) // unifiedmaglevmode - set bit 0 mode. Not revelant to OTTD
| (1 << 0x13) // unifiedmaglevmode - set bit 1 mode
| (1 << 0x14) // bridgespeedlimits
diff --git a/newgrf_callbacks.h b/newgrf_callbacks.h
index bdbb0e359..9d0a7a3da 100644
--- a/newgrf_callbacks.h
+++ b/newgrf_callbacks.h
@@ -19,6 +19,10 @@ enum CallbackID {
// 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,
diff --git a/roadveh_cmd.c b/roadveh_cmd.c
index 0777dec28..3a29ff3cd 100644
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -736,9 +736,10 @@ static void HandleRoadVehLoading(Vehicle *v)
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 && !HASBIT(v->load_status, LS_LOADING_FINISHED)))) {
SET_EXPENSES_TYPE(EXPENSES_ROADVEH_INC);
- if (LoadUnloadVehicle(v)) {
+ if (LoadUnloadVehicle(v, false)) {
InvalidateWindow(WC_ROADVEH_LIST, v->owner);
MarkRoadVehDirty(v);
}
@@ -1513,7 +1514,7 @@ again:
}
SET_EXPENSES_TYPE(EXPENSES_ROADVEH_INC);
- if (LoadUnloadVehicle(v)) {
+ if (LoadUnloadVehicle(v, true)) {
InvalidateWindow(WC_ROADVEH_LIST, v->owner);
MarkRoadVehDirty(v);
}
diff --git a/saveload.c b/saveload.c
index 9a1e20dfb..0b492c076 100644
--- a/saveload.c
+++ b/saveload.c
@@ -30,7 +30,7 @@
#include "variables.h"
#include <setjmp.h>
-const uint16 SAVEGAME_VERSION = 39;
+const uint16 SAVEGAME_VERSION = 40;
uint16 _sl_version; /// the major savegame version identifier
byte _sl_minor_version; /// the minor savegame version, DO NOT USE!
diff --git a/settings.c b/settings.c
index 4752e5256..8fc10ef9c 100644
--- a/settings.c
+++ b/settings.c
@@ -1335,6 +1335,7 @@ const SettingDesc _patch_settings[] = {
SDT_VAR(Patches, station_spread,SLE_UINT8,0, 0, 12, 4, 64, 0, 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, 40, SL_MAX_VERSION, 0, 0, true, STR_CONFIG_PATCHES_GRADUAL_LOADING, NULL),
/***************************************************************************/
/* Economy section of the GUI-configure patches window */
diff --git a/settings_gui.c b/settings_gui.c
index 996b9f340..9f6daf144 100644
--- a/settings_gui.c
+++ b/settings_gui.c
@@ -595,6 +595,7 @@ static const char *_patches_stations[] = {
"station_spread",
"serviceathelipad",
"modified_catchment",
+ "gradual_loading",
};
static const char *_patches_economy[] = {
diff --git a/ship_cmd.c b/ship_cmd.c
index c2ce21e99..e25ec5425 100644
--- a/ship_cmd.c
+++ b/ship_cmd.c
@@ -273,9 +273,10 @@ static void HandleShipLoading(Vehicle *v)
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 && !HASBIT(v->load_status, LS_LOADING_FINISHED)))) {
SET_EXPENSES_TYPE(EXPENSES_SHIP_INC);
- if (LoadUnloadVehicle(v)) {
+ if (LoadUnloadVehicle(v, false)) {
InvalidateWindow(WC_SHIPS_LIST, v->owner);
MarkShipDirty(v);
}
@@ -705,7 +706,7 @@ static void ShipController(Vehicle *v)
ShipArrivesAt(v, st);
SET_EXPENSES_TYPE(EXPENSES_SHIP_INC);
- if (LoadUnloadVehicle(v)) {
+ if (LoadUnloadVehicle(v, true)) {
InvalidateWindow(WC_SHIPS_LIST, v->owner);
MarkShipDirty(v);
}
diff --git a/table/engines.h b/table/engines.h
index 7cde8d9f1..40389082a 100644
--- a/table/engines.h
+++ b/table/engines.h
@@ -9,21 +9,35 @@
#include "../sound.h"
-/** Writes the properties of a vehicle into the EngineInfo struct.
+/** Writes the properties of a train or road vehicle into the EngineInfo struct.
* @see EngineInfo
* @param a Introduction date
* @param e Rail Type of the vehicle
* @param f Bitmask of the climates
+ * @note the 5 between d and e is the load amount
*/
-#define MK(a, b, c, d, e, f) { DAYS_TILL_ORIGINAL_BASE_YEAR + a, b, c, d, e, f, 0, 8, 0, 0 }
+#define MK(a, b, c, d, e, f) { DAYS_TILL_ORIGINAL_BASE_YEAR + a, b, c, d, 5, e, f, 0, 8, 0, 0 }
/** Writes the properties of a train carriage into the EngineInfo struct.
* @see EngineInfo
* @param a Introduction date
* @param e Rail Type of the vehicle
* @param f Bitmask of the climates
* @note the 0x80 in parameter b sets the "is carriage bit"
+ * @note the 5 between d and e is the load amount
*/
-#define MW(a, b, c, d, e, f) { DAYS_TILL_ORIGINAL_BASE_YEAR + a, b | 0x80, c, d, e, f, 0, 8, 0, 0 }
+#define MW(a, b, c, d, e, f) { DAYS_TILL_ORIGINAL_BASE_YEAR + a, b | 0x80, c, d, 5, e, f, 0, 8, 0, 0 }
+
+/** Writes the properties of a ship into the EngineInfo struct.
+ * @see MK
+ * @note the 10 between d and e is the load amount
+ */
+#define MS(a, b, c, d, e, f) { DAYS_TILL_ORIGINAL_BASE_YEAR + a, b, c, d, 10, e, f, 0, 8, 0, 0 }
+
+/** Writes the properties of an aeroplane into the EngineInfo struct.
+ * @see MK
+ * @note the 20 between d and e is the load amount
+ */
+#define MA(a, b, c, d, e, f) { DAYS_TILL_ORIGINAL_BASE_YEAR + a, b, c, d, 20, e, f, 0, 8, 0, 0 }
// Rail types
// R = Conventional railway
@@ -248,57 +262,57 @@ const EngineInfo orig_engine_info[] = {
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
@@ -309,6 +323,10 @@ const EngineInfo orig_engine_info[] = {
#undef M
#undef R
#undef E
+#undef MK
+#undef MW
+#undef MS
+#undef MA
/** Writes the properties of a rail vehicle into the RailVehicleInfo struct.
* @see RailVehicleInfo
diff --git a/train_cmd.c b/train_cmd.c
index 283a8ccc2..65154de6b 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -2609,10 +2609,11 @@ static void HandleTrainLoading(Vehicle *v, bool mode)
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 && !HASBIT(v->load_status, LS_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);
@@ -2712,7 +2713,7 @@ static void TrainEnterStation(Vehicle *v, StationID station)
v->current_order.dest = 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);
diff --git a/variables.h b/variables.h
index cf5e7702a..22f9cbcb2 100644
--- a/variables.h
+++ b/variables.h
@@ -89,6 +89,7 @@ typedef struct Patches {
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
diff --git a/vehicle.c b/vehicle.c
index 8d202c8d1..8cb22c7cf 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -725,7 +725,7 @@ bool CanFillVehicle(Vehicle *v)
))) {
// 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;
@@ -2987,6 +2987,7 @@ const SaveLoad _common_veh_desc[] = {
SLE_CONDVAR(Vehicle, build_year, SLE_INT32, 31, SL_MAX_VERSION),
SLE_VAR(Vehicle, load_unload_time_rem, SLE_UINT16),
+ SLE_CONDVAR(Vehicle, load_status, SLE_UINT8, 40, SL_MAX_VERSION),
SLE_VAR(Vehicle, profit_this_year, SLE_INT32),
SLE_VAR(Vehicle, profit_last_year, SLE_INT32),
diff --git a/vehicle.h b/vehicle.h
index b4e1a7190..3dde48548 100644
--- a/vehicle.h
+++ b/vehicle.h
@@ -28,6 +28,11 @@ enum VehStatus {
VS_CRASHED = 0x80,
};
+enum LoadStatus {
+ LS_LOADING_FINISHED,
+ LS_CARGO_UNLOADING,
+};
+
/* Effect vehicle types */
typedef enum EffectVehicle {
EV_CHIMNEY_SMOKE = 0,
@@ -230,6 +235,7 @@ struct Vehicle {
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;
+ byte load_status;
int32 profit_this_year;
int32 profit_last_year;
@@ -311,7 +317,7 @@ void ShowAircraftViewWindow(const Vehicle* v);
UnitID GetFreeUnitNumber(byte type);
-int LoadUnloadVehicle(Vehicle *v);
+int LoadUnloadVehicle(Vehicle *v, bool just_arrived);
void TrainConsistChanged(Vehicle *v);
void TrainPowerChanged(Vehicle *v);