From 765ecfed848bd7fc8e3e10e99f7ecc3f1ae338a4 Mon Sep 17 00:00:00 2001 From: tron Date: Wed, 15 Dec 2004 22:18:54 +0000 Subject: [PATCH] (svn r1117) Move map arrays and some related macros into their own files map.c and map.h --- Makefile | 1 + ai.c | 1 + ai_build.c | 1 + ai_new.c | 1 + ai_pathfinder.c | 1 + ai_shared.c | 1 + aircraft_cmd.c | 1 + aircraft_gui.c | 1 + airport.c | 1 + airport_gui.c | 1 + bridge_gui.c | 1 + clear_cmd.c | 1 + command.c | 1 + disaster_cmd.c | 1 + dock_gui.c | 1 + economy.c | 1 + industry_cmd.c | 1 + industry_gui.c | 1 + landscape.c | 9 +-------- macros.h | 8 -------- main_gui.c | 1 + map.c | 11 +++++++++++ map.h | 21 +++++++++++++++++++++ misc.c | 1 + misc_gui.c | 1 + network.c | 1 + oldloader.c | 1 + order_gui.c | 1 + pathfind.c | 1 + players.c | 1 + rail_cmd.c | 1 + rail_gui.c | 1 + road_cmd.c | 1 + road_gui.c | 1 + roadveh_cmd.c | 1 + roadveh_gui.c | 1 + ship_cmd.c | 1 + ship_gui.c | 1 + smallmap_gui.c | 1 + sound.c | 1 + station_cmd.c | 1 + town_cmd.c | 1 + train_cmd.c | 1 + train_gui.c | 1 + tree_cmd.c | 1 + ttd.c | 1 + tunnelbridge_cmd.c | 1 + unmovable_cmd.c | 1 + variables.h | 7 ------- vehicle.c | 1 + viewport.c | 1 + water_cmd.c | 1 + window.c | 1 + 53 files changed, 81 insertions(+), 23 deletions(-) create mode 100644 map.c create mode 100644 map.h diff --git a/Makefile b/Makefile index 9610337ed4..0e87cae293 100644 --- a/Makefile +++ b/Makefile @@ -575,6 +575,7 @@ C_SOURCES += industry_gui.c C_SOURCES += intro_gui.c C_SOURCES += landscape.c C_SOURCES += main_gui.c +C_SOURCES += map.c C_SOURCES += md5.c C_SOURCES += minilzo.c C_SOURCES += misc.c diff --git a/ai.c b/ai.c index 1d8d583f36..855c39c22b 100644 --- a/ai.c +++ b/ai.c @@ -1,5 +1,6 @@ #include "stdafx.h" #include "ttd.h" +#include "map.h" #include "player.h" #include "vehicle.h" #include "engine.h" diff --git a/ai_build.c b/ai_build.c index f6c4f1d547..2530a78b61 100644 --- a/ai_build.c +++ b/ai_build.c @@ -1,5 +1,6 @@ #include "stdafx.h" #include "ttd.h" +#include "map.h" #include "command.h" #include "ai.h" #include "engine.h" diff --git a/ai_new.c b/ai_new.c index ba335196a9..9e72d3c907 100644 --- a/ai_new.c +++ b/ai_new.c @@ -16,6 +16,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "command.h" #include "ai.h" #include "town.h" diff --git a/ai_pathfinder.c b/ai_pathfinder.c index f51f34b832..5c837a4603 100644 --- a/ai_pathfinder.c +++ b/ai_pathfinder.c @@ -1,5 +1,6 @@ #include "stdafx.h" #include "ttd.h" +#include "map.h" #include "command.h" #include "ai.h" diff --git a/ai_shared.c b/ai_shared.c index 9e7edaad06..9558c72bd8 100644 --- a/ai_shared.c +++ b/ai_shared.c @@ -1,5 +1,6 @@ #include "stdafx.h" #include "ttd.h" +#include "map.h" #include "ai.h" #include "vehicle.h" diff --git a/aircraft_cmd.c b/aircraft_cmd.c index a851343fe0..11cfec92be 100644 --- a/aircraft_cmd.c +++ b/aircraft_cmd.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "vehicle.h" #include "engine.h" #include "command.h" diff --git a/aircraft_gui.c b/aircraft_gui.c index 5dbfebaa8b..74c4150d29 100644 --- a/aircraft_gui.c +++ b/aircraft_gui.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "window.h" #include "gui.h" #include "vehicle.h" diff --git a/airport.c b/airport.c index 0b5ea344bd..7b6c96276f 100644 --- a/airport.c +++ b/airport.c @@ -1,5 +1,6 @@ #include "stdafx.h" #include "ttd.h" +#include "map.h" #include "airport.h" AirportFTAClass *CountryAirport; diff --git a/airport_gui.c b/airport_gui.c index 65c42a1e4a..2c7f035f62 100644 --- a/airport_gui.c +++ b/airport_gui.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "window.h" #include "gui.h" #include "viewport.h" diff --git a/bridge_gui.c b/bridge_gui.c index af2739f08f..c38f1ce59f 100644 --- a/bridge_gui.c +++ b/bridge_gui.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "window.h" #include "gui.h" #include "viewport.h" diff --git a/clear_cmd.c b/clear_cmd.c index 225f40ed05..a6d0628398 100644 --- a/clear_cmd.c +++ b/clear_cmd.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "viewport.h" #include "command.h" diff --git a/command.c b/command.c index 95c290b9c2..756c5dda25 100644 --- a/command.c +++ b/command.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "gui.h" #include "command.h" #include "player.h" diff --git a/disaster_cmd.c b/disaster_cmd.c index 9e72f7c6b4..a1bf71644a 100644 --- a/disaster_cmd.c +++ b/disaster_cmd.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "vehicle.h" #include "command.h" #include "news.h" diff --git a/dock_gui.c b/dock_gui.c index 36efe83b8d..e9a80fe1ea 100644 --- a/dock_gui.c +++ b/dock_gui.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "window.h" #include "station.h" #include "gui.h" diff --git a/economy.c b/economy.c index 78b88ba141..fb42abe0dd 100644 --- a/economy.c +++ b/economy.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "news.h" #include "player.h" #include "station.h" diff --git a/industry_cmd.c b/industry_cmd.c index 53da5e600c..528fc231cc 100644 --- a/industry_cmd.c +++ b/industry_cmd.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "viewport.h" #include "command.h" #include "industry.h" diff --git a/industry_gui.c b/industry_gui.c index e031844f39..9c13e2b215 100644 --- a/industry_gui.c +++ b/industry_gui.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" //#include "gui.h" #include "window.h" #include "gfx.h" diff --git a/landscape.c b/landscape.c index 5126115a28..78da7197f9 100644 --- a/landscape.c +++ b/landscape.c @@ -1,19 +1,12 @@ #include "stdafx.h" #include "ttd.h" +#include "map.h" #include #include "gfx.h" #include "viewport.h" #include "command.h" #include "vehicle.h" -byte _map_type_and_height[TILES_X * TILES_Y]; -byte _map5[TILES_X * TILES_Y]; -byte _map3_lo[TILES_X * TILES_Y]; -byte _map3_hi[TILES_X * TILES_Y]; -byte _map_owner[TILES_X * TILES_Y]; -byte _map2[TILES_X * TILES_Y]; -byte _map_extra_bits[TILES_X * TILES_Y/4]; - extern const TileTypeProcs _tile_type_clear_procs, _tile_type_rail_procs, diff --git a/macros.h b/macros.h index 7517d6feda..584006312d 100644 --- a/macros.h +++ b/macros.h @@ -66,8 +66,6 @@ static inline int64 BIGMULS(int32 a, int32 b) { //#define IS_INSIDE_1D(x, base, size) ((x) >= (base) && (x) < (base) + (size)) #define IS_INSIDE_1D(x, base, size) ( (uint)((x) - (base)) < ((uint)(size)) ) -#define TILE_X_BITS 8 -#define TILE_Y_BITS 8 #define LANDSCAPE_SIZE_FACTOR 1 #define TILE_FROM_XY(x,y) (int)((((y) >> 4) << TILE_X_BITS) + ((x) >> 4)) @@ -82,12 +80,6 @@ enum { }; #define CORRECT_Z(tileh) (CORRECT_Z_BITS & (1 << tileh)) -#define TILES_X (1 << TILE_X_BITS) -#define TILES_Y (1 << TILE_Y_BITS) - -#define TILE_X_MAX (TILES_X-1) -#define TILE_Y_MAX (TILES_Y-1) - #define TILE_ASSERT(x) assert( TILE_MASK(x) == (x) ); extern uint SafeTileAdd(uint x, int add, const char *exp, const char *file, int line); diff --git a/main_gui.c b/main_gui.c index 765ef19355..3bc7349a54 100644 --- a/main_gui.c +++ b/main_gui.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "window.h" #include "gui.h" #include "viewport.h" diff --git a/map.c b/map.c new file mode 100644 index 0000000000..6cd86d2608 --- /dev/null +++ b/map.c @@ -0,0 +1,11 @@ +#include "stdafx.h" +#include "ttd.h" +#include "map.h" + +byte _map_type_and_height[TILES_X * TILES_Y]; +byte _map5[TILES_X * TILES_Y]; +byte _map3_lo[TILES_X * TILES_Y]; +byte _map3_hi[TILES_X * TILES_Y]; +byte _map_owner[TILES_X * TILES_Y]; +byte _map2[TILES_X * TILES_Y]; +byte _map_extra_bits[TILES_X * TILES_Y / 4]; diff --git a/map.h b/map.h new file mode 100644 index 0000000000..8694ff277a --- /dev/null +++ b/map.h @@ -0,0 +1,21 @@ +#ifndef MAP_H +#define MAP_H + +#define TILE_X_BITS 8 +#define TILE_Y_BITS 8 + +#define TILES_X (1 << TILE_X_BITS) +#define TILES_Y (1 << TILE_Y_BITS) + +#define TILE_X_MAX (TILES_X - 1) +#define TILE_Y_MAX (TILES_Y - 1) + +extern byte _map_type_and_height[TILES_X * TILES_Y]; +extern byte _map5[TILES_X * TILES_Y]; +extern byte _map3_lo[TILES_X * TILES_Y]; +extern byte _map3_hi[TILES_X * TILES_Y]; +extern byte _map_owner[TILES_X * TILES_Y]; +extern byte _map2[TILES_X * TILES_Y]; +extern byte _map_extra_bits[TILES_X * TILES_Y / 4]; + +#endif diff --git a/misc.c b/misc.c index bca6cc9735..8b6a7b032f 100644 --- a/misc.c +++ b/misc.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "vehicle.h" #include "gfx.h" #include "assert.h" diff --git a/misc_gui.c b/misc_gui.c index 73e378197d..e85fcc7413 100644 --- a/misc_gui.c +++ b/misc_gui.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "window.h" #include "gui.h" #include "viewport.h" diff --git a/network.c b/network.c index 1b3e529d66..006c2cd917 100644 --- a/network.c +++ b/network.c @@ -1,4 +1,5 @@ #include "stdafx.h" +#include "map.h" #include "network_data.h" #if defined(WITH_REV) diff --git a/oldloader.c b/oldloader.c index 522d3ec709..d09ddf20aa 100644 --- a/oldloader.c +++ b/oldloader.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "town.h" #include "industry.h" #include "station.h" diff --git a/order_gui.c b/order_gui.c index 23a5074e9c..0722215e0d 100644 --- a/order_gui.c +++ b/order_gui.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "window.h" #include "gui.h" #include "gfx.h" diff --git a/pathfind.c b/pathfind.c index 775fe98189..9c6e14c7fa 100644 --- a/pathfind.c +++ b/pathfind.c @@ -1,5 +1,6 @@ #include "stdafx.h" #include "ttd.h" +#include "map.h" #include "pathfind.h" // remember which tiles we have already visited so we don't visit them again. diff --git a/players.c b/players.c index 603d1ead72..2bddbecee0 100644 --- a/players.c +++ b/players.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "player.h" #include "town.h" #include "vehicle.h" diff --git a/rail_cmd.c b/rail_cmd.c index 4b5eb17d88..1bb4172bf1 100644 --- a/rail_cmd.c +++ b/rail_cmd.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "vehicle.h" #include "viewport.h" #include "command.h" diff --git a/rail_gui.c b/rail_gui.c index 36d13ba74b..49f9856c86 100644 --- a/rail_gui.c +++ b/rail_gui.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "window.h" #include "gui.h" #include "viewport.h" diff --git a/road_cmd.c b/road_cmd.c index a269171be6..07874499f1 100644 --- a/road_cmd.c +++ b/road_cmd.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "vehicle.h" #include "viewport.h" #include "command.h" diff --git a/road_gui.c b/road_gui.c index 948cbd4a1f..e64e47ff87 100644 --- a/road_gui.c +++ b/road_gui.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "window.h" #include "gui.h" #include "viewport.h" diff --git a/roadveh_cmd.c b/roadveh_cmd.c index a366047131..c051039c01 100644 --- a/roadveh_cmd.c +++ b/roadveh_cmd.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "vehicle.h" #include "engine.h" #include "command.h" diff --git a/roadveh_gui.c b/roadveh_gui.c index cf2be1ea70..31172e5d6b 100644 --- a/roadveh_gui.c +++ b/roadveh_gui.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "window.h" #include "gui.h" #include "gfx.h" diff --git a/ship_cmd.c b/ship_cmd.c index 8f2dfb89ac..201ccadacc 100644 --- a/ship_cmd.c +++ b/ship_cmd.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "vehicle.h" #include "command.h" #include "pathfind.h" diff --git a/ship_gui.c b/ship_gui.c index 1e5eaca681..74b0834875 100644 --- a/ship_gui.c +++ b/ship_gui.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "window.h" #include "gui.h" #include "gfx.h" diff --git a/smallmap_gui.c b/smallmap_gui.c index 3f8debefea..515a80a29a 100644 --- a/smallmap_gui.c +++ b/smallmap_gui.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "gui.h" #include "window.h" #include "gfx.h" diff --git a/sound.c b/sound.c index 6bf6a68845..1dd67e8346 100644 --- a/sound.c +++ b/sound.c @@ -1,5 +1,6 @@ #include "stdafx.h" #include "ttd.h" +#include "map.h" #include "sound.h" #include "vehicle.h" #include "window.h" diff --git a/station_cmd.c b/station_cmd.c index 56c51ec383..9c2f6cf8f7 100644 --- a/station_cmd.c +++ b/station_cmd.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "station.h" #include "gfx.h" #include "window.h" diff --git a/town_cmd.c b/town_cmd.c index 2cdfc56b97..8208cf0a59 100644 --- a/town_cmd.c +++ b/town_cmd.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "viewport.h" #include "town.h" #include "command.h" diff --git a/train_cmd.c b/train_cmd.c index 50df00a595..d2bab6abf6 100644 --- a/train_cmd.c +++ b/train_cmd.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "vehicle.h" #include "command.h" #include "pathfind.h" diff --git a/train_gui.c b/train_gui.c index 92175b13e2..ad88ea98e5 100644 --- a/train_gui.c +++ b/train_gui.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "window.h" #include "gui.h" #include "gfx.h" diff --git a/tree_cmd.c b/tree_cmd.c index 64590fa692..f5830c88bb 100644 --- a/tree_cmd.c +++ b/tree_cmd.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "viewport.h" #include "command.h" #include "town.h" diff --git a/ttd.c b/ttd.c index 94722239d5..2074f79e9d 100644 --- a/ttd.c +++ b/ttd.c @@ -1,5 +1,6 @@ #include "stdafx.h" #include "table/strings.h" +#include "map.h" #define VARDEF #include "ttd.h" diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c index 5ff825ddb4..f301d7be74 100644 --- a/tunnelbridge_cmd.c +++ b/tunnelbridge_cmd.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "vehicle.h" #include "viewport.h" #include "command.h" diff --git a/unmovable_cmd.c b/unmovable_cmd.c index 61b6fb4b06..277086a9c1 100644 --- a/unmovable_cmd.c +++ b/unmovable_cmd.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "command.h" #include "viewport.h" #include "player.h" diff --git a/variables.h b/variables.h index 667bd4a834..e95b8bb35e 100644 --- a/variables.h +++ b/variables.h @@ -384,13 +384,6 @@ static inline uint32 GetDParam(uint n) /* landscape.c */ extern const byte _tileh_to_sprite[32]; -extern byte _map_type_and_height[TILES_X * TILES_Y]; -extern byte _map5[TILES_X * TILES_Y]; -extern byte _map3_lo[TILES_X * TILES_Y]; -extern byte _map3_hi[TILES_X * TILES_Y]; -extern byte _map_owner[TILES_X * TILES_Y]; -extern byte _map2[TILES_X * TILES_Y]; -extern byte _map_extra_bits[TILES_X * TILES_Y/4]; static const byte _inclined_tileh[] = { 3,9,3,6,12,6,12,9, diff --git a/vehicle.c b/vehicle.c index 55bb3a1866..87590054d2 100644 --- a/vehicle.c +++ b/vehicle.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "vehicle.h" #include "gfx.h" //#include "station.h" diff --git a/viewport.c b/viewport.c index dc91e988da..1c64641c6c 100644 --- a/viewport.c +++ b/viewport.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "viewport.h" #include "window.h" #include "vehicle.h" diff --git a/water_cmd.c b/water_cmd.c index 8682e59119..3a878a50b0 100644 --- a/water_cmd.c +++ b/water_cmd.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "map.h" #include "vehicle.h" #include "viewport.h" #include "command.h" diff --git a/window.c b/window.c index ba0e488dde..29bfb3b88a 100644 --- a/window.c +++ b/window.c @@ -1,5 +1,6 @@ #include "stdafx.h" #include "ttd.h" +#include "map.h" #include "window.h" #include "gfx.h" #include "viewport.h"