From d56827a9a9a109b639a25514f1a6424ba9111a70 Mon Sep 17 00:00:00 2001 From: rubidium Date: Wed, 23 Apr 2008 20:56:08 +0000 Subject: (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. --- src/rail_cmd.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src/rail_cmd.cpp') 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 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); -- cgit v1.2.3-54-g00ecf