(svn r11605) -Fix [FS#1482, FS#1523]: wrong count of Kirby trains when a ship was build.
--- a/src/ship_cmd.cpp Sat Dec 08 21:57:24 2007 +0000
+++ b/src/ship_cmd.cpp Sun Dec 09 15:15:26 2007 +0000
@@ -806,7 +806,6 @@
CommandCost CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
CommandCost value;
- Vehicle *v;
UnitID unit_num;
Engine *e;
@@ -822,11 +821,9 @@
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 @@
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 @@
InvalidateAutoreplaceWindow(v->engine_type, v->group_id); // updates the replace Ship window
GetPlayer(_current_player)->num_engines[p1]++;
-
- v_auto_delete.Detach();
}
return value;