summaryrefslogtreecommitdiff
path: root/vehicle.c
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2006-05-11 13:31:14 +0000
committerbjarni <bjarni@openttd.org>2006-05-11 13:31:14 +0000
commit2e05a16959ff23ff504f823a9d2b8d92a9a3f873 (patch)
treefc7719c3c53e3f59a9936181309d7e95d37f5698 /vehicle.c
parent06156142d4857acb6ed04166c28b2ec787ec9c10 (diff)
downloadopenttd-2e05a16959ff23ff504f823a9d2b8d92a9a3f873.tar.xz
(svn r4826) -Fix: [autoreplace] fixed possible problem when autoreplacing and was number of vehicles (of a type, not total) was reached
now the new vehicle gets the same number as the old one, completely removing the problem where we could run out of numbers since we don't have to find free numbers for the new vehicles, autoreplace should be somewhat faster, specially in late games NOTE: in CmdBuildRailVehicle(), bit 0 and 1 in p2 have been switched to make the meaning of bit 0 consistent with the other build commands. CmdCloneVehicle() is modified to follow this as well
Diffstat (limited to 'vehicle.c')
-rw-r--r--vehicle.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/vehicle.c b/vehicle.c
index 9404a6db2..3d1103014 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -1490,7 +1490,7 @@ int32 CmdCloneVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
Vehicle *v_front, *v;
Vehicle *w_front, *w, *w_rear;
int cost, total_cost = 0;
- uint32 build_argument = 1;
+ uint32 build_argument = 2;
if (!IsVehicleIndex(p1)) return CMD_ERROR;
v = GetVehicle(p1);
@@ -1624,7 +1624,7 @@ static int32 ReplaceVehicle(Vehicle **w, byte flags)
new_engine_type = EngineReplacementForPlayer(p, old_v->engine_type);
if (new_engine_type == INVALID_ENGINE) new_engine_type = old_v->engine_type;
- cost = DoCommand(old_v->tile, new_engine_type, 1, flags, CMD_BUILD_VEH(old_v->type));
+ cost = DoCommand(old_v->tile, new_engine_type, 3, flags, CMD_BUILD_VEH(old_v->type));
if (CmdFailed(cost)) return cost;
if (flags & DC_EXEC) {
@@ -1660,6 +1660,7 @@ static int32 ReplaceVehicle(Vehicle **w, byte flags)
new_v->profit_last_year = old_v->profit_last_year;
new_v->service_interval = old_v->service_interval;
new_front = true;
+ new_v->unitnumber = old_v->unitnumber; // use the same unit number
new_v->current_order = old_v->current_order;
if (old_v->type == VEH_Train && GetNextVehicle(old_v) != NULL){