summaryrefslogtreecommitdiff
path: root/train_cmd.c
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-06-09 07:03:53 +0000
committerpeter1138 <peter1138@openttd.org>2006-06-09 07:03:53 +0000
commitd6ebfb8338dcd1d7c5a9543068c43c60dfc60601 (patch)
treebbc05f231ea2e6adea3e7eefd67c28471cbf456f /train_cmd.c
parenta7fbd158a03671831a9199f0ac13d37217526e86 (diff)
downloadopenttd-d6ebfb8338dcd1d7c5a9543068c43c60dfc60601.tar.xz
(svn r5187) - NewGRF: temporarily change a vehicle's cargo subtype when calling the refit capacity callback.
Diffstat (limited to 'train_cmd.c')
-rw-r--r--train_cmd.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/train_cmd.c b/train_cmd.c
index 90b6cb224..bf8b29629 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -1760,11 +1760,16 @@ int32 CmdRefitRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
uint16 amount = CALLBACK_FAILED;
if (HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_REFIT_CAPACITY)) {
- /* Check the 'refit capacity' callback */
+ /* Back up the vehicle's cargo type */
CargoID temp_cid = v->cargo_type;
+ byte temp_subtype = v->cargo_subtype;
v->cargo_type = new_cid;
+ v->cargo_subtype = new_subtype;
+ /* Check the refit capacity callback */
amount = GetVehicleCallback(CBID_VEHICLE_REFIT_CAPACITY, 0, 0, v->engine_type, v);
+ /* Restore the original cargo type */
v->cargo_type = temp_cid;
+ v->cargo_subtype = temp_subtype;
}
if (amount == CALLBACK_FAILED) { // callback failed or not used, use default