(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
This commit is contained in:
bjarni
2006-05-11 13:31:14 +00:00
parent 37ec349dec
commit f17a23e06a
5 changed files with 18 additions and 20 deletions

View File

@@ -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) {