summaryrefslogtreecommitdiff
path: root/src/water_cmd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-04-23 20:56:08 +0000
committerrubidium <rubidium@openttd.org>2008-04-23 20:56:08 +0000
commit6939569362a8c3e2c1b5174962309d0d73152845 (patch)
treea6906b106143841dcbc6aea392d11baa75492e05 /src/water_cmd.cpp
parent1ba6e3deebf4c26896491842df51dc26f29a1c5d (diff)
downloadopenttd-6939569362a8c3e2c1b5174962309d0d73152845.tar.xz
(svn r12855) -Codechange: do not use autoptr's for testing whether certain objects can be build, but check it directly in the pool so we do not have to call destructors in the testing phase. Stations still use the autoptr though.
Diffstat (limited to 'src/water_cmd.cpp')
-rw-r--r--src/water_cmd.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp
index 8e16b5856..6412a82b2 100644
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -24,7 +24,6 @@
#include "industry_map.h"
#include "newgrf.h"
#include "newgrf_canal.h"
-#include "misc/autoptr.hpp"
#include "transparency.h"
#include "strings_func.h"
#include "functions.h"
@@ -201,18 +200,16 @@ 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 *depot = new Depot(tile);
- if (depot == NULL) return CMD_ERROR;
- AutoPtrT<Depot> d_auto_delete = depot;
+ if (!Depot::CanAllocateItem()) return CMD_ERROR;
if (flags & DC_EXEC) {
+ Depot *depot = new Depot(tile);
depot->town_index = ClosestTownFromTile(tile, (uint)-1)->index;
MakeShipDepot(tile, _current_player, DEPOT_NORTH, axis, wc1);
MakeShipDepot(tile2, _current_player, DEPOT_SOUTH, axis, wc2);
MarkTileDirtyByTile(tile);
MarkTileDirtyByTile(tile2);
- d_auto_delete.Detach();
}
return CommandCost(EXPENSES_CONSTRUCTION, _price.build_ship_depot);