diff options
author | rubidium <rubidium@openttd.org> | 2007-08-03 19:36:00 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-08-03 19:36:00 +0000 |
commit | b21f29c38fc1629a1c03991b217d0a96d205a159 (patch) | |
tree | ea92676733322e0fc10f54254112dd92b294ebfb /src/ship_cmd.cpp | |
parent | 7e9594e0a506f00951db4c3c654bb819b89d0d66 (diff) | |
download | openttd-b21f29c38fc1629a1c03991b217d0a96d205a159.tar.xz |
(svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
-Codechange: do not force "special" vehicles to be allocated in the low 1024 vehicle slots and non "special" vehicles in the rest of the slots.
Diffstat (limited to 'src/ship_cmd.cpp')
-rw-r--r-- | src/ship_cmd.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index 4a8fbe630..1cba23e0d 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -33,6 +33,7 @@ #include "newgrf_sound.h" #include "date.h" #include "spritecache.h" +#include "misc/autoptr.hpp" static const uint16 _ship_sprites[] = {0x0E5D, 0x0E55, 0x0E65, 0x0E6D}; @@ -833,8 +834,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 = AllocateVehicle(); + 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) return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); @@ -898,6 +900,8 @@ CommandCost CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) InvalidateAutoreplaceWindow(VEH_SHIP, v->group_id); // updates the replace Ship window GetPlayer(_current_player)->num_engines[p1]++; + + v_auto_delete.Detach(); } return value; @@ -931,7 +935,7 @@ CommandCost CmdSellShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) InvalidateWindow(WC_COMPANY, v->owner); DeleteWindowById(WC_VEHICLE_VIEW, v->index); DeleteDepotHighlightOfVehicle(v); - DeleteVehicle(v); + delete v; } return CommandCost(-v->value); |