changeset 1035:3edb35954288 draft

(svn r1536) Move GET_TILEHEIGHT, GET_TILETYPE and IS_TILETYPE to map.h, turn them into inline functions and add some asserts
author tron <tron@openttd.org>
date Sun, 16 Jan 2005 11:24:58 +0000
parents 77f146e1aba7
children b2b382908480
files ai.c ai.h ai_build.c ai_new.c ai_pathfinder.c aircraft_cmd.c aircraft_gui.c clear_cmd.c disaster_cmd.c industry_cmd.c landscape.c macros.h main_gui.c map.h oldloader.c order_gui.c pathfind.c rail_cmd.c rail_gui.c road_cmd.c road_gui.c roadveh_cmd.c ship_cmd.c smallmap_gui.c station_cmd.c town_cmd.c train_cmd.c tree_cmd.c ttd.c tunnelbridge_cmd.c unmovable_cmd.c vehicle.c water_cmd.c
diffstat 33 files changed, 239 insertions(+), 217 deletions(-) [+]
line wrap: on
line diff
--- a/ai.c
+++ b/ai.c
@@ -1599,7 +1599,7 @@
 			}
 		} else if (p->mode == 2) {
 			// Rail
-			if (IS_TILETYPE(c, MP_RAILWAY))
+			if (IsTileType(c, MP_RAILWAY))
 				return CMD_ERROR;
 
 			j = p->attr;
@@ -1618,7 +1618,7 @@
 			/* signals too? */
 			if (j&3) {
 				// Can't build signals on a road.
-				if (IS_TILETYPE(c, MP_STREET))
+				if (IsTileType(c, MP_STREET))
 					return CMD_ERROR;
 
 				if (flag & DC_EXEC) {
@@ -2179,7 +2179,7 @@
 	int offs;
 	TileIndex tilenew;
 
-	if (IS_TILETYPE(tile, MP_TUNNELBRIDGE)) {
+	if (IsTileType(tile, MP_TUNNELBRIDGE)) {
 		if (!(_map5[tile] & 0x80)) {
 			// Clear the tunnel and continue at the other side of it.
 			if (DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR) == CMD_ERROR)
@@ -2219,7 +2219,7 @@
 	bit = FindFirstBit(b);
 
 	// Then remove and signals if there are any.
-	if (IS_TILETYPE(tile, MP_RAILWAY) &&
+	if (IsTileType(tile, MP_RAILWAY) &&
 			(_map5[tile]&0xC0) == 0x40) {
 		DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_REMOVE_SIGNALS);
 	}
@@ -2542,7 +2542,7 @@
 		_cleared_town = NULL;
 
 		if (p->mode == 2) {
-			if (IS_TILETYPE(c, MP_STREET) &&
+			if (IsTileType(c, MP_STREET) &&
 					(_map5[c]&0xF0)==0 &&
 					(_map5[c]&p->attr)!=0) {
 				roadflag |= 2;
@@ -2590,7 +2590,7 @@
 			if (GetTileSlope(c, NULL) != 0)
 				return CMD_ERROR;
 
-			if (!(IS_TILETYPE(c, MP_STREET) && (_map5[c]&0xF0)==0)) {
+			if (!(IsTileType(c, MP_STREET) && (_map5[c] & 0xF0) == 0)) {
 				r = DoCommandByTile(c, 0, 0, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_LANDSCAPE_CLEAR);
 				if (r == CMD_ERROR) return CMD_ERROR;
 			}
@@ -2773,7 +2773,7 @@
 
 	if (dist <= a->best_dist) {
 		tile2 = TILE_MASK(tile + TileOffsByDir(_dir_by_track[track]));
-		if (IS_TILETYPE(tile2, MP_STREET) &&
+		if (IsTileType(tile2, MP_STREET) &&
 				(_map5[tile2]&0xF0) == 0) {
 			a->best_dist = dist;
 			a->best_tile = tile;
@@ -3426,9 +3426,9 @@
 			rule = AiFindBestDefaultAirportBlock(aib->use_tile, aib->cargo, p->ai.build_kind, &cost);
 
 #if 0
-			if (!IS_TILETYPE(aib->use_tile, MP_STREET) &&
-					!IS_TILETYPE(aib->use_tile, MP_RAILWAY) &&
-					!IS_TILETYPE(aib->use_tile, MP_STATION)
+			if (!IsTileType(aib->use_tile, MP_STREET) &&
+					!IsTileType(aib->use_tile, MP_RAILWAY) &&
+					!IsTileType(aib->use_tile, MP_STATION)
 					) {
 
 				_map_type_and_height[aib->use_tile] = 0xa1;
@@ -3643,7 +3643,7 @@
 {
 	byte m5;
 
-	if (IS_TILETYPE(tile, MP_RAILWAY)) {
+	if (IsTileType(tile, MP_RAILWAY)) {
 		if (_map_owner[tile] != _current_player)
 			return;
 		m5 = _map5[tile];
@@ -3702,7 +3702,7 @@
 
 			DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
 		}
-	} else if (IS_TILETYPE(tile, MP_STREET)) {
+	} else if (IsTileType(tile, MP_STREET)) {
 		if (_map_owner[tile] != _current_player)
 			return;
 
@@ -3713,19 +3713,19 @@
 			int dir;
 
 			// Check if there are any stations around.
-			if (IS_TILETYPE(tile + TILE_XY(-1,0), MP_STATION) &&
+			if (IsTileType(tile + TILE_XY(-1,0), MP_STATION) &&
 					_map_owner[tile + TILE_XY(-1,0)] == _current_player)
 						return;
 
-			if (IS_TILETYPE(tile + TILE_XY(1,0), MP_STATION) &&
+			if (IsTileType(tile + TILE_XY(1,0), MP_STATION) &&
 					_map_owner[tile + TILE_XY(1,0)] == _current_player)
 						return;
 
-			if (IS_TILETYPE(tile + TILE_XY(0,-1), MP_STATION) &&
+			if (IsTileType(tile + TILE_XY(0,-1), MP_STATION) &&
 					_map_owner[tile + TILE_XY(0,-1)] == _current_player)
 						return;
 
-			if (IS_TILETYPE(tile + TILE_XY(0,1), MP_STATION) &&
+			if (IsTileType(tile + TILE_XY(0,1), MP_STATION) &&
 					_map_owner[tile + TILE_XY(0,1)] == _current_player)
 						return;
 
@@ -3739,7 +3739,7 @@
 				DC_EXEC,
 				CMD_REMOVE_ROAD);
 		}
-	} else if (IS_TILETYPE(tile, MP_TUNNELBRIDGE)) {
+	} else if (IsTileType(tile, MP_TUNNELBRIDGE)) {
 		byte b;
 
 		if (_map_owner[tile] != _current_player || (_map5[tile] & 0xC6) != 0x80)
--- a/ai.h
+++ b/ai.h
@@ -230,8 +230,8 @@
 
 // A macro for mp_street, where 0x20 is depot
 //   mp_tunnelbridge, where 0xf0 is a bridge, and 0x4/0x2 means: roadtunnel/bridge
-#define AI_PATHFINDER_IS_ROAD(tile) ((IS_TILETYPE(tile, MP_STREET) && !(_map5[tile] & 0x20)) || \
-(IS_TILETYPE(tile, MP_TUNNELBRIDGE) && \
+#define AI_PATHFINDER_IS_ROAD(tile) ((IsTileType(tile, MP_STREET) && !(_map5[tile] & 0x20)) || \
+(IsTileType(tile, MP_TUNNELBRIDGE) && \
 	(((_map5[tile] & 0x80) == 0 && (_map5[tile] & 0x4) == 0x4) || \
 	 ((_map5[tile] & 0x80) != 0 && (_map5[tile] & 0x2) == 0x2))))
 
--- a/ai_build.c
+++ b/ai_build.c
@@ -174,11 +174,11 @@
 	     		if (old_dir != -1 && old_dir != dir) break;
 	     		old_dir = dir;
 	     		// There is already some road, and it is a bridge.. don't build!!!
-	     		if (!IS_TILETYPE(route[part], MP_TUNNELBRIDGE)) {
+	     		if (!IsTileType(route[part], MP_TUNNELBRIDGE)) {
 	     			// Build the tile
 	     			res = DoCommandByTile(route[part], dir, 0, flag | DC_NO_WATER, CMD_BUILD_ROAD);
 	     			// Currently, we ignore CMD_ERRORs!
-	     			if (res == CMD_ERROR && flag == DC_EXEC && !IS_TILETYPE(route[part], MP_STREET) && !EnsureNoVehicle(route[part])) {
+	     			if (res == CMD_ERROR && flag == DC_EXEC && !IsTileType(route[part], MP_STREET) && !EnsureNoVehicle(route[part])) {
      					// Problem.. let's just abort it all!
      					DEBUG(ai,0)("Darn, the route could not be builded.. aborting!");
     	     			p->ainew.state = AI_STATE_NOTHING;
--- a/ai_new.c
+++ b/ai_new.c
@@ -607,7 +607,7 @@
 	    for (x = TileX(tile) - AI_FINDSTATION_TILE_RANGE; x <= TileX(tile) + AI_FINDSTATION_TILE_RANGE; x++) {
 	    	for (y = TileY(tile) - AI_FINDSTATION_TILE_RANGE; y <= TileY(tile) + AI_FINDSTATION_TILE_RANGE; y++) {
 	    		new_tile = TILE_XY(x,y);
-	    		if (IS_TILETYPE(new_tile, MP_CLEAR) || IS_TILETYPE(new_tile, MP_TREES)) {
+	    		if (IsTileType(new_tile, MP_CLEAR) || IsTileType(new_tile, MP_TREES)) {
 	    			// This tile we can build on!
 	    			// Check acceptance
 						// XXX - Get the catchment area
@@ -744,7 +744,7 @@
 	for (i=2;i<p->ainew.path_info.route_length-2;i++) {
 		tile = p->ainew.path_info.route[i];
 		for (j = 0; j < 4; j++) {
-			if (IS_TILETYPE(tile + TileOffsByDir(j), MP_STREET)) {
+			if (IsTileType(tile + TileOffsByDir(j), MP_STREET)) {
 				// Its a street, test if it is a depot
 				if (_map5[tile + TileOffsByDir(j)] & 0x20) {
 					// We found a depot, is it ours? (TELL ME!!!)
@@ -787,10 +787,10 @@
 					tile + TileOffsByDir(j) == p->ainew.path_info.route[i+1]) continue;
 			// Not around a bridge?
 			if (p->ainew.path_info.route_extra[i] != 0) continue;
-			if (IS_TILETYPE(tile, MP_TUNNELBRIDGE)) continue;
+			if (IsTileType(tile, MP_TUNNELBRIDGE)) continue;
 			// Is the terrain clear?
-			if (IS_TILETYPE(tile + TileOffsByDir(j), MP_CLEAR) ||
-					IS_TILETYPE(tile + TileOffsByDir(j), MP_TREES)) {
+			if (IsTileType(tile + TileOffsByDir(j), MP_CLEAR) ||
+					IsTileType(tile + TileOffsByDir(j), MP_TREES)) {
 				TileInfo ti;
 				FindLandscapeHeightByTile(&ti, tile);
 				// If the current tile is on a slope (tileh != 0) then we do not allow this
@@ -929,11 +929,11 @@
 	int res = 0;
     assert(p->ainew.state == AI_STATE_BUILD_STATION);
     if (p->ainew.temp == 0) {
-    	if (!IS_TILETYPE(p->ainew.from_tile, MP_STATION))
+    	if (!IsTileType(p->ainew.from_tile, MP_STATION))
     		res = AiNew_Build_Station(p, p->ainew.tbt, p->ainew.from_tile, 0, 0, p->ainew.from_direction, DC_EXEC);
    	}
     else {
-       	if (!IS_TILETYPE(p->ainew.to_tile, MP_STATION))
+       	if (!IsTileType(p->ainew.to_tile, MP_STATION))
        	   	res = AiNew_Build_Station(p, p->ainew.tbt, p->ainew.to_tile, 0, 0, p->ainew.to_direction, DC_EXEC);
     	p->ainew.state = AI_STATE_BUILD_PATH;
     }
@@ -1000,10 +1000,10 @@
             	r = DoCommandByTile(tile, _roadbits_by_dir[dir1], 0, DC_EXEC | DC_NO_WATER, CMD_BUILD_ROAD);
 				if (r != CMD_ERROR) {
 					dir1 = TileOffsByDir(dir1);
-					if (IS_TILETYPE(tile+dir1, MP_CLEAR) || IS_TILETYPE(tile+dir1, MP_TREES)) {
+					if (IsTileType(tile + dir1, MP_CLEAR) || IsTileType(tile + dir1, MP_TREES)) {
 						r = DoCommandByTile(tile+dir1, AiNew_GetRoadDirection(tile, tile+dir1, tile+dir1+dir1), 0, DC_EXEC | DC_NO_WATER, CMD_BUILD_ROAD);
 						if (r != CMD_ERROR) {
-							if (IS_TILETYPE(tile+dir1+dir1, MP_CLEAR) || IS_TILETYPE(tile+dir1+dir1, MP_TREES))
+							if (IsTileType(tile + dir1 + dir1, MP_CLEAR) || IsTileType(tile + dir1 + dir1, MP_TREES))
 								DoCommandByTile(tile+dir1+dir1, AiNew_GetRoadDirection(tile+dir1, tile+dir1+dir1, tile+dir1+dir1+dir1), 0, DC_EXEC | DC_NO_WATER, CMD_BUILD_ROAD);
 						}
 					}
@@ -1012,10 +1012,10 @@
 				r = DoCommandByTile(tile, _roadbits_by_dir[dir2], 0, DC_EXEC | DC_NO_WATER, CMD_BUILD_ROAD);
 				if (r != CMD_ERROR) {
 					dir2 = TileOffsByDir(dir2);
-					if (IS_TILETYPE(tile+dir2, MP_CLEAR) || IS_TILETYPE(tile+dir2, MP_TREES)) {
+					if (IsTileType(tile + dir2, MP_CLEAR) || IsTileType(tile + dir2, MP_TREES)) {
 						r = DoCommandByTile(tile+dir2, AiNew_GetRoadDirection(tile, tile+dir2, tile+dir2+dir2), 0, DC_EXEC | DC_NO_WATER, CMD_BUILD_ROAD);
 						if (r != CMD_ERROR) {
-							if (IS_TILETYPE(tile+dir2+dir2, MP_CLEAR) || IS_TILETYPE(tile+dir2+dir2, MP_TREES))
+							if (IsTileType(tile + dir2 + dir2, MP_CLEAR) || IsTileType(tile + dir2 + dir2, MP_TREES))
 								DoCommandByTile(tile+dir2+dir2, AiNew_GetRoadDirection(tile+dir2, tile+dir2+dir2, tile+dir2+dir2+dir2), 0, DC_EXEC | DC_NO_WATER, CMD_BUILD_ROAD);
 						}
 					}
@@ -1024,10 +1024,10 @@
 				r = DoCommandByTile(tile, _roadbits_by_dir[dir3^2], 0, DC_EXEC | DC_NO_WATER, CMD_BUILD_ROAD);
 				if (r != CMD_ERROR) {
 					dir3 = TileOffsByDir(dir3);
-					if (IS_TILETYPE(tile+dir3, MP_CLEAR) || IS_TILETYPE(tile+dir3, MP_TREES)) {
+					if (IsTileType(tile + dir3, MP_CLEAR) || IsTileType(tile + dir3, MP_TREES)) {
 						r = DoCommandByTile(tile+dir3, AiNew_GetRoadDirection(tile, tile+dir3, tile+dir3+dir3), 0, DC_EXEC | DC_NO_WATER, CMD_BUILD_ROAD);
 						if (r != CMD_ERROR) {
-							if (IS_TILETYPE(tile+dir3+dir3, MP_CLEAR) || IS_TILETYPE(tile+dir3+dir3, MP_TREES))
+							if (IsTileType(tile + dir3 + dir3, MP_CLEAR) || IsTileType(tile + dir3 + dir3, MP_TREES))
 								DoCommandByTile(tile+dir3+dir3, AiNew_GetRoadDirection(tile+dir3, tile+dir3+dir3, tile+dir3+dir3+dir3), 0, DC_EXEC | DC_NO_WATER, CMD_BUILD_ROAD);
 						}
 					}
@@ -1046,7 +1046,7 @@
 	int res = 0;
 	assert(p->ainew.state == AI_STATE_BUILD_DEPOT);
 
-	if (IS_TILETYPE(p->ainew.depot_tile, MP_STREET) && _map5[p->ainew.depot_tile] & 0x20) {
+	if (IsTileType(p->ainew.depot_tile, MP_STREET) && _map5[p->ainew.depot_tile] & 0x20) {
 		if (_map_owner[p->ainew.depot_tile] == _current_player) {
 			// The depot is already builded!
 			p->ainew.state = AI_STATE_BUILD_VEHICLE;
--- a/ai_pathfinder.c
+++ b/ai_pathfinder.c
@@ -36,7 +36,7 @@
 	// It is not allowed to have a station on the end of a bridge or tunnel ;)
 	if (current->path.node.user_data[0] != 0) return AYSTAR_DONE;
 	if (TILES_BETWEEN(current->path.node.tile, PathFinderInfo->end_tile_tl, PathFinderInfo->end_tile_br))
-		if (IS_TILETYPE(current->path.node.tile, MP_CLEAR) || IS_TILETYPE(current->path.node.tile, MP_TREES))
+		if (IsTileType(current->path.node.tile, MP_CLEAR) || IsTileType(current->path.node.tile, MP_TREES))
 			if (current->path.parent == NULL || TestCanBuildStationHere(current->path.node.tile,AiNew_GetDirection(current->path.parent->node.tile, current->path.node.tile)))
     			return AYSTAR_FOUND_END_NODE;
 
@@ -119,7 +119,7 @@
 	// Now we add all the starting tiles
 	for (x = TileX(PathFinderInfo->start_tile_tl); x <= TileX(PathFinderInfo->start_tile_br); x++) {
 		for (y = TileY(PathFinderInfo->start_tile_tl); y <= TileY(PathFinderInfo->start_tile_br); y++) {
-			if (!(IS_TILETYPE(TILE_XY(x,y), MP_CLEAR) || IS_TILETYPE(TILE_XY(x,y), MP_TREES))) continue;
+			if (!(IsTileType(TILE_XY(x,y), MP_CLEAR) || IsTileType(TILE_XY(x,y), MP_TREES))) continue;
 			if (!TestCanBuildStationHere(TILE_XY(x,y),TEST_STATION_NO_DIR)) continue;
 			start_node.node.tile = TILE_XY(x,y);
 			aystar->addstart(aystar, &start_node.node);
@@ -187,19 +187,19 @@
 
        		// If the next step is a bridge, we have to enter it the right way
        		if (!PathFinderInfo->rail_or_road && AI_PATHFINDER_IS_ROAD(current->path.node.tile + TileOffsByDir(i))) {
-       			if (IS_TILETYPE(current->path.node.tile + TileOffsByDir(i), MP_TUNNELBRIDGE)) {
+       			if (IsTileType(current->path.node.tile + TileOffsByDir(i), MP_TUNNELBRIDGE)) {
        				// An existing bridge... let's test the direction ;)
        				if ((_map5[current->path.node.tile + TileOffsByDir(i)] & 1U) != (i & 1)) continue;
    					// This problem only is valid for tunnels:
        				// When the last tile was not yet a tunnel, check if we enter from the right side..
-       				if (!IS_TILETYPE(current->path.node.tile, MP_TUNNELBRIDGE) && (_map5[current->path.node.tile + TileOffsByDir(i)] & 0x80) == 0) {
+       				if (!IsTileType(current->path.node.tile, MP_TUNNELBRIDGE) && (_map5[current->path.node.tile + TileOffsByDir(i)] & 0x80) == 0) {
        					if (i != (_map5[current->path.node.tile + TileOffsByDir(i)] & 3U)) continue;
        				}
        			}
        		}
        		// But also if we are on a bridge, we can only move a certain direction
        		if (!PathFinderInfo->rail_or_road && AI_PATHFINDER_IS_ROAD(current->path.node.tile)) {
-       			if (IS_TILETYPE(current->path.node.tile, MP_TUNNELBRIDGE)) {
+       			if (IsTileType(current->path.node.tile, MP_TUNNELBRIDGE)) {
        				// An existing bridge/tunnel... let's test the direction ;)
        				if ((_map5[current->path.node.tile] & 1U) != (i & 1)) continue;
        			}
@@ -241,7 +241,7 @@
        				// Road check
        				dir = AiNew_GetRoadDirection(current->path.parent->node.tile, current->path.node.tile, current->path.node.tile + TileOffsByDir(i));
        				if (AI_PATHFINDER_IS_ROAD(current->path.node.tile)) {
-       					if (IS_TILETYPE(current->path.node.tile, MP_TUNNELBRIDGE)) {
+       					if (IsTileType(current->path.node.tile, MP_TUNNELBRIDGE)) {
        						// We have a bridge, how nicely! We should mark it...
        						dir = 0;
        					} else {
@@ -285,8 +285,8 @@
    		// Bridges can only be build on land that is not flat
    		//  And if there is a road or rail blocking
    		if (ti.tileh != 0 ||
-     		(PathFinderInfo->rail_or_road && IS_TILETYPE(tile + TileOffsByDir(dir), MP_STREET)) ||
-       		(!PathFinderInfo->rail_or_road && IS_TILETYPE(tile + TileOffsByDir(dir), MP_RAILWAY))) {
+     		(PathFinderInfo->rail_or_road && IsTileType(tile + TileOffsByDir(dir), MP_STREET)) ||
+       		(!PathFinderInfo->rail_or_road && IsTileType(tile + TileOffsByDir(dir), MP_RAILWAY))) {
 
     		for (;;) {
     			new_tile += TileOffsByDir(dir);
@@ -378,7 +378,7 @@
 					res += AI_PATHFINDER_TILE_GOES_UP_PENALTY;
 				}
 			} else {
-				if (!(AI_PATHFINDER_IS_ROAD(parent->path.node.tile) && IS_TILETYPE(parent->path.node.tile, MP_TUNNELBRIDGE))) {
+				if (!(AI_PATHFINDER_IS_ROAD(parent->path.node.tile) && IsTileType(parent->path.node.tile, MP_TUNNELBRIDGE))) {
 					r = GetRoadFoundation(parent_ti.tileh, AiNew_GetRoadDirection(parent->path.parent->node.tile, parent->path.node.tile, current->tile));
 					if (r >= 15 || r == 0)
 						res += AI_PATHFINDER_TILE_GOES_UP_PENALTY;
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -277,7 +277,7 @@
 	// 0x56 - hangar facing other way international airport (86)
 	// 0x20 - hangar large airport (32)
 	// 0x41 - hangar small airport (65)
-	return IS_TILETYPE(tile, MP_STATION) &&
+	return IsTileType(tile, MP_STATION) &&
 				(_map5[tile] == 32 || _map5[tile] == 65 || _map5[tile] == 86);
 }
 
--- a/aircraft_gui.c
+++ b/aircraft_gui.c
@@ -577,7 +577,7 @@
 
 		{
 			uint tile = v->tile;
-			if (IS_TILETYPE(tile, MP_STATION) &&
+			if (IsTileType(tile, MP_STATION) &&
 					(_map5[tile] == 32 || _map5[tile] == 65) &&
 					v->vehstatus&VS_STOPPED)
 						disabled = 0;
--- a/clear_cmd.c
+++ b/clear_cmd.c
@@ -395,7 +395,7 @@
 	if (!EnsureNoVehicle(tile))
 		return CMD_ERROR;
 
-	if (IS_TILETYPE(tile, MP_UNMOVABLE) &&
+	if (IsTileType(tile, MP_UNMOVABLE) &&
 			_map5[tile] == 3 &&
 			_map_owner[tile] == _current_player)
 		return_cmd_error(STR_5807_YOU_ALREADY_OWN_IT);
@@ -549,16 +549,16 @@
 	uint dirty = -1;
 
 	img_1 = 0;
-	if (IS_TILETYPE(tile, MP_CLEAR)) {
+	if (IsTileType(tile, MP_CLEAR)) {
 		img_1 = img_by_map5[(_map5[tile] & 0x1C) >> 2];
-	} else if (IS_TILETYPE(tile, MP_TREES) && (_map2[tile] & 0x30) == 0x20) {
+	} else if (IsTileType(tile, MP_TREES) && (_map2[tile] & 0x30) == 0x20) {
 		img_1 = 1;
 	}
 
 	img_2 = 0;
-	if (IS_TILETYPE(TILE_ADDXY(tile, 1, 0), MP_CLEAR)) {
+	if (IsTileType(TILE_ADDXY(tile, 1, 0), MP_CLEAR)) {
 		img_2 = img_by_map5[(_map5[TILE_ADDXY(tile, 1, 0)] & 0x1C) >> 2];
-	} else if (IS_TILETYPE(TILE_ADDXY(tile, 1, 0), MP_TREES) && (_map2[TILE_ADDXY(tile, 1, 0)] & 0x30) == 0x20) {
+	} else if (IsTileType(TILE_ADDXY(tile, 1, 0), MP_TREES) && (_map2[TILE_ADDXY(tile, 1, 0)] & 0x30) == 0x20) {
 		img_2 = 1;
 	}
 
@@ -575,9 +575,9 @@
 	}
 
 	img_2 = 0;
-	if (IS_TILETYPE(TILE_ADDXY(tile, 0, 1), MP_CLEAR)) {
+	if (IsTileType(TILE_ADDXY(tile, 0, 1), MP_CLEAR)) {
 		img_2 = img_by_map5[(_map5[TILE_ADDXY(tile, 0, 1)] & 0x1C) >> 2];
-	} else if (IS_TILETYPE(TILE_ADDXY(tile, 0, 1), MP_TREES) && (_map2[TILE_ADDXY(tile, 0, 1)] & 0x30) == 0x20) {
+	} else if (IsTileType(TILE_ADDXY(tile, 0, 1), MP_TREES) && (_map2[TILE_ADDXY(tile, 0, 1)] & 0x30) == 0x20) {
 		img_2 = 1;
 	}
 
@@ -741,7 +741,7 @@
 	i = (Random() & 0x3FF) | 0x400;
 	do {
 		tile = TILE_MASK(Random());
-		if (IS_TILETYPE(tile, MP_CLEAR))
+		if (IsTileType(tile, MP_CLEAR))
 			_map5[tile] = (byte)((_map5[tile] & ~(3<<2)) | (1<<2));
 	} while (--i);
 
@@ -750,14 +750,14 @@
 	do {
 		r = Random();
 		tile = TILE_MASK(r);
-		if (IS_TILETYPE(tile, MP_CLEAR)) {
+		if (IsTileType(tile, MP_CLEAR)) {
 			j = ((r >> 16) & 0xF) + 5;
 			for(;;) {
 				_map5[tile] = (byte)((_map5[tile] & ~(3<<2)) | (2<<2));
 				do {
 					if (--j == 0) goto get_out;
 					tile_new = tile + TileOffsByDir(Random() & 3);
-				} while (!IS_TILETYPE(tile_new, MP_CLEAR));
+				} while (!IsTileType(tile_new, MP_CLEAR));
 				tile = tile_new;
 			}
 get_out:;
--- a/disaster_cmd.c
+++ b/disaster_cmd.c
@@ -164,7 +164,7 @@
 		} else if (v->current_order.station == 0) {
 			tile = v->tile; /**/
 
-			if (IS_TILETYPE(tile, MP_STATION) &&
+			if (IsTileType(tile, MP_STATION) &&
 				IS_BYTE_INSIDE(_map5[tile], 8, 0x43) &&
 				IS_HUMAN_PLAYER(_map_owner[tile])) {
 
@@ -189,7 +189,7 @@
 
 		tile = v->tile; /**/
 
-		if (IS_TILETYPE(tile, MP_STATION) &&
+		if (IsTileType(tile, MP_STATION) &&
 			IS_BYTE_INSIDE(_map5[tile], 8, 0x43) &&
 			IS_HUMAN_PLAYER(_map_owner[tile])) {
 
@@ -231,7 +231,7 @@
 	}
 
 	tile = v->tile;/**/
-	if (IS_TILETYPE(tile, MP_STATION) &&
+	if (IsTileType(tile, MP_STATION) &&
 		IS_BYTE_INSIDE(_map5[tile], 8, 0x43) &&
 		IS_HUMAN_PLAYER(_map_owner[tile])) {
 
@@ -325,7 +325,7 @@
 	uint tile;
 
 	for(tile=0; tile != MapSize(); tile++) {
-		if (IS_TILETYPE(tile, MP_INDUSTRY) &&	_map2[tile] == i->index) {
+		if (IsTileType(tile, MP_INDUSTRY) &&	_map2[tile] == i->index) {
 			_map_owner[tile] = 0;
 			MarkTileDirtyByTile(tile);
 		}
@@ -391,7 +391,7 @@
 			return;
 
 		tile = TILE_FROM_XY(x,y);
-		if (!IS_TILETYPE(tile, MP_INDUSTRY))
+		if (!IsTileType(tile, MP_INDUSTRY))
 			return;
 
 		v->dest_tile = ind = _map2[tile];
@@ -462,7 +462,7 @@
 			return;
 
 		tile = TILE_FROM_XY(x,y);
-		if (!IS_TILETYPE(tile, MP_INDUSTRY))
+		if (!IsTileType(tile, MP_INDUSTRY))
 			return;
 
 		v->dest_tile = ind = _map2[tile];
@@ -570,7 +570,7 @@
 
 		tile_org = tile = TILE_MASK(Random());
 		do {
-			if (IS_TILETYPE(tile, MP_RAILWAY) &&
+			if (IsTileType(tile, MP_RAILWAY) &&
 					(_map5[tile]&~3)!=0xC0 &&	IS_HUMAN_PLAYER(_map_owner[tile]))
 						break;
 			tile = TILE_MASK(tile+1);
--- a/industry_cmd.c
+++ b/industry_cmd.c
@@ -836,11 +836,11 @@
 void DeleteIndustry(Industry *i)
 {
 	BEGIN_TILE_LOOP(tile_cur, i->width, i->height, i->xy);
-		if (IS_TILETYPE(tile_cur, MP_INDUSTRY)) {
+		if (IsTileType(tile_cur, MP_INDUSTRY)) {
 			if (_map2[tile_cur] == i->index) {
 				DoClearSquare(tile_cur);
 			}
-		} else if (IS_TILETYPE(tile_cur, MP_STATION) && _map5[tile_cur] == 0x4B) {
+		} else if (IsTileType(tile_cur, MP_STATION) && _map5[tile_cur] == 0x4B) {
 			DeleteOilRig(tile_cur);
 		}
 	END_TILE_LOOP(tile_cur, i->width, i->height, i->xy);
@@ -856,12 +856,12 @@
 
 static bool IsBadFarmFieldTile(uint tile)
 {
-	if (IS_TILETYPE(tile,MP_CLEAR)) {
+	if (IsTileType(tile, MP_CLEAR)) {
 		byte m5 = _map5[tile] & 0x1C;
 		if (m5 == 0xC || m5 == 0x10)
 			return true;
 		return false;
-	} else if (IS_TILETYPE(tile,MP_TREES)) {
+	} else if (IsTileType(tile, MP_TREES)) {
 		return false;
 	} else {
 		return true;
@@ -870,12 +870,12 @@
 
 static bool IsBadFarmFieldTile2(uint tile)
 {
-	if (IS_TILETYPE(tile,MP_CLEAR)) {
+	if (IsTileType(tile, MP_CLEAR)) {
 		byte m5 = _map5[tile] & 0x1C;
 		if (m5 == 0x10)
 			return true;
 		return false;
-	} else if (IS_TILETYPE(tile,MP_TREES)) {
+	} else if (IsTileType(tile, MP_TREES)) {
 		return false;
 	} else {
 		return true;
@@ -889,7 +889,7 @@
 	do {
 		tile = TILE_MASK(tile);
 
-		if (IS_TILETYPE(tile, MP_CLEAR) || IS_TILETYPE(tile, MP_TREES)) {
+		if (IsTileType(tile, MP_CLEAR) || IsTileType(tile, MP_TREES)) {
 
 			or = type;
 			if (or == 1 && (uint16)Random() <= 9362) or = 2;
@@ -999,7 +999,7 @@
 			j = a;
 			do {
 				tile = TILE_MASK(tile);
-				if (IS_TILETYPE(tile, MP_TREES)) {
+				if (IsTileType(tile, MP_TREES)) {
 					uint old_player = _current_player;
 					/* found a tree */
 
--- a/landscape.c
+++ b/landscape.c
@@ -93,7 +93,7 @@
 
 	ti->tile = tile;
 	ti->map5 = _map5[tile];
-	ti->type = GET_TILETYPE(tile);
+	ti->type = TileType(tile);
 	ti->tileh = GetTileSlope(tile, &ti->z);
 //	ti->z = min * 8;
 }
@@ -295,28 +295,28 @@
 
 uint32 GetTileTrackStatus(uint tile, TransportType mode)
 {
-	return _tile_type_procs[GET_TILETYPE(tile)]->get_tile_track_status_proc(tile, mode);
+	return _tile_type_procs[TileType(tile)]->get_tile_track_status_proc(tile, mode);
 }
 
 void ChangeTileOwner(uint tile, byte old_player, byte new_player)
 {
-	_tile_type_procs[GET_TILETYPE(tile)]->change_tile_owner_proc(tile, old_player, new_player);
+	_tile_type_procs[TileType(tile)]->change_tile_owner_proc(tile, old_player, new_player);
 }
 
 void GetAcceptedCargo(uint tile, AcceptedCargo ac)
 {
 	memset(ac, 0, sizeof(AcceptedCargo));
-	_tile_type_procs[GET_TILETYPE(tile)]->get_accepted_cargo_proc(tile, ac);
+	_tile_type_procs[TileType(tile)]->get_accepted_cargo_proc(tile, ac);
 }
 
 void AnimateTile(uint tile)
 {
-	_tile_type_procs[GET_TILETYPE(tile)]->animate_tile_proc(tile);
+	_tile_type_procs[TileType(tile)]->animate_tile_proc(tile);
 }
 
 void ClickTile(uint tile)
 {
-	_tile_type_procs[GET_TILETYPE(tile)]->click_tile_proc(tile);
+	_tile_type_procs[TileType(tile)]->click_tile_proc(tile);
 }
 
 void DrawTile(TileInfo *ti)
@@ -326,7 +326,7 @@
 
 void GetTileDesc(uint tile, TileDesc *td)
 {
-	_tile_type_procs[GET_TILETYPE(tile)]->get_tile_desc_proc(tile, td);
+	_tile_type_procs[TileType(tile)]->get_tile_desc_proc(tile, td);
 }
 
 /* Clear a piece of landscape
@@ -340,7 +340,7 @@
 	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
 
 	tile = TILE_FROM_XY(x,y);
-	return _tile_type_procs[GET_TILETYPE(tile)]->clear_tile_proc(tile, flags);
+	return _tile_type_procs[TileType(tile)]->clear_tile_proc(tile, flags);
 }
 
 // p1 = end tile
@@ -467,7 +467,7 @@
 	assert( (tile & ~TILELOOP_ASSERTMASK) == 0);
 	count = (MapSizeX() / TILELOOP_SIZE) * (MapSizeY() / TILELOOP_SIZE);
 	do {
-		_tile_type_procs[GET_TILETYPE(tile)]->tile_loop_proc(tile);
+		_tile_type_procs[TileType(tile)]->tile_loop_proc(tile);
 
 		if (TileX(tile) < MapSizeX() - TILELOOP_SIZE) {
 			tile += TILELOOP_SIZE; /* no overflow */
@@ -509,7 +509,7 @@
 	int h;
 
 	while(true) {
-		if (IS_TILETYPE(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h == 0) {
+		if (IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h == 0) {
 			_map_type_and_height[tile] = MP_WATER << 4;
 			_map5[tile] = 0;
 			_map_owner[tile] = OWNER_WATER;
@@ -654,7 +654,7 @@
 		for (data = _make_desert_or_rainforest_data;
 				data != endof(_make_desert_or_rainforest_data); ++data) {
 			TileIndex t = TILE_MASK(tile + ToTileIndexDiff(*data));
-			if (IS_TILETYPE(t, MP_CLEAR) && (_map5[t] & 0x1c) == 0x14) break;
+			if (IsTileType(t, MP_CLEAR) && (_map5[t] & 0x1c) == 0x14) break;
 		}
 		if (data == endof(_make_desert_or_rainforest_data))
 			SetMapExtraBits(tile, 2);
--- a/macros.h
+++ b/macros.h
@@ -70,10 +70,6 @@
 
 #define LANDSCAPE_SIZE_FACTOR 1
 
-#define IS_TILETYPE(_t_, _s_) (_map_type_and_height[(_t_)] >> 4 == (_s_))
-#define GET_TILETYPE(_t_) (_map_type_and_height[(_t_)] >> 4)
-#define GET_TILEHEIGHT(_t_) ((_map_type_and_height[_t_] & 0xF) * 8)
-
 enum {
 	CORRECT_Z_BITS = 1 << 1 | 1 << 2 | 1 << 3 | 1 << 4 | 1 << 5 | 1 << 6 | 1 << 7
 };
--- a/main_gui.c
+++ b/main_gui.c
@@ -1193,7 +1193,7 @@
 
 static void PlaceProc_RockyArea(uint tile)
 {
-	if (!IS_TILETYPE(tile, MP_CLEAR) && !IS_TILETYPE(tile, MP_TREES))
+	if (!IsTileType(tile, MP_CLEAR) && !IsTileType(tile, MP_TREES))
 		return;
 
 	ModifyTile(tile, MP_SETTYPE(MP_CLEAR) | MP_MAP5, (_map5[tile] & ~0x1C) | 0xB);
--- a/map.h
+++ b/map.h
@@ -72,4 +72,22 @@
 	return ToTileIndexDiff(_tileoffs_by_dir[dir]);
 }
 
+
+static inline uint TileHeight(TileIndex tile)
+{
+	assert(tile < MapSize());
+	return (_map_type_and_height[tile] & 0xf) * 8;
+}
+
+static inline int TileType(TileIndex tile)
+{
+	assert(tile < MapSize());
+	return _map_type_and_height[tile] >> 4;
+}
+
+static inline bool IsTileType(TileIndex tile, int type)
+{
+	return TileType(tile) == type;
+}
+
 #endif
--- a/oldloader.c
+++ b/oldloader.c
@@ -1478,7 +1478,7 @@
 
 	// go through the tables and see if we can find any ttdpatch presignals. Then convert those to our format.
 	for (i = 0; i != map_size; i++) {
-		if (IS_TILETYPE(i, MP_RAILWAY) && (_map5[i] & 0xC0) == 0x40) {
+		if (IsTileType(i, MP_RAILWAY) && (_map5[i] & 0xC0) == 0x40) {
 			// this byte is always zero in real ttd.
 			if (_map3_hi[i]) {
 				// convert ttdpatch presignal format to openttd presignal format.
--- a/order_gui.c
+++ b/order_gui.c
@@ -184,7 +184,7 @@
 
 	// check depot first
 	if (_patches.gotodepot) {
-		switch(GET_TILETYPE(tile)) {
+		switch (TileType(tile)) {
 		case MP_RAILWAY:
 			if (v->type == VEH_Train && _map_owner[tile] == _local_player) {
 				if ((_map5[tile]&0xFC)==0xC0) {
@@ -231,7 +231,7 @@
 	}
 
 	// check waypoint
-	if (IS_TILETYPE(tile, MP_RAILWAY)
+	if (IsTileType(tile, MP_RAILWAY)
 	&& v->type == VEH_Train
 	&& _map_owner[tile] == _local_player
 	&& (_map5[tile]&0xFE)==0xC4) {
@@ -241,7 +241,7 @@
 		return order;
 	}
 
-	if (IS_TILETYPE(tile, MP_STATION)) {
+	if (IsTileType(tile, MP_STATION)) {
 		st = GetStation(st_index = _map2[tile]);
 
 		if (st->owner == _current_player || st->owner == OWNER_NONE) {
--- a/pathfind.c
+++ b/pathfind.c
@@ -131,10 +131,10 @@
 	int owner = -1;
 
 	if (tpf->tracktype == TRANSPORT_RAIL) {
-		if ((IS_TILETYPE(tile, MP_RAILWAY) || IS_TILETYPE(tile, MP_STATION) || IS_TILETYPE(tile, MP_TUNNELBRIDGE))) {
+		if (IsTileType(tile, MP_RAILWAY) || IsTileType(tile, MP_STATION) || IsTileType(tile, MP_TUNNELBRIDGE)) {
 			owner = _map_owner[tile];
 			/* Check if we are on the middle of a bridge (has no owner) */
-			if (IS_TILETYPE(tile, MP_TUNNELBRIDGE) && (_map5[tile] & 0xC0) == 0xC0)
+			if (IsTileType(tile, MP_TUNNELBRIDGE) && (_map5[tile] & 0xC0) == 0xC0)
 				owner = -1;
 		}
 	}
@@ -146,9 +146,9 @@
 
 	/* Check in case of rail if the owner is the same */
 	if (tpf->tracktype == TRANSPORT_RAIL) {
-		if ((IS_TILETYPE(tile, MP_RAILWAY) || IS_TILETYPE(tile, MP_STATION) || IS_TILETYPE(tile, MP_TUNNELBRIDGE)))
+		if (IsTileType(tile, MP_RAILWAY) || IsTileType(tile, MP_STATION) || IsTileType(tile, MP_TUNNELBRIDGE))
 			/* Check if we are on the middle of a bridge (has no owner) */
-			if (!IS_TILETYPE(tile, MP_TUNNELBRIDGE) || (_map5[tile] & 0xC0) != 0xC0)
+			if (!IsTileType(tile, MP_TUNNELBRIDGE) || (_map5[tile] & 0xC0) != 0xC0)
 				if (owner != -1 && _map_owner[tile] != owner)
 					return;
 	}
@@ -231,7 +231,7 @@
 
 		tile = TILE_FROM_XY(x,y);
 
-		if (IS_TILETYPE(tile, MP_TUNNELBRIDGE) &&
+		if (IsTileType(tile, MP_TUNNELBRIDGE) &&
 				(_map5[tile] & 0xF0) == 0 &&					// tunnel entrance/exit
 				//((_map5[tile]>>2)&3) == type &&		// rail/road-tunnel <-- This is not necesary to check, right?
 				((_map5[tile] & 3)^2) == direction &&	// entrance towards: 0 = NE, 1 = SE, 2 = SW, 3 = NW
@@ -281,7 +281,7 @@
 	RememberData rd;
 	uint tile_org = tile;
 
-	if (IS_TILETYPE(tile, MP_TUNNELBRIDGE) && (_map5[tile] & 0xF0)==0) {
+	if (IsTileType(tile, MP_TUNNELBRIDGE) && (_map5[tile] & 0xF0) == 0) {
 		if ((_map5[tile] & 3) != direction || ((_map5[tile]>>2)&3) != tpf->tracktype)
 			return;
 		tile = SkipToEndOfTunnel(tpf, tile, direction);
@@ -290,11 +290,11 @@
 
 	/* Check in case of rail if the owner is the same */
 	if (tpf->tracktype == TRANSPORT_RAIL) {
-		if ((IS_TILETYPE(tile_org, MP_RAILWAY) || IS_TILETYPE(tile_org, MP_STATION) || IS_TILETYPE(tile_org, MP_TUNNELBRIDGE)))
-			if ((IS_TILETYPE(tile, MP_RAILWAY) || IS_TILETYPE(tile, MP_STATION) || IS_TILETYPE(tile, MP_TUNNELBRIDGE)))
+		if (IsTileType(tile_org, MP_RAILWAY) || IsTileType(tile_org, MP_STATION) || IsTileType(tile_org, MP_TUNNELBRIDGE))
+			if (IsTileType(tile, MP_RAILWAY) || IsTileType(tile, MP_STATION) || IsTileType(tile, MP_TUNNELBRIDGE))
 				/* Check if we are on a bridge (middle parts don't have an owner */
-				if (!IS_TILETYPE(tile, MP_TUNNELBRIDGE) || (_map5[tile] & 0xC0) != 0xC0)
-					if (!IS_TILETYPE(tile_org, MP_TUNNELBRIDGE) || (_map5[tile_org] & 0xC0) != 0xC0)
+				if (!IsTileType(tile, MP_TUNNELBRIDGE) || (_map5[tile] & 0xC0) != 0xC0)
+					if (!IsTileType(tile_org, MP_TUNNELBRIDGE) || (_map5[tile_org] & 0xC0) != 0xC0)
 						if (_map_owner[tile_org] != _map_owner[tile])
 							return;
 	}
@@ -628,7 +628,7 @@
 	si.state = 0;
 
 restart:
-	if (IS_TILETYPE(tile, MP_TUNNELBRIDGE) && (_map5[tile] & 0xF0)==0) {
+	if (IsTileType(tile, MP_TUNNELBRIDGE) && (_map5[tile] & 0xF0) == 0) {
 		/* This is a tunnel tile */
 		if ( (uint)(_map5[tile] & 3) != (direction ^ 2)) { /* ^ 2 is reversing the direction */
 			/* We are not just driving out of the tunnel */
@@ -653,7 +653,7 @@
 			goto popnext;
 
 		// not a regular rail tile?
-		if (!IS_TILETYPE(tile, MP_RAILWAY) || (bits = _map5[tile]) & 0xC0) {
+		if (!IsTileType(tile, MP_RAILWAY) || (bits = _map5[tile]) & 0xC0) {
 			bits = GetTileTrackStatus(tile, TRANSPORT_RAIL) & _tpfmode1_and[direction];
 			bits = (bits | (bits >> 8)) & 0x3F;
 			break;
--- a/rail_cmd.c
+++ b/rail_cmd.c
@@ -235,7 +235,7 @@
 		rail_bits |= existing;
 
 		// don't allow building on the lower side of a coast
-		if (IS_TILETYPE(tile, MP_WATER) && ~_valid_tileh_slopes[2][tileh] & rail_bits) {
+		if (IsTileType(tile, MP_WATER) && ~_valid_tileh_slopes[2][tileh] & rail_bits) {
 			return_cmd_error(STR_3807_CAN_T_BUILD_ON_WATER);
 		}
 
@@ -279,7 +279,7 @@
 
 	if (ti.type == MP_TUNNELBRIDGE) {
 /* BUILD ON BRIDGE CODE */
-		if (!EnsureNoVehicleZ(tile, GET_TILEHEIGHT(tile)))
+		if (!EnsureNoVehicleZ(tile, TileHeight(tile)))
 			return CMD_ERROR;
 
 		if ((ti.map5 & 0xF8) == 0xC0) {
@@ -438,7 +438,7 @@
 		return CMD_ERROR;
 
 	if (ti.type == MP_TUNNELBRIDGE) {
-		if (!EnsureNoVehicleZ(tile, GET_TILEHEIGHT(tile)))
+		if (!EnsureNoVehicleZ(tile, TileHeight(tile)))
 			return CMD_ERROR;
 
 		if ((ti.map5 & 0xF8) != 0xE0)
@@ -721,7 +721,7 @@
 
 	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
 
-	if (!IS_TILETYPE(tile, MP_RAILWAY) || ((dir=0, _map5[tile] != 1) && (dir=1, _map5[tile] != 2)))
+	if (!IsTileType(tile, MP_RAILWAY) || ((dir = 0, _map5[tile] != 1) && (dir = 1, _map5[tile] != 2)))
 		return_cmd_error(STR_1005_NO_SUITABLE_RAILROAD_TRACK);
 
 	if (!CheckTileOwnership(tile))
@@ -793,7 +793,7 @@
 	Waypoint *cp;
 
 	// make sure it's a waypoint
-	if (!IS_TILETYPE(tile, MP_RAILWAY) || !IS_RAIL_WAYPOINT(_map5[tile]))
+	if (!IsTileType(tile, MP_RAILWAY) || !IS_RAIL_WAYPOINT(_map5[tile]))
 		return CMD_ERROR;
 
 	if (!CheckTileOwnership(tile) && !(_current_player==17))
@@ -885,7 +885,7 @@
 		return CMD_ERROR;
 
 	// must be railway, and not a depot, and it must have a track in the suggested position.
-	if (!IS_TILETYPE(tile, MP_RAILWAY) || (m5=_map5[tile], m5&0x80) || !HASBIT(m5, track))
+	if (!IsTileType(tile, MP_RAILWAY) || (m5 = _map5[tile], m5 & 0x80) || !HASBIT(m5, track))
 		return CMD_ERROR;
 
 	_error_message = STR_1005_NO_SUITABLE_RAILROAD_TRACK;
@@ -1159,10 +1159,10 @@
 			uint tile = TILE_FROM_XY(x,y);
 			DoConvertRailProc *p;
 
-			if (IS_TILETYPE(tile, MP_RAILWAY)) p = DoConvertRail;
-			else if (IS_TILETYPE(tile, MP_STATION)) p = DoConvertStationRail;
-			else if (IS_TILETYPE(tile, MP_STREET)) p = DoConvertStreetRail;
-			else if (IS_TILETYPE(tile, MP_TUNNELBRIDGE)) p = DoConvertTunnelBridgeRail;
+			if (IsTileType(tile, MP_RAILWAY)) p = DoConvertRail;
+			else if (IsTileType(tile, MP_STATION)) p = DoConvertStationRail;
+			else if (IsTileType(tile, MP_STREET)) p = DoConvertStreetRail;
+			else if (IsTileType(tile, MP_TUNNELBRIDGE)) p = DoConvertTunnelBridgeRail;
 			else continue;
 
 			ret = p(tile, p2, false);
@@ -1749,7 +1749,7 @@
 static bool SetSignalsEnumProc(uint tile, SetSignalsData *ssd, int track, uint length, byte *state)
 {
 	// the tile has signals?
-	if (IS_TILETYPE(tile, MP_RAILWAY)) {
+	if (IsTileType(tile, MP_RAILWAY)) {
 		if ((_map5[tile]&RAIL_TYPE_MASK) == RAIL_TYPE_SIGNALS) {
 			if ((_map3_lo[tile] & _signals_table_both[track]) != 0) {
 
@@ -2040,28 +2040,28 @@
 			owner = _map_owner[tile];
 
 			if ( (!(rail&(RAIL_BIT_DIAG2|RAIL_BIT_UPPER|RAIL_BIT_LEFT)) && (rail&RAIL_BIT_DIAG1)) || rail==(RAIL_BIT_LOWER|RAIL_BIT_RIGHT)) {
-				if (!IS_TILETYPE(tile + TILE_XY(0,-1), MP_RAILWAY) ||
+				if (!IsTileType(tile + TILE_XY(0,-1), MP_RAILWAY) ||
 						owner != _map_owner[tile + TILE_XY(0,-1)] ||
 						(_map5[tile + TILE_XY(0,-1)]==RAIL_BIT_UPPER || _map5[tile + TILE_XY(0,-1)]==RAIL_BIT_LEFT))
 							a2 = RAIL_GROUND_FENCE_NW;
 			}
 
 			if ( (!(rail&(RAIL_BIT_DIAG2|RAIL_BIT_LOWER|RAIL_BIT_RIGHT)) && (rail&RAIL_BIT_DIAG1)) || rail==(RAIL_BIT_UPPER|RAIL_BIT_LEFT)) {
-				if (!IS_TILETYPE(tile + TILE_XY(0,1), MP_RAILWAY) ||
+				if (!IsTileType(tile + TILE_XY(0,1), MP_RAILWAY) ||
 						owner != _map_owner[tile + TILE_XY(0,1)] ||
 						(_map5[tile + TILE_XY(0,1)]==RAIL_BIT_LOWER || _map5[tile + TILE_XY(0,1)]==RAIL_BIT_RIGHT))
 							a2 = (a2 == RAIL_GROUND_FENCE_NW) ? RAIL_GROUND_FENCE_SENW : RAIL_GROUND_FENCE_SE;
 			}
 
 			if ( (!(rail&(RAIL_BIT_DIAG1|RAIL_BIT_UPPER|RAIL_BIT_RIGHT)) && (rail&RAIL_BIT_DIAG2)) || rail==(RAIL_BIT_LOWER|RAIL_BIT_LEFT)) {
-				if (!IS_TILETYPE(tile + TILE_XY(-1,0), MP_RAILWAY) ||
+				if (!IsTileType(tile + TILE_XY(-1,0), MP_RAILWAY) ||
 						owner != _map_owner[tile + TILE_XY(-1,0)] ||
 						(_map5[tile + TILE_XY(-1,0)]==RAIL_BIT_UPPER || _map5[tile + TILE_XY(-1,0)]==RAIL_BIT_RIGHT))
 							a2 = RAIL_GROUND_FENCE_NE;
 			}
 
 			if ( (!(rail&(RAIL_BIT_DIAG1|RAIL_BIT_LOWER|RAIL_BIT_LEFT)) && (rail&RAIL_BIT_DIAG2)) || rail==(RAIL_BIT_UPPER|RAIL_BIT_RIGHT)) {
-				if (!IS_TILETYPE(tile + TILE_XY(1,0), MP_RAILWAY) ||
+				if (!IsTileType(tile + TILE_XY(1,0), MP_RAILWAY) ||
 						owner != _map_owner[tile + TILE_XY(1,0)] ||
 						(_map5[tile + TILE_XY(1,0)]==RAIL_BIT_LOWER || _map5[tile + TILE_XY(1,0)]==RAIL_BIT_LEFT))
 							a2 = (a2 == RAIL_GROUND_FENCE_NE) ? RAIL_GROUND_FENCE_NESW : RAIL_GROUND_FENCE_SW;
--- a/rail_gui.c
+++ b/rail_gui.c
@@ -100,7 +100,7 @@
 
 		tile += TileOffsByDir(dir);
 
-		if (IS_TILETYPE(tile, MP_RAILWAY)) {
+		if (IsTileType(tile, MP_RAILWAY)) {
 			PlaceExtraDepotRail(tile, _place_depot_extra[dir]);
 			PlaceExtraDepotRail(tile, _place_depot_extra[dir + 4]);
 			PlaceExtraDepotRail(tile, _place_depot_extra[dir + 8]);
@@ -394,11 +394,11 @@
 		};
 		tile += ToTileIndexDiff(_tile_inc[i]);
 		m[i] = 0;
-		if (IS_TILETYPE(tile, MP_RAILWAY) && _map5[tile] < 0x80)
+		if (IsTileType(tile, MP_RAILWAY) && _map5[tile] < 0x80)
 			m[i] = _map5[tile]&0x3F;
 
 		// handle tracks under bridge
-		if(IS_TILETYPE(tile, MP_TUNNELBRIDGE) && (_map5[tile]&0xF8)==0xE0)
+		if(IsTileType(tile, MP_TUNNELBRIDGE) && (_map5[tile]&0xF8)==0xE0)
 			m[i] = (byte) !(_map5[tile]&0x01) + 1;
 
 		if (_remove_button_clicked) m[i] ^= 0x3F;
--- a/road_cmd.c
+++ b/road_cmd.c
@@ -25,7 +25,7 @@
 	int mask;
 	byte b;
 
-	switch(GET_TILETYPE(tile)) {
+	switch (TileType(tile)) {
 	case MP_STREET:
 		b = _map5[tile];
 
@@ -76,7 +76,7 @@
 		return true;
 
 	// A railway crossing has the road owner in the map3_lo byte.
-	if (IS_TILETYPE(tile, MP_STREET) && (_map5[tile] & 0xF0) == 0x10) {
+	if (IsTileType(tile, MP_STREET) && (_map5[tile] & 0xF0) == 0x10) {
 		owner = _map3_lo[tile];
 	} else {
 		owner = _map_owner[tile];
@@ -117,7 +117,7 @@
 
 bool IsRoadDepotTile(TileIndex tile)
 {
-	return IS_TILETYPE(tile, MP_STREET) &&
+	return IsTileType(tile, MP_STREET) &&
 					(_map5[tile] & 0xF0) == 0x20;
 }
 
@@ -164,7 +164,7 @@
 	}
 
 	if (ti.type == MP_TUNNELBRIDGE) {
-		if (!EnsureNoVehicleZ(tile, GET_TILEHEIGHT(tile)))
+		if (!EnsureNoVehicleZ(tile, TileHeight(tile)))
 			return CMD_ERROR;
 
 		if ((ti.map5 & 0xE9) == 0xE8) {
--- a/road_gui.c
+++ b/road_gui.c
@@ -67,7 +67,7 @@
 	static const byte _roadbits_by_dir[4] = {2,1,8,4};
 	tile += TileOffsByDir(direction);
 	// if there is a roadpiece just outside of the station entrance, build a connecting route
-	if (IS_TILETYPE(tile, MP_STREET) && !(_map5[tile]&0x20)) {
+	if (IsTileType(tile, MP_STREET) && !(_map5[tile] & 0x20)) {
 		DoCommandP(tile, _roadbits_by_dir[direction], 0, NULL, CMD_BUILD_ROAD);
 	}
 }
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -253,7 +253,7 @@
 {
 	tile += TileOffsByDir(_road_pf_directions[track]);
 
-	if (IS_TILETYPE(tile, MP_STREET) &&
+	if (IsTileType(tile, MP_STREET) &&
 			(_map5[tile] & 0xF0) == 0x20 &&
 			_map_owner[tile] == rfdd->owner) {
 
@@ -417,7 +417,7 @@
 	RebuildVehicleLists();
 	InvalidateWindow(WC_COMPANY, v->owner);
 
-	if(IS_TILETYPE(v->tile, MP_STATION))
+	if (IsTileType(v->tile, MP_STATION))
 		ClearCrashedStation(v);
 
 	BeginVehicleMove(v);
@@ -511,7 +511,7 @@
 	tile = v->tile;
 
 	// Make sure it's a road/rail crossing
-	if (!IS_TILETYPE(tile, MP_STREET) ||
+	if (!IsTileType(tile, MP_STREET) ||
 	    (_map5[tile] & 0xF0) != 0x10)
 				return;
 
@@ -942,11 +942,11 @@
 		bitmask = (uint16)r;
 	}
 
-	if (IS_TILETYPE(tile, MP_STREET)) {
+	if (IsTileType(tile, MP_STREET)) {
 		if ((_map5[tile]&0xF0) == 0x20 && v->owner == _map_owner[tile])
 			/* Road crossing */
 			bitmask |= _road_veh_fp_ax_or[_map5[tile]&3];
-	} else if (IS_TILETYPE(tile, MP_STATION)) {
+	} else if (IsTileType(tile, MP_STATION)) {
 		if (_map_owner[tile] == OWNER_NONE || _map_owner[tile] == v->owner) {
 			/* Our station */
 			Station *st = GetStation(_map2[tile]);
@@ -990,11 +990,11 @@
 		return_track(FindFirstBit2x64(bitmask));
 	}
 
-	if (IS_TILETYPE(desttile, MP_STREET)) {
+	if (IsTileType(desttile, MP_STREET)) {
 		m5 = _map5[desttile];
 		if ((m5&0xF0) == 0x20)
 			goto do_it;
-	} else if (IS_TILETYPE(desttile, MP_STATION)) {
+	} else if (IsTileType(desttile, MP_STATION)) {
 		m5 = _map5[desttile];
 		if (IS_BYTE_INSIDE(m5, 0x43, 0x4B)) {
 			m5 -= 0x43;
@@ -1147,7 +1147,7 @@
 			return;
 		}
 
-		if (IS_TILETYPE(gp.new_tile, MP_TUNNELBRIDGE) &&
+		if (IsTileType(gp.new_tile, MP_TUNNELBRIDGE) &&
 				(_map5[gp.new_tile]&0xF0) == 0 &&
 				(VehicleEnterTile(v, gp.new_tile, gp.x, gp.y)&4)) {
 
@@ -1198,7 +1198,7 @@
 
 		r = VehicleEnterTile(v, tile, x, y);
 		if (r & 8) {
-			if (!IS_TILETYPE(tile, MP_TUNNELBRIDGE)) {
+			if (!IsTileType(tile, MP_TUNNELBRIDGE)) {
 				v->cur_speed = 0;
 				return;
 			}
@@ -1206,7 +1206,7 @@
 			goto again;
 		}
 
-		if (IS_BYTE_INSIDE(v->u.road.state, 0x20, 0x30) && IS_TILETYPE(v->tile, MP_STATION)) {
+		if (IS_BYTE_INSIDE(v->u.road.state, 0x20, 0x30) && IsTileType(v->tile, MP_STATION)) {
 			if ((tmp&7) >= 6) { v->cur_speed = 0; return; }
 			if (IS_BYTE_INSIDE(_map5[v->tile], 0x43, 0x4B)) {
 				Station *st = GetStation(_map2[v->tile]);
--- a/ship_cmd.c
+++ b/ship_cmd.c
@@ -84,7 +84,7 @@
 
 	for(i=0; i!=lengthof(_depots); i++) {
 		tile = _depots[i].xy;
-		if (IS_TILETYPE(tile, MP_WATER) && _map_owner[tile] == owner) {
+		if (IsTileType(tile, MP_WATER) && _map_owner[tile] == owner) {
 			dist = GetTileDist(tile, tile2);
 			if (dist < best_dist) {
 				best_dist = dist;
--- a/smallmap_gui.c
+++ b/smallmap_gui.c
@@ -297,7 +297,7 @@
 {
 	uint t;
 
-	t = GET_TILETYPE(tile);
+	t = TileType(tile);
 	if (t == MP_TUNNELBRIDGE) {
 		t = _map5[tile];
 		if ((t & 0x80) == 0) t>>=1;
@@ -327,7 +327,7 @@
 {
 	uint t;
 
-	t = GET_TILETYPE(tile);
+	t = TileType(tile);
 	if (t == MP_TUNNELBRIDGE) {
 		t = _map5[tile];
 		if ((t & 0x80) == 0) t>>=1;
@@ -380,7 +380,7 @@
 {
 	int t;
 
-	t = GET_TILETYPE(tile);
+	t = TileType(tile);
 	if (t == MP_INDUSTRY) {
 		byte color = _industry_smallmap_colors[_map5[tile]];
 		return color + (color << 8) + (color << 16) + (color << 24);
@@ -413,7 +413,7 @@
 	int t;
 	uint32 bits;
 
-	t = GET_TILETYPE(tile);
+	t = TileType(tile);
 	if (t == MP_STATION) {
 		byte m5 = _map5[tile];
 		(bits = MKCOLOR(0x56565656), m5 < 8) ||			//   8 - railroad station (green)
@@ -469,7 +469,7 @@
 	int i,t;
 	uint32 bits;
 
-	t = GET_TILETYPE(tile);
+	t = TileType(tile);
 	if (t == MP_CLEAR) {
 		i = (_map5[tile] & 0x1F) - 4;
 		if (i >= 0) i = (i >> 2);
@@ -514,7 +514,7 @@
 {
 	int t;
 
-	t = GET_TILETYPE(tile);
+	t = TileType(tile);
 	if (t == MP_HOUSE || _map_owner[tile] == OWNER_TOWN) {
 		t = 0x80;
 	} else if (t == MP_INDUSTRY) {
--- a/station_cmd.c
+++ b/station_cmd.c
@@ -73,7 +73,7 @@
 {
 	// check around to see if there's any stations there
 	BEGIN_TILE_LOOP(tile_cur, w + 2, h + 2, tile - TILE_XY(1,1))
-		if (IS_TILETYPE(tile_cur, MP_STATION)) {
+		if (IsTileType(tile_cur, MP_STATION)) {
 			int t;
 			t = _map2[tile_cur];
 			{
@@ -118,7 +118,7 @@
 	uint t;
 
 	for (i = 0; i != MapSize(); i++) {
-		if (IS_TILETYPE(i, MP_STATION) && _map2[i] == station_index) {
+		if (IsTileType(i, MP_STATION) && _map2[i] == station_index) {
 			t = TileX(i);
 			if (t < x1) x1 = t;
 			if (t > x2) x2 = t;
@@ -180,7 +180,7 @@
 	for (p = _count_square_table; p != endof(_count_square_table); ++p) {
 		tile = TILE_MASK(tile + ToTileIndexDiff(*p));
 
-		if (IS_TILETYPE(tile, type) && _map5[tile] >= min && _map5[tile] <= max)
+		if (IsTileType(tile, type) && _map5[tile] >= min && _map5[tile] <= max)
 			num++;
 	}
 
@@ -435,7 +435,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[GET_TILETYPE(tile)]->get_produced_cargo_proc;
+				gpc = _tile_type_procs[TileType(tile)]->get_produced_cargo_proc;
 				if (gpc != NULL) {
 					cargos[0] = cargos[1] = 0xFF;
 					gpc(tile, cargos);
@@ -480,7 +480,7 @@
 		xc = x1;
 		do {
 			uint tile = TILE_XY(xc, yc);
-			if (!IS_TILETYPE(tile, MP_STATION)) {
+			if (!IsTileType(tile, MP_STATION)) {
 				AcceptedCargo ac;
 				int i;
 
@@ -647,7 +647,7 @@
 		// if station is set, then we have special handling to allow building on top of already existing stations.
 		// so station points to -1 if we can build on any station. or it points to a station if we're only allowed to build
 		// on exactly that station.
-		if ( (station != NULL) && IS_TILETYPE(tile_cur, MP_STATION)) {
+		if (station != NULL && IsTileType(tile_cur, MP_STATION)) {
 			if (_map5[tile_cur] >= 8) {
 				_error_message = ClearTile_Station(tile_cur, DC_AUTO); // get error message
 				return CMD_ERROR;
@@ -914,7 +914,7 @@
 
 static bool TileBelongsToRailStation(Station *st, uint tile)
 {
-	return IS_TILETYPE(tile, MP_STATION) && _map2[tile] == st->index && _map5[tile] < 8;
+	return IsTileType(tile, MP_STATION) && _map2[tile] == st->index && _map5[tile] < 8;
 }
 
 static void MakeRailwayStationAreaSmaller(Station *st)
@@ -965,7 +965,7 @@
 	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
 
 	// make sure the specified tile belongs to the current player, and that it is a railroad station.
-	if (!IS_TILETYPE(tile, MP_STATION) || _map5[tile] >= 8 || !_patches.nonuniform_stations) return CMD_ERROR;
+	if (!IsTileType(tile, MP_STATION) || _map5[tile] >= 8 || !_patches.nonuniform_stations) return CMD_ERROR;
 	st = GetStation(_map2[tile]);
 	if (_current_player != OWNER_WATER && (!CheckOwnership(st->owner) || !EnsureNoVehicle(tile))) return CMD_ERROR;
 
@@ -2174,7 +2174,7 @@
 }
 
 static inline bool IsTrainStationTile(uint tile) {
-	return IS_TILETYPE(tile, MP_STATION) && IS_BYTE_INSIDE(_map5[tile], 0, 8);
+	return IsTileType(tile, MP_STATION) && IS_BYTE_INSIDE(_map5[tile], 0, 8);
 }
 
 static const byte _enter_station_speedtable[12] = {
@@ -2530,7 +2530,7 @@
 
 	BEGIN_TILE_LOOP(cur_tile, w, h, tile - TILE_XY(max_rad,max_rad))
 		cur_tile = TILE_MASK(cur_tile);
-		if (IS_TILETYPE(cur_tile, MP_STATION)) {
+		if (IsTileType(cur_tile, MP_STATION)) {
 			st_index = _map2[cur_tile];
 			for(i=0; i!=8; i++)	{
 				if (around[i] == 0xFF) {
--- a/town_cmd.c
+++ b/town_cmd.c
@@ -207,7 +207,7 @@
 {
 	byte b;
 
-	assert(IS_TILETYPE(tile, MP_HOUSE));
+	assert(IsTileType(tile, MP_HOUSE));
 
 	b = _map5[tile];
 	if (b & 0x80)
@@ -515,7 +515,7 @@
 	}
 }
 
-#define IS_WATER_TILE(t) (IS_TILETYPE((t), MP_WATER) && _map5[(t)] == 0)
+#define IS_WATER_TILE(t) (IsTileType((t), MP_WATER) && _map5[(t)] == 0)
 
 static void GrowTownInTile(uint *tile_ptr, uint mask, int block, Town *t1)
 {
@@ -563,8 +563,8 @@
 				return;
 
 			// Return if neither side of the new road is a house
-			if (!IS_TILETYPE(TILE_ADD(tile, ToTileIndexDiff(_roadblock_tileadd[a + 1])), MP_HOUSE) &&
-					!IS_TILETYPE(TILE_ADD(tile, ToTileIndexDiff(_roadblock_tileadd[a + 3])), MP_HOUSE))
+			if (!IsTileType(TILE_ADD(tile, ToTileIndexDiff(_roadblock_tileadd[a + 1])), MP_HOUSE) &&
+					!IsTileType(TILE_ADD(tile, ToTileIndexDiff(_roadblock_tileadd[a + 3])), MP_HOUSE))
 				return;
 
 			// That means that the road is only allowed if there is a house
@@ -580,14 +580,14 @@
 	} else {
 
 		// Reached a tunnel? Then continue at the other side of it.
-		if (IS_TILETYPE(tile, MP_TUNNELBRIDGE) && (_map5[tile]&~3)==4) {
+		if (IsTileType(tile, MP_TUNNELBRIDGE) && (_map5[tile]& ~3) == 4) {
 			FindLengthOfTunnelResult flotr = FindLengthOfTunnel(tile, _map5[tile]&3);
 			*tile_ptr = flotr.tile;
 			return;
 		}
 
 		// For any other kind of tunnel/bridge, bail out.
-		if (IS_TILETYPE(tile, MP_TUNNELBRIDGE))
+		if (IsTileType(tile, MP_TUNNELBRIDGE))
 			return;
 
 		// Possibly extend the road in a direction.
@@ -614,7 +614,7 @@
 		//  always ok if no road allowed.
 		if (!IsRoadAllowedHere(tmptile, i) || CHANCE16(6,10)) {
 			// But not if there already is a house there.
-			if (!IS_TILETYPE(tmptile, MP_HOUSE)) {
+			if (!IsTileType(tmptile, MP_HOUSE)) {
 				// Level the land if possible
 				LevelTownLand(tmptile);
 
@@ -1223,7 +1223,7 @@
 			m5 = (r >> 16) & 0x3F;
 		}
 
-		assert(IS_TILETYPE(tile, MP_CLEAR));
+		assert(IsTileType(tile, MP_CLEAR));
 
 		ModifyTile(tile,
 			MP_SETTYPE(MP_HOUSE) | MP_MAP2 | MP_MAP3LO | MP_MAP3HI_CLEAR | MP_MAP5 | MP_MAPOWNER,
@@ -1236,7 +1236,7 @@
 		eflags = _housetype_extra_flags[house];
 
 		if (eflags&0x18) {
-			assert(IS_TILETYPE(tile + TILE_XY(0,1), MP_CLEAR));
+			assert(IsTileType(tile + TILE_XY(0,1), MP_CLEAR));
 			ModifyTile(tile + TILE_XY(0,1),
 				MP_SETTYPE(MP_HOUSE) | MP_MAP2 | MP_MAP3LO | MP_MAP3HI_CLEAR | MP_MAP5 | MP_MAPOWNER,
 				++house,	/* map2 */
@@ -1247,7 +1247,7 @@
 		}
 
 		if (eflags&0x14) {
-			assert(IS_TILETYPE(tile + TILE_XY(1,0), MP_CLEAR));
+			assert(IsTileType(tile + TILE_XY(1,0), MP_CLEAR));
 			ModifyTile(tile + TILE_XY(1,0),
 				MP_SETTYPE(MP_HOUSE) | MP_MAP2 | MP_MAP3LO | MP_MAP3HI_CLEAR | MP_MAP5 | MP_MAPOWNER,
 				++house,	/* map2 */
@@ -1258,7 +1258,7 @@
 		}
 
 		if (eflags&0x10) {
-			assert(IS_TILETYPE(tile + TILE_XY(1,1), MP_CLEAR));
+			assert(IsTileType(tile + TILE_XY(1,1), MP_CLEAR));
 			ModifyTile(tile + TILE_XY(1,1),
 				MP_SETTYPE(MP_HOUSE) | MP_MAP2 | MP_MAP3LO | MP_MAP3HI_CLEAR | MP_MAP5 | MP_MAPOWNER,
 				++house,	/* map2 */
@@ -1290,7 +1290,7 @@
 
 static void DoClearTownHouseHelper(uint tile)
 {
-	assert(IS_TILETYPE(tile, MP_HOUSE));
+	assert(IsTileType(tile, MP_HOUSE));
 	DoClearSquare(tile);
 	DeleteAnimatedTile(tile);
 }
@@ -1299,7 +1299,7 @@
 	uint house = _map2[tile];
 	uint eflags;
 
-	assert(IS_TILETYPE(tile, MP_HOUSE));
+	assert(IsTileType(tile, MP_HOUSE));
 
 	// need to align the tile to point to the upper left corner of the house
 	if (house >= 3) { // house id 0,1,2 MUST be single tile houses, or this code breaks.
@@ -1395,11 +1395,11 @@
 	// Go through all tiles and delete those belonging to the town
 	tile = 0;
 	do {
-		if (IS_TILETYPE(tile, MP_HOUSE)) {
+		if (IsTileType(tile, MP_HOUSE)) {
 			if (ClosestTownFromTile(tile, (uint)-1) == t) {
 				DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
 			}
-		} else if (IS_TILETYPE(tile, MP_TUNNELBRIDGE) || IS_TILETYPE(tile, MP_STREET)) {
+		} else if (IsTileType(tile, MP_TUNNELBRIDGE) || IsTileType(tile, MP_STREET)) {
 			if (_map_owner[tile] == OWNER_TOWN && ClosestTownFromTile(tile, (uint)-1) == t) {
 				DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
 			}
@@ -1656,7 +1656,7 @@
 	}
 
 	if (_opt.landscape == LT_HILLY) {
- 		if (GET_TILEHEIGHT(t->xy) >= _opt.snow_line && t->act_food == 0 && t->population > 90)
+ 		if (TileHeight(t->xy) >= _opt.snow_line && t->act_food == 0 && t->population > 90)
 			return;
 	} else if (_opt.landscape == LT_DESERT) {
  		if (GetMapExtraBits(t->xy) == 1 && (t->act_food==0 || t->act_water==0) && t->population > 60)
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -487,13 +487,13 @@
 
 bool IsTrainDepotTile(TileIndex tile)
 {
-	return IS_TILETYPE(tile, MP_RAILWAY) &&
+	return IsTileType(tile, MP_RAILWAY) &&
 					(_map5[tile] & 0xFC) == 0xC0;
 }
 
 static bool IsTunnelTile(TileIndex tile)
 {
-	return IS_TILETYPE(tile, MP_TUNNELBRIDGE) &&
+	return IsTileType(tile, MP_TUNNELBRIDGE) &&
 				 (_map5[tile]&0x80) == 0;
 }
 
@@ -983,7 +983,7 @@
 		/* Calculate next tile */
 		tile += TileOffsByDir(t);
 		/* Test if we have a rail/road-crossing */
-		if (IS_TILETYPE(tile, MP_STREET) && (_map5[tile] & 0xF0)==0x10) {
+		if (IsTileType(tile, MP_STREET) && (_map5[tile] & 0xF0) == 0x10) {
 			/* Check if there is a train on the tile itself */
 			if (VehicleFromPos(tile, &tile, TestTrainOnCrossing) == NULL) {
 				/* If light is on, switch light off */
@@ -1119,7 +1119,7 @@
 
 static bool TrainFindDepotEnumProc(uint tile, TrainFindDepotData *tfdd, int track, uint length, byte *state)
 {
-	if (IS_TILETYPE(tile, MP_RAILWAY) && _map_owner[tile] == tfdd->owner) {
+	if (IsTileType(tile, MP_RAILWAY) && _map_owner[tile] == tfdd->owner) {
 		if ((_map5[tile] & ~0x3) == 0xC0) {
 			if (length < tfdd->best_length) {
 				tfdd->best_length = length;
@@ -1357,7 +1357,7 @@
 } TrainTrackFollowerData;
 
 static bool TrainTrackFollower(uint tile, TrainTrackFollowerData *ttfd, int track, uint length, byte *state){
-	if (IS_TILETYPE(tile, MP_RAILWAY) && (_map5[tile]&0xC0) == 0x40) {
+	if (IsTileType(tile, MP_RAILWAY) && (_map5[tile]&0xC0) == 0x40) {
 		// the tile has a signal
 		byte m3 = _map3_lo[tile];
 		if (!(m3 & _signal_onedir[track])) {
@@ -1380,7 +1380,7 @@
 
 	// did we reach the final station?
  if ((ttfd->station_index == -1 && tile == ttfd->dest_coords) ||
-  (IS_TILETYPE(tile, MP_STATION) && IS_BYTE_INSIDE(_map5[tile], 0, 8) && _map2[tile] == ttfd->station_index)) {
+  (IsTileType(tile, MP_STATION) && IS_BYTE_INSIDE(_map5[tile], 0, 8) && _map2[tile] == ttfd->station_index)) {
   /* We do not check for dest_coords if we have a station_index,
    * because in that case the dest_coords are just an
    * approximation of where the station is */
@@ -1895,9 +1895,9 @@
 /* Check if the vehicle is compatible with the specified tile */
 static bool CheckCompatibleRail(Vehicle *v, uint tile)
 {
-	if (IS_TILETYPE(tile, MP_RAILWAY) || IS_TILETYPE(tile, MP_STATION)) {
+	if (IsTileType(tile, MP_RAILWAY) || IsTileType(tile, MP_STATION)) {
 		// normal tracks, jump to owner check
-	} else if (IS_TILETYPE(tile, MP_TUNNELBRIDGE)) {
+	} else if (IsTileType(tile, MP_TUNNELBRIDGE)) {
 		if ((_map5[tile] & 0xC0) == 0xC0) {// is bridge middle part?
 			TileInfo ti;
 			FindLandscapeHeightByTile(&ti, tile);
@@ -1909,7 +1909,7 @@
 			if(v->z_pos != ti.z) // train is going over bridge
 				return true;
 		}
-	} else if (IS_TILETYPE(tile, MP_STREET)) { // train is going over a road-crossing
+	} else if (IsTileType(tile, MP_STREET)) { // train is going over a road-crossing
 		// tracks over roads, do owner check of tracks (_map_owner[tile])
 		if (_map_owner[tile] != v->owner || (v->subtype == 0 && (_map3_hi[tile] & 0xF) != v->u.rail.railtype))
 			return false;
@@ -1977,7 +1977,7 @@
 static void TrainMovedChangeSignals(uint tile, int dir)
 {
 	int i;
-	if (IS_TILETYPE(tile, MP_RAILWAY) && (_map5[tile]&0xC0)==0x40) {
+	if (IsTileType(tile, MP_RAILWAY) && (_map5[tile] & 0xC0) == 0x40) {
 		i = FindFirstBit2x64((_map5[tile]+(_map5[tile]<<8)) & _reachable_tracks[dir]);
 		UpdateSignalsOnSegment(tile, _otherside_signal_directions[i]);
 	}
@@ -2215,7 +2215,7 @@
 			/* in tunnel */
 			GetNewVehiclePos(v, &gp);
 
-			if (IS_TILETYPE(gp.new_tile, MP_TUNNELBRIDGE) &&
+			if (IsTileType(gp.new_tile, MP_TUNNELBRIDGE) &&
 					!(_map5[gp.new_tile] & 0xF0)) {
 				r = VehicleEnterTile(v, gp.new_tile, gp.x, gp.y);
 				if (r & 0x4) goto common;
@@ -2443,14 +2443,14 @@
 	tile = v->tile;
 
 	// tunnel entrance?
-	if (IS_TILETYPE(tile, MP_TUNNELBRIDGE) &&
+	if (IsTileType(tile, MP_TUNNELBRIDGE) &&
 			(_map5[tile] & 0xF0) == 0 && (byte)((_map5[tile] & 3)*2+1) == v->direction)
 				return true;
 
 	// depot?
 	/* XXX -- When enabled, this makes it possible to crash trains of others
 	     (by building a depot right against a station) */
-/*	if (IS_TILETYPE(tile, MP_RAILWAY) && (_map5[tile] & 0xFC) == 0xC0)
+/*	if (IsTileType(tile, MP_RAILWAY) && (_map5[tile] & 0xFC) == 0xC0)
 		return true;*/
 
 	/* Determine the non-diagonal direction in which we will exit this tile */
@@ -2500,7 +2500,7 @@
 		}
 		if ((ts &= (ts >> 16)) == 0) {
 			// make a rail/road crossing red
-			if (IS_TILETYPE(tile, MP_STREET) && (_map5[tile] & 0xF0)==0x10) {
+			if (IsTileType(tile, MP_STREET) && (_map5[tile] & 0xF0) == 0x10) {
 				if (!(_map5[tile] & 4)) {
 					_map5[tile] |= 4;
 					SndPlayVehicleFx(SND_0E_LEVEL_CROSSING, v);
--- a/tree_cmd.c
+++ b/tree_cmd.c
@@ -81,7 +81,7 @@
 
 		/* Only on tiles within 13 squares from tile,
 		    on clear tiles, and NOT on farm-tiles or rocks */
-		if (dist <= 13 && IS_TILETYPE(cur_tile, MP_CLEAR) &&
+		if (dist <= 13 && IsTileType(cur_tile, MP_CLEAR) &&
 			 (_map5[cur_tile] & 0x1F) != 0x0F && (_map5[cur_tile] & 0x1C) != 8) {
 			PlaceTree(cur_tile, r, dist <= 6 ? 0xC0 : 0);
 		}
@@ -107,7 +107,7 @@
 		r = Random();
 		tile = TILE_MASK(r);
 		/* Only on clear tiles, and NOT on farm-tiles or rocks */
-		if (IS_TILETYPE(tile, MP_CLEAR) && (_map5[tile] & 0x1F) != 0x0F && (_map5[tile] & 0x1C) != 8) {
+		if (IsTileType(tile, MP_CLEAR) && (_map5[tile] & 0x1F) != 0x0F && (_map5[tile] & 0x1C) != 8) {
 			PlaceTree(tile, r, 0);
 		}
 	} while (--i);
@@ -119,7 +119,7 @@
 		do {
 			r = Random();
 			tile = TILE_MASK(r);
-			if (IS_TILETYPE(tile, MP_CLEAR) && GetMapExtraBits(tile) == 2) {
+			if (IsTileType(tile, MP_CLEAR) && GetMapExtraBits(tile) == 2) {
 				PlaceTree(tile, r, 0);
 			}
 		} while (--i);
@@ -516,7 +516,7 @@
 
 				tile += ToTileIndexDiff(_tileloop_trees_dir[Random() & 7]);
 
-				if (!IS_TILETYPE(tile, MP_CLEAR))
+				if (!IsTileType(tile, MP_CLEAR))
 					return;
 
 				if ( (_map5[tile] & 0x1C) == 4) {
@@ -579,7 +579,7 @@
 	/* place a tree at a random rainforest spot */
 	if (_opt.landscape == LT_DESERT &&
 			(r=Random(),tile=TILE_MASK(r),GetMapExtraBits(tile)==2) &&
-			IS_TILETYPE(tile, MP_CLEAR) &&
+			IsTileType(tile, MP_CLEAR) &&
 			(m=_map5[tile]&0x1C, m<=4) &&
 			(tree=GetRandomTreeType(tile, r>>24)) >= 0) {
 
@@ -600,7 +600,7 @@
 	/* place a tree at a random spot */
 	r = Random();
 	tile = TILE_MASK(r);
-	if (IS_TILETYPE(tile, MP_CLEAR) &&
+	if (IsTileType(tile, MP_CLEAR) &&
 			(m=_map5[tile]&0x1C, m==0 || m==4 || m==0x10) &&
 			(tree=GetRandomTreeType(tile, r>>24)) >= 0) {
 		int m2;
--- a/ttd.c
+++ b/ttd.c
@@ -1193,13 +1193,13 @@
 	uint tile;
 
 	for (tile = 0; tile != MapSize(); tile++) {
-		if (IS_TILETYPE(tile, MP_STREET)) {
+		if (IsTileType(tile, MP_STREET)) {
 			if ((_map5[tile] & 0xF0) == 0x10 && _map3_lo[tile] & 0x80)
 				_map3_lo[tile] = OWNER_TOWN;
 
 			if (_map_owner[tile] & 0x80)
 				_map_owner[tile] = OWNER_TOWN;
-		} else if (IS_TILETYPE(tile, MP_TUNNELBRIDGE)) {
+		} else if (IsTileType(tile, MP_TUNNELBRIDGE)) {
 			if (_map_owner[tile] & 0x80)
 				_map_owner[tile] = OWNER_TOWN;
 		}
@@ -1292,7 +1292,7 @@
 		uint h = MapSizeY();
 
 		BEGIN_TILE_LOOP(tile_cur, w, h, tile)
-			if (IS_TILETYPE(tile_cur, MP_WATER) && _map_owner[tile_cur] >= MAX_PLAYERS)
+			if (IsTileType(tile_cur, MP_WATER) && _map_owner[tile_cur] >= MAX_PLAYERS)
 				_map_owner[tile_cur] = OWNER_WATER;
 		END_TILE_LOOP(tile_cur, w, h, tile)
 	}
--- a/tunnelbridge_cmd.c
+++ b/tunnelbridge_cmd.c
@@ -593,7 +593,15 @@
 	uint starttile = tile;
 	Vehicle *v;
 
-	do { tile += delta; len++; } while (!IS_TILETYPE(tile, MP_TUNNELBRIDGE) || _map5[tile]&0xF0 || (byte)(_map5[tile] ^ 2) != m5 || GetTileZ(tile) != z);
+	do {
+		tile += delta;
+		len++;
+	} while (
+		!IsTileType(tile, MP_TUNNELBRIDGE) ||
+		(_map5[tile] & 0xF0) != 0 ||
+		(byte)(_map5[tile] ^ 2) != m5 ||
+		GetTileZ(tile) != z
+	);
 
 	if ((v=FindVehicleBetween(starttile, tile, z)) != NULL) {
 		_error_message = v->type == VEH_Train ? STR_5000_TRAIN_IN_TUNNEL : STR_5001_ROAD_VEHICLE_IN_TUNNEL;
@@ -655,7 +663,7 @@
 
 	// find start of bridge
 	for(;;) {
-		if (IS_TILETYPE(tile, MP_TUNNELBRIDGE) && (_map5[tile] & 0xE0) == 0x80)
+		if (IsTileType(tile, MP_TUNNELBRIDGE) && (_map5[tile] & 0xE0) == 0x80)
 			break;
 		tile += direction ? TILE_XY(0,-1) : TILE_XY(-1,0);
 	}
@@ -664,7 +672,7 @@
 
 	// find end of bridge
 	for(;;) {
-		if (IS_TILETYPE(tile, MP_TUNNELBRIDGE) && (_map5[tile] & 0xE0) == 0xA0)
+		if (IsTileType(tile, MP_TUNNELBRIDGE) && (_map5[tile] & 0xE0) == 0xA0)
 			break;
 		tile += direction ? TILE_XY(0,1) : TILE_XY(1,0);
 	}
@@ -690,7 +698,7 @@
 		int32 cost;
 
 		// check if we own the tile below the bridge..
-		if (_current_player != OWNER_WATER && (!CheckTileOwnership(tile) || !EnsureNoVehicleZ(tile, GET_TILEHEIGHT(tile)) ))
+		if (_current_player != OWNER_WATER && (!CheckTileOwnership(tile) || !EnsureNoVehicleZ(tile, TileHeight(tile))))
 			return CMD_ERROR;
 
 		cost = (_map5[tile] & 8) ? _price.remove_road * 2 : _price.remove_rail;
@@ -703,11 +711,11 @@
 		return cost;
 
 	/* delete canal under bridge */
-	} else if(_map5[tile]==0xC8 && GET_TILEHEIGHT(tile)!=0) {
+	} else if(_map5[tile] == 0xC8 && TileHeight(tile) != 0) {
 		int32 cost;
 
 		// check for vehicles under bridge
-		if ( !EnsureNoVehicleZ(tile, GET_TILEHEIGHT(tile)) )
+		if (!EnsureNoVehicleZ(tile, TileHeight(tile)))
 			return CMD_ERROR;
 		cost = _price.clear_water;
 		if (flags & DC_EXEC) {
@@ -735,7 +743,7 @@
 	*/
 	tile		+= direction ? TILE_XY(0, 1) : TILE_XY( 1,0);
 	endtile	-= direction ? TILE_XY(0, 1) : TILE_XY( 1,0);
-	if ((v=FindVehicleBetween(tile, endtile, GET_TILEHEIGHT(tile) + 8)) != NULL) {
+	if ((v = FindVehicleBetween(tile, endtile, TileHeight(tile) + 8)) != NULL) {
 		VehicleInTheWayErrMsg(v);
 		return CMD_ERROR;
 	}
@@ -844,7 +852,7 @@
 	} else if ((_map5[tile] & 0xF8) == 0xE0) {
 		// bridge middle part with rail below
 		// only check for train under bridge
-		if (!CheckTileOwnership(tile) || !EnsureNoVehicleZ(tile, GET_TILEHEIGHT(tile)))
+		if (!CheckTileOwnership(tile) || !EnsureNoVehicleZ(tile, TileHeight(tile)))
 			return CMD_ERROR;
 
 		// tile is already of requested type?
@@ -912,7 +920,7 @@
 		z_correction += 8;
 
 	// return the height there (the height of the NORTH CORNER)
-	return GET_TILEHEIGHT(tile) + z_correction;
+	return TileHeight(tile) + z_correction;
 }
 
 static const byte _bridge_foundations[2][16] = {
--- a/unmovable_cmd.c
+++ b/unmovable_cmd.c
@@ -240,7 +240,7 @@
 
 	BEGIN_TILE_LOOP(tile, 9, 9, tile_s)
 		// already a radio tower here?
-		if (IS_TILETYPE(tile, MP_UNMOVABLE) && _map5[tile] == 0)
+		if (IsTileType(tile, MP_UNMOVABLE) && _map5[tile] == 0)
 			return false;
 	END_TILE_LOOP(tile, 9, 9, tile_s)
 	return true;
@@ -265,7 +265,7 @@
 		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) {
+		if (IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h >= 32) {
 			if(!checkRadioTowerNearby(tile))
 				continue;
 			_map_type_and_height[tile] |= MP_UNMOVABLE << 4;
@@ -296,7 +296,7 @@
 			if (--j == 0)
 				goto restart;
 			tile = TILE_MASK(tile + ToTileIndexDiff(_tile_add[dir]));
-		} while (!(IS_TILETYPE(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h <= 16));
+		} while (!(IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h <= 16));
 
 		assert(tile == TILE_MASK(tile));
 
--- a/vehicle.c
+++ b/vehicle.c
@@ -604,7 +604,7 @@
 		BeginVehicleMove(v);
 
 		tile = TILE_FROM_XY(v->x_pos, v->y_pos);
-		if (!IS_TILETYPE(tile, MP_INDUSTRY)) {
+		if (!IsTileType(tile, MP_INDUSTRY)) {
 			EndVehicleMove(v);
 			DeleteVehicle(v);
 			return;
@@ -1074,7 +1074,7 @@
 		SndPlayVehicleFx(SND_31_EXTRACT, v);
 
 		tile = TILE_FROM_XY(v->x_pos, v->y_pos);
-		if (IS_TILETYPE(tile, MP_INDUSTRY) &&
+		if (IsTileType(tile, MP_INDUSTRY) &&
 				_map5[tile]==0xA2) {
 			AddAnimatedTile(tile);
 		}
@@ -1642,13 +1642,13 @@
 uint32 VehicleEnterTile(Vehicle *v, uint tile, int x, int y)
 {
 	uint old_tile = v->tile;
-	uint32 result = _tile_type_procs[GET_TILETYPE(tile)]->vehicle_enter_tile_proc(v, tile, x, y);
+	uint32 result = _tile_type_procs[TileType(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[GET_TILETYPE(old_tile)]->vehicle_leave_tile_proc;
+		VehicleLeaveTileProc *proc = _tile_type_procs[TileType(old_tile)]->vehicle_leave_tile_proc;
 		if (proc != NULL)
 			proc(v, old_tile, x, y);
 	}
--- a/water_cmd.c
+++ b/water_cmd.c
@@ -13,7 +13,7 @@
 
 bool IsShipDepotTile(TileIndex tile)
 {
-	return IS_TILETYPE(tile, MP_WATER) &&	(_map5[tile]&~3) == 0x80;
+	return IsTileType(tile, MP_WATER) && (_map5[tile] & ~3) == 0x80;
 }
 
 static bool IsClearWaterTile(uint tile)
@@ -206,12 +206,12 @@
 			return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
 
 			// can't make water of water!
-			if (IS_TILETYPE(tile, MP_WATER)) {
+			if (IsTileType(tile, MP_WATER)) {
 				_error_message = STR_1007_ALREADY_BUILT;
 			} else {
 
 				/* is middle piece of a bridge? */
-				if (IS_TILETYPE(tile, MP_TUNNELBRIDGE) && _map5[tile] & 0x40) { /* build under bridge */
+				if (IsTileType(tile, MP_TUNNELBRIDGE) && _map5[tile] & 0x40) { /* build under bridge */
 					if(_map5[tile] & 0x20) { // transport route under bridge
 						_error_message = STR_5800_OBJECT_IN_THE_WAY;
 						ret = CMD_ERROR;
@@ -230,7 +230,7 @@
 
 				/* execute modifications */
 				if (flags & DC_EXEC) {
-					if(IS_TILETYPE(tile, MP_TUNNELBRIDGE)) {
+					if (IsTileType(tile, MP_TUNNELBRIDGE)) {
 						// change owner to OWNER_WATER and set land under bridge bit to water
 						ModifyTile(tile, MP_MAP5 | MP_MAPOWNER, OWNER_WATER, _map5[tile] | 0x08);
 					} else {
@@ -318,13 +318,13 @@
 static bool IsWateredTile(uint tile)
 {
 	byte m5 = _map5[tile];
-	if (IS_TILETYPE(tile, MP_WATER)) {
+	if (IsTileType(tile, MP_WATER)) {
 		return m5 != 1;
-	} else if (IS_TILETYPE(tile, MP_STATION)) {
+	} else if (IsTileType(tile, MP_STATION)) {
 		// returns true if it is a dock-station (m5 inside values is m5<75 all stations,
 		// 83<=m5<=114 new airports
 		return !(m5 < 75 || (m5 >= 83 && m5 <= 114));
-	} else if (IS_TILETYPE(tile, MP_TUNNELBRIDGE)) {
+	} else if (IsTileType(tile, MP_TUNNELBRIDGE)) {
 		return (m5 & 0xF8) == 0xC8;
 	} else
 		return false;
@@ -459,7 +459,7 @@
 
 static void GetTileDesc_Water(uint tile, TileDesc *td)
 {
-	if (_map5[tile] == 0 && GET_TILEHEIGHT(tile) == 0)
+	if (_map5[tile] == 0 && TileHeight(tile) == 0)
 		td->str = STR_3804_WATER;
 	else if (_map5[tile] == 0)
 		td->str = STR_LANDINFO_CANAL;
@@ -501,7 +501,7 @@
 				ModifyTile(tile, MP_SETTYPE(MP_WATER) | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR | MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR,OWNER_WATER,1);
 		}
 	} else {
-		if (IS_TILETYPE(tile, MP_TUNNELBRIDGE)) {
+		if (IsTileType(tile, MP_TUNNELBRIDGE)) {
 			byte m5 = _map5[tile];
 			if ( (m5&0xF8) == 0xC8 || (m5&0xF8) == 0xF0)
 				return;