summaryrefslogtreecommitdiff
path: root/src/water_cmd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-08-02 22:33:53 +0000
committerrubidium <rubidium@openttd.org>2007-08-02 22:33:53 +0000
commit549450d31a4676039e2663e66e23e2f5bae3f7f1 (patch)
tree04f6cea517d07342aa29326257419e2460c68a49 /src/water_cmd.cpp
parent5016f5497ccacd0837d37d5099433b3d7728838b (diff)
downloadopenttd-549450d31a4676039e2663e66e23e2f5bae3f7f1.tar.xz
(svn r10758) -Codechange: make the depot struct use the pool item class as super class.
Diffstat (limited to 'src/water_cmd.cpp')
-rw-r--r--src/water_cmd.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp
index 792017130..f942349af 100644
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -28,6 +28,7 @@
#include "water_map.h"
#include "newgrf.h"
#include "newgrf_canal.h"
+#include "misc/autoptr.hpp"
static const SpriteID _water_shore_sprites[] = {
0,
@@ -62,7 +63,6 @@ CommandCost CmdBuildShipDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
TileIndex tile2;
CommandCost cost, ret;
- Depot *depot;
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
@@ -83,17 +83,18 @@ CommandCost CmdBuildShipDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
ret = DoCommand(tile2, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(ret)) return CMD_ERROR;
- depot = AllocateDepot();
+ Depot *depot = new Depot(tile);
if (depot == NULL) return CMD_ERROR;
+ AutoPtrT<Depot> d_auto_delete = depot;
if (flags & DC_EXEC) {
- depot->xy = tile;
depot->town_index = ClosestTownFromTile(tile, (uint)-1)->index;
MakeShipDepot(tile, _current_player, DEPOT_NORTH, axis);
MakeShipDepot(tile2, _current_player, DEPOT_SOUTH, axis);
MarkTileDirtyByTile(tile);
MarkTileDirtyByTile(tile2);
+ d_auto_delete.Detach();
}
return cost.AddCost(_price.build_ship_depot);
@@ -113,7 +114,7 @@ static CommandCost RemoveShipDepot(TileIndex tile, uint32 flags)
if (flags & DC_EXEC) {
/* Kill the depot, which is registered at the northernmost tile. Use that one */
- DeleteDepot(GetDepotByTile(tile2 < tile ? tile2 : tile));
+ delete GetDepotByTile(tile2 < tile ? tile2 : tile);
MakeWater(tile);
MakeWater(tile2);