diff options
author | bjarni <bjarni@openttd.org> | 2007-02-17 13:50:22 +0000 |
---|---|---|
committer | bjarni <bjarni@openttd.org> | 2007-02-17 13:50:22 +0000 |
commit | 790a3f5d5e6cb6987361518b3d7dd15449702270 (patch) | |
tree | 9379f4d2ddfcf057fb6767a7b8310b747de5547f /src | |
parent | d71a8f6ac48effc690314bb22c4a6108cebbbf92 (diff) | |
download | openttd-790a3f5d5e6cb6987361518b3d7dd15449702270.tar.xz |
(svn r8777) -Fix: FS#596 Cloning Maglev in UKRS forgets Mail refit
Cloning were unaware that articulated locomotives could refit without refitting the front unit
Diffstat (limited to 'src')
-rw-r--r-- | src/vehicle.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp index f76a49b96..ac5f93fbc 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -1848,11 +1848,18 @@ int32 CmdCloneVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) if (flags & DC_EXEC) { w = GetVehicle(_new_vehicle_id); - if (v->cargo_type != w->cargo_type || v->cargo_subtype != w->cargo_subtype) { - // we can't pay for refitting because we can't estimate refitting costs for a vehicle before it's build - // if we pay for it anyway, the cost and the estimated cost will not be the same and we will have an assert - DoCommand(0, w->index, v->cargo_type | (v->cargo_subtype << 8), flags, GetCmdRefitVeh(v)); - } + Vehicle *w2 = w; + Vehicle *v2 = v; + do { + if (v2->cargo_type != w2->cargo_type || v2->cargo_subtype != w2->cargo_subtype) { + /* We can't pay for refitting because we can't estimate refitting costs for a vehicle before it's build. + * If we pay for it anyway, the cost and the estimated cost will not be the same and we will have an assert. + * We need to check the whole chain if it is a train because some newgrf articulated engines can refit some units only (and not the front) */ + DoCommand(0, w->index, v2->cargo_type | (v2->cargo_subtype << 8), flags, GetCmdRefitVeh(v)); + break; // We learned that the engine in question needed a refit. No need to check anymore + } + } while (v->type == VEH_Train && (w2 = w2->next) != NULL && (v2 = v2->next) != NULL); + if (v->type == VEH_Train && HASBIT(v->u.rail.flags, VRF_REVERSE_DIRECTION)) { SETBIT(w->u.rail.flags, VRF_REVERSE_DIRECTION); } |