diff --git a/disaster_cmd.c b/disaster_cmd.c --- a/disaster_cmd.c +++ b/disaster_cmd.c @@ -19,7 +19,7 @@ static void DisasterClearSquare(TileInde if (!EnsureNoVehicle(tile)) return; - switch (TileType(tile)) { + switch (GetTileType(tile)) { case MP_RAILWAY: if (IS_HUMAN_PLAYER(_map_owner[tile])) DoClearSquare(tile); break; diff --git a/industry_cmd.c b/industry_cmd.c --- a/industry_cmd.c +++ b/industry_cmd.c @@ -857,7 +857,7 @@ static const byte _plantfarmfield_type[] static bool IsBadFarmFieldTile(TileIndex tile) { - switch (TileType(tile)) { + switch (GetTileType(tile)) { case MP_CLEAR: { byte m5 = _map5[tile] & 0x1C; return m5 == 0xC || m5 == 0x10; @@ -873,7 +873,7 @@ static bool IsBadFarmFieldTile(TileIndex static bool IsBadFarmFieldTile2(TileIndex tile) { - switch (TileType(tile)) { + switch (GetTileType(tile)) { case MP_CLEAR: { byte m5 = _map5[tile] & 0x1C; return m5 == 0x10; diff --git a/landscape.c b/landscape.c --- a/landscape.c +++ b/landscape.c @@ -87,7 +87,7 @@ void FindLandscapeHeightByTile(TileInfo ti->tile = tile; ti->map5 = _map5[tile]; - ti->type = TileType(tile); + ti->type = GetTileType(tile); ti->tileh = GetTileSlope(tile, &ti->z); } @@ -288,28 +288,28 @@ void DoClearSquare(uint tile) uint32 GetTileTrackStatus(uint tile, TransportType mode) { - return _tile_type_procs[TileType(tile)]->get_tile_track_status_proc(tile, mode); + return _tile_type_procs[GetTileType(tile)]->get_tile_track_status_proc(tile, mode); } void ChangeTileOwner(uint tile, byte old_player, byte new_player) { - _tile_type_procs[TileType(tile)]->change_tile_owner_proc(tile, old_player, new_player); + _tile_type_procs[GetTileType(tile)]->change_tile_owner_proc(tile, old_player, new_player); } void GetAcceptedCargo(uint tile, AcceptedCargo ac) { memset(ac, 0, sizeof(AcceptedCargo)); - _tile_type_procs[TileType(tile)]->get_accepted_cargo_proc(tile, ac); + _tile_type_procs[GetTileType(tile)]->get_accepted_cargo_proc(tile, ac); } void AnimateTile(uint tile) { - _tile_type_procs[TileType(tile)]->animate_tile_proc(tile); + _tile_type_procs[GetTileType(tile)]->animate_tile_proc(tile); } void ClickTile(uint tile) { - _tile_type_procs[TileType(tile)]->click_tile_proc(tile); + _tile_type_procs[GetTileType(tile)]->click_tile_proc(tile); } void DrawTile(TileInfo *ti) @@ -319,7 +319,7 @@ void DrawTile(TileInfo *ti) void GetTileDesc(uint tile, TileDesc *td) { - _tile_type_procs[TileType(tile)]->get_tile_desc_proc(tile, td); + _tile_type_procs[GetTileType(tile)]->get_tile_desc_proc(tile, td); } /* Clear a piece of landscape @@ -333,7 +333,7 @@ int32 CmdLandscapeClear(int x, int y, ui SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); tile = TILE_FROM_XY(x,y); - return _tile_type_procs[TileType(tile)]->clear_tile_proc(tile, flags); + return _tile_type_procs[GetTileType(tile)]->clear_tile_proc(tile, flags); } // p1 = end tile @@ -446,7 +446,7 @@ void RunTileLoop(void) assert( (tile & ~TILELOOP_ASSERTMASK) == 0); count = (MapSizeX() / TILELOOP_SIZE) * (MapSizeY() / TILELOOP_SIZE); do { - _tile_type_procs[TileType(tile)]->tile_loop_proc(tile); + _tile_type_procs[GetTileType(tile)]->tile_loop_proc(tile); if (TileX(tile) < MapSizeX() - TILELOOP_SIZE) { tile += TILELOOP_SIZE; /* no overflow */ diff --git a/order_gui.c b/order_gui.c --- a/order_gui.c +++ b/order_gui.c @@ -185,7 +185,7 @@ static Order GetOrderCmdFromTile(Vehicle // check depot first if (_patches.gotodepot) { - switch (TileType(tile)) { + switch (GetTileType(tile)) { case MP_RAILWAY: if (v->type == VEH_Train && _map_owner[tile] == _local_player) { if ((_map5[tile]&0xFC)==0xC0) { @@ -228,6 +228,9 @@ static Order GetOrderCmdFromTile(Vehicle order.station = GetDepotByTile(tile); return order; } + + default: + break; } } diff --git a/road_cmd.c b/road_cmd.c --- a/road_cmd.c +++ b/road_cmd.c @@ -26,7 +26,7 @@ static bool HasTileRoadAt(uint tile, int int mask; byte b; - switch (TileType(tile)) { + switch (GetTileType(tile)) { case MP_STREET: b = _map5[tile]; diff --git a/smallmap_gui.c b/smallmap_gui.c --- a/smallmap_gui.c +++ b/smallmap_gui.c @@ -298,7 +298,7 @@ static inline uint32 GetSmallMapCountour { uint t; - t = TileType(tile); + t = GetTileType(tile); if (t == MP_TUNNELBRIDGE) { t = _map5[tile]; if ((t & 0x80) == 0) t>>=1; @@ -328,7 +328,7 @@ static inline uint32 GetSmallMapVehicles { uint t; - t = TileType(tile); + t = GetTileType(tile); if (t == MP_TUNNELBRIDGE) { t = _map5[tile]; if ((t & 0x80) == 0) t>>=1; @@ -381,7 +381,7 @@ static inline uint32 GetSmallMapIndustri { int t; - t = TileType(tile); + t = GetTileType(tile); if (t == MP_INDUSTRY) { byte color = _industry_smallmap_colors[_map5[tile]]; return color + (color << 8) + (color << 16) + (color << 24); @@ -414,7 +414,7 @@ static inline uint32 GetSmallMapRoutesPi int t; uint32 bits; - t = TileType(tile); + t = GetTileType(tile); if (t == MP_STATION) { byte m5 = _map5[tile]; (bits = MKCOLOR(0x56565656), m5 < 8) || // 8 - railroad station (green) @@ -470,7 +470,7 @@ static inline uint32 GetSmallMapVegetati int i,t; uint32 bits; - t = TileType(tile); + t = GetTileType(tile); if (t == MP_CLEAR) { i = (_map5[tile] & 0x1F) - 4; if (i >= 0) i = (i >> 2); @@ -515,7 +515,7 @@ static inline uint32 GetSmallMapOwnerPix { int t; - t = TileType(tile); + t = GetTileType(tile); if (t == MP_HOUSE || _map_owner[tile] == OWNER_TOWN) { t = 0x80; } else if (t == MP_INDUSTRY) { diff --git a/station_cmd.c b/station_cmd.c --- a/station_cmd.c +++ b/station_cmd.c @@ -436,7 +436,7 @@ void GetProductionAroundTiles(uint *prod if (!(IS_INSIDE_1D(xc, x, w) && IS_INSIDE_1D(yc, y, h))) { GetProducedCargoProc *gpc; uint tile = TILE_XY(xc, yc); - gpc = _tile_type_procs[TileType(tile)]->get_produced_cargo_proc; + gpc = _tile_type_procs[GetTileType(tile)]->get_produced_cargo_proc; if (gpc != NULL) { cargos[0] = cargos[1] = 0xFF; gpc(tile, cargos); diff --git a/tile.h b/tile.h --- a/tile.h +++ b/tile.h @@ -3,6 +3,20 @@ #include "map.h" +typedef enum TileType { + MP_CLEAR, + MP_RAILWAY, + MP_STREET, + MP_HOUSE, + MP_TREES, + MP_STATION, + MP_WATER, + MP_VOID, // invisible tiles at the SW and SE border + MP_INDUSTRY, + MP_TUNNELBRIDGE, + MP_UNMOVABLE +} TileType; + void SetMapExtraBits(TileIndex tile, byte flags); uint GetMapExtraBits(TileIndex tile); @@ -25,22 +39,22 @@ static inline uint TilePixelHeight(TileI return TileHeight(tile) * 8; } -static inline int TileType(TileIndex tile) +static inline TileType GetTileType(TileIndex tile) { assert(tile < MapSize()); return _map_type_and_height[tile] >> 4; } -static inline void SetTileType(TileIndex tile, uint type) +static inline void SetTileType(TileIndex tile, TileType type) { assert(tile < MapSize()); _map_type_and_height[tile] &= ~0xF0; _map_type_and_height[tile] |= type << 4; } -static inline bool IsTileType(TileIndex tile, int type) +static inline bool IsTileType(TileIndex tile, TileType type) { - return TileType(tile) == type; + return GetTileType(tile) == type; } #endif diff --git a/train_cmd.c b/train_cmd.c --- a/train_cmd.c +++ b/train_cmd.c @@ -2079,7 +2079,7 @@ static int GetDirectionToVehicle(Vehicle /* Check if the vehicle is compatible with the specified tile */ static bool CheckCompatibleRail(const Vehicle *v, TileIndex tile) { - switch (TileType(tile)) { + switch (GetTileType(tile)) { case MP_RAILWAY: case MP_STATION: // normal tracks, jump to owner check diff --git a/ttd.h b/ttd.h --- a/ttd.h +++ b/ttd.h @@ -86,20 +86,6 @@ enum SwitchModes { SM_START_SCENARIO = 10, }; -enum MapTileTypes { - MP_CLEAR, - MP_RAILWAY, - MP_STREET, - MP_HOUSE, - MP_TREES, - MP_STATION, - MP_WATER, - MP_VOID, // invisible tiles at the SW and SE border - MP_INDUSTRY, - MP_TUNNELBRIDGE, - MP_UNMOVABLE -}; - typedef enum TransportTypes { /* These constants are for now linked to the representation of bridges * and tunnels, so they can be used by GetTileTrackStatus_TunnelBridge diff --git a/vehicle.c b/vehicle.c --- a/vehicle.c +++ b/vehicle.c @@ -1733,13 +1733,13 @@ byte GetDirectionTowards(Vehicle *v, int uint32 VehicleEnterTile(Vehicle *v, uint tile, int x, int y) { uint old_tile = v->tile; - uint32 result = _tile_type_procs[TileType(tile)]->vehicle_enter_tile_proc(v, tile, x, y); + uint32 result = _tile_type_procs[GetTileType(tile)]->vehicle_enter_tile_proc(v, tile, x, y); /* When vehicle_enter_tile_proc returns 8, that apparently means that * we cannot enter the tile at all. In that case, don't call * leave_tile. */ if (!(result & 8) && old_tile != tile) { - VehicleLeaveTileProc *proc = _tile_type_procs[TileType(old_tile)]->vehicle_leave_tile_proc; + VehicleLeaveTileProc *proc = _tile_type_procs[GetTileType(old_tile)]->vehicle_leave_tile_proc; if (proc != NULL) proc(v, old_tile, x, y); } diff --git a/water_cmd.c b/water_cmd.c --- a/water_cmd.c +++ b/water_cmd.c @@ -320,7 +320,7 @@ static bool IsWateredTile(TileIndex tile { byte m5 = _map5[tile]; - switch (TileType(tile)) { + switch (GetTileType(tile)) { case MP_WATER: // true, if not coast/riverbank return m5 != 1; @@ -502,7 +502,7 @@ static void TileLoopWaterHelper(TileInde if (TileHeight(TILE_ADD(tile, ToTileIndexDiff(offs[3]))) != 0 || TileHeight(TILE_ADD(tile, ToTileIndexDiff(offs[4]))) != 0) { // make coast.. - switch (TileType(target)) { + switch (GetTileType(target)) { case MP_RAILWAY: { uint slope = GetTileSlope(target, NULL); byte tracks = _map5[target] & 0x3F;