(svn r7268) -Codechange: change rail vehicle cached weight from 16 to 32 bit values to avoid possible overflows.
--- a/train_cmd.c Mon Nov 27 14:09:13 2006 +0000
+++ b/train_cmd.c Mon Nov 27 21:14:19 2006 +0000
@@ -48,11 +48,11 @@
static void TrainCargoChanged(Vehicle* v)
{
Vehicle *u;
- uint16 weight = 0;
+ uint32 weight = 0;
for (u = v; u != NULL; u = u->next) {
const RailVehicleInfo *rvi = RailVehInfo(u->engine_type);
- uint16 vweight = (_cargoc.weights[u->cargo_type] * u->cargo_count) / 16;
+ uint32 vweight = (_cargoc.weights[u->cargo_type] * u->cargo_count) / 16;
// Vehicle weight is not added for articulated parts.
if (!IsArticulatedPart(u)) {
--- a/vehicle.h Mon Nov 27 14:09:13 2006 +0000
+++ b/vehicle.h Mon Nov 27 21:14:19 2006 +0000
@@ -54,8 +54,8 @@
uint16 cached_total_length; ///< Length of the whole train, valid only for first engine.
// cached values, recalculated when the cargo on a train changes (in addition to the conditions above)
- uint16 cached_weight; // total weight of the consist.
- uint16 cached_veh_weight; // weight of the vehicle.
+ uint32 cached_weight; // total weight of the consist.
+ uint32 cached_veh_weight; // weight of the vehicle.
/**
* Position/type of visual effect.
* bit 0 - 3 = position of effect relative to vehicle. (0 = front, 8 = centre, 15 = rear)