summaryrefslogtreecommitdiff
path: root/train_cmd.c
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-11-27 23:11:56 +0000
committerpeter1138 <peter1138@openttd.org>2006-11-27 23:11:56 +0000
commit470c383738d84b9e2e1e202fec2633d10f6e1712 (patch)
treee4b1dd8ccb2c63d47646c0471b322b9ea585313a /train_cmd.c
parent45e7e61aa969764dc71ab1bbc574655e07a346a4 (diff)
downloadopenttd-470c383738d84b9e2e1e202fec2633d10f6e1712.tar.xz
(svn r7269) -Feature: Add freight trains patch option. This option is a multiplier for the weight of cargo on freight trains, to simulate longer heavier trains. The default value of 1 behaves as before.
Diffstat (limited to 'train_cmd.c')
-rw-r--r--train_cmd.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/train_cmd.c b/train_cmd.c
index a38c9d02e..33303a152 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -40,6 +40,20 @@ static const byte _vehicle_initial_x_fract[4] = {10, 8, 4, 8};
static const byte _vehicle_initial_y_fract[4] = { 8, 4, 8, 10};
static const byte _state_dir_table[4] = { 0x20, 8, 0x10, 4 };
+
+/** Return the cargo weight multiplier to use for a rail vehicle
+ * @param v Vehicle (wagon) to get multiplier for
+ * @return Cargo weight multiplier
+ */
+byte FreightWagonMult(const Vehicle *v)
+{
+ assert(v->type == VEH_Train);
+ // XXX NewCargos introduces a specific "is freight" flag for this test.
+ if (v->cargo_type == CT_PASSENGERS || v->cargo_type == CT_MAIL) return 1;
+ return _patches.freight_trains;
+}
+
+
/**
* Recalculates the cached weight of a train and its vehicles. Should be called each time the cargo on
* the consist changes.
@@ -52,7 +66,7 @@ static void TrainCargoChanged(Vehicle* v)
for (u = v; u != NULL; u = u->next) {
const RailVehicleInfo *rvi = RailVehInfo(u->engine_type);
- uint32 vweight = (_cargoc.weights[u->cargo_type] * u->cargo_count) / 16;
+ uint32 vweight = (_cargoc.weights[u->cargo_type] * u->cargo_count * FreightWagonMult(u)) / 16;
// Vehicle weight is not added for articulated parts.
if (!IsArticulatedPart(u)) {