summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2007-12-31 21:51:16 +0000
committerpeter1138 <peter1138@openttd.org>2007-12-31 21:51:16 +0000
commit7031358cff96d93b82843722f45255d432a9c088 (patch)
treed8965b2badab8204c366e10dad20226b35928378
parentd8f4a80b0afa269b6d0e803e2f946de7a047c48a (diff)
downloadopenttd-7031358cff96d93b82843722f45255d432a9c088.tar.xz
(svn r11731) -Fix [FS#1582]: Clear sprite override data before performing NewGRF wagon attach callback. This stopped
the callback working for autoreplace and when moving wagons from train to train in a depot. -Fix (r11724): Don't check wagon attach callback for the chain when moving a single wagon.
-rw-r--r--src/train_cmd.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 12ea3ddaf..c47c23dae 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -1063,7 +1063,15 @@ CommandCost CmdMoveRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p
Vehicle *src_previous = src->Previous();
while (next_to_attach != NULL) {
+ /* Back up and clear the first_engine data to avoid using wagon override group */
+ EngineID first_engine = next_to_attach->u.rail.first_engine;
+ next_to_attach->u.rail.first_engine = INVALID_ENGINE;
+
uint16 callback = GetVehicleCallbackParent(CBID_TRAIN_ALLOW_WAGON_ATTACH, 0, 0, dst_head->engine_type, next_to_attach, dst_head);
+
+ /* Restore original first_engine data */
+ next_to_attach->u.rail.first_engine = first_engine;
+
if (callback != CALLBACK_FAILED) {
StringID error = STR_NULL;
@@ -1088,6 +1096,9 @@ CommandCost CmdMoveRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p
}
}
+ /* Only check further wagons if told to move the chain */
+ if (!HasBit(p2, 0)) break;
+
/*
* Adding a next wagon to the chain so we can test the other wagons.
* First 'take' the first wagon from 'next_to_attach' and move it