1
0
Fork 0

(svn r9828) -Codechange: [NewGRF] Add support for changing cargo capacity with callback 36. This is set on construction for ships and roadvehicles, and whenever carriages are attached for trains.

release/0.6
peter1138 2007-05-12 07:05:34 +00:00
parent 5e00e688f8
commit 1d5135830a
4 changed files with 14 additions and 7 deletions

View File

@ -386,7 +386,7 @@ static int DrawRailWagonPurchaseInfo(int x, int y, EngineID engine_number, const
/* Wagon weight - (including cargo) */ /* Wagon weight - (including cargo) */
uint weight = GetEngineProperty(engine_number, 0x16, rvi->weight); uint weight = GetEngineProperty(engine_number, 0x16, rvi->weight);
SetDParam(0, weight); SetDParam(0, weight);
SetDParam(1, (GetCargo(rvi->cargo_type)->weight * rvi->capacity >> 4) + weight); SetDParam(1, (GetCargo(rvi->cargo_type)->weight * GetEngineProperty(engine_number, 0x14, rvi->capacity) >> 4) + weight);
DrawString(x, y, STR_PURCHASE_INFO_WEIGHT_CWEIGHT, 0); DrawString(x, y, STR_PURCHASE_INFO_WEIGHT_CWEIGHT, 0);
y += 10; y += 10;
@ -461,7 +461,7 @@ static int DrawRoadVehPurchaseInfo(int x, int y, EngineID engine_number, const R
/* Cargo type + capacity */ /* Cargo type + capacity */
SetDParam(0, rvi->cargo_type); SetDParam(0, rvi->cargo_type);
SetDParam(1, rvi->capacity); SetDParam(1, GetEngineProperty(engine_number, 0x0F, rvi->capacity));
SetDParam(2, refittable ? STR_9842_REFITTABLE : STR_EMPTY); SetDParam(2, refittable ? STR_9842_REFITTABLE : STR_EMPTY);
DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, 0); DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, 0);
y += 10; y += 10;
@ -480,7 +480,7 @@ static int DrawShipPurchaseInfo(int x, int y, EngineID engine_number, const Ship
/* Cargo type + capacity */ /* Cargo type + capacity */
SetDParam(0, svi->cargo_type); SetDParam(0, svi->cargo_type);
SetDParam(1, svi->capacity); SetDParam(1, GetEngineProperty(engine_number, 0x0D, svi->capacity));
SetDParam(2, svi->refittable ? STR_9842_REFITTABLE : STR_EMPTY); SetDParam(2, svi->refittable ? STR_9842_REFITTABLE : STR_EMPTY);
DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, 0); DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, 0);
y += 10; y += 10;
@ -545,8 +545,9 @@ int DrawVehiclePurchaseInfo(int x, int y, uint w, EngineID engine_number)
switch (e->type) { switch (e->type) {
case VEH_TRAIN: { case VEH_TRAIN: {
const RailVehicleInfo *rvi = RailVehInfo(engine_number); const RailVehicleInfo *rvi = RailVehInfo(engine_number);
uint capacity = GetEngineProperty(engine_number, 0x14, rvi->capacity);
refitable = (EngInfo(engine_number)->refit_mask != 0) && (rvi->capacity > 0); refitable = (EngInfo(engine_number)->refit_mask != 0) && (capacity > 0);
if (rvi->railveh_type == RAILVEH_WAGON) { if (rvi->railveh_type == RAILVEH_WAGON) {
y = DrawRailWagonPurchaseInfo(x, y, engine_number, rvi); y = DrawRailWagonPurchaseInfo(x, y, engine_number, rvi);
@ -562,7 +563,7 @@ int DrawVehiclePurchaseInfo(int x, int y, uint w, EngineID engine_number)
int multihead = (rvi->railveh_type == RAILVEH_MULTIHEAD ? 1 : 0); int multihead = (rvi->railveh_type == RAILVEH_MULTIHEAD ? 1 : 0);
SetDParam(0, rvi->cargo_type); SetDParam(0, rvi->cargo_type);
SetDParam(1, (rvi->capacity * (CountArticulatedParts(engine_number) + 1)) << multihead); SetDParam(1, (capacity * (CountArticulatedParts(engine_number) + 1)) << multihead);
SetDParam(2, refitable ? STR_9842_REFITTABLE : STR_EMPTY); SetDParam(2, refitable ? STR_9842_REFITTABLE : STR_EMPTY);
} }
DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, 0); DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, 0);

View File

@ -211,6 +211,8 @@ int32 CmdBuildRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
v->vehicle_flags = 0; v->vehicle_flags = 0;
if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SETBIT(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE); if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SETBIT(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE);
v->cargo_cap = GetVehicleProperty(v, 0x0F, rvi->capacity);
VehiclePositionChanged(v); VehiclePositionChanged(v);
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile); InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
@ -1849,7 +1851,7 @@ int32 CmdRefitRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
* carry twice as much mail/goods as normal cargo, and four times as * carry twice as much mail/goods as normal cargo, and four times as
* many passengers * many passengers
*/ */
capacity = rvi->capacity; capacity = GetVehicleProperty(v, 0x0F, rvi->capacity);
switch (old_cid) { switch (old_cid) {
case CT_PASSENGERS: break; case CT_PASSENGERS: break;
case CT_MAIL: case CT_MAIL:

View File

@ -878,6 +878,8 @@ int32 CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
v->vehicle_flags = 0; v->vehicle_flags = 0;
if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SETBIT(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE); if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SETBIT(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE);
v->cargo_cap = GetVehicleProperty(v, 0x0D, svi->capacity);
VehiclePositionChanged(v); VehiclePositionChanged(v);
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile); InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
@ -1090,7 +1092,7 @@ int32 CmdRefitShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
} }
if (capacity == CALLBACK_FAILED) { if (capacity == CALLBACK_FAILED) {
capacity = ShipVehInfo(v->engine_type)->capacity; capacity = GetVehicleProperty(v, 0x0D, ShipVehInfo(v->engine_type)->capacity);
} }
_returned_refit_capacity = capacity; _returned_refit_capacity = capacity;

View File

@ -220,6 +220,8 @@ void TrainConsistChanged(Vehicle* v)
} }
} }
u->cargo_cap = GetVehicleProperty(u, 0x14, rvi_u->capacity);
/* check the vehicle length (callback) */ /* check the vehicle length (callback) */
uint16 veh_len = CALLBACK_FAILED; uint16 veh_len = CALLBACK_FAILED;
if (HASBIT(EngInfo(u->engine_type)->callbackmask, CBM_VEHICLE_LENGTH)) { if (HASBIT(EngInfo(u->engine_type)->callbackmask, CBM_VEHICLE_LENGTH)) {