From 5dc0e86d1b92b79555711ae308f2aae81fa1fb0f Mon Sep 17 00:00:00 2001 From: rubidium Date: Sun, 9 Dec 2007 15:15:26 +0000 Subject: (svn r11605) -Fix [FS#1482, FS#1523]: wrong count of Kirby trains when a ship was build. --- src/ship_cmd.cpp | 9 ++------- 1 file 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 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; -- cgit v1.2.3-54-g00ecf