summaryrefslogtreecommitdiff
path: root/train_cmd.c
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2005-11-06 01:15:10 +0000
committerbjarni <bjarni@openttd.org>2005-11-06 01:15:10 +0000
commita3c06f20fa5fdb3c3b2604b82e10ca9de98cc84d (patch)
tree7aaac75c061dcf1042aaafcca3881cf29fdf942d /train_cmd.c
parent6afe6a21ed9c6b8413350c7afd16cb694166e09e (diff)
downloadopenttd-a3c06f20fa5fdb3c3b2604b82e10ca9de98cc84d.tar.xz
(svn r3144) -Fix: a new train is now made if the front unit is an engine and the former front engine is moved away (Meush)
Diffstat (limited to 'train_cmd.c')
-rw-r--r--train_cmd.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/train_cmd.c b/train_cmd.c
index 21953870f..d39535bfd 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -953,6 +953,9 @@ int32 CmdMoveRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
/* do it? */
if (flags & DC_EXEC) {
+ Vehicle *new_front = GetNextVehicle(src); //used if next in line should make a train on it's own
+ bool make_new_front = src->subtype == TS_Front_Engine;
+
if (HASBIT(p2, 0)) {
// unlink ALL wagons
if (src != src_head) {
@@ -1004,6 +1007,15 @@ int32 CmdMoveRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
dst->next = src;
}
+ /* If there is an engine behind first_engine we moved away, it should become new first_engine
+ * To do this, CmdMoveRailVehicle must be called once more
+ * since we set p2 to a condition that makes the statement false, we can't loop forever with this one */
+ if (make_new_front && new_front != NULL && !(HASBIT(p2, 0))) {
+ if (!(RailVehInfo(new_front->engine_type)->flags & RVI_WAGON)) {
+ CmdMoveRailVehicle(x, y, flags, new_front->index | (INVALID_VEHICLE << 16), 1);
+ }
+ }
+
if (src_head) {
TrainConsistChanged(src_head);
if (src_head->subtype == TS_Front_Engine) {