diff options
author | rubidium <rubidium@openttd.org> | 2009-12-13 22:17:12 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-12-13 22:17:12 +0000 |
commit | c2ec2e2db3f632ed6e52f83403e9d689a80b9b14 (patch) | |
tree | 58cf907ebe3c07611bb5f5ca2a9f42a937edc2db /src/train_cmd.cpp | |
parent | 8b9a2218de1e291f3de5702c0ad2ddfdb1acb000 (diff) | |
download | openttd-c2ec2e2db3f632ed6e52f83403e9d689a80b9b14.tar.xz |
(svn r18494) -Fix (r18474): crash when moving non-engine to new free wagon chain and group count was off when moving a front engine within the same train and the new front isn't an engine.
Diffstat (limited to 'src/train_cmd.cpp')
-rw-r--r-- | src/train_cmd.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 3f9d81dac..3cd80ed0a 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -1441,8 +1441,13 @@ CommandCost CmdMoveRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, u /* We are going to be move to another train. So we * are no part of this group anymore. In case we * are not moving group... well, then we do not need - * to move. */ - if (dst_head != NULL && dst_head != src) DecreaseGroupNumVehicle(src->group_id); + * to move. + * Or we are moving to later in the train and our + * new head isn't a front engine anymore. + */ + if (dst_head != NULL ? dst_head != src : !src_head->IsFrontEngine()) { + DecreaseGroupNumVehicle(src->group_id); + } /* Delete orders, group stuff and the unit number as we're not the * front of any vehicle anymore. */ |