@@ -1531,48 +1531,50 @@ int32 CmdCloneVehicle(int x, int y, uint
return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
}
v = v_front;
do {
if (IsMultiheaded(v) && !IsTrainEngine(v)) {
/* we build the rear ends of multiheaded trains with the front ones */
continue;
cost = DoCommand(x, y, v->engine_type, 1, flags, CMD_BUILD_VEH(v->type));
if (CmdFailed(cost)) return cost;
total_cost += cost;
if (flags & DC_EXEC) {
w = GetVehicle(_new_vehicle_id);
if (v->type != VEH_Road) { // road vehicles can't be refitted
if (v->cargo_type != w->cargo_type) {
// 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(x, y, w->index, v->cargo_type, flags, CMD_REFIT_VEH(v->type));
if (v->type == VEH_Train && !IsFrontEngine(v)) {
// this s a train car
// add this unit to the end of the train
DoCommand(x, y, (w_rear->index << 16) | w->index, 1, flags, CMD_MOVE_RAIL_VEHICLE);
} else {
// this is a front engine or not a train. It need orders
w_front = w;
DoCommand(x, y, (v->index << 16) | w->index, p2 & 1 ? CO_SHARE : CO_COPY, flags, CMD_CLONE_ORDER);
w_rear = w; // trains needs to know the last car in the train, so they can add more in next loop
} while (v->type == VEH_Train && (v = GetNextVehicle(v)) != NULL);
if (flags & DC_EXEC && v_front->type == VEH_Train) {
// _new_train_id needs to be the front engine due to the callback function
_new_train_id = w_front->index;
return total_cost;
Status change: