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/road_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/road_cmd.cpp')
-rw-r--r-- | src/road_cmd.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index b6abc4b35..621338ea9 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -31,6 +31,7 @@ #include "newgrf.h" #include "station_map.h" #include "tunnel_map.h" +#include "misc/autoptr.hpp" static uint CountRoadBits(RoadBits r) @@ -721,7 +722,6 @@ CommandCost CmdRemoveLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint3 CommandCost CmdBuildRoadDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { CommandCost cost; - Depot *dep; Slope tileh; SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); @@ -745,15 +745,16 @@ CommandCost CmdBuildRoadDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2 if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); - dep = AllocateDepot(); + Depot *dep = new Depot(tile); if (dep == NULL) return CMD_ERROR; + AutoPtrT<Depot> d_auto_delete = dep; if (flags & DC_EXEC) { - dep->xy = tile; dep->town_index = ClosestTownFromTile(tile, (uint)-1)->index; MakeRoadDepot(tile, _current_player, dir, rt); MarkTileDirtyByTile(tile); + d_auto_delete.Detach(); } return cost.AddCost(_price.build_road_depot); } @@ -765,7 +766,10 @@ static CommandCost RemoveRoadDepot(TileIndex tile, uint32 flags) if (!EnsureNoVehicle(tile)) return CMD_ERROR; - if (flags & DC_EXEC) DeleteDepot(GetDepotByTile(tile)); + if (flags & DC_EXEC) { + DoClearSquare(tile); + delete GetDepotByTile(tile); + } return CommandCost(_price.remove_road_depot); } |