Changeset - r7389:43e81eaed707
[Not reviewed]
master
0 7 0
rubidium - 17 years ago 2007-08-02 22:33:53
rubidium@openttd.org
(svn r10758) -Codechange: make the depot struct use the pool item class as super class.
7 files changed with 43 insertions and 94 deletions:
0 comments (0 inline, 0 general)
src/depot.cpp
Show inline comments
 
@@ -5,101 +5,59 @@
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "vehicle.h"
 
#include "depot.h"
 
#include "functions.h"
 
#include "landscape.h"
 
#include "tile.h"
 
#include "map.h"
 
#include "table/strings.h"
 
#include "saveload.h"
 
#include "order.h"
 

	
 

	
 
/**
 
 * Called if a new block is added to the depot-pool
 
 */
 
static void DepotPoolNewBlock(uint start_item)
 
{
 
	Depot *d;
 

	
 
	/* We don't use FOR_ALL here, because FOR_ALL skips invalid items.
 
	 * TODO - This is just a temporary stage, this will be removed. */
 
	for (d = GetDepot(start_item); d != NULL; d = (d->index + 1U < GetDepotPoolSize()) ? GetDepot(d->index + 1U) : NULL) d->index = start_item++;
 
}
 

	
 
DEFINE_OLD_POOL(Depot, Depot, DepotPoolNewBlock, NULL)
 

	
 
DEFINE_OLD_POOL_GENERIC(Depot, Depot)
 

	
 
/**
 
 * Gets a depot from a tile
 
 *
 
 * @return Returns the depot if the tile had a depot, else it returns NULL
 
 */
 
Depot *GetDepotByTile(TileIndex tile)
 
{
 
	Depot *depot;
 

	
 
	FOR_ALL_DEPOTS(depot) {
 
		if (depot->xy == tile) return depot;
 
	}
 

	
 
	return NULL;
 
}
 

	
 
/**
 
 * Allocate a new depot
 
 */
 
Depot *AllocateDepot()
 
{
 
	Depot *d;
 

	
 
	/* We don't use FOR_ALL here, because FOR_ALL skips invalid items.
 
	 * TODO - This is just a temporary stage, this will be removed. */
 
	for (d = GetDepot(0); d != NULL; d = (d->index + 1U < GetDepotPoolSize()) ? GetDepot(d->index + 1U) : NULL) {
 
		if (!IsValidDepot(d)) {
 
			DepotID index = d->index;
 

	
 
			memset(d, 0, sizeof(Depot));
 
			d->index = index;
 

	
 
			return d;
 
		}
 
	}
 

	
 
	/* Check if we can add a block to the pool */
 
	if (AddBlockToPool(&_Depot_pool)) return AllocateDepot();
 

	
 
	return NULL;
 
}
 

	
 
/**
 
 * Clean up a depot
 
 */
 
void DestroyDepot(Depot *depot)
 
Depot::~Depot()
 
{
 
	/* Clear the tile */
 
	DoClearSquare(depot->xy);
 

	
 
	/* Clear the depot from all order-lists */
 
	RemoveOrderFromAllVehicles(OT_GOTO_DEPOT, depot->index);
 
	RemoveOrderFromAllVehicles(OT_GOTO_DEPOT, this->index);
 

	
 
	/* Delete the depot-window */
 
	DeleteWindowById(WC_VEHICLE_DEPOT, depot->xy);
 
	DeleteWindowById(WC_VEHICLE_DEPOT, this->xy);
 
	this->xy = 0;
 
}
 

	
 
void InitializeDepots()
 
{
 
	CleanPool(&_Depot_pool);
 
	AddBlockToPool(&_Depot_pool);
 
	_Depot_pool.CleanPool();
 
	_Depot_pool.AddBlockToPool();
 
}
 

	
 

	
 
static const SaveLoad _depot_desc[] = {
 
	SLE_CONDVAR(Depot, xy,         SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
 
	SLE_CONDVAR(Depot, xy,         SLE_UINT32,                 6, SL_MAX_VERSION),
 
	    SLE_VAR(Depot, town_index, SLE_UINT16),
 
	SLE_END()
 
};
 

	
 
static void Save_DEPT()
 
{
 
@@ -107,25 +65,20 @@ static void Save_DEPT()
 

	
 
	FOR_ALL_DEPOTS(depot) {
 
		SlSetArrayIndex(depot->index);
 
		SlObject(depot, _depot_desc);
 
	}
 
}
 

	
 
static void Load_DEPT()
 
{
 
	int index;
 

	
 
	while ((index = SlIterateArray()) != -1) {
 
		Depot *depot;
 

	
 
		if (!AddBlockIfNeeded(&_Depot_pool, index))
 
			error("Depots: failed loading savegame: too many depots");
 

	
 
		depot = GetDepot(index);
 
		Depot *depot = new (index) Depot();
 
		SlObject(depot, _depot_desc);
 
	}
 
}
 

	
 
extern const ChunkHandler _depot_chunk_handlers[] = {
 
	{ 'DEPT', Save_DEPT, Load_DEPT, CH_ARRAY | CH_LAST},
 
};
src/depot.h
Show inline comments
 
@@ -4,56 +4,45 @@
 

	
 
#ifndef DEPOT_H
 
#define DEPOT_H
 

	
 
#include "direction.h"
 
#include "oldpool.h"
 
#include "tile.h"
 
#include "variables.h"
 
#include "road_map.h"
 
#include "rail_map.h"
 
#include "water_map.h"
 

	
 
struct Depot {
 
	TileIndex xy;
 
	TownID town_index;
 
	DepotID index;
 
};
 

	
 
struct Depot;
 
DECLARE_OLD_POOL(Depot, Depot, 3, 8000)
 

	
 
/**
 
 * Check if a depot really exists.
 
 */
 
static inline bool IsValidDepot(const Depot *depot)
 
{
 
	return depot != NULL && depot->xy != 0;
 
}
 
struct Depot : PoolItem<Depot, DepotID, &_Depot_pool> {
 
	TileIndex xy;
 
	TownID town_index;
 

	
 
static inline bool IsValidDepotID(uint index)
 
	Depot(TileIndex xy = 0) : xy(xy) {}
 
	~Depot();
 

	
 
	bool IsValid() const { return this->xy != 0; }
 
};
 

	
 
static inline bool IsValidDepotID(DepotID index)
 
{
 
	return index < GetDepotPoolSize() && IsValidDepot(GetDepot(index));
 
}
 

	
 
void DestroyDepot(Depot *depot);
 

	
 
static inline void DeleteDepot(Depot *depot)
 
{
 
	DestroyDepot(depot);
 
	depot->xy = 0;
 
	return index < GetDepotPoolSize() && GetDepot(index)->IsValid();
 
}
 

	
 
void ShowDepotWindow(TileIndex tile, VehicleType type);
 

	
 
#define FOR_ALL_DEPOTS_FROM(d, start) for (d = GetDepot(start); d != NULL; d = (d->index + 1U < GetDepotPoolSize()) ? GetDepot(d->index + 1U) : NULL) if (IsValidDepot(d))
 
#define FOR_ALL_DEPOTS_FROM(d, start) for (d = GetDepot(start); d != NULL; d = (d->index + 1U < GetDepotPoolSize()) ? GetDepot(d->index + 1U) : NULL) if (d->IsValid())
 
#define FOR_ALL_DEPOTS(d) FOR_ALL_DEPOTS_FROM(d, 0)
 

	
 
#define MIN_SERVINT_PERCENT  5
 
#define MAX_SERVINT_PERCENT 90
 
#define MIN_SERVINT_DAYS    30
 
#define MAX_SERVINT_DAYS   800
 

	
 
/**
 
 * Get the service interval domain.
 
 * Get the new proposed service interval for the vehicle is indeed, clamped
 
 * within the given bounds. @see MIN_SERVINT_PERCENT ,etc.
 
 * @param index proposed service interval
 
@@ -99,17 +88,16 @@ static inline bool IsTileDepotType(TileI
 
 * 01 (exit towards SE) we need either bit 1 or 2 set in tileh: 0x4C >> 1 = 0110<p>
 
 * 02 (exit towards SW) we need either bit 0 or 1 set in tileh: 0x4C >> 2 = 0011<p>
 
 * 03 (exit towards NW) we need either bit 0 or 4 set in tileh: 0x4C >> 3 = 1001<p>
 
 * So ((0x4C >> direction) & tileh) determines whether the depot can be built on the current tileh
 
 */
 
static inline bool CanBuildDepotByTileh(DiagDirection direction, Slope tileh)
 
{
 
	return ((0x4C >> direction) & tileh) != 0;
 
}
 

	
 
Depot *GetDepotByTile(TileIndex tile);
 
void InitializeDepots();
 
Depot *AllocateDepot();
 

	
 
void DeleteDepotHighlightOfVehicle(const Vehicle *v);
 

	
 
#endif /* DEPOT_H */
src/oldloader.cpp
Show inline comments
 
@@ -511,25 +511,25 @@ static const OldChunks depot_chunk[] = {
 
	OCL_SVAR(   OC_TILE, Depot, xy ),
 
	OCL_VAR ( OC_UINT32,   1, &_old_town_index ),
 
	OCL_END()
 
};
 

	
 
static bool LoadOldDepot(LoadgameState *ls, int num)
 
{
 
	if (!AddBlockIfNeeded(&_Depot_pool, num))
 
		error("Depots: failed loading savegame: too many depots");
 

	
 
	if (!LoadChunk(ls, GetDepot(num), depot_chunk)) return false;
 

	
 
	if (IsValidDepot(GetDepot(num))) {
 
	if (IsValidDepotID(num)) {
 
		GetDepot(num)->town_index = REMAP_TOWN_IDX(_old_town_index);
 
	}
 

	
 
	return true;
 
}
 

	
 
static int32 _old_price;
 
static uint16 _old_price_frac;
 
static const OldChunks price_chunk[] = {
 
	OCL_VAR (  OC_INT32,   1, &_old_price ),
 
	OCL_VAR ( OC_UINT16,   1, &_old_price_frac ),
 
	OCL_END()
src/rail_cmd.cpp
Show inline comments
 
@@ -28,24 +28,25 @@
 
#include "station.h"
 
#include "sprite.h"
 
#include "depot.h"
 
#include "waypoint.h"
 
#include "window.h"
 
#include "rail.h"
 
#include "railtypes.h" // include table for railtypes
 
#include "newgrf.h"
 
#include "yapf/yapf.h"
 
#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,
 
	 0, 21, 17, 12,
 
	23,  0, 18, 20,
 
	19, 16
 
};
 

	
 

	
 
/*         4
 
 *     ---------
 
 *    |\       /|
 
@@ -565,25 +566,24 @@ CommandCost CmdRemoveRailroadTrack(TileI
 

	
 
/** Build a train depot
 
 * @param tile position of the train depot
 
 * @param flags operation to perform
 
 * @param p1 rail type
 
 * @param p2 bit 0..1 entrance direction (DiagDirection)
 
 *
 
 * @todo When checking for the tile slope,
 
 * distingush between "Flat land required" and "land sloped in wrong direction"
 
 */
 
CommandCost CmdBuildTrainDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Depot *d;
 
	CommandCost cost;
 
	Slope tileh;
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
 

	
 
	/* check railtype and valid direction for depot (0 through 3), 4 in total */
 
	if (!ValParamRailtype(p1)) return CMD_ERROR;
 

	
 
	tileh = GetTileSlope(tile, NULL);
 

	
 
	DiagDirection dir = Extract<DiagDirection, 0>(p2);
 

	
 
@@ -600,36 +600,38 @@ CommandCost CmdBuildTrainDepot(TileIndex
 
				!_patches.build_on_slopes ||
 
				IsSteepSlope(tileh) ||
 
				!CanBuildDepotByTileh(dir, tileh)
 
			)) {
 
		return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
 
	}
 

	
 
	cost = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
 
	if (CmdFailed(cost)) return CMD_ERROR;
 

	
 
	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);
 
}
 

	
 
/** Build signals, alternate between double/single, signal/semaphore,
 
 * pre/exit/combo-signals, and what-else not. If the rail piece does not
 
 * have any signals, bit 4 (cycle signal-type) is ignored
 
 * @param tile tile where to build the signals
 
 * @param flags operation to perform
 
 * @param p1 various bitstuffed elements
 
 * - p1 = (bit 0-2) - track-orientation, valid values: 0-5 (Track enum)
 
@@ -1101,25 +1103,26 @@ CommandCost CmdConvertRail(TileIndex til
 

	
 
static CommandCost RemoveTrainDepot(TileIndex tile, uint32 flags)
 
{
 
	if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER)
 
		return CMD_ERROR;
 

	
 
	if (!EnsureNoVehicleOnGround(tile))
 
		return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
		DiagDirection dir = GetRailDepotDirection(tile);
 

	
 
		DeleteDepot(GetDepotByTile(tile));
 
		DoClearSquare(tile);
 
		delete GetDepotByTile(tile);
 
		UpdateSignalsOnSegment(tile, dir);
 
		YapfNotifyTrackLayoutChange(tile, TrackdirToTrack(DiagdirToDiagTrackdir(dir)));
 
	}
 

	
 
	return CommandCost(_price.remove_train_depot);
 
}
 

	
 
static CommandCost ClearTile_Track(TileIndex tile, byte flags)
 
{
 
	CommandCost cost;
 
	CommandCost ret;
 

	
src/road_cmd.cpp
Show inline comments
 
@@ -22,24 +22,25 @@
 
#include "vehicle.h"
 
#include "viewport.h"
 
#include "command.h"
 
#include "player.h"
 
#include "town.h"
 
#include "gfx.h"
 
#include "sound.h"
 
#include "yapf/yapf.h"
 
#include "depot.h"
 
#include "newgrf.h"
 
#include "station_map.h"
 
#include "tunnel_map.h"
 
#include "misc/autoptr.hpp"
 

	
 

	
 
static uint CountRoadBits(RoadBits r)
 
{
 
	uint count = 0;
 

	
 
	if (r & ROAD_NW) ++count;
 
	if (r & ROAD_SW) ++count;
 
	if (r & ROAD_SE) ++count;
 
	if (r & ROAD_NE) ++count;
 
	return count;
 
}
 
@@ -712,69 +713,72 @@ CommandCost CmdRemoveLongRoad(TileIndex 
 
 * @param tile tile where to build the depot
 
 * @param flags operation to perform
 
 * @param p1 bit 0..1 entrance direction (DiagDirection)
 
 *           bit 2..3 road type
 
 * @param p2 unused
 
 *
 
 * @todo When checking for the tile slope,
 
 * distingush between "Flat land required" and "land sloped in wrong direction"
 
 */
 
CommandCost CmdBuildRoadDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	CommandCost cost;
 
	Depot *dep;
 
	Slope tileh;
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
 

	
 
	DiagDirection dir = Extract<DiagDirection, 0>(p1);
 
	RoadType rt = (RoadType)GB(p1, 2, 2);
 

	
 
	if (!IsValidRoadType(rt)) return CMD_ERROR;
 

	
 
	tileh = GetTileSlope(tile, NULL);
 
	if (tileh != SLOPE_FLAT && (
 
				!_patches.build_on_slopes ||
 
				IsSteepSlope(tileh) ||
 
				!CanBuildDepotByTileh(dir, tileh)
 
			)) {
 
		return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
 
	}
 

	
 
	cost = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
 
	if (CmdFailed(cost)) return CMD_ERROR;
 

	
 
	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);
 
}
 

	
 
static CommandCost RemoveRoadDepot(TileIndex tile, uint32 flags)
 
{
 
	if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER)
 
		return CMD_ERROR;
 

	
 
	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);
 
}
 

	
 
static CommandCost ClearTile_Road(TileIndex tile, byte flags)
 
{
 
	switch (GetRoadTileType(tile)) {
 
		case ROAD_TILE_NORMAL: {
 
			RoadBits b = GetAllRoadBits(tile);
 

	
 
#define M(x) (1 << (x))
 
			/* Clear the road if only one piece is on the tile OR the AI tries
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -878,25 +878,25 @@ Foundation GetBridgeFoundation(Slope til
 
 * @param offset  number representing whether to level or sloped and the direction
 
 * @param overlay do we want to still see the road?
 
 */
 
static void DrawBridgeTramBits(int x, int y, byte z, int offset, bool overlay)
 
{
 
	static const SpriteID tram_offsets[2][6] = { { 107, 108, 109, 110, 111, 112 }, { 4, 5, 15, 16, 17, 18 } };
 
	static const SpriteID back_offsets[6]    =   {  95,  96,  99, 102, 100, 101 };
 
	static const SpriteID front_offsets[6]   =   {  97,  98, 103, 106, 104, 105 };
 

	
 
	static const uint size_x[6] = { 11, 16, 16, 16, 16, 16 };
 
	static const uint size_y[6] = { 16, 11, 16, 16, 16, 16 };
 

	
 
	AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + tram_offsets[overlay][offset], PAL_NONE, x, y, size_x[offset], size_y[offset], offset >= 2 ? 1 : 0, z);
 
	AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + tram_offsets[overlay][offset], PAL_NONE, x, y, size_x[offset], size_y[offset], offset >= 2 ? 1 : 0, z, HASBIT(_transparent_opt, TO_BRIDGES));
 

	
 
	AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + back_offsets[offset],  PAL_NONE, x, y, size_x[offset], size_y[offset], 0, z, HASBIT(_transparent_opt, TO_BUILDINGS));
 
	/* For sloped sprites the bounding box needs to be higher, as the pylons stop on a higher point */
 
	AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + front_offsets[offset], PAL_NONE, x, y, size_x[offset], size_y[offset], offset >= 2 ? 0x30 : 0x10, z, HASBIT(_transparent_opt, TO_BUILDINGS));
 
}
 

	
 
/**
 
 * Draws a tunnel of bridge tile.
 
 * For tunnels, this is rather simple, as you only needa draw the entrance.
 
 * Bridges are a bit more complex. base_offset is where the sprite selection comes into play
 
 * and it works a bit like a bitmask.<p> For bridge heads:
 
 * @param ti TileInfo of the structure to draw
src/water_cmd.cpp
Show inline comments
 
@@ -19,24 +19,25 @@
 
#include "viewport.h"
 
#include "command.h"
 
#include "town.h"
 
#include "news.h"
 
#include "sound.h"
 
#include "depot.h"
 
#include "vehicle_gui.h"
 
#include "train.h"
 
#include "roadveh.h"
 
#include "water_map.h"
 
#include "newgrf.h"
 
#include "newgrf_canal.h"
 
#include "misc/autoptr.hpp"
 

	
 
static const SpriteID _water_shore_sprites[] = {
 
	0,
 
	SPR_SHORE_TILEH_1,
 
	SPR_SHORE_TILEH_2,
 
	SPR_SHORE_TILEH_3,
 
	SPR_SHORE_TILEH_4,
 
	0,
 
	SPR_SHORE_TILEH_6,
 
	0,
 
	SPR_SHORE_TILEH_8,
 
	SPR_SHORE_TILEH_9,
 
@@ -53,76 +54,76 @@ static void FloodVehicle(Vehicle *v);
 

	
 
/** Build a ship depot.
 
 * @param tile tile where ship depot is built
 
 * @param flags type of operation
 
 * @param p1 bit 0 depot orientation (Axis)
 
 * @param p2 unused
 
 */
 
CommandCost CmdBuildShipDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	TileIndex tile2;
 

	
 
	CommandCost cost, ret;
 
	Depot *depot;
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
 

	
 
	if (!EnsureNoVehicle(tile)) return CMD_ERROR;
 

	
 
	Axis axis = Extract<Axis, 0>(p1);
 

	
 
	tile2 = tile + (axis == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1));
 
	if (!EnsureNoVehicle(tile2)) return CMD_ERROR;
 

	
 
	if (!IsClearWaterTile(tile) || !IsClearWaterTile(tile2))
 
		return_cmd_error(STR_3801_MUST_BE_BUILT_ON_WATER);
 

	
 
	if (IsBridgeAbove(tile) || IsBridgeAbove(tile2)) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
 

	
 
	ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
 
	if (CmdFailed(ret)) return CMD_ERROR;
 
	ret = DoCommand(tile2, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
 
	if (CmdFailed(ret)) return CMD_ERROR;
 

	
 
	depot = AllocateDepot();
 
	Depot *depot = new Depot(tile);
 
	if (depot == NULL) return CMD_ERROR;
 
	AutoPtrT<Depot> d_auto_delete = depot;
 

	
 
	if (flags & DC_EXEC) {
 
		depot->xy = tile;
 
		depot->town_index = ClosestTownFromTile(tile, (uint)-1)->index;
 

	
 
		MakeShipDepot(tile,  _current_player, DEPOT_NORTH, axis);
 
		MakeShipDepot(tile2, _current_player, DEPOT_SOUTH, axis);
 
		MarkTileDirtyByTile(tile);
 
		MarkTileDirtyByTile(tile2);
 
		d_auto_delete.Detach();
 
	}
 

	
 
	return cost.AddCost(_price.build_ship_depot);
 
}
 

	
 
static CommandCost RemoveShipDepot(TileIndex tile, uint32 flags)
 
{
 
	TileIndex tile2;
 

	
 
	if (!IsShipDepot(tile)) return CMD_ERROR;
 
	if (!CheckTileOwnership(tile)) return CMD_ERROR;
 
	if (!EnsureNoVehicle(tile)) return CMD_ERROR;
 

	
 
	tile2 = GetOtherShipDepotTile(tile);
 

	
 
	if (!EnsureNoVehicle(tile2)) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
		/* Kill the depot, which is registered at the northernmost tile. Use that one */
 
		DeleteDepot(GetDepotByTile(tile2 < tile ? tile2 : tile));
 
		delete GetDepotByTile(tile2 < tile ? tile2 : tile);
 

	
 
		MakeWater(tile);
 
		MakeWater(tile2);
 
		MarkTileDirtyByTile(tile);
 
		MarkTileDirtyByTile(tile2);
 
	}
 

	
 
	return CommandCost(_price.remove_ship_depot);
 
}
 

	
 
/** build a shiplift */
 
static CommandCost DoBuildShiplift(TileIndex tile, DiagDirection dir, uint32 flags)
0 comments (0 inline, 0 general)