diff options
author | rubidium <rubidium@openttd.org> | 2007-12-09 15:15:26 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-12-09 15:15:26 +0000 |
commit | b6bc3aa698224ac6a22919f66486c340af1cebfd (patch) | |
tree | cbda42721824980109ad17b656d2ab1a522947b7 | |
parent | d03207df569559d63207acc819d90e26fed6eed6 (diff) | |
download | openttd-b6bc3aa698224ac6a22919f66486c340af1cebfd.tar.xz |
(svn r11605) -Fix [FS#1482, FS#1523]: wrong count of Kirby trains when a ship was build.
-rw-r--r-- | src/ship_cmd.cpp | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index 99fe66200..31f41018a 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -806,7 +806,6 @@ void ShipsYearlyLoop() CommandCost CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { CommandCost value; - Vehicle *v; UnitID unit_num; Engine *e; @@ -822,11 +821,9 @@ CommandCost CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) if (!IsTileDepotType(tile, TRANSPORT_WATER)) return CMD_ERROR; if (!IsTileOwner(tile, _current_player)) return CMD_ERROR; - v = new Ship(); unit_num = HasBit(p2, 0) ? 0 : GetFreeUnitNumber(VEH_SHIP); - AutoPtrT<Vehicle> v_auto_delete = v; - if (v == NULL || unit_num > _patches.max_ships) + if (!Vehicle::AllocateList(NULL, 1) || unit_num > _patches.max_ships) return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); if (flags & DC_EXEC) { @@ -835,7 +832,7 @@ CommandCost CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) const ShipVehicleInfo *svi = ShipVehInfo(p1); - v = new (v) Ship(); + Vehicle *v = new Ship(); v->unitnumber = unit_num; v->owner = _current_player; @@ -888,8 +885,6 @@ CommandCost CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) InvalidateAutoreplaceWindow(v->engine_type, v->group_id); // updates the replace Ship window GetPlayer(_current_player)->num_engines[p1]++; - - v_auto_delete.Detach(); } return value; |