(svn r12754) -Codechange: split depot.h into depot_map.h, depot_func.h and depot_base.h and remove quite a lot of unneeded (before this) includes of depot.h.

pull/155/head
rubidium 16 years ago
parent ec588da9e8
commit 6d063c3ad6

@ -16,7 +16,6 @@
#include "../../industry.h"
#include "../../pathfind.h"
#include "../../airport.h"
#include "../../depot.h"
#include "../../variables.h"
#include "../../bridge.h"
#include "../../date_func.h"

@ -6,7 +6,6 @@
#include "../../debug.h"
#include "../../command_func.h"
#include "trolly.h"
#include "../../depot.h"
#include "../../tunnel_map.h"
#include "../../bridge.h"
#include "../../tunnelbridge_map.h"

@ -24,12 +24,13 @@
#include "../../station_map.h"
#include "../../command_func.h"
#include "trolly.h"
#include "../../depot_base.h"
#include "../../town.h"
#include "../../industry.h"
#include "../../station_base.h"
#include "../../engine_func.h"
#include "../../gui.h"
#include "../../depot.h"
#include "../../depot_base.h"
#include "../../vehicle_base.h"
#include "../../vehicle_func.h"
#include "../../date_func.h"

@ -10,7 +10,7 @@
#include "landscape.h"
#include "station_map.h"
#include "timetable.h"
#include "depot.h"
#include "depot_func.h"
#include "news_func.h"
#include "aircraft.h"
#include "airport.h"

@ -7,7 +7,6 @@
#include "aircraft.h"
#include "debug.h"
#include "gui.h"
#include "depot.h"
#include "vehicle_gui.h"
#include "newgrf_engine.h"
#include "strings_func.h"

@ -10,7 +10,6 @@
#include "terraform_gui.h"
#include "command_func.h"
#include "airport.h"
#include "depot.h"
#include "sound_func.h"
#include "window_func.h"
#include "settings_type.h"
@ -18,6 +17,7 @@
#include "gfx_func.h"
#include "player_func.h"
#include "order_func.h"
#include "station_type.h"
#include "table/sprites.h"
#include "table/strings.h"

@ -8,7 +8,6 @@
#include "player_func.h"
#include "debug.h"
#include "vehicle_gui.h"
#include "depot.h"
#include "train.h"
#include "aircraft.h"
#include "cargotype.h"

@ -5,9 +5,9 @@
#ifndef AUTOSLOPE_H
#define AUTOSLOPE_H
#include "depot.h"
#include "settings_type.h"
#include "player_func.h"
#include "depot_func.h"
/**
* Autoslope check for tiles with an entrance on an edge.

@ -14,7 +14,6 @@
#include "textbuf_gui.h"
#include "command_func.h"
#include "player_func.h"
#include "depot.h"
#include "airport.h"
#include "vehicle_gui.h"
#include "newgrf_engine.h"

@ -4,7 +4,7 @@
#include "stdafx.h"
#include "openttd.h"
#include "depot.h"
#include "depot_base.h"
#include "landscape.h"
#include "saveload.h"
#include "order_func.h"

@ -1,91 +0,0 @@
/* $Id$ */
/** @file depot.h Header files for depots (not hangars) */
#ifndef DEPOT_H
#define DEPOT_H
#include "direction_type.h"
#include "depot_type.h"
#include "oldpool.h"
#include "road_map.h"
#include "rail_map.h"
#include "water_map.h"
#include "station_map.h"
DECLARE_OLD_POOL(Depot, Depot, 3, 8000)
struct Depot : PoolItem<Depot, DepotID, &_Depot_pool> {
TileIndex xy;
TownID town_index;
Depot(TileIndex xy = 0) : xy(xy) {}
~Depot();
inline bool IsValid() const { return this->xy != 0; }
};
static inline bool IsValidDepotID(DepotID index)
{
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 (d->IsValid())
#define FOR_ALL_DEPOTS(d) FOR_ALL_DEPOTS_FROM(d, 0)
/**
* Check if a tile is a depot and it is a depot of the given type.
*/
static inline bool IsDepotTypeTile(TileIndex tile, TransportType type)
{
switch (type) {
default: NOT_REACHED();
case TRANSPORT_RAIL:
return IsRailDepotTile(tile);
case TRANSPORT_ROAD:
return IsRoadDepotTile(tile);
case TRANSPORT_WATER:
return IsShipDepotTile(tile);
}
}
/**
* Is the given tile a tile with a depot on it?
* @param tile the tile to check
* @return true if and only if there is a depot on the tile.
*/
static inline bool IsDepotTile(TileIndex tile)
{
return IsRailDepotTile(tile) || IsRoadDepotTile(tile) || IsShipDepotTile(tile) || IsHangarTile(tile);
}
/**
* Find out if the slope of the tile is suitable to build a depot of given direction
* @param direction The direction in which the depot's exit points
* @param tileh The slope of the tile in question
* @return true if the construction is possible
* This is checked by the ugly 0x4C >> direction magic, which does the following:
* 0x4C is 0100 1100 and tileh has only bits 0..3 set (steep tiles are ruled out)
* So: for direction (only the significant bits are shown)<p>
* 00 (exit towards NE) we need either bit 2 or 3 set in tileh: 0x4C >> 0 = 1100<p>
* 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();
void DeleteDepotHighlightOfVehicle(const Vehicle *v);
#endif /* DEPOT_H */

@ -0,0 +1,35 @@
/* $Id$ */
/** @file depot.h Base for all depots (except hangars) */
#ifndef DEPOT_BASE_H
#define DEPOT_BASE_H
#include "tile_type.h"
#include "depot_type.h"
#include "oldpool.h"
#include "town_type.h"
DECLARE_OLD_POOL(Depot, Depot, 3, 8000)
struct Depot : PoolItem<Depot, DepotID, &_Depot_pool> {
TileIndex xy;
TownID town_index;
Depot(TileIndex xy = 0) : xy(xy) {}
~Depot();
inline bool IsValid() const { return this->xy != 0; }
};
static inline bool IsValidDepotID(DepotID index)
{
return index < GetDepotPoolSize() && GetDepot(index)->IsValid();
}
Depot *GetDepotByTile(TileIndex tile);
#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)
#endif /* DEPOT_BASE_H */

@ -0,0 +1,39 @@
/* $Id$ */
/** @file depot_func.h Functions related to depots. */
#ifndef DEPOT_FUNC_H
#define DEPOT_FUNC_H
#include "depot_type.h"
#include "tile_type.h"
#include "vehicle_type.h"
#include "direction_type.h"
#include "slope_type.h"
void ShowDepotWindow(TileIndex tile, VehicleType type);
void InitializeDepots();
void DeleteDepotHighlightOfVehicle(const Vehicle *v);
/**
* Find out if the slope of the tile is suitable to build a depot of given direction
* @param direction The direction in which the depot's exit points
* @param tileh The slope of the tile in question
* @return true if the construction is possible
* This is checked by the ugly 0x4C >> direction magic, which does the following:
* 0x4C is 0100 1100 and tileh has only bits 0..3 set (steep tiles are ruled out)
* So: for direction (only the significant bits are shown)<p>
* 00 (exit towards NE) we need either bit 2 or 3 set in tileh: 0x4C >> 0 = 1100<p>
* 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;
}
#endif /* DEPOT_FUNC_H */

@ -13,7 +13,7 @@
#include "viewport_func.h"
#include "gfx_func.h"
#include "command_func.h"
#include "depot.h"
#include "depot_base.h"
#include "vehicle_gui.h"
#include "station_map.h"
#include "newgrf_engine.h"
@ -23,6 +23,7 @@
#include "vehicle_func.h"
#include "player_func.h"
#include "order_func.h"
#include "depot_base.h"
#include "table/strings.h"
#include "table/sprites.h"

@ -0,0 +1,41 @@
/* $Id$ */
/** @file depot_map.h Map related accessors for depots. */
#ifndef DEPOT_MAP_H
#define DEPOT_MAP_H
#include "road_map.h"
#include "rail_map.h"
#include "water_map.h"
#include "station_map.h"
/**
* Check if a tile is a depot and it is a depot of the given type.
*/
static inline bool IsDepotTypeTile(TileIndex tile, TransportType type)
{
switch (type) {
default: NOT_REACHED();
case TRANSPORT_RAIL:
return IsRailDepotTile(tile);
case TRANSPORT_ROAD:
return IsRoadDepotTile(tile);
case TRANSPORT_WATER:
return IsShipDepotTile(tile);
}
}
/**
* Is the given tile a tile with a depot on it?
* @param tile the tile to check
* @return true if and only if there is a depot on the tile.
*/
static inline bool IsDepotTile(TileIndex tile)
{
return IsRailDepotTile(tile) || IsRoadDepotTile(tile) || IsShipDepotTile(tile) || IsHangarTile(tile);
}
#endif /* DEPOT_MAP_H */

@ -9,7 +9,6 @@
#include "textbuf_gui.h"
#include "command_func.h"
#include "vehicle_gui.h"
#include "depot.h"
#include "train.h"
#include "group.h"
#include "debug.h"

@ -14,7 +14,8 @@
#include "pathfind.h"
#include "station_base.h"
#include "station_map.h"
#include "depot.h"
#include "depot_base.h"
#include "depot_map.h"
#include "tunnel_map.h"
#include "network/network.h"
#include "water_map.h"

@ -15,7 +15,7 @@
#include "train.h"
#include "signs_base.h"
#include "debug.h"
#include "depot.h"
#include "depot_base.h"
#include "newgrf_config.h"
#include "ai/ai.h"
#include "ai/default/default.h"

@ -46,7 +46,6 @@
#include "network/network.h"
#include "signs_base.h"
#include "signs_func.h"
#include "depot.h"
#include "waypoint.h"
#include "ai/ai.h"
#include "train.h"

@ -7,7 +7,7 @@
#include "order_base.h"
#include "order_func.h"
#include "airport.h"
#include "depot.h"
#include "order_base.h"
#include "waypoint.h"
#include "command_func.h"
#include "player_func.h"
@ -26,6 +26,7 @@
#include "timetable.h"
#include "vehicle_func.h"
#include "oldpool_func.h"
#include "depot_base.h"
#include "table/strings.h"

@ -13,7 +13,7 @@
#include "command_func.h"
#include "viewport_func.h"
#include "gfx_func.h"
#include "depot.h"
#include "depot_base.h"
#include "waypoint.h"
#include "train.h"
#include "water_map.h"
@ -29,6 +29,7 @@
#include "widgets/dropdown_func.h"
#include "textbuf_gui.h"
#include "string_func.h"
#include "depot_base.h"
#include "table/sprites.h"
#include "table/strings.h"

@ -6,7 +6,6 @@
#include "openttd.h"
#include "bridge_map.h"
#include "station_map.h"
#include "depot.h"
#include "tile_cmd.h"
#include "landscape.h"
#include "pathfind.h"
@ -14,7 +13,6 @@
#include "debug.h"
#include "tunnel_map.h"
#include "settings_type.h"
#include "depot.h"
#include "tunnelbridge_map.h"
#include "core/random_func.hpp"
#include "core/alloc_type.hpp"

@ -20,7 +20,8 @@
#include "engine_func.h"
#include "town.h"
#include "sprite.h"
#include "depot.h"
#include "depot_base.h"
#include "depot_func.h"
#include "waypoint.h"
#include "rail.h"
#include "newgrf.h"
@ -40,6 +41,8 @@
#include "sound_func.h"
#include "signal_func.h"
#include "tunnelbridge.h"
#include "station_map.h"
#include "water_map.h"
#include "table/sprites.h"
#include "table/strings.h"

@ -18,7 +18,8 @@
#include "command_func.h"
#include "town.h"
#include "yapf/yapf.h"
#include "depot.h"
#include "depot_base.h"
#include "depot_func.h"
#include "newgrf.h"
#include "station_map.h"
#include "tunnel_map.h"

@ -9,7 +9,6 @@
#include "road_map.h"
#include "tunnel_map.h"
#include "station_map.h"
#include "depot.h"
#include "tunnelbridge_map.h"

@ -17,7 +17,6 @@
#include "npf.h"
#include "player_func.h"
#include "player_base.h"
#include "depot.h"
#include "bridge.h"
#include "tunnel_map.h"
#include "bridge_map.h"
@ -41,6 +40,8 @@
#include "gfx_func.h"
#include "settings_type.h"
#include "order_func.h"
#include "depot_base.h"
#include "depot_func.h"
#include "table/strings.h"

@ -11,7 +11,6 @@
#include "viewport_func.h"
#include "gfx_func.h"
#include "command_func.h"
#include "depot.h"
#include "vehicle_gui.h"
#include "newgrf_engine.h"
#include "strings_func.h"

@ -17,7 +17,8 @@
#include "player_func.h"
#include "player_base.h"
#include "npf.h"
#include "depot.h"
#include "depot_base.h"
#include "depot_func.h"
#include "vehicle_gui.h"
#include "newgrf_engine.h"
#include "water_map.h"

@ -10,7 +10,6 @@
#include "window_gui.h"
#include "viewport_func.h"
#include "gfx_func.h"
#include "depot.h"
#include "vehicle_gui.h"
#include "newgrf_engine.h"
#include "strings_func.h"

@ -13,7 +13,6 @@
#include "player_func.h"
#include "airport.h"
#include "sprite.h"
#include "depot.h"
#include "train.h"
#include "water_map.h"
#include "industry_map.h"

@ -18,7 +18,6 @@
#include "saveload.h"
#include "airport.h"
#include "sprite.h"
#include "depot.h"
#include "train.h"
#include "roadveh.h"
#include "water_map.h"

@ -10,7 +10,6 @@
#include "window_gui.h"
#include "textbuf_gui.h"
#include "cargotype.h"
#include "depot.h"
#include "strings_func.h"
#include "vehicle_base.h"
#include "string_func.h"

@ -41,6 +41,9 @@
#include "string_func.h"
#include "newgrf_cargo.h"
#include "oldpool_func.h"
#include "sprite.h"
#include "economy_func.h"
#include "station_func.h"
#include "table/strings.h"
#include "table/sprites.h"

@ -20,7 +20,8 @@
#include "engine_func.h"
#include "player_func.h"
#include "player_base.h"
#include "depot.h"
#include "depot_base.h"
#include "depot_func.h"
#include "waypoint.h"
#include "vehicle_gui.h"
#include "train.h"

@ -10,7 +10,6 @@
#include "gfx_func.h"
#include "command_func.h"
#include "vehicle_gui.h"
#include "depot.h"
#include "train.h"
#include "newgrf_engine.h"
#include "strings_func.h"

@ -35,6 +35,8 @@
#include "tunnelbridge.h"
#include "player_base.h"
#include "engine_func.h"
#include "economy_func.h"
#include "rail.h"
#include "table/sprites.h"
#include "table/strings.h"

@ -24,6 +24,8 @@
#include "window_func.h"
#include "vehicle_func.h"
#include "player_gui.h"
#include "station_type.h"
#include "economy_func.h"
#include "table/strings.h"
#include "table/sprites.h"

@ -19,7 +19,6 @@
#include "player_func.h"
#include "debug.h"
#include "vehicle_gui.h"
#include "depot.h"
#include "rail_type.h"
#include "train.h"
#include "aircraft.h"
@ -47,6 +46,7 @@
#include "string_func.h"
#include "settings_type.h"
#include "oldpool_func.h"
#include "depot_map.h"
#include "table/sprites.h"
#include "table/strings.h"

@ -21,7 +21,7 @@
#include "ship.h"
#include "aircraft.h"
#include "roadveh.h"
#include "depot.h"
#include "depot_base.h"
#include "cargotype.h"
#include "group.h"
#include "group_gui.h"
@ -35,6 +35,7 @@
#include "settings_type.h"
#include "widgets/dropdown_func.h"
#include "order_func.h"
#include "depot_base.h"
#include "table/sprites.h"
#include "table/strings.h"

@ -14,7 +14,8 @@
#include "command_func.h"
#include "town.h"
#include "news_func.h"
#include "depot.h"
#include "depot_base.h"
#include "depot_func.h"
#include "vehicle_gui.h"
#include "train.h"
#include "roadveh.h"

@ -10,6 +10,7 @@
#include "rail_map.h"
#include "command_type.h"
#include "station_type.h"
#include "town_type.h"
DECLARE_OLD_POOL(Waypoint, Waypoint, 3, 8000)

@ -6,7 +6,7 @@
#define FOLLOW_TRACK_HPP
#include "yapf.hpp"
#include "../depot_map.h"
/** Track follower helper template class (can serve pathfinders and vehicle
* controllers). See 6 different typedefs below for 3 different transport

@ -8,7 +8,6 @@
#include "track_dir.hpp"
#include "../vehicle_base.h"
#include "../depot.h"
#include "../road_map.h"
#include "../tunnel_map.h"
#include "../bridge_map.h"

@ -3,6 +3,7 @@
/** @file yapf_road.cpp */
#include "../stdafx.h"
#include "../depot_base.h"
#include "yapf.hpp"
#include "yapf_node_road.hpp"

Loading…
Cancel
Save