summaryrefslogtreecommitdiff
path: root/src/rail_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
commitd56827a9a9a109b639a25514f1a6424ba9111a70 (patch)
treea6906b106143841dcbc6aea392d11baa75492e05 /src/rail_cmd.cpp
parenta204a3b70e93db0b4fab77b2a1015ebf81ca6e1f (diff)
downloadopenttd-d56827a9a9a109b639a25514f1a6424ba9111a70.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/rail_cmd.cpp')
-rw-r--r--src/rail_cmd.cpp8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 9caf2132f..c08014d12 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -30,7 +30,6 @@
#include "newgrf_callbacks.h"
#include "newgrf_station.h"
#include "train.h"
-#include "misc/autoptr.hpp"
#include "variables.h"
#include "autoslope.h"
#include "transparency.h"
@@ -766,12 +765,10 @@ CommandCost CmdBuildTrainDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p
if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
- Depot *d = new Depot(tile);
-
- if (d == NULL) return CMD_ERROR;
- AutoPtrT<Depot> d_auto_delete = d;
+ if (!Depot::CanAllocateItem()) return CMD_ERROR;
if (flags & DC_EXEC) {
+ Depot *d = new Depot(tile);
MakeRailDepot(tile, _current_player, dir, (RailType)p1);
MarkTileDirtyByTile(tile);
@@ -779,7 +776,6 @@ CommandCost CmdBuildTrainDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p
AddSideToSignalBuffer(tile, INVALID_DIAGDIR, _current_player);
YapfNotifyTrackLayoutChange(tile, TrackdirToTrack(DiagdirToDiagTrackdir(dir)));
- d_auto_delete.Detach();
}
return cost.AddCost(_price.build_train_depot);