diff options
-rw-r--r-- | clear_cmd.c | 4 | ||||
-rw-r--r-- | disaster_cmd.c | 24 | ||||
-rw-r--r-- | economy.c | 2 | ||||
-rw-r--r-- | landscape.c | 20 | ||||
-rw-r--r-- | map.c | 16 | ||||
-rw-r--r-- | map.h | 3 | ||||
-rw-r--r-- | misc.c | 2 | ||||
-rw-r--r-- | network.c | 4 | ||||
-rw-r--r-- | station_cmd.c | 2 | ||||
-rw-r--r-- | town_cmd.c | 2 | ||||
-rw-r--r-- | ttd.c | 4 | ||||
-rw-r--r-- | unmovable_cmd.c | 2 | ||||
-rw-r--r-- | viewport.c | 3 | ||||
-rw-r--r-- | water_cmd.c | 12 |
14 files changed, 50 insertions, 50 deletions
diff --git a/clear_cmd.c b/clear_cmd.c index c97d6d9a3..ac77c1632 100644 --- a/clear_cmd.c +++ b/clear_cmd.c @@ -86,7 +86,7 @@ static int TerraformProc(TerraformerState *ts, uint tile, int mode) int r; int32 ret; - assert(tile < TILES_X * TILES_Y); + assert(tile < MapSize()); if ((r=TerraformAllowTileProcess(ts, tile)) <= 0) return r; @@ -135,7 +135,7 @@ static bool TerraformTileHeight(TerraformerState *ts, uint tile, int height) TerraformerHeightMod *mod; int count; - assert(tile < TILES_X * TILES_Y); + assert(tile < MapSize()); if (height < 0) { _error_message = STR_1003_ALREADY_AT_SEA_LEVEL; diff --git a/disaster_cmd.c b/disaster_cmd.c index 7ea7f747c..197b4d4d4 100644 --- a/disaster_cmd.c +++ b/disaster_cmd.c @@ -178,7 +178,7 @@ static void DisasterTick_Zeppeliner(Vehicle *v) 0); } } - if (v->y_pos >= (TILES_Y+9) * 16 - 1) + if (v->y_pos >= (MapSizeY() + 9) * 16 - 1) DeleteDisasterVeh(v); return; } @@ -325,7 +325,7 @@ static void DestructIndustry(Industry *i) uint tile; byte index = i - _industries; - for(tile=0; tile != TILES_X*TILES_Y; tile++) { + for(tile=0; tile != MapSize(); tile++) { if (IS_TILETYPE(tile, MP_INDUSTRY) && _map2[tile] == index) { _map_owner[tile] = 0; MarkTileDirtyByTile(tile); @@ -388,7 +388,7 @@ static void DisasterTick_2(Vehicle *v) x = v->x_pos - 15*16; y = v->y_pos; - if ( (uint)x > (TILES_X-1) * 16-1) + if ( (uint)x > MapMaxX() * 16-1) return; tile = TILE_FROM_XY(x,y); @@ -416,7 +416,7 @@ static void DisasterTick_3(Vehicle *v) GetNewVehiclePos(v, &gp); SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); - if (gp.x > TILES_X * 16 + 9*16 - 1) { + if (gp.x > MapSizeX() * 16 + 9*16 - 1) { DeleteDisasterVeh(v); return; } @@ -459,7 +459,7 @@ static void DisasterTick_3(Vehicle *v) x = v->x_pos - 15*16; y = v->y_pos; - if ( (uint)x > (TILES_X-1) * 16-1) + if ( (uint)x > MapMaxX() * 16-1) return; tile = TILE_FROM_XY(x,y); @@ -594,7 +594,7 @@ static void DisasterTick_4b(Vehicle *v) GetNewVehiclePos(v, &gp); SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); - if (gp.x > TILES_X * 16 + 9*16 - 1) { + if (gp.x > MapSizeX() * 16 + 9*16 - 1) { DeleteDisasterVeh(v); return; } @@ -737,7 +737,7 @@ static void Disaster1_Init() x = (GET_TILE_X(Random())) * 16 + 8; InitializeDisasterVehicle(v, x, 0, 135, 3, 2); - v->dest_tile = TILE_XY(TILES_X/2,TILES_Y/2); + v->dest_tile = TILE_XY(MapSizeX() / 2, MapSizeY() / 2); v->age = 0; // Allocate shadow too? @@ -772,7 +772,7 @@ static void Disaster2_Init() if (v == NULL) return; - x = (TILES_X+9) * 16 - 1; + x = (MapSizeX() + 9) * 16 - 1; y = GET_TILE_Y(found->xy)*16 + 37; InitializeDisasterVehicle(v,x,y, 135,1,4); @@ -837,9 +837,9 @@ static void Disaster4_Init() x = (GET_TILE_X(Random())) * 16 + 8; - y = (TILES_X-1)*16-1; + y = MapMaxX() * 16 - 1; InitializeDisasterVehicle(v, x, y, 135, 7, 9); - v->dest_tile = TILE_XY(TILES_X/2,TILES_Y/2); + v->dest_tile = TILE_XY(MapSizeX() / 2, MapSizeY() / 2); v->age = 0; // Allocate shadow too? @@ -867,7 +867,7 @@ static void Disaster5_Init() y = 8; dir = 3; - if (r & 0x80000000) { y = (TILES_X-1) * 16 - 8 - 1; dir = 7; } + if (r & 0x80000000) { y = MapMaxX() * 16 - 8 - 1; dir = 7; } InitializeDisasterVehicle(v, x, y, 0, dir,13); v->age = 0; } @@ -888,7 +888,7 @@ static void Disaster6_Init() y = 8; dir = 3; - if (r & 0x80000000) { y = (TILES_X-1) * 16 - 8 - 1; dir = 7; } + if (r & 0x80000000) { y = MapMaxX() * 16 - 8 - 1; dir = 7; } InitializeDisasterVehicle(v, x, y, 0, dir,14); v->age = 0; } @@ -349,7 +349,7 @@ void ChangeOwnershipOfPlayerItems(byte old_player, byte new_player) uint tile = 0; do { ChangeTileOwner(tile, old_player, new_player); - } while (++tile != TILES_X * TILES_Y); + } while (++tile != MapSize()); } // Change color of existing windows diff --git a/landscape.c b/landscape.c index e9c1f85f1..232f0e188 100644 --- a/landscape.c +++ b/landscape.c @@ -51,7 +51,7 @@ uint GetTileSlope(uint tile, int *h) return 0; } - assert(tile < TILES_X * TILES_Y && GET_TILE_X(tile) != MapMaxX() && GET_TILE_Y(tile) != MapMaxY()); + assert(tile < MapSize() && GET_TILE_X(tile) != MapMaxX() && GET_TILE_Y(tile) != MapMaxY()); min = a = _map_type_and_height[tile] & 0xF; b = _map_type_and_height[tile+TILE_XY(1,0)] & 0xF; @@ -463,21 +463,21 @@ void RunTileLoop() tile = _cur_tileloop_tile; assert( (tile & ~TILELOOP_ASSERTMASK) == 0); - count = (TILES_X/TILELOOP_SIZE) * (TILES_Y/TILELOOP_SIZE); + count = (MapSizeX() / TILELOOP_SIZE) * (MapSizeY() / TILELOOP_SIZE); do { _tile_type_procs[GET_TILETYPE(tile)]->tile_loop_proc(tile); - if ( GET_TILE_X(tile) < TILES_X - TILELOOP_SIZE) { + if ( GET_TILE_X(tile) < MapSizeX() - TILELOOP_SIZE) { tile += TILELOOP_SIZE; /* no overflow */ } else { - tile = TILE_MASK(tile - TILELOOP_SIZE * (TILES_X/TILELOOP_SIZE-1) + TILE_XY(0, TILELOOP_SIZE)); /* x would overflow, also increase y */ + tile = TILE_MASK(tile - TILELOOP_SIZE * (MapSizeX() / TILELOOP_SIZE-1) + TILE_XY(0, TILELOOP_SIZE)); /* x would overflow, also increase y */ } } while (--count); assert( (tile & ~TILELOOP_ASSERTMASK) == 0); tile += 9; if (tile & TILELOOP_CHKMASK) - tile = (tile + TILES_X) & TILELOOP_ASSERTMASK; + tile = (tile + MapSizeX()) & TILELOOP_ASSERTMASK; _cur_tileloop_tile = tile; } @@ -493,8 +493,8 @@ void InitializeLandscape() memset(_map_extra_bits, 0, map_size / 4); memset(_map_type_and_height, MP_CLEAR << 4, map_size); - for(i=0; i!=TILES_Y-1; i++) - memset(_map_type_and_height + i*TILES_X, 0, TILES_X-1); + for (i = 0; i != MapMaxY(); i++) + memset(_map_type_and_height + i * MapSizeX(), 0, MapSizeX() - 1); memset(_map5, 3, map_size); } @@ -643,7 +643,7 @@ static void CreateDesertOrRainForest() } mt = _map_type_and_height[TILE_MASK(tile + i)]; } while ((mt & 0xC) == 0 && (mt >> 4) != MP_WATER); - } while (++tile != TILES_X*TILES_Y); + } while (++tile != MapSize()); for(i=0; i!=256; i++) RunTileLoop(); @@ -657,7 +657,7 @@ static void CreateDesertOrRainForest() break; } } while ( !IS_TILETYPE(TILE_MASK(tile+i), MP_CLEAR) || (_map5[TILE_MASK(tile + i)]&0x1C) != 0x14); - } while (++tile != TILES_X*TILES_Y); + } while (++tile != MapSize()); } void GenerateLandscape() @@ -760,5 +760,5 @@ uint TileAddWrap(TileIndex tile, int addx, int addy) bool IsValidTile(uint tile) { - return (tile < TILES_X * MapMaxY() && GET_TILE_X(tile) != MapMaxX()); + return (tile < MapSizeX() * MapMaxY() && GET_TILE_X(tile) != MapMaxX()); } @@ -5,10 +5,12 @@ uint _map_log_x = TILE_X_BITS; uint _map_log_y = TILE_Y_BITS; -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]; -uint16 _map2 [TILES_X * TILES_Y]; -byte _map_extra_bits [TILES_X * TILES_Y / 4]; +#define MAP_SIZE ((1 << TILE_X_BITS) * (1 << TILE_Y_BITS)) + +byte _map_type_and_height [MAP_SIZE]; +byte _map5 [MAP_SIZE]; +byte _map3_lo [MAP_SIZE]; +byte _map3_hi [MAP_SIZE]; +byte _map_owner [MAP_SIZE]; +uint16 _map2 [MAP_SIZE]; +byte _map_extra_bits [MAP_SIZE / 4]; @@ -4,9 +4,6 @@ #define TILE_X_BITS 8 #define TILE_Y_BITS 8 -#define TILES_X (1 << TILE_X_BITS) -#define TILES_Y (1 << TILE_Y_BITS) - extern byte _map_type_and_height[]; extern byte _map5[]; extern byte _map3_lo[]; @@ -740,7 +740,7 @@ extern uint SafeTileAdd(uint tile, int add, const char *exp, const char *file, i int x = GET_TILE_X(tile) + (signed char)(add & 0xFF); int y = GET_TILE_Y(tile) + ((((0x8080 + add)>>8) & 0xFF) - 0x80); - if (x < 0 || y < 0 || x >= TILES_X || y >= TILES_Y) { + if (x < 0 || y < 0 || x >= MapSizeX() || y >= MapSizeY()) { char buf[512]; sprintf(buf, "TILE_ADD(%s) when adding 0x%.4X and %d failed", exp, tile, add); @@ -936,8 +936,8 @@ static void NetworkInitGameInfo(void) _network_game_info.spectators_on = 0; _network_game_info.game_date = _date; _network_game_info.start_date = ConvertIntDate(_patches.starting_date); - _network_game_info.map_width = TILES_X; - _network_game_info.map_height = TILES_Y; + _network_game_info.map_width = MapSizeX(); + _network_game_info.map_height = MapSizeY(); _network_game_info.map_set = _opt.landscape; if (_network_game_info.server_password[0] == '\0') { diff --git a/station_cmd.c b/station_cmd.c index 88d4e47f0..cad045458 100644 --- a/station_cmd.c +++ b/station_cmd.c @@ -113,7 +113,7 @@ static bool CheckStationSpreadOut(Station *st, uint tile, int w, int h) uint y2 = y1 + h - 1; uint t; - for(i=0; i!=TILES_X*TILES_Y; i++) { + for (i = 0; i != MapSize(); i++) { if (IS_TILETYPE(i, MP_STATION) && _map2[i] == station_index) { t = GET_TILE_X(i); if (t < x1) x1 = t; diff --git a/town_cmd.c b/town_cmd.c index 3c0c357e3..5c40cbf11 100644 --- a/town_cmd.c +++ b/town_cmd.c @@ -1410,7 +1410,7 @@ void DeleteTown(Town *t) DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR); } } - } while (++tile != TILES_X * TILES_Y); + } while (++tile != MapSize()); t->xy = 0; DeleteName(t->townnametype); @@ -1082,7 +1082,7 @@ void GameLoop() ShowScreenshotResult(MakeScreenshot()); break; case 2: // make large screenshot - ShowScreenshotResult(MakeWorldScreenshot(-(int)MapMaxX() * 32, 0, MapMaxX() * 64, TILES_Y * 32, 0)); + ShowScreenshotResult(MakeWorldScreenshot(-(int)MapMaxX() * 32, 0, MapMaxX() * 64, MapSizeY() * 32, 0)); break; } } @@ -1150,7 +1150,7 @@ void ConvertTownOwner() { uint tile; - for(tile=0; tile!=TILES_X * TILES_Y; tile++) { + for (tile = 0; tile != MapSize(); tile++) { if (IS_TILETYPE(tile, MP_STREET)) { if ((_map5[tile] & 0xF0) == 0x10 && _map3_lo[tile] & 0x80) _map3_lo[tile] = OWNER_TOWN; diff --git a/unmovable_cmd.c b/unmovable_cmd.c index 137f66461..f94156424 100644 --- a/unmovable_cmd.c +++ b/unmovable_cmd.c @@ -262,7 +262,7 @@ void GenerateUnmovables() j = 40; // limit of 40 radio towers per world. do { r = Random(); - tile = r % (TILES_X*TILES_Y); + tile = r % MapSize(); // TILE_MASK seems to be not working correctly. Radio masts accumulate in one area. // tile = TILE_MASK(r); if (IS_TILETYPE(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h >= 32) { diff --git a/viewport.c b/viewport.c index 5b1712b2c..05e461431 100644 --- a/viewport.c +++ b/viewport.c @@ -1376,7 +1376,8 @@ void MarkTileDirty(int x, int y) { int z = 0; Point pt; - if (IS_INT_INSIDE(x, 0, TILES_X*16) && IS_INT_INSIDE(y, 0, TILES_Y*16)) + if (IS_INT_INSIDE(x, 0, MapSizeX() * 16) && + IS_INT_INSIDE(y, 0, MapSizeY() * 16)) z = GetTileZ(TILE_FROM_XY(x,y)); pt = RemapCoords(x, y, z); diff --git a/water_cmd.c b/water_cmd.c index 9815e3a6f..c75cfe2e4 100644 --- a/water_cmd.c +++ b/water_cmd.c @@ -579,8 +579,8 @@ void TileLoop_Water(uint tile) {TILE_XY(0,-1), TILE_XY(0,0), TILE_XY(1,0), TILE_XY(0,-1), TILE_XY(1,-1)}, }; - if ( IS_INT_INSIDE(GET_TILE_X(tile),1,TILES_X-3+1) && - IS_INT_INSIDE(GET_TILE_Y(tile),1,TILES_Y-3+1)) { + if (IS_INT_INSIDE(GET_TILE_X(tile), 1, MapSizeX() - 3 + 1) && + IS_INT_INSIDE(GET_TILE_Y(tile), 1, MapSizeY() - 3 + 1)) { for(i=0; i!=4; i++) TileLoopWaterHelper(tile, _tile_loop_offs_array[i]); } @@ -589,16 +589,16 @@ void TileLoop_Water(uint tile) _current_player = OWNER_NONE; // edges - if ( GET_TILE_X(tile)==0 && IS_INT_INSIDE(GET_TILE_Y(tile),1,TILES_Y-3+1)) //NE + if (GET_TILE_X(tile) == 0 && IS_INT_INSIDE(GET_TILE_Y(tile), 1, MapSizeY() - 3 + 1)) //NE TileLoopWaterHelper(tile, _tile_loop_offs_array[2]); - if ( GET_TILE_X(tile)==(TILES_X-2) && IS_INT_INSIDE(GET_TILE_Y(tile),1,TILES_Y-3+1)) //SW + if (GET_TILE_X(tile) == (MapSizeX() - 2) && IS_INT_INSIDE(GET_TILE_Y(tile), 1, MapSizeY() - 3 + 1)) //SW TileLoopWaterHelper(tile, _tile_loop_offs_array[0]); - if ( GET_TILE_Y(tile)==0 && IS_INT_INSIDE(GET_TILE_X(tile),1,TILES_X-3+1)) //NW + if (GET_TILE_Y(tile) == 0 && IS_INT_INSIDE(GET_TILE_X(tile), 1, MapSizeX() - 3 + 1)) //NW TileLoopWaterHelper(tile, _tile_loop_offs_array[1]); - if ( GET_TILE_Y(tile)==(TILES_Y-2) && IS_INT_INSIDE(GET_TILE_X(tile),1,TILES_X-3+1)) //SE + if (GET_TILE_Y(tile) == (MapSizeY() - 2) && IS_INT_INSIDE(GET_TILE_X(tile), 1, MapSizeX() - 3 + 1)) //SE TileLoopWaterHelper(tile, _tile_loop_offs_array[3]); } |