diff options
author | rubidium <rubidium@openttd.org> | 2007-12-19 23:26:02 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-12-19 23:26:02 +0000 |
commit | 5b49e754535d48bb42575bc987e9c8f3251cf595 (patch) | |
tree | 6c554e9bcc282dbe3b7ab306ad3c91c7a4ff545b /src | |
parent | d582aea639e5d3ee592ec37f90b03bebbc3163f1 (diff) | |
download | openttd-5b49e754535d48bb42575bc987e9c8f3251cf595.tar.xz |
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
Diffstat (limited to 'src')
70 files changed, 229 insertions, 220 deletions
diff --git a/src/ai/default/default.cpp b/src/ai/default/default.cpp index 671f6a07e..ca6fe55c4 100644 --- a/src/ai/default/default.cpp +++ b/src/ai/default/default.cpp @@ -11,7 +11,6 @@ #include "../../road_map.h" #include "../../roadveh.h" #include "../../station_map.h" -#include "../../tile.h" #include "../../player.h" #include "../../tunnel_map.h" #include "../../vehicle.h" diff --git a/src/ai/trolly/build.cpp b/src/ai/trolly/build.cpp index 31147b17b..a83ccb5a2 100644 --- a/src/ai/trolly/build.cpp +++ b/src/ai/trolly/build.cpp @@ -6,7 +6,6 @@ #include "../../functions.h" #include "../../map.h" #include "../../road_map.h" -#include "../../tile.h" #include "../../vehicle.h" #include "../../command.h" #include "trolly.h" diff --git a/src/ai/trolly/pathfinder.cpp b/src/ai/trolly/pathfinder.cpp index bfd4a0799..a18542827 100644 --- a/src/ai/trolly/pathfinder.cpp +++ b/src/ai/trolly/pathfinder.cpp @@ -6,7 +6,6 @@ #include "../../debug.h" #include "../../functions.h" #include "../../map.h" -#include "../../tile.h" #include "../../command.h" #include "trolly.h" #include "../../depot.h" diff --git a/src/ai/trolly/trolly.cpp b/src/ai/trolly/trolly.cpp index 3c34a9bac..c95e7d1a5 100644 --- a/src/ai/trolly/trolly.cpp +++ b/src/ai/trolly/trolly.cpp @@ -25,7 +25,6 @@ #include "../../station_map.h" #include "table/strings.h" #include "../../map.h" -#include "../../tile.h" #include "../../command.h" #include "trolly.h" #include "../../town.h" diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index b333746b2..aaad42309 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -13,7 +13,6 @@ #include "strings.h" #include "table/strings.h" #include "map.h" -#include "tile.h" #include "vehicle.h" #include "timetable.h" #include "depot.h" diff --git a/src/bridge_map.h b/src/bridge_map.h index 3ec527c3c..870512d1e 100644 --- a/src/bridge_map.h +++ b/src/bridge_map.h @@ -10,7 +10,6 @@ #include "map.h" #include "rail_type.h" #include "road_map.h" -#include "tile.h" /** diff --git a/src/clear_cmd.cpp b/src/clear_cmd.cpp index 2974aa04a..29aee2856 100644 --- a/src/clear_cmd.cpp +++ b/src/clear_cmd.cpp @@ -10,7 +10,6 @@ #include "functions.h" #include "map.h" #include "player.h" -#include "tile.h" #include "viewport.h" #include "command.h" #include "tunnel_map.h" diff --git a/src/clear_map.h b/src/clear_map.h index 71b72f615..d616fb4d4 100644 --- a/src/clear_map.h +++ b/src/clear_map.h @@ -6,7 +6,6 @@ #define CLEAR_MAP_H #include "macros.h" -#include "tile.h" #include "bridge_map.h" /** diff --git a/src/command.cpp b/src/command.cpp index 00f7b4614..9b34bc0ab 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -9,6 +9,7 @@ #include "functions.h" #include "landscape.h" #include "map.h" +#include "tile_map.h" #include "gui.h" #include "command.h" #include "player.h" @@ -16,7 +17,6 @@ #include "variables.h" #include "genworld.h" #include "newgrf_storage.h" -#include "tile.h" const char *_cmd_text = NULL; diff --git a/src/depot.cpp b/src/depot.cpp index 2f6852bcc..6555c2c70 100644 --- a/src/depot.cpp +++ b/src/depot.cpp @@ -8,7 +8,6 @@ #include "depot.h" #include "functions.h" #include "landscape.h" -#include "tile.h" #include "map.h" #include "table/strings.h" #include "saveload.h" diff --git a/src/depot.h b/src/depot.h index baa53573c..ad3499c18 100644 --- a/src/depot.h +++ b/src/depot.h @@ -7,7 +7,6 @@ #include "direction_type.h" #include "oldpool.h" -#include "tile.h" #include "variables.h" #include "road_map.h" #include "rail_map.h" diff --git a/src/disaster_cmd.cpp b/src/disaster_cmd.cpp index 79b8d6e2c..242dd0861 100644 --- a/src/disaster_cmd.cpp +++ b/src/disaster_cmd.cpp @@ -25,7 +25,6 @@ #include "table/strings.h" #include "strings.h" #include "map.h" -#include "tile.h" #include "vehicle.h" #include "command.h" #include "news.h" diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index 0423cab14..0064163a8 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -8,6 +8,7 @@ #include "table/strings.h" #include "functions.h" #include "map.h" +#include "tile_map.h" #include "station.h" #include "gui.h" #include "window_gui.h" diff --git a/src/elrail.cpp b/src/elrail.cpp index 4e529869d..f5acc08ff 100644 --- a/src/elrail.cpp +++ b/src/elrail.cpp @@ -48,7 +48,6 @@ #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 */ diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp index ad01dea8f..a886b4290 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -12,7 +12,6 @@ #include "window_gui.h" #include "textbuf_gui.h" #include "gfx.h" -#include "tile.h" #include "strings.h" #include "gfxinit.h" #include "player.h" @@ -9,7 +9,7 @@ #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); diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index 987aa3fd5..619713165 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -12,7 +12,6 @@ #include "strings.h" #include "table/sprites.h" #include "map.h" -#include "tile.h" #include "train.h" #include "landscape.h" #include "viewport.h" diff --git a/src/industry_map.h b/src/industry_map.h index 6ae571752..f4047f4bc 100644 --- a/src/industry_map.h +++ b/src/industry_map.h @@ -7,7 +7,7 @@ #include "industry.h" #include "macros.h" -#include "tile.h" +#include "tile_map.h" diff --git a/src/landscape.cpp b/src/landscape.cpp index 1e38ce694..1b421459a 100644 --- a/src/landscape.cpp +++ b/src/landscape.cpp @@ -11,7 +11,6 @@ #include "player.h" #include "spritecache.h" #include "table/sprites.h" -#include "tile.h" #include <stdarg.h> #include "viewport.h" #include "command.h" diff --git a/src/main_gui.cpp b/src/main_gui.cpp index 26ea19ead..24df0f3ae 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -13,7 +13,6 @@ #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" @@ -7,6 +7,7 @@ #include "stdafx.h" #include "direction_func.h" +#include "tile_type.h" extern uint _map_tile_mask; @@ -136,11 +137,6 @@ uint ScaleByMapSize(uint); 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 diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index a00eb8e1c..a27044b84 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -17,6 +17,7 @@ #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" diff --git a/src/newgrf_canal.cpp b/src/newgrf_canal.cpp index b49191de6..f7cc633d7 100644 --- a/src/newgrf_canal.cpp +++ b/src/newgrf_canal.cpp @@ -10,6 +10,7 @@ #include "newgrf_commons.h" #include "newgrf_spritegroup.h" #include "newgrf_canal.h" +#include "tile_map.h" /** Table of canal 'feature' sprite groups */ diff --git a/src/newgrf_commons.cpp b/src/newgrf_commons.cpp index 6c8743f31..af7cbda9f 100644 --- a/src/newgrf_commons.cpp +++ b/src/newgrf_commons.cpp @@ -12,6 +12,7 @@ #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 diff --git a/src/newgrf_house.cpp b/src/newgrf_house.cpp index 2b770fede..169396245 100644 --- a/src/newgrf_house.cpp +++ b/src/newgrf_house.cpp @@ -10,7 +10,6 @@ #include "viewport.h" #include "landscape.h" #include "date.h" -#include "tile.h" #include "town.h" #include "town_map.h" #include "sound.h" diff --git a/src/npf.cpp b/src/npf.cpp index 15120dc4e..653aff2a2 100644 --- a/src/npf.cpp +++ b/src/npf.cpp @@ -14,7 +14,6 @@ #include "pathfind.h" #include "station.h" #include "station_map.h" -#include "tile.h" #include "depot.h" #include "tunnel_map.h" #include "network/network.h" @@ -9,7 +9,7 @@ #include "aystar.h" #include "station.h" #include "vehicle.h" -#include "tile.h" +#include "tile_type.h" /* mowing grass */ enum { diff --git a/src/openttd.cpp b/src/openttd.cpp index 0d88448c9..df0cb80bb 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -9,8 +9,6 @@ #include "driver.h" #include "saveload.h" #include "map.h" -#include "tile.h" -#include "void_map.h" #include "helpers.hpp" #include "openttd.h" @@ -79,6 +77,7 @@ #include "unmovable_map.h" #include "tree_map.h" #include "tunnelbridge_map.h" +#include "void_map.h" #include <stdarg.h> diff --git a/src/openttd.h b/src/openttd.h index ec68bf914..7fd02174b 100644 --- a/src/openttd.h +++ b/src/openttd.h @@ -26,10 +26,10 @@ struct Pair { }; #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; @@ -55,7 +55,6 @@ 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; diff --git a/src/order_gui.cpp b/src/order_gui.cpp index f1f7ee122..d84182a00 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -11,7 +11,6 @@ #include "strings.h" #include "functions.h" #include "map.h" -#include "tile.h" #include "gui.h" #include "window_gui.h" #include "gfx.h" diff --git a/src/pathfind.cpp b/src/pathfind.cpp index 6fc812c89..ae7d258fa 100644 --- a/src/pathfind.cpp +++ b/src/pathfind.cpp @@ -10,7 +10,6 @@ #include "functions.h" #include "landscape.h" #include "map.h" -#include "tile.h" #include "pathfind.h" #include "rail_type.h" #include "debug.h" diff --git a/src/players.cpp b/src/players.cpp index 9f6ce32fd..db368c686 100644 --- a/src/players.cpp +++ b/src/players.cpp @@ -29,6 +29,7 @@ #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 diff --git a/src/rail.h b/src/rail.h index 8b5848bc4..fe5664152 100644 --- a/src/rail.h +++ b/src/rail.h @@ -8,7 +8,6 @@ #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. @@ -228,8 +227,6 @@ 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 */ diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index bca945341..cf135eb64 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -15,7 +15,6 @@ #include "table/strings.h" #include "map.h" #include "landscape.h" -#include "tile.h" #include "town_map.h" #include "tunnel_map.h" #include "vehicle.h" diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 7791bf7c5..41dd83bab 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -11,7 +11,6 @@ #include "landscape.h" #include "date.h" #include "map.h" -#include "tile.h" #include "gui.h" #include "window_gui.h" #include "station_gui.h" diff --git a/src/rail_map.h b/src/rail_map.h index 181d42563..6472a5760 100644 --- a/src/rail_map.h +++ b/src/rail_map.h @@ -8,7 +8,7 @@ #include "direction_func.h" #include "track_func.h" #include "rail.h" -#include "tile.h" +#include "tile_map.h" /** Different types of Rail-related tiles */ diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index e1c362a04..7318889de 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -17,7 +17,6 @@ #include "functions.h" #include "map.h" #include "landscape.h" -#include "tile.h" #include "town_map.h" #include "vehicle.h" #include "viewport.h" diff --git a/src/road_gui.cpp b/src/road_gui.cpp index e32b8b591..85b63dca1 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -9,7 +9,6 @@ #include "strings.h" #include "functions.h" #include "map.h" -#include "tile.h" #include "gui.h" #include "window_gui.h" #include "station_gui.h" diff --git a/src/road_map.h b/src/road_map.h index 02ec36512..5854f0dc8 100644 --- a/src/road_map.h +++ b/src/road_map.h @@ -9,7 +9,7 @@ #include "track_func.h" #include "rail_type.h" #include "road_func.h" -#include "tile.h" +#include "tile_map.h" enum RoadTileType { diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index d9cdeb4d3..e01568137 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -13,7 +13,6 @@ #include "table/strings.h" #include "strings.h" #include "map.h" -#include "tile.h" #include "vehicle.h" #include "timetable.h" #include "engine.h" diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index 31f41018a..b29dd78b3 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -10,7 +10,6 @@ #include "functions.h" #include "landscape.h" #include "map.h" -#include "tile.h" #include "vehicle.h" #include "timetable.h" #include "command.h" diff --git a/src/slope.h b/src/slope_func.h index 9f4985941..4a68f6713 100644 --- a/src/slope.h +++ b/src/slope_func.h @@ -1,71 +1,12 @@ /* $Id$ */ -/** @file slope.h Definitions of a slope. - * This file defines the enumeration and helper functions for handling - * the slope info of a tile. - */ - -#ifndef SLOPE_H -#define SLOPE_H - -/** - * Enumeration of tile corners - */ -enum Corner { - CORNER_W = 0, - CORNER_S = 1, - CORNER_E = 2, - CORNER_N = 3, - CORNER_END, - CORNER_INVALID = 0xFF -}; +/** @file slope_func.h Functions related to slopes. */ -/** - * 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) +#ifndef SLOPE_FUNC_H +#define SLOPE_FUNC_H - 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) -}; +#include "slope_type.h" +#include "direction_type.h" /** * Rangecheck for Corner enumeration. @@ -78,6 +19,7 @@ static inline bool IsValidCorner(Corner corner) return IsInsideMM(corner, 0, CORNER_END); } + /** * Checks if a slope is steep. * @@ -228,32 +170,6 @@ static inline Slope HalftileSlope(Slope s, Corner corner) /** - * 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. -}; - -/** * Tests for FOUNDATION_NONE. * * @param f Maybe a #Foundation. @@ -383,4 +299,4 @@ static inline Foundation SpecialRailFoundation(Corner corner) return (Foundation)(FOUNDATION_RAIL_W + corner); } -#endif /* SLOPE_H */ +#endif /* SLOPE_FUNC_H */ diff --git a/src/slope_type.h b/src/slope_type.h new file mode 100644 index 000000000..a61a09182 --- /dev/null +++ b/src/slope_type.h @@ -0,0 +1,101 @@ +/* $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 */ diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index 59c1992db..eaf016cb4 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -15,7 +15,6 @@ #include "table/sprites.h" #include "landscape.h" #include "map.h" -#include "tile.h" #include "gui.h" #include "window_gui.h" #include "tree_map.h" diff --git a/src/station.cpp b/src/station.cpp index 326521d8e..53afb24ac 100644 --- a/src/station.cpp +++ b/src/station.cpp @@ -11,7 +11,6 @@ #include "table/sprites.h" #include "table/strings.h" #include "map.h" -#include "tile.h" #include "station.h" #include "gfx.h" #include "viewport.h" diff --git a/src/station.h b/src/station.h index 0969a52e4..77896448a 100644 --- a/src/station.h +++ b/src/station.h @@ -9,7 +9,6 @@ #include "player.h" #include "oldpool.h" #include "sprite.h" -#include "tile.h" #include "road_type.h" #include "newgrf_station.h" #include "cargopacket.h" diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 3b64116fe..02fc77898 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -15,7 +15,6 @@ #include "table/sprites.h" #include "table/strings.h" #include "map.h" -#include "tile.h" #include "station.h" #include "gfx.h" #include "viewport.h" diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index 5b0af2050..04a99878c 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -10,7 +10,6 @@ #include "table/strings.h" #include "functions.h" #include "player.h" -#include "tile.h" #include "gui.h" #include "window_gui.h" #include "viewport.h" diff --git a/src/tgp.cpp b/src/tgp.cpp index f856a51c6..0d5c27870 100644 --- a/src/tgp.cpp +++ b/src/tgp.cpp @@ -10,7 +10,6 @@ #include "map.h" #include "table/strings.h" #include "clear_map.h" -#include "tile.h" #include "variables.h" #include "void_map.h" #include "tgp.h" diff --git a/src/tile.cpp b/src/tile_map.cpp index a7199c1b8..a4d106ebe 100644 --- a/src/tile.cpp +++ b/src/tile_map.cpp @@ -3,7 +3,8 @@ /** @file tile.cpp */ #include "stdafx.h" -#include "tile.h" +#include "openttd.h" +#include "tile_map.h" Slope GetTileSlope(TileIndex tile, uint *h) { diff --git a/src/tile.h b/src/tile_map.h index c4ce7454b..4f13d1bd2 100644 --- a/src/tile.h +++ b/src/tile_map.h @@ -1,57 +1,13 @@ /* $Id$ */ -/** @file tile.h */ +/** @file tile_map.h Map writing/reading functions for tiles. */ -#ifndef TILE_H -#define TILE_H +#ifndef TILE_MAP_H +#define TILE_MAP_H -#include "macros.h" -#include "openttd.h" +#include "tile_type.h" +#include "slope_type.h" #include "map.h" -#include "slope.h" - -/** 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 -}; - -Slope GetTileSlope(TileIndex tile, uint *h); -uint GetTileZ(TileIndex tile); -uint GetTileMaxZ(TileIndex tile); /** * Returns the height of a tile @@ -226,4 +182,9 @@ static inline TropicZone GetTropicZone(TileIndex tile) assert(tile < MapSize()); return (TropicZone)GB(_m[tile].m6, 0, 2); } -#endif /* TILE_H */ + +Slope GetTileSlope(TileIndex tile, uint *h); +uint GetTileZ(TileIndex tile); +uint GetTileMaxZ(TileIndex tile); + +#endif /* TILE_TYPE_H */ diff --git a/src/tile_type.h b/src/tile_type.h new file mode 100644 index 000000000..4c4f2a9c8 --- /dev/null +++ b/src/tile_type.h @@ -0,0 +1,54 @@ +/* $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 */ diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 70368a59c..34ea6a5aa 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -13,7 +13,6 @@ #include "table/sprites.h" #include "map.h" #include "landscape.h" -#include "tile.h" #include "town_map.h" #include "tunnel_map.h" #include "viewport.h" diff --git a/src/town_map.h b/src/town_map.h index 20d0f9950..1c1b8e871 100644 --- a/src/town_map.h +++ b/src/town_map.h @@ -7,6 +7,7 @@ #include "town.h" #include "date.h" +#include "tile_map.h" /** * Get the index of which town this house/street is attached to. diff --git a/src/track_func.h b/src/track_func.h index 3f36129f6..030872385 100644 --- a/src/track_func.h +++ b/src/track_func.h @@ -7,6 +7,7 @@ #include "track_type.h" #include "direction_type.h" +#include "slope_func.h" /** * Convert an Axis to the corresponding Track diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 5d56be133..c0c7e8d05 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -13,7 +13,6 @@ #include "table/strings.h" #include "strings.h" #include "map.h" -#include "tile.h" #include "tunnel_map.h" #include "vehicle.h" #include "timetable.h" diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp index 3b985965a..1d309ab8a 100644 --- a/src/tree_cmd.cpp +++ b/src/tree_cmd.cpp @@ -12,7 +12,6 @@ #include "functions.h" #include "map.h" #include "landscape.h" -#include "tile.h" #include "tree_map.h" #include "viewport.h" #include "command.h" diff --git a/src/tunnel_map.cpp b/src/tunnel_map.cpp index ac7255155..57ab9a6ec 100644 --- a/src/tunnel_map.cpp +++ b/src/tunnel_map.cpp @@ -4,7 +4,6 @@ #include "stdafx.h" #include "openttd.h" -#include "tile.h" #include "tunnel_map.h" #include "tunnelbridge_map.h" diff --git a/src/tunnel_map.h b/src/tunnel_map.h index b14d8f0f8..2902fa7cb 100644 --- a/src/tunnel_map.h +++ b/src/tunnel_map.h @@ -10,6 +10,7 @@ #include "map.h" #include "rail_type.h" #include "road_type.h" +#include "tile_map.h" /** diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp index 95fc6f980..9dd44cd23 100644 --- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -16,7 +16,6 @@ #include "functions.h" #include "map.h" #include "landscape.h" -#include "tile.h" #include "tunnel_map.h" #include "unmovable_map.h" #include "vehicle.h" diff --git a/src/tunnelbridge_map.h b/src/tunnelbridge_map.h index 892d4ed58..b83e6e8d0 100644 --- a/src/tunnelbridge_map.h +++ b/src/tunnelbridge_map.h @@ -8,7 +8,7 @@ #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 */ diff --git a/src/unmovable_cmd.cpp b/src/unmovable_cmd.cpp index 66da42d78..f2c3baa1f 100644 --- a/src/unmovable_cmd.cpp +++ b/src/unmovable_cmd.cpp @@ -9,7 +9,6 @@ #include "functions.h" #include "landscape.h" #include "map.h" -#include "tile.h" #include "command.h" #include "viewport.h" #include "player.h" diff --git a/src/vehicle.cpp b/src/vehicle.cpp index b35e3afd9..cd839d98f 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -13,7 +13,6 @@ #include "functions.h" #include "landscape.h" #include "map.h" -#include "tile.h" #include "vehicle.h" #include "timetable.h" #include "gfx.h" diff --git a/src/vehicle.h b/src/vehicle.h index 48c507f15..7ab327fee 100644 --- a/src/vehicle.h +++ b/src/vehicle.h @@ -5,6 +5,7 @@ #ifndef VEHICLE_H #define VEHICLE_H +#include "vehicle_type.h" #include "oldpool.h" #include "order.h" #include "track_type.h" @@ -69,20 +70,6 @@ enum RoadVehicleStates { 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, @@ -218,7 +205,6 @@ struct VehicleShip { TrackBitsByte state; }; -struct Vehicle; DECLARE_OLD_POOL(Vehicle, Vehicle, 9, 125) /* Some declarations of functions, so we can make them friendly */ diff --git a/src/vehicle_type.h b/src/vehicle_type.h new file mode 100644 index 000000000..d752d1b63 --- /dev/null +++ b/src/vehicle_type.h @@ -0,0 +1,28 @@ +/* $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 */ diff --git a/src/void_map.h b/src/void_map.h index aae284821..df650cfcb 100644 --- a/src/void_map.h +++ b/src/void_map.h @@ -5,6 +5,8 @@ #ifndef VOID_MAP_H #define VOID_MAP_H +#include "tile_map.h" + /** * Make a nice void tile ;) * @param t the tile to make void diff --git a/src/water.h b/src/water.h index 27f411e0f..dbb2e114f 100644 --- a/src/water.h +++ b/src/water.h @@ -10,5 +10,6 @@ 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 */ diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index f26e3a109..ea123d05c 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -14,7 +14,6 @@ #include "functions.h" #include "landscape.h" #include "map.h" -#include "tile.h" #include "vehicle.h" #include "viewport.h" #include "command.h" @@ -25,6 +24,7 @@ #include "vehicle_gui.h" #include "train.h" #include "roadveh.h" +#include "water.h" #include "water_map.h" #include "industry_map.h" #include "newgrf.h" diff --git a/src/waypoint.cpp b/src/waypoint.cpp index c4422f8d4..aadf04c7f 100644 --- a/src/waypoint.cpp +++ b/src/waypoint.cpp @@ -15,7 +15,6 @@ #include "bridge_map.h" #include "saveload.h" #include "station.h" -#include "tile.h" #include "town.h" #include "waypoint.h" #include "variables.h" diff --git a/src/yapf/track_dir.hpp b/src/yapf/track_dir.hpp index 824075577..bb3de4488 100644 --- a/src/yapf/track_dir.hpp +++ b/src/yapf/track_dir.hpp @@ -3,9 +3,9 @@ #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 */ |