21 #include "water.h" |
21 #include "water.h" |
22 #include "water_map.h" |
22 #include "water_map.h" |
23 #include "industry_map.h" |
23 #include "industry_map.h" |
24 #include "newgrf.h" |
24 #include "newgrf.h" |
25 #include "newgrf_canal.h" |
25 #include "newgrf_canal.h" |
26 #include "misc/autoptr.hpp" |
|
27 #include "transparency.h" |
26 #include "transparency.h" |
28 #include "strings_func.h" |
27 #include "strings_func.h" |
29 #include "functions.h" |
28 #include "functions.h" |
30 #include "window_func.h" |
29 #include "window_func.h" |
31 #include "vehicle_func.h" |
30 #include "vehicle_func.h" |
194 ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
193 ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
195 if (CmdFailed(ret)) return CMD_ERROR; |
194 if (CmdFailed(ret)) return CMD_ERROR; |
196 ret = DoCommand(tile2, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
195 ret = DoCommand(tile2, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
197 if (CmdFailed(ret)) return CMD_ERROR; |
196 if (CmdFailed(ret)) return CMD_ERROR; |
198 |
197 |
199 Depot *depot = new Depot(tile); |
198 if (!Depot::CanAllocateItem()) return CMD_ERROR; |
200 if (depot == NULL) return CMD_ERROR; |
|
201 AutoPtrT<Depot> d_auto_delete = depot; |
|
202 |
199 |
203 if (flags & DC_EXEC) { |
200 if (flags & DC_EXEC) { |
|
201 Depot *depot = new Depot(tile); |
204 depot->town_index = ClosestTownFromTile(tile, (uint)-1)->index; |
202 depot->town_index = ClosestTownFromTile(tile, (uint)-1)->index; |
205 |
203 |
206 MakeShipDepot(tile, _current_player, DEPOT_NORTH, axis, wc1); |
204 MakeShipDepot(tile, _current_player, DEPOT_NORTH, axis, wc1); |
207 MakeShipDepot(tile2, _current_player, DEPOT_SOUTH, axis, wc2); |
205 MakeShipDepot(tile2, _current_player, DEPOT_SOUTH, axis, wc2); |
208 MarkTileDirtyByTile(tile); |
206 MarkTileDirtyByTile(tile); |
209 MarkTileDirtyByTile(tile2); |
207 MarkTileDirtyByTile(tile2); |
210 d_auto_delete.Detach(); |
|
211 } |
208 } |
212 |
209 |
213 return CommandCost(EXPENSES_CONSTRUCTION, _price.build_ship_depot); |
210 return CommandCost(EXPENSES_CONSTRUCTION, _price.build_ship_depot); |
214 } |
211 } |
215 |
212 |