Changeset - r8108:1d5bdeea7e20
[Not reviewed]
master
! ! !
rubidium - 16 years ago 2007-12-19 23:26:02
rubidium@openttd.org
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
77 files changed with 772 insertions and 763 deletions:
0 comments (0 inline, 0 general)
projects/openttd.vcproj
Show inline comments
 
@@ -369,13 +369,13 @@
 
				RelativePath=".\..\src\tgp.cpp">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\thread.cpp">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\tile.cpp">
 
				RelativePath=".\..\src\tile_map.cpp">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\vehicle.cpp">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\viewport.cpp">
projects/openttd_vs80.vcproj
Show inline comments
 
@@ -725,13 +725,13 @@
 
			</File>
 
			<File
 
				RelativePath=".\..\src\thread.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\tile.cpp"
 
				RelativePath=".\..\src\tile_map.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\vehicle.cpp"
 
				>
 
			</File>
projects/openttd_vs90.vcproj
Show inline comments
 
@@ -722,13 +722,13 @@
 
			</File>
 
			<File
 
				RelativePath=".\..\src\thread.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\tile.cpp"
 
				RelativePath=".\..\src\tile_map.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\vehicle.cpp"
 
				>
 
			</File>
source.list
Show inline comments
 
@@ -72,13 +72,13 @@ spritecache.cpp
 
station.cpp
 
string.cpp
 
strings.cpp
 
texteff.cpp
 
tgp.cpp
 
thread.cpp
 
tile.cpp
 
tile_map.cpp
 
#if WIN32
 
#else
 
	#if WINCE
 
		win32.cpp
 
	#else
 
		#if OS2
src/ai/default/default.cpp
Show inline comments
 
@@ -8,13 +8,12 @@
 
#include "../../landscape.h"
 
#include "../../map.h"
 
#include "../../rail_map.h"
 
#include "../../road_map.h"
 
#include "../../roadveh.h"
 
#include "../../station_map.h"
 
#include "../../tile.h"
 
#include "../../player.h"
 
#include "../../tunnel_map.h"
 
#include "../../vehicle.h"
 
#include "../../engine.h"
 
#include "../../command.h"
 
#include "../../town.h"
src/ai/trolly/build.cpp
Show inline comments
 
@@ -3,13 +3,12 @@
 
#include "../../stdafx.h"
 
#include "../../openttd.h"
 
#include "../../debug.h"
 
#include "../../functions.h"
 
#include "../../map.h"
 
#include "../../road_map.h"
 
#include "../../tile.h"
 
#include "../../vehicle.h"
 
#include "../../command.h"
 
#include "trolly.h"
 
#include "../../engine.h"
 
#include "../../station.h"
 
#include "../../variables.h"
src/ai/trolly/pathfinder.cpp
Show inline comments
 
@@ -3,13 +3,12 @@
 
#include "../../stdafx.h"
 
#include "../../openttd.h"
 
#include "../../bridge_map.h"
 
#include "../../debug.h"
 
#include "../../functions.h"
 
#include "../../map.h"
 
#include "../../tile.h"
 
#include "../../command.h"
 
#include "trolly.h"
 
#include "../../depot.h"
 
#include "../../tunnel_map.h"
 
#include "../../bridge.h"
 
#include "../../tunnelbridge_map.h"
src/ai/trolly/trolly.cpp
Show inline comments
 
@@ -22,13 +22,12 @@
 
#include "../../debug.h"
 
#include "../../functions.h"
 
#include "../../road_map.h"
 
#include "../../station_map.h"
 
#include "table/strings.h"
 
#include "../../map.h"
 
#include "../../tile.h"
 
#include "../../command.h"
 
#include "trolly.h"
 
#include "../../town.h"
 
#include "../../industry.h"
 
#include "../../station.h"
 
#include "../../engine.h"
src/aircraft_cmd.cpp
Show inline comments
 
@@ -10,13 +10,12 @@
 
#include "functions.h"
 
#include "landscape.h"
 
#include "station_map.h"
 
#include "strings.h"
 
#include "table/strings.h"
 
#include "map.h"
 
#include "tile.h"
 
#include "vehicle.h"
 
#include "timetable.h"
 
#include "depot.h"
 
#include "engine.h"
 
#include "command.h"
 
#include "station.h"
src/bridge_map.h
Show inline comments
 
@@ -7,13 +7,12 @@
 

	
 
#include "direction_func.h"
 
#include "macros.h"
 
#include "map.h"
 
#include "rail_type.h"
 
#include "road_map.h"
 
#include "tile.h"
 

	
 

	
 
/**
 
 * Checks if this is a bridge, instead of a tunnel
 
 * @param t The tile to analyze
 
 * @pre IsTileType(t, MP_TUNNELBRIDGE)
src/clear_cmd.cpp
Show inline comments
 
@@ -7,13 +7,12 @@
 
#include "clear_map.h"
 
#include "rail_map.h"
 
#include "table/strings.h"
 
#include "functions.h"
 
#include "map.h"
 
#include "player.h"
 
#include "tile.h"
 
#include "viewport.h"
 
#include "command.h"
 
#include "tunnel_map.h"
 
#include "bridge_map.h"
 
#include "bridge.h"
 
#include "landscape.h"
src/clear_map.h
Show inline comments
 
@@ -3,13 +3,12 @@
 
/** @file clear_map.h Map accessors for 'clear' tiles */
 

	
 
#ifndef CLEAR_MAP_H
 
#define CLEAR_MAP_H
 

	
 
#include "macros.h"
 
#include "tile.h"
 
#include "bridge_map.h"
 

	
 
/**
 
 * Ground types. Valid densities in comments after the enum.
 
 */
 
enum ClearGround {
src/command.cpp
Show inline comments
 
@@ -6,20 +6,20 @@
 
#include "openttd.h"
 
#include "table/strings.h"
 
#include "strings.h"
 
#include "functions.h"
 
#include "landscape.h"
 
#include "map.h"
 
#include "tile_map.h"
 
#include "gui.h"
 
#include "command.h"
 
#include "player.h"
 
#include "network/network.h"
 
#include "variables.h"
 
#include "genworld.h"
 
#include "newgrf_storage.h"
 
#include "tile.h"
 

	
 
const char *_cmd_text = NULL;
 

	
 
/**
 
 * Helper macro to define the header of all command handler macros.
 
 *
src/depot.cpp
Show inline comments
 
@@ -5,13 +5,12 @@
 
#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"
 

	
 
DEFINE_OLD_POOL_GENERIC(Depot, Depot)
src/depot.h
Show inline comments
 
@@ -4,13 +4,12 @@
 

	
 
#ifndef DEPOT_H
 
#define DEPOT_H
 

	
 
#include "direction_type.h"
 
#include "oldpool.h"
 
#include "tile.h"
 
#include "variables.h"
 
#include "road_map.h"
 
#include "rail_map.h"
 
#include "water_map.h"
 
#include "station_map.h"
 

	
src/disaster_cmd.cpp
Show inline comments
 
@@ -22,13 +22,12 @@
 
#include "landscape.h"
 
#include "industry_map.h"
 
#include "station_map.h"
 
#include "table/strings.h"
 
#include "strings.h"
 
#include "map.h"
 
#include "tile.h"
 
#include "vehicle.h"
 
#include "command.h"
 
#include "news.h"
 
#include "station.h"
 
#include "waypoint.h"
 
#include "town.h"
src/dock_gui.cpp
Show inline comments
 
@@ -5,12 +5,13 @@
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "table/sprites.h"
 
#include "table/strings.h"
 
#include "functions.h"
 
#include "map.h"
 
#include "tile_map.h"
 
#include "station.h"
 
#include "gui.h"
 
#include "window_gui.h"
 
#include "station_gui.h"
 
#include "viewport.h"
 
#include "gfx.h"
src/elrail.cpp
Show inline comments
 
@@ -45,13 +45,12 @@
 
 *
 
 */
 

	
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "station_map.h"
 
#include "tile.h"
 
#include "viewport.h"
 
#include "functions.h" /* We should REALLY get rid of this goddamn file, as it is butt-ugly */
 
#include "variables.h" /* ... same here */
 
#include "landscape.h"
 
#include "rail_type.h"
 
#include "debug.h"
src/genworld_gui.cpp
Show inline comments
 
@@ -9,13 +9,12 @@
 
#include "table/strings.h"
 
#include "table/sprites.h"
 
#include "gui.h"
 
#include "window_gui.h"
 
#include "textbuf_gui.h"
 
#include "gfx.h"
 
#include "tile.h"
 
#include "strings.h"
 
#include "gfxinit.h"
 
#include "player.h"
 
#include "command.h"
 
#include "sound.h"
 
#include "variables.h"
src/gui.h
Show inline comments
 
@@ -6,13 +6,13 @@
 
#define GUI_H
 

	
 
#include "string.h"
 
#include "window_type.h"
 
#include "rail_type.h"
 
#include "road_type.h"
 
#include "vehicle.h"
 
#include "vehicle_type.h"
 

	
 
/* main_gui.cpp */
 
void CcPlaySound10(bool success, TileIndex tile, uint32 p1, uint32 p2);
 
void CcBuildCanal(bool success, TileIndex tile, uint32 p1, uint32 p2);
 
void CcTerraform(bool success, TileIndex tile, uint32 p1, uint32 p2);
 

	
src/industry_cmd.cpp
Show inline comments
 
@@ -9,13 +9,12 @@
 
#include "industry_map.h"
 
#include "station_map.h"
 
#include "table/strings.h"
 
#include "strings.h"
 
#include "table/sprites.h"
 
#include "map.h"
 
#include "tile.h"
 
#include "train.h"
 
#include "landscape.h"
 
#include "viewport.h"
 
#include "command.h"
 
#include "industry.h"
 
#include "town.h"
src/industry_map.h
Show inline comments
 
@@ -4,13 +4,13 @@
 

	
 
#ifndef INDUSTRY_MAP_H
 
#define INDUSTRY_MAP_H
 

	
 
#include "industry.h"
 
#include "macros.h"
 
#include "tile.h"
 
#include "tile_map.h"
 

	
 

	
 

	
 
/**
 
 * The following enums are indices used to know what to draw for this industry tile.
 
 * They all are pointing toward array _industry_draw_tile_data, in table/industry_land.h
src/landscape.cpp
Show inline comments
 
@@ -8,13 +8,12 @@
 
#include "date.h"
 
#include "functions.h"
 
#include "map.h"
 
#include "player.h"
 
#include "spritecache.h"
 
#include "table/sprites.h"
 
#include "tile.h"
 
#include <stdarg.h>
 
#include "viewport.h"
 
#include "command.h"
 
#include "landscape.h"
 
#include "vehicle.h"
 
#include "variables.h"
src/main_gui.cpp
Show inline comments
 
@@ -10,13 +10,12 @@
 
#include "spritecache.h"
 
#include "station.h"
 
#include "strings.h"
 
#include "table/sprites.h"
 
#include "table/strings.h"
 
#include "map.h"
 
#include "tile.h"
 
#include "gui.h"
 
#include "window_gui.h"
 
#include "window_func.h"
 
#include "textbuf_gui.h"
 
#include "viewport.h"
 
#include "gfx.h"
src/map.h
Show inline comments
 
@@ -4,12 +4,13 @@
 

	
 
#ifndef MAP_H
 
#define MAP_H
 

	
 
#include "stdafx.h"
 
#include "direction_func.h"
 
#include "tile_type.h"
 

	
 
extern uint _map_tile_mask;
 

	
 
/**
 
 * 'Wraps' the given tile to it is within the map. It does
 
 * this by masking the 'high' bits of.
 
@@ -133,17 +134,12 @@ uint ScaleByMapSize(uint);
 
/**
 
 * Scale relative to the circumference of the map.
 
 */
 
uint ScaleByMapSize1D(uint);
 

	
 
/**
 
 * The index/ID of a Tile.
 
 */
 
typedef uint32 TileIndex;
 

	
 
/**
 
 * An offset value between to tiles.
 
 *
 
 * This value is used fro the difference between
 
 * to tiles. It can be added to a tileindex to get
 
 * the resulting tileindex of the start tile applied
 
 * with this saved difference.
src/misc_gui.cpp
Show inline comments
 
@@ -14,12 +14,13 @@
 
#include "strings.h"
 
#include "table/sprites.h"
 
#include "table/strings.h"
 
#include "strings.h"
 
#include "table/tree_land.h"
 
#include "map.h"
 
#include "tile_map.h"
 
#include "gui.h"
 
#include "window_gui.h"
 
#include "station_gui.h"
 
#include "textbuf_gui.h"
 
#include "viewport.h"
 
#include "gfx.h"
src/newgrf_canal.cpp
Show inline comments
 
@@ -7,12 +7,13 @@
 
#include "debug.h"
 
#include "newgrf.h"
 
#include "newgrf_callbacks.h"
 
#include "newgrf_commons.h"
 
#include "newgrf_spritegroup.h"
 
#include "newgrf_canal.h"
 
#include "tile_map.h"
 

	
 

	
 
/** Table of canal 'feature' sprite groups */
 
const SpriteGroup *_canal_sg[CF_END];
 

	
 

	
src/newgrf_commons.cpp
Show inline comments
 
@@ -9,12 +9,13 @@
 
#include "variables.h"
 
#include "landscape.h"
 
#include "town.h"
 
#include "industry.h"
 
#include "newgrf.h"
 
#include "newgrf_commons.h"
 
#include "tile_map.h"
 

	
 
/** Constructor of generic class
 
 * @param offset end of original data for this entity. i.e: houses = 110
 
 * @param maximum of entities this manager can deal with. i.e: houses = 512
 
 * @param invalid is the ID used to identify an invalid entity id
 
 */
src/newgrf_house.cpp
Show inline comments
 
@@ -7,13 +7,12 @@
 
#include "functions.h"
 
#include "variables.h"
 
#include "debug.h"
 
#include "viewport.h"
 
#include "landscape.h"
 
#include "date.h"
 
#include "tile.h"
 
#include "town.h"
 
#include "town_map.h"
 
#include "sound.h"
 
#include "sprite.h"
 
#include "strings.h"
 
#include "table/strings.h"
src/npf.cpp
Show inline comments
 
@@ -11,13 +11,12 @@
 
#include "npf.h"
 
#include "aystar.h"
 
#include "macros.h"
 
#include "pathfind.h"
 
#include "station.h"
 
#include "station_map.h"
 
#include "tile.h"
 
#include "depot.h"
 
#include "tunnel_map.h"
 
#include "network/network.h"
 
#include "water_map.h"
 
#include "tunnelbridge_map.h"
 

	
src/npf.h
Show inline comments
 
@@ -6,13 +6,13 @@
 
#define NPF_H
 

	
 
#include "openttd.h"
 
#include "aystar.h"
 
#include "station.h"
 
#include "vehicle.h"
 
#include "tile.h"
 
#include "tile_type.h"
 

	
 
/* mowing grass */
 
enum {
 
	NPF_HASH_BITS = 12, ///< The size of the hash used in pathfinding. Just changing this value should be sufficient to change the hash size. Should be an even value.
 
	/* Do no change below values */
 
	NPF_HASH_SIZE = 1 << NPF_HASH_BITS,
src/openttd.cpp
Show inline comments
 
@@ -6,14 +6,12 @@
 
#define VARDEF
 
#include "string.h"
 
#include "debug.h"
 
#include "driver.h"
 
#include "saveload.h"
 
#include "map.h"
 
#include "tile.h"
 
#include "void_map.h"
 
#include "helpers.hpp"
 

	
 
#include "openttd.h"
 
#include "table/strings.h"
 
#include "strings.h"
 
#include "bridge_map.h"
 
@@ -76,12 +74,13 @@
 
#include "road_map.h"
 
#include "water_map.h"
 
#include "industry_map.h"
 
#include "unmovable_map.h"
 
#include "tree_map.h"
 
#include "tunnelbridge_map.h"
 
#include "void_map.h"
 

	
 
#include <stdarg.h>
 

	
 
void CallLandscapeTick();
 
void IncreaseDate();
 
void DoPaletteAnimations();
src/openttd.h
Show inline comments
 
@@ -23,16 +23,16 @@ struct BoundingRect {
 
struct Pair {
 
	int a;
 
	int b;
 
};
 

	
 
#include "map.h"
 
#include "slope.h"
 
#include "slope_type.h"
 
#include "vehicle_type.h"
 

	
 
// Forward declarations of structs.
 
struct Vehicle;
 
struct Depot;
 
struct Waypoint;
 
struct Station;
 
struct ViewPort;
 
struct Town;
 
struct NewsItem;
 
@@ -52,13 +52,12 @@ typedef uint16 UnitID;
 
typedef uint16 StringID;
 
static const StringID INVALID_STRING_ID = 0xFFFF;
 

	
 
typedef EngineID *EngineList; ///< engine list type placeholder acceptable for C code (see helpers.cpp)
 

	
 
/* IDs used in Pools */
 
typedef uint16 VehicleID;
 
typedef uint16 StationID;
 
static const StationID INVALID_STATION = 0xFFFF;
 
typedef uint16 RoadStopID;
 
typedef uint16 TownID;
 
typedef uint16 IndustryID;
 
typedef uint16 DepotID;
src/order_gui.cpp
Show inline comments
 
@@ -8,13 +8,12 @@
 
#include "station_map.h"
 
#include "table/sprites.h"
 
#include "table/strings.h"
 
#include "strings.h"
 
#include "functions.h"
 
#include "map.h"
 
#include "tile.h"
 
#include "gui.h"
 
#include "window_gui.h"
 
#include "gfx.h"
 
#include "vehicle.h"
 
#include "station.h"
 
#include "town.h"
src/pathfind.cpp
Show inline comments
 
@@ -7,13 +7,12 @@
 
#include "bridge_map.h"
 
#include "station_map.h"
 
#include "depot.h"
 
#include "functions.h"
 
#include "landscape.h"
 
#include "map.h"
 
#include "tile.h"
 
#include "pathfind.h"
 
#include "rail_type.h"
 
#include "debug.h"
 
#include "tunnel_map.h"
 
#include "variables.h"
 
#include "depot.h"
src/players.cpp
Show inline comments
 
@@ -26,12 +26,13 @@
 
#include "ai/ai.h"
 
#include "date.h"
 
#include "player_face.h"
 
#include "group.h"
 
#include "settings.h"
 
#include "window_func.h"
 
#include "tile_map.h"
 

	
 
/**
 
 * Sets the local player and updates the patch settings that are set on a
 
 * per-company (player) basis to reflect the core's state in the GUI.
 
 * @param new_player the new player
 
 * @pre IsValidPlayer(new_player) || new_player == PLAYER_SPECTATOR || new_player == OWNER_NONE
src/rail.h
Show inline comments
 
@@ -5,13 +5,12 @@
 
#ifndef RAIL_H
 
#define RAIL_H
 

	
 
#include "gfx.h"
 
#include "rail_type.h"
 
#include "track_type.h"
 
#include "tile.h"
 
#include "variables.h"
 

	
 
/** This struct contains all the info that is needed to draw and construct tracks.
 
 */
 
struct RailtypeInfo {
 
	/** Struct containing the main sprites. @note not all sprites are listed, but only
 
@@ -225,11 +224,9 @@ void DrawDefaultWaypointSprite(int x, in
 
 */
 
void DrawCatenary(const TileInfo *ti);
 
void DrawCatenaryOnTunnel(const TileInfo *ti);
 

	
 
Foundation GetRailFoundation(Slope tileh, TrackBits bits);
 

	
 
void FloodHalftile(TileIndex t);
 

	
 
int32 SettingsDisableElrail(int32 p1); ///< _patches.disable_elrail callback
 

	
 
#endif /* RAIL_H */
src/rail_cmd.cpp
Show inline comments
 
@@ -12,13 +12,12 @@
 
#include "rail_map.h"
 
#include "road_map.h"
 
#include "table/sprites.h"
 
#include "table/strings.h"
 
#include "map.h"
 
#include "landscape.h"
 
#include "tile.h"
 
#include "town_map.h"
 
#include "tunnel_map.h"
 
#include "vehicle.h"
 
#include "viewport.h"
 
#include "command.h"
 
#include "pathfind.h"
src/rail_gui.cpp
Show inline comments
 
@@ -8,13 +8,12 @@
 
#include "table/strings.h"
 
#include "strings.h"
 
#include "functions.h"
 
#include "landscape.h"
 
#include "date.h"
 
#include "map.h"
 
#include "tile.h"
 
#include "gui.h"
 
#include "window_gui.h"
 
#include "station_gui.h"
 
#include "viewport.h"
 
#include "gfx.h"
 
#include "sound.h"
src/rail_map.h
Show inline comments
 
@@ -5,13 +5,13 @@
 
#ifndef RAIL_MAP_H
 
#define RAIL_MAP_H
 

	
 
#include "direction_func.h"
 
#include "track_func.h"
 
#include "rail.h"
 
#include "tile.h"
 
#include "tile_map.h"
 

	
 

	
 
/** Different types of Rail-related tiles */
 
enum RailTileType {
 
	RAIL_TILE_NORMAL   = 0, ///< Normal rail tile without signals
 
	RAIL_TILE_SIGNALS  = 1, ///< Normal rail tile with signals
src/road_cmd.cpp
Show inline comments
 
@@ -14,13 +14,12 @@
 
#include "table/sprites.h"
 
#include "table/strings.h"
 
#include "strings.h"
 
#include "functions.h"
 
#include "map.h"
 
#include "landscape.h"
 
#include "tile.h"
 
#include "town_map.h"
 
#include "vehicle.h"
 
#include "viewport.h"
 
#include "command.h"
 
#include "player.h"
 
#include "town.h"
src/road_gui.cpp
Show inline comments
 
@@ -6,13 +6,12 @@
 
#include "openttd.h"
 
#include "table/sprites.h"
 
#include "table/strings.h"
 
#include "strings.h"
 
#include "functions.h"
 
#include "map.h"
 
#include "tile.h"
 
#include "gui.h"
 
#include "window_gui.h"
 
#include "station_gui.h"
 
#include "viewport.h"
 
#include "gfx.h"
 
#include "sound.h"
src/road_map.h
Show inline comments
 
@@ -6,13 +6,13 @@
 
#define ROAD_MAP_H
 

	
 
#include "macros.h"
 
#include "track_func.h"
 
#include "rail_type.h"
 
#include "road_func.h"
 
#include "tile.h"
 
#include "tile_map.h"
 

	
 

	
 
enum RoadTileType {
 
	ROAD_TILE_NORMAL,
 
	ROAD_TILE_CROSSING,
 
	ROAD_TILE_DEPOT
src/roadveh_cmd.cpp
Show inline comments
 
@@ -10,13 +10,12 @@
 
#include "road_map.h"
 
#include "roadveh.h"
 
#include "station_map.h"
 
#include "table/strings.h"
 
#include "strings.h"
 
#include "map.h"
 
#include "tile.h"
 
#include "vehicle.h"
 
#include "timetable.h"
 
#include "engine.h"
 
#include "command.h"
 
#include "station.h"
 
#include "news.h"
src/ship_cmd.cpp
Show inline comments
 
@@ -7,13 +7,12 @@
 
#include "ship.h"
 
#include "table/strings.h"
 
#include "strings.h"
 
#include "functions.h"
 
#include "landscape.h"
 
#include "map.h"
 
#include "tile.h"
 
#include "vehicle.h"
 
#include "timetable.h"
 
#include "command.h"
 
#include "pathfind.h"
 
#include "station_map.h"
 
#include "station.h"
src/slope.h
Show inline comments
 
deleted file
src/slope_func.h
Show inline comments
 
new file 100644
 
/* $Id$ */
 

	
 
/** @file slope_func.h Functions related to slopes. */
 

	
 
#ifndef SLOPE_FUNC_H
 
#define SLOPE_FUNC_H
 

	
 
#include "slope_type.h"
 
#include "direction_type.h"
 

	
 
/**
 
 * Rangecheck for Corner enumeration.
 
 *
 
 * @param corner A #Corner.
 
 * @return true iff corner is in a valid range.
 
 */
 
static inline bool IsValidCorner(Corner corner)
 
{
 
	return IsInsideMM(corner, 0, CORNER_END);
 
}
 

	
 

	
 
/**
 
 * Checks if a slope is steep.
 
 *
 
 * @param s The given #Slope.
 
 * @return True if the slope is steep, else false.
 
 */
 
static inline bool IsSteepSlope(Slope s)
 
{
 
	return (s & SLOPE_STEEP) != 0;
 
}
 

	
 
/**
 
 * Checks for non-continuous slope on halftile foundations.
 
 *
 
 * @param s The given #Slope.
 
 * @return True if the slope is non-continuous, else false.
 
 */
 
static inline bool IsHalftileSlope(Slope s)
 
{
 
	return (s & SLOPE_HALFTILE) != 0;
 
}
 

	
 
/**
 
 * Return the complement of a slope.
 
 *
 
 * This method returns the complement of a slope. The complement of a
 
 * slope is a slope with raised corner which aren't raised in the given
 
 * slope.
 
 *
 
 * @pre The slope must neither be steep nor a halftile slope.
 
 * @param s The #Slope to get the complement.
 
 * @return a complement Slope of the given slope.
 
 */
 
static inline Slope ComplementSlope(Slope s)
 
{
 
	assert(!IsSteepSlope(s) && !IsHalftileSlope(s));
 
	return (Slope)(0xF ^ s);
 
}
 

	
 
/**
 
 * Tests if a slope has a highest corner (i.e. one corner raised or a steep slope).
 
 *
 
 * Note: A halftile slope is ignored.
 
 *
 
 * @param s The #Slope.
 
 * @return  true iff the slope has a highest corner.
 
 */
 
static inline bool HasSlopeHighestCorner(Slope s)
 
{
 
	s = (Slope)(s & ~SLOPE_HALFTILE_MASK);
 
	return IsSteepSlope(s) || (s == SLOPE_W) || (s == SLOPE_S) || (s == SLOPE_E) || (s == SLOPE_N);
 
}
 

	
 
/**
 
 * Returns the highest corner of a slope (one corner raised or a steep slope).
 
 *
 
 * @pre      The slope must be a slope with one corner raised or a steep slope. A halftile slope is ignored.
 
 * @param s  The #Slope.
 
 * @return   Highest corner.
 
 */
 
static inline Corner GetHighestSlopeCorner(Slope s)
 
{
 
	switch (s & ~SLOPE_HALFTILE_MASK) {
 
		case SLOPE_W:
 
		case SLOPE_STEEP_W: return CORNER_W;
 
		case SLOPE_S:
 
		case SLOPE_STEEP_S: return CORNER_S;
 
		case SLOPE_E:
 
		case SLOPE_STEEP_E: return CORNER_E;
 
		case SLOPE_N:
 
		case SLOPE_STEEP_N: return CORNER_N;
 
		default: NOT_REACHED();
 
	}
 
}
 

	
 
/**
 
 * Returns the leveled halftile of a halftile slope.
 
 *
 
 * @pre     The slope must be a halftile slope.
 
 * @param s The #Slope.
 
 * @return  The corner of the leveled halftile.
 
 */
 
static inline Corner GetHalftileSlopeCorner(Slope s)
 
{
 
	assert(IsHalftileSlope(s));
 
	return (Corner)((s >> 6) & 3);
 
}
 

	
 
/**
 
 * Returns the height of the highest corner of a slope relative to TileZ (= minimal height)
 
 *
 
 * @param s The #Slope.
 
 * @return Relative height of highest corner.
 
 */
 
static inline uint GetSlopeMaxZ(Slope s)
 
{
 
	if (s == SLOPE_FLAT) return 0;
 
	if (IsSteepSlope(s)) return 2 * TILE_HEIGHT;
 
	return TILE_HEIGHT;
 
}
 

	
 
/**
 
 * Returns the opposite corner.
 
 *
 
 * @param corner A #Corner.
 
 * @return The opposite corner to "corner".
 
 */
 
static inline Corner OppositeCorner(Corner corner)
 
{
 
	return (Corner)(corner ^ 2);
 
}
 

	
 
/**
 
 * Returns the slope with a specific corner raised.
 
 *
 
 * @param corner The #Corner.
 
 * @return The #Slope with corner "corner" raised.
 
 */
 
static inline Slope SlopeWithOneCornerRaised(Corner corner)
 
{
 
	assert(IsValidCorner(corner));
 
	return (Slope)(1 << corner);
 
}
 

	
 
/**
 
 * Returns the slope with all except one corner raised.
 
 *
 
 * @param corner The #Corner.
 
 * @return The #Slope with all corners but "corner" raised.
 
 */
 
static inline Slope SlopeWithThreeCornersRaised(Corner corner)
 
{
 
	return ComplementSlope(SlopeWithOneCornerRaised(corner));
 
}
 

	
 
/**
 
 * Adds a halftile slope to a slope.
 
 *
 
 * @param s #Slope without a halftile slope.
 
 * @param corner The #Corner of the halftile.
 
 * @return The #Slope s with the halftile slope added.
 
 */
 
static inline Slope HalftileSlope(Slope s, Corner corner)
 
{
 
	assert(IsValidCorner(corner));
 
	return (Slope)(s | SLOPE_HALFTILE | (corner << 6));
 
}
 

	
 

	
 
/**
 
 * Tests for FOUNDATION_NONE.
 
 *
 
 * @param f  Maybe a #Foundation.
 
 * @return   true iff f is a foundation.
 
 */
 
static inline bool IsFoundation(Foundation f)
 
{
 
	return f != FOUNDATION_NONE;
 
}
 

	
 
/**
 
 * Tests if the foundation is a leveled foundation.
 
 *
 
 * @param f  The #Foundation.
 
 * @return   true iff f is a leveled foundation.
 
 */
 
static inline bool IsLeveledFoundation(Foundation f)
 
{
 
	return f == FOUNDATION_LEVELED;
 
}
 

	
 
/**
 
 * Tests if the foundation is an inclined foundation.
 
 *
 
 * @param f  The #Foundation.
 
 * @return   true iff f is an inclined foundation.
 
 */
 
static inline bool IsInclinedFoundation(Foundation f)
 
{
 
	return (f == FOUNDATION_INCLINED_X) || (f == FOUNDATION_INCLINED_Y);
 
}
 

	
 
/**
 
 * Tests if a foundation is a non-continuous foundation, i.e. halftile-foundation or FOUNDATION_STEEP_BOTH.
 
 *
 
 * @param f  The #Foundation.
 
 * @return   true iff f is a non-continuous foundation
 
 */
 
static inline bool IsNonContinuousFoundation(Foundation f)
 
{
 
	return IsInsideMM(f, FOUNDATION_STEEP_BOTH, FOUNDATION_HALFTILE_N + 1);
 
}
 

	
 
/**
 
 * Returns the halftile corner of a halftile-foundation
 
 *
 
 * @pre f != FOUNDATION_STEEP_BOTH
 
 *
 
 * @param f  The #Foundation.
 
 * @return   The #Corner with track.
 
 */
 
static inline Corner GetHalftileFoundationCorner(Foundation f)
 
{
 
	assert(IsInsideMM(f, FOUNDATION_HALFTILE_W, FOUNDATION_HALFTILE_N + 1));
 
	return (Corner)(f - FOUNDATION_HALFTILE_W);
 
}
 

	
 
/**
 
 * Tests if a foundation is a special rail foundation for single horizontal/vertical track.
 
 *
 
 * @param f  The #Foundation.
 
 * @return   true iff f is a special rail foundation for single horizontal/vertical track.
 
 */
 
static inline bool IsSpecialRailFoundation(Foundation f)
 
{
 
	return IsInsideMM(f, FOUNDATION_RAIL_W, FOUNDATION_RAIL_N + 1);
 
}
 

	
 
/**
 
 * Returns the track corner of a special rail foundation
 
 *
 
 * @param f  The #Foundation.
 
 * @return   The #Corner with track.
 
 */
 
static inline Corner GetRailFoundationCorner(Foundation f)
 
{
 
	assert(IsSpecialRailFoundation(f));
 
	return (Corner)(f - FOUNDATION_RAIL_W);
 
}
 

	
 
/**
 
 * Returns the foundation needed to flatten a slope.
 
 * The returned foundation is either FOUNDATION_NONE if the tile was already flat, or FOUNDATION_LEVELED.
 
 *
 
 * @pre      The slope must not be steep.
 
 * @param s  The current #Slope.
 
 * @return   The needed #Foundation.
 
 */
 
static inline Foundation FlatteningFoundation(Slope s)
 
{
 
	assert(!IsSteepSlope(s));
 
	return (s == SLOPE_FLAT ? FOUNDATION_NONE : FOUNDATION_LEVELED);
 
}
 

	
 
/**
 
 * Returns the along a specific axis inclined foundation.
 
 *
 
 * @param axis  The #Axis.
 
 * @return      The needed #Foundation.
 
 */
 
static inline Foundation InclinedFoundation(Axis axis)
 
{
 
	return (axis == AXIS_X ? FOUNDATION_INCLINED_X : FOUNDATION_INCLINED_Y);
 
}
 

	
 
/**
 
 * Returns the halftile foundation for single horizontal/vertical track.
 
 *
 
 * @param corner The #Corner with the track.
 
 * @return       The wanted #Foundation.
 
 */
 
static inline Foundation HalftileFoundation(Corner corner)
 
{
 
	assert(IsValidCorner(corner));
 
	return (Foundation)(FOUNDATION_HALFTILE_W + corner);
 
}
 

	
 
/**
 
 * Returns the special rail foundation for single horizontal/vertical track.
 
 *
 
 * @param corner The #Corner with the track.
 
 * @return       The wanted #Foundation.
 
 */
 
static inline Foundation SpecialRailFoundation(Corner corner)
 
{
 
	assert(IsValidCorner(corner));
 
	return (Foundation)(FOUNDATION_RAIL_W + corner);
 
}
 

	
 
#endif /* SLOPE_FUNC_H */
src/slope_type.h
Show inline comments
 
new file 100644
 
/* $Id$ */
 

	
 
/**
 
 * @file slope_type.h Definitions of a slope.
 
 * This file defines the enumeration and helper functions for handling
 
 * the slope info of a tile.
 
 */
 

	
 
#ifndef SLOPE_TYPE_H
 
#define SLOPE_TYPE_H
 

	
 
#include "core/enum_type.hpp"
 

	
 
/**
 
 * Enumeration of tile corners
 
 */
 
enum Corner {
 
	CORNER_W = 0,
 
	CORNER_S = 1,
 
	CORNER_E = 2,
 
	CORNER_N = 3,
 
	CORNER_END,
 
	CORNER_INVALID = 0xFF
 
};
 

	
 

	
 
/**
 
 * Enumeration for the slope-type.
 
 *
 
 * This enumeration use the chars N,E,S,W corresponding the
 
 * direction north, east, south and west. The top corner of a tile
 
 * is the north-part of the tile. The whole slope is encoded with
 
 * 5 bits, 4 bits for each corner and 1 bit for a steep-flag.
 
 *
 
 * For halftile slopes an extra 3 bits are used to represent this
 
 * properly; 1 bit for a halftile-flag and 2 bits to encode which
 
 * extra side (corner) is leveled when the slope of the first 5
 
 * bits is applied. This means that there can only be one leveled
 
 * slope for steep slopes, which is logical because two leveled
 
 * slopes would mean that it is not a steep slope as halftile
 
 * slopes only span one height level.
 
 */
 
enum Slope {
 
	SLOPE_FLAT     = 0x00,                                  ///< a flat tile
 
	SLOPE_W        = 0x01,                                  ///< the west corner of the tile is raised
 
	SLOPE_S        = 0x02,                                  ///< the south corner of the tile is raised
 
	SLOPE_E        = 0x04,                                  ///< the east corner of the tile is raised
 
	SLOPE_N        = 0x08,                                  ///< the north corner of the tile is raised
 
	SLOPE_STEEP    = 0x10,                                  ///< indicates the slope is steep
 
	SLOPE_NW       = SLOPE_N | SLOPE_W,                     ///< north and west corner are raised
 
	SLOPE_SW       = SLOPE_S | SLOPE_W,                     ///< south and west corner are raised
 
	SLOPE_SE       = SLOPE_S | SLOPE_E,                     ///< south and east corner are raised
 
	SLOPE_NE       = SLOPE_N | SLOPE_E,                     ///< north and east corner are raised
 
	SLOPE_EW       = SLOPE_E | SLOPE_W,                     ///< east and west corner are raised
 
	SLOPE_NS       = SLOPE_N | SLOPE_S,                     ///< north and south corner are raised
 
	SLOPE_ELEVATED = SLOPE_N | SLOPE_E | SLOPE_S | SLOPE_W, ///< all corner are raised, similar to SLOPE_FLAT
 
	SLOPE_NWS      = SLOPE_N | SLOPE_W | SLOPE_S,           ///< north, west and south corner are raised
 
	SLOPE_WSE      = SLOPE_W | SLOPE_S | SLOPE_E,           ///< west, south and east corner are raised
 
	SLOPE_SEN      = SLOPE_S | SLOPE_E | SLOPE_N,           ///< south, east and north corner are raised
 
	SLOPE_ENW      = SLOPE_E | SLOPE_N | SLOPE_W,           ///< east, north and west corner are raised
 
	SLOPE_STEEP_W  = SLOPE_STEEP | SLOPE_NWS,               ///< a steep slope falling to east (from west)
 
	SLOPE_STEEP_S  = SLOPE_STEEP | SLOPE_WSE,               ///< a steep slope falling to north (from south)
 
	SLOPE_STEEP_E  = SLOPE_STEEP | SLOPE_SEN,               ///< a steep slope falling to west (from east)
 
	SLOPE_STEEP_N  = SLOPE_STEEP | SLOPE_ENW,               ///< a steep slope falling to south (from north)
 

	
 
	SLOPE_HALFTILE = 0x20,                                  ///< one halftile is leveled (non continuous slope)
 
	SLOPE_HALFTILE_MASK = 0xE0,                             ///< three bits used for halftile slopes
 
	SLOPE_HALFTILE_W = SLOPE_HALFTILE | (CORNER_W << 6),    ///< the west halftile is leveled (non continuous slope)
 
	SLOPE_HALFTILE_S = SLOPE_HALFTILE | (CORNER_S << 6),    ///< the south halftile is leveled (non continuous slope)
 
	SLOPE_HALFTILE_E = SLOPE_HALFTILE | (CORNER_E << 6),    ///< the east halftile is leveled (non continuous slope)
 
	SLOPE_HALFTILE_N = SLOPE_HALFTILE | (CORNER_N << 6),    ///< the north halftile is leveled (non continuous slope)
 
};
 

	
 

	
 
/**
 
 * Enumeration for Foundations.
 
 */
 
enum Foundation {
 
	FOUNDATION_NONE,             ///< The tile has no foundation, the slope remains unchanged.
 
	FOUNDATION_LEVELED,          ///< The tile is leveled up to a flat slope.
 
	FOUNDATION_INCLINED_X,       ///< The tile has an along X-axis inclined foundation.
 
	FOUNDATION_INCLINED_Y,       ///< The tile has an along Y-axis inclined foundation.
 
	FOUNDATION_STEEP_LOWER,      ///< The tile has a steep slope. The lowest corner is raised by a foundation to allow building railroad on the lower halftile.
 

	
 
	/* Halftile foundations */
 
	FOUNDATION_STEEP_BOTH,       ///< The tile has a steep slope. The lowest corner is raised by a foundation and the upper halftile is leveled.
 
	FOUNDATION_HALFTILE_W,       ///< Level west halftile non-continuously.
 
	FOUNDATION_HALFTILE_S,       ///< Level south halftile non-continuously.
 
	FOUNDATION_HALFTILE_E,       ///< Level east halftile non-continuously.
 
	FOUNDATION_HALFTILE_N,       ///< Level north halftile non-continuously.
 

	
 
	/* Special anti-zig-zag foundations for single horizontal/vertical track */
 
	FOUNDATION_RAIL_W,           ///< Foundation for TRACK_BIT_LEFT, but not a leveled foundation.
 
	FOUNDATION_RAIL_S,           ///< Foundation for TRACK_BIT_LOWER, but not a leveled foundation.
 
	FOUNDATION_RAIL_E,           ///< Foundation for TRACK_BIT_RIGHT, but not a leveled foundation.
 
	FOUNDATION_RAIL_N,           ///< Foundation for TRACK_BIT_UPPER, but not a leveled foundation.
 

	
 
	FOUNDATION_INVALID = 0xFF    ///< Used inside "rail_cmd.cpp" to indicate invalid slope/track combination.
 
};
 

	
 
#endif /* SLOPE_TYPE_H */
src/smallmap_gui.cpp
Show inline comments
 
@@ -12,13 +12,12 @@
 
#include "station_map.h"
 
#include "table/strings.h"
 
#include "strings.h"
 
#include "table/sprites.h"
 
#include "landscape.h"
 
#include "map.h"
 
#include "tile.h"
 
#include "gui.h"
 
#include "window_gui.h"
 
#include "tree_map.h"
 
#include "tunnel_map.h"
 
#include "gfx.h"
 
#include "viewport.h"
src/station.cpp
Show inline comments
 
@@ -8,13 +8,12 @@
 
#include "debug.h"
 
#include "functions.h"
 
#include "station_map.h"
 
#include "table/sprites.h"
 
#include "table/strings.h"
 
#include "map.h"
 
#include "tile.h"
 
#include "station.h"
 
#include "gfx.h"
 
#include "viewport.h"
 
#include "command.h"
 
#include "town.h"
 
#include "vehicle.h"
src/station.h
Show inline comments
 
@@ -6,13 +6,12 @@
 
#define STATION_H
 

	
 
#include "airport.h"
 
#include "player.h"
 
#include "oldpool.h"
 
#include "sprite.h"
 
#include "tile.h"
 
#include "road_type.h"
 
#include "newgrf_station.h"
 
#include "cargopacket.h"
 
#include <list>
 
#include <set>
 

	
src/station_cmd.cpp
Show inline comments
 
@@ -12,13 +12,12 @@
 
#include "functions.h"
 
#include "landscape.h"
 
#include "station_map.h"
 
#include "table/sprites.h"
 
#include "table/strings.h"
 
#include "map.h"
 
#include "tile.h"
 
#include "station.h"
 
#include "gfx.h"
 
#include "viewport.h"
 
#include "command.h"
 
#include "town.h"
 
#include "vehicle.h"
src/terraform_gui.cpp
Show inline comments
 
@@ -7,13 +7,12 @@
 
#include "bridge_map.h"
 
#include "clear_map.h"
 
#include "table/sprites.h"
 
#include "table/strings.h"
 
#include "functions.h"
 
#include "player.h"
 
#include "tile.h"
 
#include "gui.h"
 
#include "window_gui.h"
 
#include "viewport.h"
 
#include "gfx.h"
 
#include "sound.h"
 
#include "command.h"
src/tgp.cpp
Show inline comments
 
@@ -7,13 +7,12 @@
 
#include "openttd.h"
 
#include "clear_map.h"
 
#include "functions.h"
 
#include "map.h"
 
#include "table/strings.h"
 
#include "clear_map.h"
 
#include "tile.h"
 
#include "variables.h"
 
#include "void_map.h"
 
#include "tgp.h"
 
#include "console.h"
 
#include "genworld.h"
 
#include "helpers.hpp"
src/tile.cpp
Show inline comments
 
deleted file
src/tile.h
Show inline comments
 
deleted file
src/tile_map.cpp
Show inline comments
 
new file 100644
 
/* $Id$ */
 

	
 
/** @file tile.cpp */
 

	
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "tile_map.h"
 

	
 
Slope GetTileSlope(TileIndex tile, uint *h)
 
{
 
	uint a;
 
	uint b;
 
	uint c;
 
	uint d;
 
	uint min;
 
	uint r;
 

	
 
	assert(tile < MapSize());
 

	
 
	if (TileX(tile) == MapMaxX() || TileY(tile) == MapMaxY()) {
 
		if (h != NULL) *h = 0;
 
		return SLOPE_FLAT;
 
	}
 

	
 
	min = a = TileHeight(tile);
 
	b = TileHeight(tile + TileDiffXY(1, 0));
 
	if (min > b) min = b;
 
	c = TileHeight(tile + TileDiffXY(0, 1));
 
	if (min > c) min = c;
 
	d = TileHeight(tile + TileDiffXY(1, 1));
 
	if (min > d) min = d;
 

	
 
	r = SLOPE_FLAT;
 
	if ((a -= min) != 0) r += (--a << 4) + SLOPE_N;
 
	if ((c -= min) != 0) r += (--c << 4) + SLOPE_E;
 
	if ((d -= min) != 0) r += (--d << 4) + SLOPE_S;
 
	if ((b -= min) != 0) r += (--b << 4) + SLOPE_W;
 

	
 
	if (h != NULL) *h = min * TILE_HEIGHT;
 

	
 
	return (Slope)r;
 
}
 

	
 
uint GetTileZ(TileIndex tile)
 
{
 
	if (TileX(tile) == MapMaxX() || TileY(tile) == MapMaxY()) return 0;
 

	
 
	uint h = TileHeight(tile);
 
	h = min(h, TileHeight(tile + TileDiffXY(1, 0)));
 
	h = min(h, TileHeight(tile + TileDiffXY(0, 1)));
 
	h = min(h, TileHeight(tile + TileDiffXY(1, 1)));
 

	
 
	return h * TILE_HEIGHT;
 
}
 

	
 

	
 
uint GetTileMaxZ(TileIndex t)
 
{
 
	if (TileX(t) == MapMaxX() || TileY(t) == MapMaxY()) return 0;
 

	
 
	uint h = TileHeight(t);
 
	h = max(h, TileHeight(t + TileDiffXY(1, 0)));
 
	h = max(h, TileHeight(t + TileDiffXY(0, 1)));
 
	h = max(h, TileHeight(t + TileDiffXY(1, 1)));
 

	
 
	return h * TILE_HEIGHT;
 
}
src/tile_map.h
Show inline comments
 
new file 100644
 
/* $Id$ */
 

	
 
/** @file tile_map.h Map writing/reading functions for tiles. */
 

	
 
#ifndef TILE_MAP_H
 
#define TILE_MAP_H
 

	
 
#include "tile_type.h"
 
#include "slope_type.h"
 
#include "map.h"
 

	
 
/**
 
 * Returns the height of a tile
 
 *
 
 * This function returns the height of the northern corner of a tile.
 
 * This is saved in the global map-array. It does not take affect by
 
 * any slope-data of the tile.
 
 *
 
 * @param tile The tile to get the height from
 
 * @return the height of the tile
 
 * @pre tile < MapSize()
 
 */
 
static inline uint TileHeight(TileIndex tile)
 
{
 
	assert(tile < MapSize());
 
	return GB(_m[tile].type_height, 0, 4);
 
}
 

	
 
/**
 
 * Sets the height of a tile.
 
 *
 
 * This function sets the height of the northern corner of a tile.
 
 *
 
 * @param tile The tile to change the height
 
 * @param height The new height value of the tile
 
 * @pre tile < MapSize()
 
 * @pre heigth <= MAX_TILE_HEIGHT
 
 */
 
static inline void SetTileHeight(TileIndex tile, uint height)
 
{
 
	assert(tile < MapSize());
 
	assert(height <= MAX_TILE_HEIGHT);
 
	SB(_m[tile].type_height, 0, 4, height);
 
}
 

	
 
/**
 
 * Returns the height of a tile in pixels.
 
 *
 
 * This function returns the height of the northern corner of a tile in pixels.
 
 *
 
 * @param tile The tile to get the height
 
 * @return The height of the tile in pixel
 
 */
 
static inline uint TilePixelHeight(TileIndex tile)
 
{
 
	return TileHeight(tile) * TILE_HEIGHT;
 
}
 

	
 
/**
 
 * Get the tiletype of a given tile.
 
 *
 
 * @param tile The tile to get the TileType
 
 * @return The tiletype of the tile
 
 * @pre tile < MapSize()
 
 */
 
static inline TileType GetTileType(TileIndex tile)
 
{
 
	assert(tile < MapSize());
 
	return (TileType)GB(_m[tile].type_height, 4, 4);
 
}
 

	
 
/**
 
 * Set the type of a tile
 
 *
 
 * This functions sets the type of a tile. If the type
 
 * MP_VOID is selected the tile must be at the south-west or
 
 * south-east edges of the map and vice versa.
 
 *
 
 * @param tile The tile to save the new type
 
 * @param type The type to save
 
 * @pre tile < MapSize()
 
 * @pre type MP_VOID <=> tile is on the south-east or south-west edge.
 
 */
 
static inline void SetTileType(TileIndex tile, TileType type)
 
{
 
	assert(tile < MapSize());
 
	/* VOID tiles (and no others) are exactly allowed at the lower left and right
 
	 * edges of the map */
 
	assert((TileX(tile) == MapMaxX() || TileY(tile) == MapMaxY()) == (type == MP_VOID));
 
	SB(_m[tile].type_height, 4, 4, type);
 
}
 

	
 
/**
 
 * Checks if a tile is a give tiletype.
 
 *
 
 * This function checks if a tile got the given tiletype.
 
 *
 
 * @param tile The tile to check
 
 * @param type The type to check agains
 
 * @return true If the type matches agains the type of the tile
 
 */
 
static inline bool IsTileType(TileIndex tile, TileType type)
 
{
 
	return GetTileType(tile) == type;
 
}
 

	
 
/**
 
 * Returns the owner of a tile
 
 *
 
 * This function returns the owner of a tile. This cannot used
 
 * for tiles which type is one of MP_HOUSE, MP_VOID and MP_INDUSTRY
 
 * as no player owned any of these buildings.
 
 *
 
 * @param tile The tile to check
 
 * @return The owner of the tile
 
 * @pre tile < MapSize()
 
 * @pre The type of the tile must not be MP_HOUSE, MP_VOID and MP_INDUSTRY
 
 */
 
static inline Owner GetTileOwner(TileIndex tile)
 
{
 
	assert(tile < MapSize());
 
	assert(!IsTileType(tile, MP_HOUSE));
 
	assert(!IsTileType(tile, MP_VOID));
 
	assert(!IsTileType(tile, MP_INDUSTRY));
 

	
 
	return (Owner)_m[tile].m1;
 
}
 

	
 
/**
 
 * Sets the owner of a tile
 
 *
 
 * This function sets the owner status of a tile. Note that you cannot
 
 * set a owner for tiles of type MP_HOUSE, MP_VOID and MP_INDUSTRY.
 
 *
 
 * @param tile The tile to change the owner status.
 
 * @param owner The new owner.
 
 * @pre tile < MapSize()
 
 * @pre The type of the tile must not be MP_HOUSE, MP_VOID and MP_INDUSTRY
 
 */
 
static inline void SetTileOwner(TileIndex tile, Owner owner)
 
{
 
	assert(tile < MapSize());
 
	assert(!IsTileType(tile, MP_HOUSE));
 
	assert(!IsTileType(tile, MP_VOID));
 
	assert(!IsTileType(tile, MP_INDUSTRY));
 

	
 
	_m[tile].m1 = owner;
 
}
 

	
 
/**
 
 * Checks if a tile belongs to the given owner
 
 *
 
 * @param tile The tile to check
 
 * @param owner The owner to check agains
 
 * @return True if a tile belongs the the given owner
 
 */
 
static inline bool IsTileOwner(TileIndex tile, Owner owner)
 
{
 
	return GetTileOwner(tile) == owner;
 
}
 

	
 
/**
 
 * Set the tropic zone
 
 * @param tile the tile to set the zone of
 
 * @param type the new type
 
 * @pre assert(tile < MapSize());
 
 */
 
static inline void SetTropicZone(TileIndex tile, TropicZone type)
 
{
 
	assert(tile < MapSize());
 
	SB(_m[tile].m6, 0, 2, type);
 
}
 

	
 
/**
 
 * Get the tropic zone
 
 * @param tile the tile to get the zone of
 
 * @pre assert(tile < MapSize());
 
 * @return the zone type
 
 */
 
static inline TropicZone GetTropicZone(TileIndex tile)
 
{
 
	assert(tile < MapSize());
 
	return (TropicZone)GB(_m[tile].m6, 0, 2);
 
}
 

	
 
Slope GetTileSlope(TileIndex tile, uint *h);
 
uint GetTileZ(TileIndex tile);
 
uint GetTileMaxZ(TileIndex tile);
 

	
 
#endif /* TILE_TYPE_H */
src/tile_type.h
Show inline comments
 
new file 100644
 
/* $Id$ */
 

	
 
/** @file tile_type.h Types related to tiles. */
 

	
 
#ifndef TILE_TYPE_H
 
#define TILE_TYPE_H
 

	
 
#include "core/enum_type.hpp"
 

	
 
/** Maximum allowed tile height */
 
#define MAX_TILE_HEIGHT 15
 

	
 
/** Maximum allowed snowline height */
 
#define MAX_SNOWLINE_HEIGHT (MAX_TILE_HEIGHT - 2)
 

	
 
/**
 
 * The different type of a tile.
 
 *
 
 * Each tile belongs to one type, according whatever is build on it.
 
 *
 
 * @note A railway with a crossing street is marked as MP_ROAD.
 
 */
 
enum TileType {
 
	MP_CLEAR,               ///< A tile without any structures, i.e. grass, rocks, farm fields etc.
 
	MP_RAILWAY,             ///< A railway
 
	MP_ROAD,                ///< A tile with road (or tram tracks)
 
	MP_HOUSE,               ///< A house by a town
 
	MP_TREES,               ///< Tile got trees
 
	MP_STATION,             ///< A tile of a station
 
	MP_WATER,               ///< Water tile
 
	MP_VOID,                ///< Invisible tiles at the SW and SE border
 
	MP_INDUSTRY,            ///< Part of an industry
 
	MP_TUNNELBRIDGE,        ///< Tunnel entry/exit and bridge heads
 
	MP_UNMOVABLE,           ///< Contains an object with cannot be removed like transmitters
 
};
 

	
 
/**
 
 * Additional infos of a tile on a tropic game.
 
 *
 
 * Each non-water tile in a tropic game is either a rainforest tile or a
 
 * desert one.
 
 */
 
enum TropicZone {
 
	TROPICZONE_INVALID    = 0,      ///< Invalid tropiczone-type
 
	TROPICZONE_DESERT     = 1,      ///< Tile is desert
 
	TROPICZONE_RAINFOREST = 2,      ///< Rainforest tile
 
};
 

	
 
/**
 
 * The index/ID of a Tile.
 
 */
 
typedef uint32 TileIndex;
 

	
 
#endif /* TILE_TYPE_H */
src/town_cmd.cpp
Show inline comments
 
@@ -10,13 +10,12 @@
 
#include "road_map.h"
 
#include "road_internal.h" /* Cleaning up road bits */
 
#include "table/strings.h"
 
#include "table/sprites.h"
 
#include "map.h"
 
#include "landscape.h"
 
#include "tile.h"
 
#include "town_map.h"
 
#include "tunnel_map.h"
 
#include "viewport.h"
 
#include "town.h"
 
#include "command.h"
 
#include "gfx.h"
src/town_map.h
Show inline comments
 
@@ -4,12 +4,13 @@
 

	
 
#ifndef TOWN_MAP_H
 
#define TOWN_MAP_H
 

	
 
#include "town.h"
 
#include "date.h"
 
#include "tile_map.h"
 

	
 
/**
 
 * Get the index of which town this house/street is attached to.
 
 * @param t the tile
 
 * @pre IsTileType(t, MP_HOUSE) or IsTileType(t, MP_ROAD)
 
 * @return TownID
src/track_func.h
Show inline comments
 
@@ -4,12 +4,13 @@
 

	
 
#ifndef TRACK_FUNC_H
 
#define TRACK_FUNC_H
 

	
 
#include "track_type.h"
 
#include "direction_type.h"
 
#include "slope_func.h"
 

	
 
/**
 
 * Convert an Axis to the corresponding Track
 
 * AXIS_X -> TRACK_X
 
 * AXIS_Y -> TRACK_Y
 
 * Uses the fact that they share the same internal encoding
src/train_cmd.cpp
Show inline comments
 
@@ -10,13 +10,12 @@
 
#include "landscape.h"
 
#include "gui.h"
 
#include "station_map.h"
 
#include "table/strings.h"
 
#include "strings.h"
 
#include "map.h"
 
#include "tile.h"
 
#include "tunnel_map.h"
 
#include "vehicle.h"
 
#include "timetable.h"
 
#include "articulated_vehicles.h"
 
#include "command.h"
 
#include "pathfind.h"
src/tree_cmd.cpp
Show inline comments
 
@@ -9,13 +9,12 @@
 
#include "table/strings.h"
 
#include "table/sprites.h"
 
#include "table/tree_land.h"
 
#include "functions.h"
 
#include "map.h"
 
#include "landscape.h"
 
#include "tile.h"
 
#include "tree_map.h"
 
#include "viewport.h"
 
#include "command.h"
 
#include "town.h"
 
#include "sound.h"
 
#include "variables.h"
src/tunnel_map.cpp
Show inline comments
 
/* $Id$ */
 

	
 
/** @file tunnel_map.cpp */
 

	
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "tile.h"
 
#include "tunnel_map.h"
 
#include "tunnelbridge_map.h"
 

	
 

	
 
/**
 
 * Gets the other end of the tunnel. Where a vehicle would reappear when it
src/tunnel_map.h
Show inline comments
 
@@ -7,12 +7,13 @@
 

	
 
#include "direction_func.h"
 
#include "macros.h"
 
#include "map.h"
 
#include "rail_type.h"
 
#include "road_type.h"
 
#include "tile_map.h"
 

	
 

	
 
/**
 
 * Is this a tunnel (entrance)?
 
 * @param t the tile that might be a tunnel
 
 * @pre IsTileType(t, MP_TUNNELBRIDGE)
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -13,13 +13,12 @@
 
#include "table/sprites.h"
 
#include "table/strings.h"
 
#include "strings.h"
 
#include "functions.h"
 
#include "map.h"
 
#include "landscape.h"
 
#include "tile.h"
 
#include "tunnel_map.h"
 
#include "unmovable_map.h"
 
#include "vehicle.h"
 
#include "viewport.h"
 
#include "command.h"
 
#include "player.h"
src/tunnelbridge_map.h
Show inline comments
 
@@ -5,13 +5,13 @@
 
#ifndef TUNNELBRIDGE_MAP_H
 
#define TUNNELBRIDGE_MAP_H
 

	
 
#include "direction_func.h"
 
#include "core/bitmath_func.hpp"  /* GB, HasBit, SB */
 
#include "map.h"                  /* Tile, TileIndex */
 
#include "tile.h"                 /* TileType, IsTileType */
 
#include "tile_map.h"             /* TileType, IsTileType */
 
#include "openttd.h"              /* TransportType */
 

	
 

	
 
/**
 
 * Tunnel: Get the direction facing out of the tunnel
 
 * Bridge: Get the direction pointing onto the bridge
src/unmovable_cmd.cpp
Show inline comments
 
@@ -6,13 +6,12 @@
 
#include "openttd.h"
 
#include "table/strings.h"
 
#include "table/sprites.h"
 
#include "functions.h"
 
#include "landscape.h"
 
#include "map.h"
 
#include "tile.h"
 
#include "command.h"
 
#include "viewport.h"
 
#include "player.h"
 
#include "gui.h"
 
#include "station.h"
 
#include "economy.h"
src/vehicle.cpp
Show inline comments
 
@@ -10,13 +10,12 @@
 
#include "spritecache.h"
 
#include "table/sprites.h"
 
#include "table/strings.h"
 
#include "functions.h"
 
#include "landscape.h"
 
#include "map.h"
 
#include "tile.h"
 
#include "vehicle.h"
 
#include "timetable.h"
 
#include "gfx.h"
 
#include "viewport.h"
 
#include "news.h"
 
#include "command.h"
src/vehicle.h
Show inline comments
 
@@ -2,12 +2,13 @@
 

	
 
/** @vehicle.h */
 

	
 
#ifndef VEHICLE_H
 
#define VEHICLE_H
 

	
 
#include "vehicle_type.h"
 
#include "oldpool.h"
 
#include "order.h"
 
#include "track_type.h"
 
#include "rail_type.h"
 
#include "road_type.h"
 
#include "window_type.h"
 
@@ -66,26 +67,12 @@ enum RoadVehicleStates {
 
	RVSB_IN_DT_ROAD_STOP_END     = RVSB_IN_DT_ROAD_STOP + TRACKDIR_END,
 

	
 
	RVSB_TRACKDIR_MASK           = 0x0F,                      ///< The mask used to extract track dirs
 
	RVSB_ROAD_STOP_TRACKDIR_MASK = 0x09                       ///< Only bits 0 and 3 are used to encode the trackdir for road stops
 
};
 

	
 
enum VehicleType {
 
	VEH_TRAIN,
 
	VEH_ROAD,
 
	VEH_SHIP,
 
	VEH_AIRCRAFT,
 
	VEH_SPECIAL,
 
	VEH_DISASTER,
 
	VEH_END,
 
	VEH_INVALID = 0xFF,
 
};
 
DECLARE_POSTFIX_INCREMENT(VehicleType);
 
template <> struct EnumPropsT<VehicleType> : MakeEnumPropsT<VehicleType, byte, VEH_TRAIN, VEH_END, VEH_INVALID> {};
 
typedef TinyEnumT<VehicleType> VehicleTypeByte;
 

	
 
enum VehStatus {
 
	VS_HIDDEN          = 0x01,
 
	VS_STOPPED         = 0x02,
 
	VS_UNCLICKABLE     = 0x04,
 
	VS_DEFPAL          = 0x08,
 
	VS_TRAIN_SLOWING   = 0x10,
 
@@ -215,13 +202,12 @@ struct VehicleDisaster {
 
};
 

	
 
struct VehicleShip {
 
	TrackBitsByte state;
 
};
 

	
 
struct Vehicle;
 
DECLARE_OLD_POOL(Vehicle, Vehicle, 9, 125)
 

	
 
/* Some declarations of functions, so we can make them friendly */
 
struct SaveLoad;
 
extern const SaveLoad *GetVehicleDescription(VehicleType vt);
 
extern void AfterLoadVehicles();
src/vehicle_type.h
Show inline comments
 
new file 100644
 
/* $Id$ */
 

	
 
/** @file vehicle_type.h Types related to vehicles. */
 

	
 
#ifndef VEHICLE_TYPE_H
 
#define VEHICLE_TYPE_H
 

	
 
#include "core/enum_type.hpp"
 

	
 
typedef uint16 VehicleID;
 

	
 
enum VehicleType {
 
	VEH_TRAIN,
 
	VEH_ROAD,
 
	VEH_SHIP,
 
	VEH_AIRCRAFT,
 
	VEH_SPECIAL,
 
	VEH_DISASTER,
 
	VEH_END,
 
	VEH_INVALID = 0xFF,
 
};
 
DECLARE_POSTFIX_INCREMENT(VehicleType);
 
template <> struct EnumPropsT<VehicleType> : MakeEnumPropsT<VehicleType, byte, VEH_TRAIN, VEH_END, VEH_INVALID> {};
 
typedef TinyEnumT<VehicleType> VehicleTypeByte;
 

	
 
struct Vehicle;
 

	
 
#endif /* VEHICLE_TYPE_H */
src/void_map.h
Show inline comments
 
@@ -2,12 +2,14 @@
 

	
 
/** @file void_map.h */
 

	
 
#ifndef VOID_MAP_H
 
#define VOID_MAP_H
 

	
 
#include "tile_map.h"
 

	
 
/**
 
 * Make a nice void tile ;)
 
 * @param t the tile to make void
 
 */
 
static inline void MakeVoid(TileIndex t)
 
{
src/water.h
Show inline comments
 
@@ -7,8 +7,9 @@
 

	
 
void TileLoop_Water(TileIndex tile);
 
void DrawShipDepotSprite(int x, int y, int image);
 
void DrawCanalWater(TileIndex tile);
 
void MakeWaterOrCanalDependingOnOwner(TileIndex tile, Owner o);
 
void MakeWaterOrCanalDependingOnSurroundings(TileIndex t, Owner o);
 
void FloodHalftile(TileIndex t);
 

	
 
#endif /* WATER_H */
src/water_cmd.cpp
Show inline comments
 
@@ -11,23 +11,23 @@
 
#include "table/sprites.h"
 
#include "table/strings.h"
 
#include "strings.h"
 
#include "functions.h"
 
#include "landscape.h"
 
#include "map.h"
 
#include "tile.h"
 
#include "vehicle.h"
 
#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.h"
 
#include "water_map.h"
 
#include "industry_map.h"
 
#include "newgrf.h"
 
#include "newgrf_canal.h"
 
#include "misc/autoptr.hpp"
 
#include "transparency.h"
src/waypoint.cpp
Show inline comments
 
@@ -12,13 +12,12 @@
 
#include "map.h"
 
#include "order.h"
 
#include "rail_map.h"
 
#include "bridge_map.h"
 
#include "saveload.h"
 
#include "station.h"
 
#include "tile.h"
 
#include "town.h"
 
#include "waypoint.h"
 
#include "variables.h"
 
#include "table/strings.h"
 
#include "vehicle.h"
 
#include "yapf/yapf.h"
src/yapf/track_dir.hpp
Show inline comments
 
/* $Id$ */
 

	
 
#ifndef  TRACK_DIR_HPP
 
#define  TRACK_DIR_HPP
 

	
 
#include "../tile.h"
 
#include "../tile_type.h"
 
#include "../openttd.h"
 
#include "../map.h"
 
#include "../rail.h"
 
#include "../rail_type.h"
 

	
 
#endif /* TRACK_DIR_HPP */
0 comments (0 inline, 0 general)