diff options
author | rubidium <rubidium@openttd.org> | 2007-08-02 22:33:53 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-08-02 22:33:53 +0000 |
commit | 549450d31a4676039e2663e66e23e2f5bae3f7f1 (patch) | |
tree | 04f6cea517d07342aa29326257419e2460c68a49 /src/rail_cmd.cpp | |
parent | 5016f5497ccacd0837d37d5099433b3d7728838b (diff) | |
download | openttd-549450d31a4676039e2663e66e23e2f5bae3f7f1.tar.xz |
(svn r10758) -Codechange: make the depot struct use the pool item class as super class.
Diffstat (limited to 'src/rail_cmd.cpp')
-rw-r--r-- | src/rail_cmd.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index ac22758fa..024fd620d 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -37,6 +37,7 @@ #include "newgrf_callbacks.h" #include "newgrf_station.h" #include "train.h" +#include "misc/autoptr.hpp" const byte _track_sloped_sprites[14] = { 14, 15, 22, 13, @@ -574,7 +575,6 @@ CommandCost CmdRemoveRailroadTrack(TileIndex tile, uint32 flags, uint32 p1, uint */ CommandCost CmdBuildTrainDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { - Depot *d; CommandCost cost; Slope tileh; @@ -609,18 +609,20 @@ CommandCost CmdBuildTrainDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); - d = AllocateDepot(); + Depot *d = new Depot(tile); + if (d == NULL) return CMD_ERROR; + AutoPtrT<Depot> d_auto_delete = d; if (flags & DC_EXEC) { MakeRailDepot(tile, _current_player, dir, (RailType)p1); MarkTileDirtyByTile(tile); - d->xy = tile; d->town_index = ClosestTownFromTile(tile, (uint)-1)->index; UpdateSignalsOnSegment(tile, dir); YapfNotifyTrackLayoutChange(tile, TrackdirToTrack(DiagdirToDiagTrackdir(dir))); + d_auto_delete.Detach(); } return cost.AddCost(_price.build_train_depot); @@ -1110,7 +1112,8 @@ static CommandCost RemoveTrainDepot(TileIndex tile, uint32 flags) if (flags & DC_EXEC) { DiagDirection dir = GetRailDepotDirection(tile); - DeleteDepot(GetDepotByTile(tile)); + DoClearSquare(tile); + delete GetDepotByTile(tile); UpdateSignalsOnSegment(tile, dir); YapfNotifyTrackLayoutChange(tile, TrackdirToTrack(DiagdirToDiagTrackdir(dir))); } |