(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
This makes it necessary to rename TileType() to GetTileType() because a type and a function may not share the same name.
--- a/disaster_cmd.c Sat Jan 29 14:56:25 2005 +0000
+++ b/disaster_cmd.c Sat Jan 29 15:12:40 2005 +0000
@@ -19,7 +19,7 @@
if (!EnsureNoVehicle(tile))
return;
- switch (TileType(tile)) {
+ switch (GetTileType(tile)) {
case MP_RAILWAY:
if (IS_HUMAN_PLAYER(_map_owner[tile])) DoClearSquare(tile);
break;
--- a/industry_cmd.c Sat Jan 29 14:56:25 2005 +0000
+++ b/industry_cmd.c Sat Jan 29 15:12:40 2005 +0000
@@ -857,7 +857,7 @@
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 IsBadFarmFieldTile2(TileIndex tile)
{
- switch (TileType(tile)) {
+ switch (GetTileType(tile)) {
case MP_CLEAR: {
byte m5 = _map5[tile] & 0x1C;
return m5 == 0x10;
--- a/landscape.c Sat Jan 29 14:56:25 2005 +0000
+++ b/landscape.c Sat Jan 29 15:12:40 2005 +0000
@@ -87,7 +87,7 @@
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 @@
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 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 @@
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 @@
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 */
--- a/order_gui.c Sat Jan 29 14:56:25 2005 +0000
+++ b/order_gui.c Sat Jan 29 15:12:40 2005 +0000
@@ -185,7 +185,7 @@
// 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 @@
order.station = GetDepotByTile(tile);
return order;
}
+
+ default:
+ break;
}
}
--- a/road_cmd.c Sat Jan 29 14:56:25 2005 +0000
+++ b/road_cmd.c Sat Jan 29 15:12:40 2005 +0000
@@ -26,7 +26,7 @@
int mask;
byte b;
- switch (TileType(tile)) {
+ switch (GetTileType(tile)) {
case MP_STREET:
b = _map5[tile];
--- a/smallmap_gui.c Sat Jan 29 14:56:25 2005 +0000
+++ b/smallmap_gui.c Sat Jan 29 15:12:40 2005 +0000
@@ -298,7 +298,7 @@
{
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 @@
{
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 @@
{
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 @@
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 @@
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 @@
{
int t;
- t = TileType(tile);
+ t = GetTileType(tile);
if (t == MP_HOUSE || _map_owner[tile] == OWNER_TOWN) {
t = 0x80;
} else if (t == MP_INDUSTRY) {
--- a/station_cmd.c Sat Jan 29 14:56:25 2005 +0000
+++ b/station_cmd.c Sat Jan 29 15:12:40 2005 +0000
@@ -436,7 +436,7 @@
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);
--- a/tile.h Sat Jan 29 14:56:25 2005 +0000
+++ b/tile.h Sat Jan 29 15:12:40 2005 +0000
@@ -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 @@
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
--- a/train_cmd.c Sat Jan 29 14:56:25 2005 +0000
+++ b/train_cmd.c Sat Jan 29 15:12:40 2005 +0000
@@ -2079,7 +2079,7 @@
/* 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
--- a/ttd.h Sat Jan 29 14:56:25 2005 +0000
+++ b/ttd.h Sat Jan 29 15:12:40 2005 +0000
@@ -86,20 +86,6 @@
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
--- a/vehicle.c Sat Jan 29 14:56:25 2005 +0000
+++ b/vehicle.c Sat Jan 29 15:12:40 2005 +0000
@@ -1733,13 +1733,13 @@
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);
}
--- a/water_cmd.c Sat Jan 29 14:56:25 2005 +0000
+++ b/water_cmd.c Sat Jan 29 15:12:40 2005 +0000
@@ -320,7 +320,7 @@
{
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 @@
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;