From 2e05a16959ff23ff504f823a9d2b8d92a9a3f873 Mon Sep 17 00:00:00 2001 From: bjarni Date: Thu, 11 May 2006 13:31:14 +0000 Subject: (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 --- ship_cmd.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'ship_cmd.c') diff --git a/ship_cmd.c b/ship_cmd.c index 3cb66e430..1d6e1383d 100644 --- a/ship_cmd.c +++ b/ship_cmd.c @@ -811,7 +811,7 @@ void ShipsYearlyLoop(void) /** Build a ship. * @param tile tile of depot where ship is built * @param p1 ship type being built (engine) - * @param p2 unused + * @param p2 bit 0 when set, the unitnumber will be 0, otherwise it will be a free number */ int32 CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { @@ -833,8 +833,9 @@ int32 CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) if (!IsTileOwner(tile, _current_player)) return CMD_ERROR; v = AllocateVehicle(); - if (v == NULL || IsOrderPoolFull() || - (unit_num = GetFreeUnitNumber(VEH_Ship)) > _patches.max_ships) + unit_num = (HASBIT(p2, 0) == true) ? 0 : GetFreeUnitNumber(VEH_Ship); + + if (v == NULL || IsOrderPoolFull() || unit_num > _patches.max_ships) return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); if (flags & DC_EXEC) { -- cgit v1.2.3-70-g09d2