(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
authortron
Thu, 06 Jan 2005 11:39:00 +0000
changeset 909 65cdb609b7a6
parent 908 283e87112491
child 910 131e37201940
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
ai.c
aircraft_cmd.c
airport.c
airport.h
airport_movement.h
clear_cmd.c
disaster_cmd.c
industry_cmd.c
landscape.c
map.c
map.h
rail_gui.c
ship_cmd.c
station_cmd.c
table/ai_rail.h
table/build_industry.h
table/genland.h
town_cmd.c
tree_cmd.c
unmovable_cmd.c
water_cmd.c
--- a/ai.c	Thu Jan 06 08:08:17 2005 +0000
+++ b/ai.c	Thu Jan 06 11:39:00 2005 +0000
@@ -1534,7 +1534,7 @@
 	int rad;
 
 	for(;p->mode != 4;p++) if (p->mode == 1) {
-		tile2 = TILE_ADD(tile, p->tileoffs);
+		tile2 = TILE_ADD(tile, ToTileIndexDiff(p->tileoffs));
 
 		w = ((p->attr>>1) & 7);
 		h = ((p->attr>>4) & 7);
@@ -1573,7 +1573,7 @@
 
 	for(;;) {
 		// This will seldomly overflow for valid reasons. Mask it to be on the safe side.
-		uint c = TILE_MASK(tile + p->tileoffs);
+		uint c = TILE_MASK(tile + ToTileIndexDiff(p->tileoffs));
 
 		_cleared_town = NULL;
 
@@ -1822,7 +1822,7 @@
 
 	while (p->mode != 3 || !((--cmd) & 0x80)) p++;
 
-	return tile + p->tileoffs - TileOffsByDir(*dir = p->attr);
+	return tile + ToTileIndexDiff(p->tileoffs) - TileOffsByDir(*dir = p->attr);
 }
 
 typedef struct AiRailPathFindData {
@@ -2357,7 +2357,7 @@
 {
 	const AiDefaultBlockData *p = _default_rail_track_data[id]->data;
 	while (p->mode != 1) p++;
-	return _map2[TILE_ADD(tile,p->tileoffs)];
+	return _map2[TILE_ADD(tile, ToTileIndexDiff(p->tileoffs))];
 }
 
 static void AiStateBuildRailVeh(Player *p)
@@ -2373,7 +2373,7 @@
 	ptr = _default_rail_track_data[p->ai.src.cur_building_rule]->data;
 	while (ptr->mode != 0) {	ptr++; }
 
-	tile = TILE_ADD(p->ai.src.use_tile, ptr->tileoffs);
+	tile = TILE_ADD(p->ai.src.use_tile, ToTileIndexDiff(ptr->tileoffs));
 
 	cargo = p->ai.cargo_type;
 	for(i=0;;) {
@@ -2469,7 +2469,7 @@
 		if (aib->cur_building_rule != 255) {
 			b = _default_rail_track_data[aib->cur_building_rule]->data;
 			while (b->mode != 4) {
-				DoCommandByTile(TILE_ADD(aib->use_tile, b->tileoffs), 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
+				DoCommandByTile(TILE_ADD(aib->use_tile, ToTileIndexDiff(b->tileoffs)), 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
 				b++;
 			}
 		}
@@ -2493,7 +2493,7 @@
 		if (p->mode == 4) {
 			return true;
 		} else if (p->mode == 1) {
-			uint tile2 = TILE_ADD(tile, p->tileoffs);
+			uint tile2 = TILE_ADD(tile, ToTileIndexDiff(p->tileoffs));
 			if (cargo & 0x80) {
 				GetProductionAroundTiles(values, tile2, 1, 1, rad);
 				return values[cargo & 0x7F] != 0;
@@ -2536,7 +2536,7 @@
 	int roadflag = 0;
 
 	for(;p->mode != 4;p++) {
-		uint c = TILE_MASK(tile+ p->tileoffs);
+		uint c = TILE_MASK(tile + ToTileIndexDiff(p->tileoffs));
 
 		_cleared_town = NULL;
 
@@ -3085,7 +3085,7 @@
 	const AiDefaultBlockData *p = _road_default_block_data[rule]->data;
 	while (p->mode != 1) p++;
 	*dir = p->attr;
-	return TILE_ADD(tile, p->tileoffs);
+	return TILE_ADD(tile, ToTileIndexDiff(p->tileoffs));
 }
 
 
@@ -3158,7 +3158,7 @@
 {
 	const AiDefaultBlockData *p = _road_default_block_data[id]->data;
 	while (p->mode != 1) p++;
-	return _map2[TILE_ADD(tile, p->tileoffs)];
+	return _map2[TILE_ADD(tile, ToTileIndexDiff(p->tileoffs))];
 }
 
 static void AiStateBuildRoadVehicles(Player *p)
@@ -3170,7 +3170,7 @@
 
 	ptr = _road_default_block_data[p->ai.src.cur_building_rule]->data;
 	for(;ptr->mode != 0;ptr++) {}
-	tile = TILE_ADD(p->ai.src.use_tile, ptr->tileoffs);
+	tile = TILE_ADD(p->ai.src.use_tile, ToTileIndexDiff(ptr->tileoffs));
 
 	veh = AiChooseRoadVehToBuild(p->ai.cargo_type, p->player_money);
 	if (veh == -1) {
@@ -3227,7 +3227,7 @@
 			b = _road_default_block_data[aib->cur_building_rule]->data;
 			while (b->mode != 4) {
 				if (b->mode <= 1) {
-					DoCommandByTile(TILE_ADD(aib->use_tile, b->tileoffs), 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
+					DoCommandByTile(TILE_ADD(aib->use_tile, ToTileIndexDiff(b->tileoffs)), 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
 				}
 				b++;
 			}
@@ -3339,7 +3339,7 @@
 	for(;p->mode == 0;p++) {
 		if (!HASBIT(_avail_aircraft, p->attr))
 			return CMD_ERROR;
-		r = DoCommandByTile(TILE_MASK(tile + p->tileoffs), p->attr,0,flag | DC_AUTO | DC_NO_WATER,CMD_BUILD_AIRPORT);
+		r = DoCommandByTile(TILE_MASK(tile + ToTileIndexDiff(p->tileoffs)), p->attr,0,flag | DC_AUTO | DC_NO_WATER,CMD_BUILD_AIRPORT);
 		if (r == CMD_ERROR)
 			return CMD_ERROR;
 		total_cost += r;
@@ -3362,7 +3362,7 @@
 	}
 
 	for(;p->mode==0;p++) {
-		tile2 = TILE_ADD(tile, p->tileoffs);
+		tile2 = TILE_ADD(tile, ToTileIndexDiff(p->tileoffs));
 		w = _airport_size_x[p->attr];
 		h = _airport_size_y[p->attr];
 		if (cargo & 0x80) {
@@ -3479,7 +3479,7 @@
 {
 	const AiDefaultBlockData *p = _airport_default_block_data[id];
 	while (p->mode != 1) p++;
-	return _map2[TILE_ADD(tile, p->tileoffs)];
+	return _map2[TILE_ADD(tile, ToTileIndexDiff(p->tileoffs))];
 }
 
 static void AiStateBuildAircraftVehicles(Player *p)
@@ -3494,7 +3494,7 @@
 	ptr = _airport_default_block_data[p->ai.src.cur_building_rule];
 	for(;ptr->mode!=0;ptr++) {}
 
-	tile = TILE_ADD(p->ai.src.use_tile, ptr->tileoffs);
+	tile = TILE_ADD(p->ai.src.use_tile, ToTileIndexDiff(ptr->tileoffs));
 
 	veh = AiChooseAircraftToBuild(p->player_money, p->ai.build_kind!=0 ? 1 : 0);
 	if (veh == -1) {
--- a/aircraft_cmd.c	Thu Jan 06 08:08:17 2005 +0000
+++ b/aircraft_cmd.c	Thu Jan 06 11:39:00 2005 +0000
@@ -215,12 +215,12 @@
 		{
 			Station *st;
 			const AirportFTAClass *Airport;
-			const uint16 *cur_depot;
+			const TileIndexDiffC *cur_depot;
 			byte i = 0;
 			st = DEREF_STATION(_map2[tile]);
 			Airport = GetAirport(st->airport_type);
 			for (cur_depot = Airport->airport_depots; i != Airport->nof_depots; cur_depot++) {
-				if ((uint)(st->airport_tile + *cur_depot) == tile) {
+				if ((uint)(st->airport_tile + ToTileIndexDiff(*cur_depot)) == tile) {
 					assert(Airport->layout[i].heading == HANGAR);
 					v->u.air.pos = Airport->layout[i].position;
 					break;
--- a/airport.c	Thu Jan 06 08:08:17 2005 +0000
+++ b/airport.c	Thu Jan 06 11:39:00 2005 +0000
@@ -14,7 +14,7 @@
 																				const byte nofhelipads,  const byte nofhelipadgroups,
 																				const byte entry_point,  const byte acc_planes,
 																				const AirportFTAbuildup *FA,
-																				const TileIndex *depots, const byte nof_depots);
+																				const TileIndexDiffC *depots, const byte nof_depots);
 static void AirportFTAClass_Destructor(AirportFTAClass *Airport);
 
 static uint16 AirportGetNofElements(const AirportFTAbuildup *FA);
@@ -61,7 +61,7 @@
 																				const byte nofhelipads, const byte nofhelipadgroups,
 																				const byte entry_point, const byte acc_planes,
 																				const AirportFTAbuildup *FA,
-																				const TileIndex *depots, const byte nof_depots)
+																				const TileIndexDiffC *depots, const byte nof_depots)
 {
 	// if there are more terminals than 6, internal variables have to be changed, so don't allow that
 	// same goes for helipads
--- a/airport.h	Thu Jan 06 08:08:17 2005 +0000
+++ b/airport.h	Thu Jan 06 11:39:00 2005 +0000
@@ -32,7 +32,7 @@
 	byte nofhelipadgroups;				// helipads belong to so many groups (MAX is the nofhelipads)
 	byte entry_point;							// when an airplane arrives at this airport, enter it at position entry_point
 	byte acc_planes;							// accept airplanes or helicopters or both
-	const TileIndex *airport_depots;	// gives the position of the depots on the airports
+	const TileIndexDiffC *airport_depots;	// gives the position of the depots on the airports
 	byte nof_depots;							// number of depots this airport has
 	struct AirportFTA *layout;		// state machine for airport
 } AirportFTAClass;
--- a/airport_movement.h	Thu Jan 06 08:08:17 2005 +0000
+++ b/airport_movement.h	Thu Jan 06 11:39:00 2005 +0000
@@ -263,7 +263,7 @@
 /////**********Movement Machine on Airports*********************///////
 // first element of depots array tells us how many depots there are (to know size of array)
 // this may be changed later when airports are moved to external file
-static const TileIndex _airport_depots_country[] = {TILE_XY(3,0)};
+static const TileIndexDiffC _airport_depots_country[] = {{3, 0}};
 static const AirportFTAbuildup _airport_fta_country[] = {
 	{ 0,HANGAR,NOTHING_block,1},
 	{ 1,255,AIRPORT_BUSY_block,0}, {1,HANGAR,0,0}, {1,TERM1,TERM1_block,2}, {1,TERM2,0,4}, {1,HELITAKEOFF,0,19}, {1,0,0,6},
@@ -293,7 +293,7 @@
 	{MAX_ELEMENTS,0,0,0} // end marker. DO NOT REMOVE
 };
 
-static const TileIndex _airport_depots_city[] = {TILE_XY(5,0)};
+static const TileIndexDiffC _airport_depots_city[] = {{5, 0}};
 static const AirportFTAbuildup _airport_fta_city[] = {
 	{ 0,HANGAR,NOTHING_block,1}, {0,TAKEOFF,OUT_WAY_block,1}, {0,0,0,1},
 	{ 1,255,TAXIWAY_BUSY_block,0}, {1,HANGAR,0,0}, {1,TERM2,0,6}, {1,TERM3,0,6}, {1,0,0,7}, // for all else, go to 7
@@ -327,7 +327,7 @@
 	{MAX_ELEMENTS,0,0,0} // end marker. DO NOT REMOVE
 };
 
-static const TileIndex _airport_depots_metropolitan[] = {TILE_XY(5,0)};
+static const TileIndexDiffC _airport_depots_metropolitan[] = {{5, 0}};
 static const AirportFTAbuildup _airport_fta_metropolitan[] = {
 	{ 0,HANGAR,NOTHING_block,1},
 	{ 1,255,TAXIWAY_BUSY_block,0}, {1,HANGAR,0,0}, {1,TERM2,0,6}, {1,TERM3,0,6}, {1,0,0,7}, // for all else, go to 7
@@ -363,7 +363,7 @@
 	{MAX_ELEMENTS,0,0,0} // end marker. DO NOT REMOVE
 };
 
-static const TileIndex _airport_depots_international[] = {TILE_XY(0,3), TILE_XY(6,1)};
+static const TileIndexDiffC _airport_depots_international[] = {{0, 3}, {6, 1}};
 static const AirportFTAbuildup _airport_fta_international[] = {
 	{ 0,HANGAR,NOTHING_block,2}, {0,255,TERM_GROUP1_block,0}, {0,255,TERM_GROUP2_ENTER1_block,1}, {0,HELITAKEOFF,HELIPAD1_block,2}, {0,0,0,2},
 	{ 1,HANGAR,NOTHING_block,3}, {1,255,HANGAR2_AREA_block,1}, {1,HELITAKEOFF,HELIPAD2_block,3}, {1,0,0,3},
--- a/clear_cmd.c	Thu Jan 06 08:08:17 2005 +0000
+++ b/clear_cmd.c	Thu Jan 06 11:39:00 2005 +0000
@@ -186,12 +186,17 @@
 
 	{
 		int direction = ts->direction, r;
-		const TileIndexDiff *ttm;
+		const TileIndexDiffC *ttm;
 
-		static const TileIndexDiff _terraform_tilepos[5] = {TILE_XY(1,0), TILE_XY(-2,0), TILE_XY(1,1), TILE_XY(0,-2), 0 };
+		static const TileIndexDiffC _terraform_tilepos[] = {
+			{ 1,  0},
+			{-2,  0},
+			{ 1,  1},
+			{ 0, -2}
+		};
 
-		for(ttm = _terraform_tilepos; *ttm != 0; ttm++) {
-			tile += *ttm;
+		for(ttm = _terraform_tilepos; ttm != endof(_terraform_tilepos); ttm++) {
+			tile += ToTileIndexDiff(*ttm);
 
 			r = TerraformGetHeightOfTile(ts, tile);
 			if (r != height && r-direction != height && r+direction != height) {
--- a/disaster_cmd.c	Thu Jan 06 08:08:17 2005 +0000
+++ b/disaster_cmd.c	Thu Jan 06 11:39:00 2005 +0000
@@ -909,7 +909,7 @@
 
 				{
 					uint tile = i->xy;
-					int step = TileOffsByDir(Random() & 3);
+					TileIndexDiff step = TileOffsByDir(Random() & 3);
 					int count = 30;
 					do {
 						DisasterClearSquare(tile);
--- a/industry_cmd.c	Thu Jan 06 08:08:17 2005 +0000
+++ b/industry_cmd.c	Thu Jan 06 11:39:00 2005 +0000
@@ -49,7 +49,7 @@
 
 
 typedef struct IndustryTileTable {
-	TileIndexDiff ti;
+	TileIndexDiffC ti;
 	byte map5;
 } IndustryTileTable;
 
@@ -982,7 +982,12 @@
 
 static void ChopLumberMillTrees(Industry *i)
 {
-	static const TileIndexDiff _chop_dir[4] = { TILE_XY(0,1), TILE_XY(1,0), TILE_XY(0,-1), TILE_XY(-1,0) };
+	static const TileIndexDiffC _chop_dir[] = {
+		{ 0,  1},
+		{ 1,  0},
+		{ 0, -1},
+		{-1,  0}
+	};
 
 	uint tile = i->xy;
 	int dir, a, j;
@@ -1013,7 +1018,7 @@
 					_current_player = old_player;
 					return;
 				}
-				tile += _chop_dir[dir];
+				tile += ToTileIndexDiff(_chop_dir[dir]);
 			} while (--j);
 		}
 		tile -= TILE_XY(1,1);
@@ -1280,7 +1285,7 @@
 	_error_message = STR_0239_SITE_UNSUITABLE;
 
 	do {
-		cur_tile = tile + it->ti;
+		cur_tile = tile + ToTileIndexDiff(it->ti);
 		if (!IsValidTile(cur_tile)) {
 			if (it->map5 == 0xff)
 				continue;
@@ -1353,7 +1358,7 @@
 				}
 			}
 		}
-	} while ( (++it)->ti != -0x8000);
+	} while ((++it)->ti.x != -0x80);
 
 	return true;
 }
@@ -1456,14 +1461,14 @@
 	i->prod_level = 0x10;
 
 	do {
-		cur_tile = tile + it->ti;
+		cur_tile = tile + ToTileIndexDiff(it->ti);
 
 		if (it->map5 != 0xFF) {
 			byte size;
 
-			size = GET_TILE_X((TileIndex)it->ti);
+			size = it->ti.x;
 			if (size > i->width) i->width = size;
-			size = GET_TILE_Y((TileIndex)it->ti);
+			size = it->ti.y;
 			if (size > i->height)i->height = size;
 
 			DoCommandByTile(cur_tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
@@ -1473,7 +1478,7 @@
 			_map2[cur_tile] = i - _industries;
 			_map_owner[cur_tile] = _generating_world ? 0x1E : 0; /* maturity */
 		}
-	} while ( (++it)->ti != -0x8000);
+	} while ((++it)->ti.x != -0x80);
 
 	i->width++;
 	i->height++;
--- a/landscape.c	Thu Jan 06 08:08:17 2005 +0000
+++ b/landscape.c	Thu Jan 06 11:39:00 2005 +0000
@@ -631,35 +631,32 @@
 static void CreateDesertOrRainForest()
 {
 	uint tile;
-	const TileIndexDiff *data;
+	const TileIndexDiffC *data;
 	byte mt;
 	int i;
 
-	tile = 0;
-	do {
-		data = _make_desert_or_rainforest_data;
-		do {
-			if ((i = *data++) == MDORD_LAST) {
-				SetMapExtraBits(tile, 1);
-				break;
-			}
-			mt = _map_type_and_height[TILE_MASK(tile + i)];
-		} while ((mt & 0xC) == 0 && (mt >> 4) != MP_WATER);
-	} while (++tile != MapSize());
+	for (tile = 0; tile != MapSize(); ++tile) {
+		for (data = _make_desert_or_rainforest_data;
+				data != endof(_make_desert_or_rainforest_data); ++data) {
+			mt = _map_type_and_height[TILE_MASK(tile + ToTileIndexDiff(*data))];
+			if ((mt & 0xf) >= 4 || (mt >> 4) == MP_WATER) break;
+		}
+		if (data == endof(_make_desert_or_rainforest_data))
+			SetMapExtraBits(tile, 1);
+	}
 
 	for(i=0; i!=256; i++)
 		RunTileLoop();
 
-	tile = 0;
-	do {
-		data = _make_desert_or_rainforest_data;
-		do {
-			if ((i = *data++) == MDORD_LAST) {
-				SetMapExtraBits(tile, 2);
-				break;
-			}
-		} while ( !IS_TILETYPE(TILE_MASK(tile+i), MP_CLEAR) || (_map5[TILE_MASK(tile + i)]&0x1C) != 0x14);
-	} while (++tile != MapSize());
+	for (tile = 0; tile != MapSize(); ++tile) {
+		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 (data == endof(_make_desert_or_rainforest_data))
+			SetMapExtraBits(tile, 2);
+	}
 }
 
 void GenerateLandscape()
--- a/map.c	Thu Jan 06 08:08:17 2005 +0000
+++ b/map.c	Thu Jan 06 11:39:00 2005 +0000
@@ -15,9 +15,9 @@
 uint16 _map2                [MAP_SIZE];
 byte   _map_extra_bits      [MAP_SIZE / 4];
 
-const TileIndexDiff _tileoffs_by_dir[4] = {
-	TILE_XY(-1, 0),
-	TILE_XY(0, 1),
-	TILE_XY(1, 0),
-	TILE_XY(0, -1),
+const TileIndexDiffC _tileoffs_by_dir[] = {
+	{-1,  0},
+	{ 0,  1},
+	{ 1,  0},
+	{ 0, -1}
 };
--- a/map.h	Thu Jan 06 08:08:17 2005 +0000
+++ b/map.h	Thu Jan 06 11:39:00 2005 +0000
@@ -26,13 +26,22 @@
 
 typedef int16 TileIndexDiff;
 
+typedef struct TileIndexDiffC {
+	int16 x;
+	int16 y;
+} TileIndexDiffC;
+
+static inline TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc)
+{
+	return (tidc.y << MapLogX()) + tidc.x;
+}
 
 static inline TileIndexDiff TileOffsByDir(uint dir)
 {
-	extern const TileIndexDiff _tileoffs_by_dir[4];
+	extern const TileIndexDiffC _tileoffs_by_dir[4];
 
 	assert(dir < lengthof(_tileoffs_by_dir));
-	return _tileoffs_by_dir[dir];
+	return ToTileIndexDiff(_tileoffs_by_dir[dir]);
 }
 
 #endif
--- a/rail_gui.c	Thu Jan 06 08:08:17 2005 +0000
+++ b/rail_gui.c	Thu Jan 06 11:39:00 2005 +0000
@@ -385,14 +385,14 @@
 	// get the rail in each direction
 	tile = TILE_FROM_XY(x,y);
 	for(i=0; i!=5; i++) {
-		static TileIndexDiff _tile_inc[5] = {
-			TILE_XY(-1, 0),
-			TILE_XY(0, 1) - TILE_XY(-1, 0),
-			TILE_XY(1, 0) - TILE_XY(0, 1),
-			TILE_XY(0, -1) - TILE_XY(1, 0),
-			TILE_XY(0, 0) - TILE_XY(0, -1),
+		static const TileIndexDiffC _tile_inc[] = {
+			{-1     ,  0     },
+			{ 0 - -1,  1 -  0},
+			{ 1 -  0,  0 -  1},
+			{ 0 -  1, -1 -  0},
+			{ 0 -  0,  0 - -1}
 		};
-		tile += _tile_inc[i];
+		tile += ToTileIndexDiff(_tile_inc[i]);
 		m[i] = 0;
 		if (IS_TILETYPE(tile, MP_RAILWAY) && _map5[tile] < 0x80)
 			m[i] = _map5[tile]&0x3F;
--- a/ship_cmd.c	Thu Jan 06 08:08:17 2005 +0000
+++ b/ship_cmd.c	Thu Jan 06 11:39:00 2005 +0000
@@ -190,15 +190,15 @@
 	SndPlayVehicleFx(ShipVehInfo(v->engine_type)->sfx, v);
 }
 
-static const TileIndexDiff _dock_offs[] = {
-	TILE_XY(2, 0),
-	TILE_XY(-2, 0),
-	TILE_XY(0, 2),
-	TILE_XY(2, 0),
-	TILE_XY(0, -2),
-	TILE_XY(0,0),
-	TILE_XY(0,0),
-	TILE_XY(0,0),
+static const TileIndexDiffC _dock_offs[] = {
+	{ 2,  0},
+	{-2,  0},
+	{ 0,  2},
+	{ 2,  0},
+	{ 0, -2},
+	{ 0,  0},
+	{ 0,  0},
+	{ 0,  0}
 };
 
 static void ProcessShipOrder(Vehicle *v)
@@ -245,7 +245,7 @@
 
 		st = DEREF_STATION(order.station);
 		if (st->dock_tile != 0) {
-			v->dest_tile = TILE_ADD(st->dock_tile, _dock_offs[_map5[st->dock_tile]-0x4B]);
+			v->dest_tile = TILE_ADD(st->dock_tile, ToTileIndexDiff(_dock_offs[_map5[st->dock_tile]-0x4B]));
 		}
 	} else if (order.type == OT_GOTO_DEPOT) {
 		v->dest_tile = _depots[order.station].xy;
@@ -319,9 +319,9 @@
 	InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
 }
 
-static const TileIndexDiff _ship_leave_depot_offs[] = {
-	TILE_XY(-1,0),
-	TILE_XY(0,-1),
+static const TileIndexDiffC _ship_leave_depot_offs[] = {
+	{-1,  0},
+	{ 0, -1}
 };
 
 static void CheckShipLeaveDepot(Vehicle *v)
@@ -337,10 +337,10 @@
 	d = (_map5[tile]&2) ? 1 : 0;
 
 	// Check first side
-	if (_ship_sometracks[d] & GetTileShipTrackStatus(TILE_ADD(tile,_ship_leave_depot_offs[d]))) {
+	if (_ship_sometracks[d] & GetTileShipTrackStatus(TILE_ADD(tile, ToTileIndexDiff(_ship_leave_depot_offs[d])))) {
 		m = (d==0) ? 0x101 : 0x207;
 	// Check second side
-	} else if (_ship_sometracks[d+2] & GetTileShipTrackStatus(TILE_ADD(tile, -2*_ship_leave_depot_offs[d]))) {
+	} else if (_ship_sometracks[d+2] & GetTileShipTrackStatus(TILE_ADD(tile, -2 * ToTileIndexDiff(_ship_leave_depot_offs[d])))) {
 		m = (d==0) ? 0x105 : 0x203;
 	} else {
 		return;
--- a/station_cmd.c	Thu Jan 06 08:08:17 2005 +0000
+++ b/station_cmd.c	Thu Jan 06 11:39:00 2005 +0000
@@ -162,20 +162,20 @@
 
 
 static int CountMapSquareAround(uint tile, byte type, byte min, byte max) {
-	static const TileIndexDiff _count_square_table[7*7+1] = {
-		TILE_XY(-3,-3), 1, 1, 1, 1, 1, 1,
-		TILE_XY(-6,1),  1, 1, 1, 1, 1, 1,
-		TILE_XY(-6,1),  1, 1, 1, 1, 1, 1,
-		TILE_XY(-6,1),  1, 1, 1, 1, 1, 1,
-		TILE_XY(-6,1),  1, 1, 1, 1, 1, 1,
-		TILE_XY(-6,1),  1, 1, 1, 1, 1, 1,
-		TILE_XY(-6,1),  1, 1, 1, 1, 1, 1,
+	static const TileIndexDiffC _count_square_table[] = {
+		{-3, -3}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0},
+		{-6,  1}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0},
+		{-6,  1}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0},
+		{-6,  1}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0},
+		{-6,  1}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0},
+		{-6,  1}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0},
+		{-6,  1}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}
 	};
-	const TileIndexDiff *p;
+	const TileIndexDiffC *p;
 	int num = 0;
 
 	for (p = _count_square_table; p != endof(_count_square_table); ++p) {
-		tile = TILE_MASK(tile + *p);
+		tile = TILE_MASK(tile + ToTileIndexDiff(*p));
 
 		if (IS_TILETYPE(tile, type) && _map5[tile] >= min && _map5[tile] <= max)
 			num++;
@@ -1612,7 +1612,7 @@
 
 		st->owner = _current_player;
 		if (_current_player == _local_player && afc->nof_depots != 0) {
-      _last_built_aircraft_depot_tile = tile + afc->airport_depots[0];
+      _last_built_aircraft_depot_tile = tile + ToTileIndexDiff(afc->airport_depots[0]);
     }
 
 		st->airport_tile = tile;
@@ -1682,7 +1682,7 @@
 		uint i;
 
 		for (i = 0; i < afc->nof_depots; ++i)
-			DeleteWindowById(WC_VEHICLE_DEPOT, tile + afc->airport_depots[i]);
+			DeleteWindowById(WC_VEHICLE_DEPOT, tile + ToTileIndexDiff(afc->airport_depots[i]));
 
 		st->airport_tile = 0;
 		st->facilities &= ~FACIL_AIRPORT;
@@ -1779,10 +1779,11 @@
 	return _price.remove_truck_station;
 }
 
-static const TileIndexDiff _dock_tileoffs_chkaround[4] = {
-	TILE_XY(-1,0),
-	0,0,
-	TILE_XY(0,-1),
+static const TileIndexDiffC _dock_tileoffs_chkaround[] = {
+	{-1,  0},
+	{ 0,  0},
+	{ 0,  0},
+	{ 0, -1}
 };
 static const byte _dock_w_chk[4] = { 2,1,2,1 };
 static const byte _dock_h_chk[4] = { 1,2,1,2 };
@@ -1831,7 +1832,8 @@
 		return_cmd_error(STR_304B_SITE_UNSUITABLE);
 
 	/* middle */
-	st = GetStationAround(tile + _dock_tileoffs_chkaround[direction],
+	st = GetStationAround(
+		tile + ToTileIndexDiff(_dock_tileoffs_chkaround[direction]),
 		_dock_w_chk[direction], _dock_h_chk[direction], -1);
 	if (st == CHECK_STATIONS_ERR)
 		return CMD_ERROR;
--- a/table/ai_rail.h	Thu Jan 06 08:08:17 2005 +0000
+++ b/table/ai_rail.h	Thu Jan 06 11:39:00 2005 +0000
@@ -1,7 +1,7 @@
 typedef struct {
 	byte mode;
 	byte attr;
-	TileIndexDiff tileoffs;
+	TileIndexDiffC tileoffs;
 } AiDefaultBlockData;
 
 typedef struct {
@@ -20,303 +20,303 @@
 
 
 #define MKHDR(a,b,c,d,e) a,b,c,d,e,{
-#define MKDEPOT(a,b) {0,a,b}
-#define MKSTATION(a,b) {1,a,b}
-#define MKRAIL(a,b) {2,a,b}
-#define MKCLRRAIL(a,b) {3,a,b}
-#define MKEND {4, 0, 0}}
+#define MKDEPOT(a, b, c)   {0, a, {b, c}}
+#define MKSTATION(a, b, c) {1, a, {b, c}}
+#define MKRAIL(a, b, c)    {2, a, {b, c}}
+#define MKCLRRAIL(a, b, c) {3, a, {b, c}}
+#define MKEND              {4, 0, {0, 0}}}
 
 static const AiDefaultRailBlock _raildata_ai_0 = {
 	MKHDR(1,2,1,0,1)
-	MKDEPOT(2,TILE_XY(-1,1)),
-	MKSTATION(0x15,TILE_XY(0,-1)),
-	MKRAIL(0x26,TILE_XY(0,1)),
-	MKCLRRAIL(1,TILE_XY(0,2)),
+	MKDEPOT(2, -1,1),
+	MKSTATION(0x15, 0,-1),
+	MKRAIL(0x26, 0,1),
+	MKCLRRAIL(1, 0,2),
 	MKEND
 };
 
 static const AiDefaultRailBlock _raildata_ai_1 = {
 	MKHDR(1,2,1,0,3)
-	MKDEPOT(2,TILE_XY(-1,-1)),
-	MKRAIL(0x26,TILE_XY(0,-1)),
-	MKSTATION(0x15,TILE_XY(0,0)),
-	MKCLRRAIL(3,TILE_XY(0,-2)),
+	MKDEPOT(2, -1,-1),
+	MKRAIL(0x26, 0,-1),
+	MKSTATION(0x15, 0,0),
+	MKCLRRAIL(3, 0,-2),
 	MKEND
 };
 
 static const AiDefaultRailBlock _raildata_ai_2 = {
 	MKHDR(1,2,1,0,0)
-	MKDEPOT(1,TILE_XY(-1,-1)),
-	MKRAIL(0x15,TILE_XY(-1,0)),
-	MKSTATION(0x14,TILE_XY(0,0)),
-	MKCLRRAIL(0,TILE_XY(-2,0)),
+	MKDEPOT(1, -1,-1),
+	MKRAIL(0x15, -1,0),
+	MKSTATION(0x14, 0,0),
+	MKCLRRAIL(0, -2,0),
 	MKEND
 };
 
 static const AiDefaultRailBlock _raildata_ai_3 = {
 	MKHDR(1,2,1,0,2)
-	MKDEPOT(1,TILE_XY(1,-1)),
-	MKRAIL(0x15,TILE_XY(1,0)),
-	MKSTATION(0x14,TILE_XY(-1,0)),
-	MKCLRRAIL(2,TILE_XY(2,0)),
+	MKDEPOT(1, 1,-1),
+	MKRAIL(0x15, 1,0),
+	MKSTATION(0x14, -1,0),
+	MKCLRRAIL(2, 2,0),
 	MKEND
 };
 
 static const AiDefaultRailBlock _raildata_ai_4 = {
 	MKHDR(1,2,2,0,255)
-	MKSTATION(0x15,TILE_XY(0,0)),
-	MKCLRRAIL(3,TILE_XY(0,-1)),
-	MKCLRRAIL(1,TILE_XY(0,2)),
+	MKSTATION(0x15, 0,0),
+	MKCLRRAIL(3, 0,-1),
+	MKCLRRAIL(1, 0,2),
 	MKEND
 };
 
 static const AiDefaultRailBlock _raildata_ai_5 = {
 	MKHDR(1,2,2,0,255)
-	MKSTATION(0x14,TILE_XY(0,0)),
-	MKCLRRAIL(0,TILE_XY(-1,0)),
-	MKCLRRAIL(2,TILE_XY(2,0)),
+	MKSTATION(0x14, 0,0),
+	MKCLRRAIL(0, -1,0),
+	MKCLRRAIL(2, 2,0),
 	MKEND
 };
 
 static const AiDefaultRailBlock _raildata_ai_6 = {
 	MKHDR(2,3,1,0,1)
-	MKSTATION(0x27,TILE_XY(0,-2)),
-	MKRAIL(0xC2,TILE_XY(0,1)),
-	MKRAIL(0xC2,TILE_XY(1,1)),
-	MKRAIL(0x1A,TILE_XY(0,2)),
-	MKRAIL(0x26,TILE_XY(1,2)),
-	MKDEPOT(3,TILE_XY(1,3)),
-	MKCLRRAIL(1,TILE_XY(0,3)),
+	MKSTATION(0x27, 0,-2),
+	MKRAIL(0xC2, 0,1),
+	MKRAIL(0xC2, 1,1),
+	MKRAIL(0x1A, 0,2),
+	MKRAIL(0x26, 1,2),
+	MKDEPOT(3, 1,3),
+	MKCLRRAIL(1, 0,3),
 	MKEND
 };
 
 static const AiDefaultRailBlock _raildata_ai_7 = {
 	MKHDR(2,3,1,0,3)
-	MKDEPOT(1,TILE_XY(0,-3)),
-	MKRAIL(0x1A,TILE_XY(0,-2)),
-	MKRAIL(0x26,TILE_XY(1,-2)),
-	MKRAIL(0xC2,TILE_XY(0,-1)),
-	MKRAIL(0xC2,TILE_XY(1,-1)),
-	MKSTATION(0x27,TILE_XY(0,0)),
-	MKCLRRAIL(3,TILE_XY(1,-3)),
+	MKDEPOT(1, 0,-3),
+	MKRAIL(0x1A, 0,-2),
+	MKRAIL(0x26, 1,-2),
+	MKRAIL(0xC2, 0,-1),
+	MKRAIL(0xC2, 1,-1),
+	MKSTATION(0x27, 0,0),
+	MKCLRRAIL(3, 1,-3),
 	MKEND
 };
 
 static const AiDefaultRailBlock _raildata_ai_8 = {
 	MKHDR(2,3,1,0,2)
-	MKSTATION(0x26,TILE_XY(-2,0)),
-	MKRAIL(0xC1,TILE_XY(1,0)),
-	MKRAIL(0xC1,TILE_XY(1,1)),
-	MKRAIL(0x29,TILE_XY(2,0)),
-	MKRAIL(0x15,TILE_XY(2,1)),
-	MKDEPOT(0,TILE_XY(3,0)),
-	MKCLRRAIL(2,TILE_XY(3,1)),
+	MKSTATION(0x26, -2,0),
+	MKRAIL(0xC1, 1,0),
+	MKRAIL(0xC1, 1,1),
+	MKRAIL(0x29, 2,0),
+	MKRAIL(0x15, 2,1),
+	MKDEPOT(0, 3,0),
+	MKCLRRAIL(2, 3,1),
 	MKEND
 };
 
 static const AiDefaultRailBlock _raildata_ai_9 = {
 	MKHDR(2,3,1,0,0)
-	MKDEPOT(2,TILE_XY(-3,-1)),
-	MKRAIL(0x29,TILE_XY(-2,-1)),
-	MKRAIL(0x15,TILE_XY(-2,0)),
-	MKRAIL(0xC1,TILE_XY(-1,-1)),
-	MKRAIL(0xC1,TILE_XY(-1,0)),
-	MKSTATION(0x26,TILE_XY(0,-1)),
-	MKCLRRAIL(0,TILE_XY(-3,0)),
+	MKDEPOT(2, -3,-1),
+	MKRAIL(0x29, -2,-1),
+	MKRAIL(0x15, -2,0),
+	MKRAIL(0xC1, -1,-1),
+	MKRAIL(0xC1, -1,0),
+	MKSTATION(0x26, 0,-1),
+	MKCLRRAIL(0, -3,0),
 	MKEND
 };
 
 static const AiDefaultRailBlock _raildata_ai_10 = {
 	MKHDR(2,3,2,0,255)
-	MKRAIL(0x1A,TILE_XY(0,-3)),
-	MKRAIL(0x20,TILE_XY(1,-3)),
-	MKRAIL(0xC2,TILE_XY(0,-2)),
-	MKRAIL(0xC2,TILE_XY(1,-2)),
-	MKSTATION(0x27,TILE_XY(0,-1)),
-	MKRAIL(0xC2,TILE_XY(0,2)),
-	MKRAIL(0xC2,TILE_XY(1,2)),
-	MKRAIL(0x1A,TILE_XY(0,3)),
-	MKRAIL(0x4,TILE_XY(1,3)),
-	MKCLRRAIL(3,TILE_XY(0,-4)),
-	MKCLRRAIL(1,TILE_XY(0,4)),
+	MKRAIL(0x1A, 0,-3),
+	MKRAIL(0x20, 1,-3),
+	MKRAIL(0xC2, 0,-2),
+	MKRAIL(0xC2, 1,-2),
+	MKSTATION(0x27, 0,-1),
+	MKRAIL(0xC2, 0,2),
+	MKRAIL(0xC2, 1,2),
+	MKRAIL(0x1A, 0,3),
+	MKRAIL(0x4, 1,3),
+	MKCLRRAIL(3, 0,-4),
+	MKCLRRAIL(1, 0,4),
 	MKEND
 };
 
 static const AiDefaultRailBlock _raildata_ai_11 = {
 	MKHDR(2,3,2,0,255)
-	MKRAIL(0x29,TILE_XY(-3,0)),
-	MKRAIL(0x10,TILE_XY(-3,1)),
-	MKRAIL(0xC1,TILE_XY(-2,0)),
-	MKRAIL(0xC1,TILE_XY(-2,1)),
-	MKSTATION(0x26,TILE_XY(-1,0)),
-	MKRAIL(0xC1,TILE_XY(2,0)),
-	MKRAIL(0xC1,TILE_XY(2,1)),
-	MKRAIL(0x29,TILE_XY(3,0)),
-	MKRAIL(0x4,TILE_XY(3,1)),
-	MKCLRRAIL(0,TILE_XY(-4,0)),
-	MKCLRRAIL(2,TILE_XY(4,0)),
+	MKRAIL(0x29, -3,0),
+	MKRAIL(0x10, -3,1),
+	MKRAIL(0xC1, -2,0),
+	MKRAIL(0xC1, -2,1),
+	MKSTATION(0x26, -1,0),
+	MKRAIL(0xC1, 2,0),
+	MKRAIL(0xC1, 2,1),
+	MKRAIL(0x29, 3,0),
+	MKRAIL(0x4, 3,1),
+	MKCLRRAIL(0, -4,0),
+	MKCLRRAIL(2, 4,0),
 	MKEND
 };
 
 static const AiDefaultRailBlock _raildata_ai_12 = {
 	MKHDR(2,3,2,1,3)
-	MKRAIL(0x88,TILE_XY(-1,-3)),
-	MKRAIL(0x6,TILE_XY(0,-3)),
-	MKRAIL(0x2,TILE_XY(-1,-2)),
-	MKRAIL(0x42,TILE_XY(0,-2)),
-	MKRAIL(0x2,TILE_XY(-1,-1)),
-	MKRAIL(0x2,TILE_XY(0,-1)),
-	MKRAIL(0x2,TILE_XY(-1,0)),
-	MKRAIL(0x2,TILE_XY(0,0)),
-	MKRAIL(0x82,TILE_XY(-1,1)),
-	MKRAIL(0x2,TILE_XY(0,1)),
-	MKRAIL(0xA,TILE_XY(-1,2)),
-	MKRAIL(0x44,TILE_XY(0,2)),
-	MKCLRRAIL(3,TILE_XY(0,-4)),
-	MKCLRRAIL(1,TILE_XY(-1,3)),
+	MKRAIL(0x88, -1,-3),
+	MKRAIL(0x6, 0,-3),
+	MKRAIL(0x2, -1,-2),
+	MKRAIL(0x42, 0,-2),
+	MKRAIL(0x2, -1,-1),
+	MKRAIL(0x2, 0,-1),
+	MKRAIL(0x2, -1,0),
+	MKRAIL(0x2, 0,0),
+	MKRAIL(0x82, -1,1),
+	MKRAIL(0x2, 0,1),
+	MKRAIL(0xA, -1,2),
+	MKRAIL(0x44, 0,2),
+	MKCLRRAIL(3, 0,-4),
+	MKCLRRAIL(1, -1,3),
 	MKEND
 };
 
 static const AiDefaultRailBlock _raildata_ai_13 = {
 	MKHDR(2,3,2,1,0)
-	MKRAIL(0x21,TILE_XY(-3,0)),
-	MKRAIL(0x90,TILE_XY(-3,1)),
-	MKRAIL(0x81,TILE_XY(-2,0)),
-	MKRAIL(0x1,TILE_XY(-2,1)),
-	MKRAIL(0x1,TILE_XY(-1,0)),
-	MKRAIL(0x1,TILE_XY(-1,1)),
-	MKRAIL(0x1,TILE_XY(0,0)),
-	MKRAIL(0x1,TILE_XY(0,1)),
-	MKRAIL(0x1,TILE_XY(1,0)),
-	MKRAIL(0x41,TILE_XY(1,1)),
-	MKRAIL(0x60,TILE_XY(2,0)),
-	MKRAIL(0x11,TILE_XY(2,1)),
-	MKCLRRAIL(0,TILE_XY(-4,0)),
-	MKCLRRAIL(2,TILE_XY(3,1)),
+	MKRAIL(0x21, -3,0),
+	MKRAIL(0x90, -3,1),
+	MKRAIL(0x81, -2,0),
+	MKRAIL(0x1, -2,1),
+	MKRAIL(0x1, -1,0),
+	MKRAIL(0x1, -1,1),
+	MKRAIL(0x1, 0,0),
+	MKRAIL(0x1, 0,1),
+	MKRAIL(0x1, 1,0),
+	MKRAIL(0x41, 1,1),
+	MKRAIL(0x60, 2,0),
+	MKRAIL(0x11, 2,1),
+	MKCLRRAIL(0, -4,0),
+	MKCLRRAIL(2, 3,1),
 	MKEND
 };
 
 static const AiDefaultRailBlock _raildata_ai_14 = {
 	MKHDR(2,3,2,1,1)
-	MKRAIL(0x88,TILE_XY(-1,-3)),
-	MKRAIL(0x6,TILE_XY(0,-3)),
-	MKRAIL(0x2,TILE_XY(-1,-2)),
-	MKRAIL(0x42,TILE_XY(0,-2)),
-	MKRAIL(0x2,TILE_XY(-1,-1)),
-	MKRAIL(0x2,TILE_XY(0,-1)),
-	MKRAIL(0x2,TILE_XY(-1,0)),
-	MKRAIL(0x2,TILE_XY(0,0)),
-	MKRAIL(0x82,TILE_XY(-1,1)),
-	MKRAIL(0x2,TILE_XY(0,1)),
-	MKRAIL(0xA,TILE_XY(-1,2)),
-	MKRAIL(0x44,TILE_XY(0,2)),
-	MKCLRRAIL(1,TILE_XY(-1,3)),
-	MKCLRRAIL(3,TILE_XY(0,-4)),
+	MKRAIL(0x88, -1,-3),
+	MKRAIL(0x6, 0,-3),
+	MKRAIL(0x2, -1,-2),
+	MKRAIL(0x42, 0,-2),
+	MKRAIL(0x2, -1,-1),
+	MKRAIL(0x2, 0,-1),
+	MKRAIL(0x2, -1,0),
+	MKRAIL(0x2, 0,0),
+	MKRAIL(0x82, -1,1),
+	MKRAIL(0x2, 0,1),
+	MKRAIL(0xA, -1,2),
+	MKRAIL(0x44, 0,2),
+	MKCLRRAIL(1, -1,3),
+	MKCLRRAIL(3, 0,-4),
 	MKEND
 };
 
 static const AiDefaultRailBlock _raildata_ai_15 = {
 	MKHDR(2,3,2,1,2)
-	MKRAIL(0x21,TILE_XY(-3,0)),
-	MKRAIL(0x90,TILE_XY(-3,1)),
-	MKRAIL(0x81,TILE_XY(-2,0)),
-	MKRAIL(0x1,TILE_XY(-2,1)),
-	MKRAIL(0x1,TILE_XY(-1,0)),
-	MKRAIL(0x1,TILE_XY(-1,1)),
-	MKRAIL(0x1,TILE_XY(0,0)),
-	MKRAIL(0x1,TILE_XY(0,1)),
-	MKRAIL(0x1,TILE_XY(1,0)),
-	MKRAIL(0x41,TILE_XY(1,1)),
-	MKRAIL(0x60,TILE_XY(2,0)),
-	MKRAIL(0x11,TILE_XY(2,1)),
-	MKCLRRAIL(2,TILE_XY(3,1)),
-	MKCLRRAIL(0,TILE_XY(-4,0)),
+	MKRAIL(0x21, -3,0),
+	MKRAIL(0x90, -3,1),
+	MKRAIL(0x81, -2,0),
+	MKRAIL(0x1, -2,1),
+	MKRAIL(0x1, -1,0),
+	MKRAIL(0x1, -1,1),
+	MKRAIL(0x1, 0,0),
+	MKRAIL(0x1, 0,1),
+	MKRAIL(0x1, 1,0),
+	MKRAIL(0x41, 1,1),
+	MKRAIL(0x60, 2,0),
+	MKRAIL(0x11, 2,1),
+	MKCLRRAIL(2, 3,1),
+	MKCLRRAIL(0, -4,0),
 	MKEND
 };
 
 static const AiDefaultRailBlock _raildata_ai_16 = {
 	MKHDR(1,3,1,0,1)
-	MKSTATION(0x17,TILE_XY(0,-2)),
-	MKRAIL(0x1A,TILE_XY(0,1)),
-	MKCLRRAIL(1,TILE_XY(0,2)),
-	MKDEPOT(0,TILE_XY(1,1)),
+	MKSTATION(0x17, 0,-2),
+	MKRAIL(0x1A, 0,1),
+	MKCLRRAIL(1, 0,2),
+	MKDEPOT(0, 1,1),
 	MKEND
 };
 
 static const AiDefaultRailBlock _raildata_ai_17 = {
 	MKHDR(1,3,1,0,3)
-	MKCLRRAIL(3,TILE_XY(0,-2)),
-	MKRAIL(0x26,TILE_XY(0,-1)),
-	MKDEPOT(2,TILE_XY(-1,-1)),
-	MKSTATION(0x17,TILE_XY(0,0)),
+	MKCLRRAIL(3, 0,-2),
+	MKRAIL(0x26, 0,-1),
+	MKDEPOT(2, -1,-1),
+	MKSTATION(0x17, 0,0),
 	MKEND
 };
 
 static const AiDefaultRailBlock _raildata_ai_18 = {
 	MKHDR(1,3,1,0,0)
-	MKCLRRAIL(0,TILE_XY(-2,0)),
-	MKRAIL(0x29,TILE_XY(-1,0)),
-	MKDEPOT(3,TILE_XY(-1,1)),
-	MKSTATION(0x16,TILE_XY(0,0)),
+	MKCLRRAIL(0, -2,0),
+	MKRAIL(0x29, -1,0),
+	MKDEPOT(3, -1,1),
+	MKSTATION(0x16, 0,0),
 	MKEND
 };
 
 static const AiDefaultRailBlock _raildata_ai_19 = {
 	MKHDR(1,3,1,0,2)
-	MKSTATION(0x16,TILE_XY(-2,0)),
-	MKDEPOT(2,TILE_XY(0,-1)),
-	MKRAIL(0x20,TILE_XY(1,-1)),
-	MKRAIL(0x15,TILE_XY(1,0)),
-	MKCLRRAIL(2,TILE_XY(2,0)),
+	MKSTATION(0x16, -2,0),
+	MKDEPOT(2, 0,-1),
+	MKRAIL(0x20, 1,-1),
+	MKRAIL(0x15, 1,0),
+	MKCLRRAIL(2, 2,0),
 	MKEND
 };
 
 static const AiDefaultRailBlock _raildata_ai_20 = {
 	MKHDR(2,3,1,0,1)
-	MKSTATION(0x26,TILE_XY(-2,0)),
-	MKRAIL(0xC1,TILE_XY(1,0)),
-	MKRAIL(0xC1,TILE_XY(1,1)),
-	MKRAIL(0x26,TILE_XY(2,0)),
-	MKRAIL(0x26,TILE_XY(2,1)),
-	MKDEPOT(1,TILE_XY(2,-1)),
-	MKCLRRAIL(1,TILE_XY(2,2)),
+	MKSTATION(0x26, -2,0),
+	MKRAIL(0xC1, 1,0),
+	MKRAIL(0xC1, 1,1),
+	MKRAIL(0x26, 2,0),
+	MKRAIL(0x26, 2,1),
+	MKDEPOT(1, 2,-1),
+	MKCLRRAIL(1, 2,2),
 	MKEND
 };
 
 static const AiDefaultRailBlock _raildata_ai_21 = {
 	MKHDR(2,3,1,0,3)
-	MKDEPOT(2,TILE_XY(-3,-1)),
-	MKRAIL(0x3F,TILE_XY(-2,-1)),
-	MKRAIL(0x10,TILE_XY(-2,0)),
-	MKRAIL(0xC1,TILE_XY(-1,-1)),
-	MKRAIL(0xC1,TILE_XY(-1,0)),
-	MKSTATION(0x26,TILE_XY(0,-1)),
-	MKCLRRAIL(3,TILE_XY(-2,-2)),
+	MKDEPOT(2, -3,-1),
+	MKRAIL(0x3F, -2,-1),
+	MKRAIL(0x10, -2,0),
+	MKRAIL(0xC1, -1,-1),
+	MKRAIL(0xC1, -1,0),
+	MKSTATION(0x26, 0,-1),
+	MKCLRRAIL(3, -2,-2),
 	MKEND
 };
 
 static const AiDefaultRailBlock _raildata_ai_22 = {
 	MKHDR(2,3,1,0,0)
-	MKSTATION(0x27,TILE_XY(0,-2)),
-	MKRAIL(0xC2,TILE_XY(0,1)),
-	MKRAIL(0xC2,TILE_XY(1,1)),
-	MKRAIL(0x15,TILE_XY(0,2)),
-	MKRAIL(0x4,TILE_XY(1,2)),
-	MKRAIL(0x15,TILE_XY(-1,2)),
-	MKDEPOT(1,TILE_XY(-1,1)),
-	MKCLRRAIL(0,TILE_XY(-2,2)),
+	MKSTATION(0x27, 0,-2),
+	MKRAIL(0xC2, 0,1),
+	MKRAIL(0xC2, 1,1),
+	MKRAIL(0x15, 0,2),
+	MKRAIL(0x4, 1,2),
+	MKRAIL(0x15, -1,2),
+	MKDEPOT(1, -1,1),
+	MKCLRRAIL(0, -2,2),
 	MKEND
 };
 
 static const AiDefaultRailBlock _raildata_ai_23 = {
 	MKHDR(2,3,1,0,2)
-	MKDEPOT(1,TILE_XY(0,-3)),
-	MKRAIL(0x1A,TILE_XY(0,-2)),
-	MKRAIL(0x29,TILE_XY(1,-2)),
-	MKRAIL(0xC2,TILE_XY(0,-1)),
-	MKRAIL(0xC2,TILE_XY(1,-1)),
-	MKSTATION(0x27,TILE_XY(0,0)),
-	MKCLRRAIL(2,TILE_XY(2,-2)),
+	MKDEPOT(1, 0,-3),
+	MKRAIL(0x1A, 0,-2),
+	MKRAIL(0x29, 1,-2),
+	MKRAIL(0xC2, 0,-1),
+	MKRAIL(0xC2, 1,-1),
+	MKSTATION(0x27, 0,0),
+	MKCLRRAIL(2, 2,-2),
 	MKEND
 };
 
@@ -356,93 +356,93 @@
 
 static const AiDefaultRoadBlock _roaddata_ai_0 = {
 	MKHDR(0)
-	MKDEPOT(2,TILE_XY(-1,1)),
-	MKSTATION(0x2,TILE_XY(-1,0)),
-	MKRAIL(0xC,TILE_XY(0,0)),
-	MKRAIL(0x9,TILE_XY(0,1)),
-	MKCLRRAIL(0,TILE_XY(0,-1)),
-	MKCLRRAIL(0,TILE_XY(1,0)),
-	MKCLRRAIL(0,TILE_XY(1,1)),
-	MKCLRRAIL(0,TILE_XY(0,2)),
+	MKDEPOT(2, -1,1),
+	MKSTATION(0x2, -1,0),
+	MKRAIL(0xC, 0,0),
+	MKRAIL(0x9, 0,1),
+	MKCLRRAIL(0, 0,-1),
+	MKCLRRAIL(0, 1,0),
+	MKCLRRAIL(0, 1,1),
+	MKCLRRAIL(0, 0,2),
 	MKEND
 };
 
 static const AiDefaultRoadBlock _roaddata_ai_1 = {
 	MKHDR(0)
-	MKDEPOT(1,TILE_XY(0,-1)),
-	MKSTATION(0x1,TILE_XY(1,-1)),
-	MKRAIL(0x3,TILE_XY(0,0)),
-	MKRAIL(0x9,TILE_XY(1,0)),
-	MKCLRRAIL(0,TILE_XY(-1,0)),
-	MKCLRRAIL(0,TILE_XY(0,1)),
-	MKCLRRAIL(0,TILE_XY(1,1)),
-	MKCLRRAIL(0,TILE_XY(2,0)),
+	MKDEPOT(1, 0,-1),
+	MKSTATION(0x1, 1,-1),
+	MKRAIL(0x3, 0,0),
+	MKRAIL(0x9, 1,0),
+	MKCLRRAIL(0, -1,0),
+	MKCLRRAIL(0, 0,1),
+	MKCLRRAIL(0, 1,1),
+	MKCLRRAIL(0, 2,0),
 	MKEND
 };
 
 static const AiDefaultRoadBlock _roaddata_ai_2 = {
 	MKHDR(0)
-	MKDEPOT(3,TILE_XY(1,1)),
-	MKSTATION(0x3,TILE_XY(0,1)),
-	MKRAIL(0x6,TILE_XY(0,0)),
-	MKRAIL(0xC,TILE_XY(1,0)),
-	MKCLRRAIL(0,TILE_XY(-1,0)),
-	MKCLRRAIL(0,TILE_XY(0,-1)),
-	MKCLRRAIL(0,TILE_XY(1,-1)),
-	MKCLRRAIL(0,TILE_XY(2,0)),
+	MKDEPOT(3, 1,1),
+	MKSTATION(0x3, 0,1),
+	MKRAIL(0x6, 0,0),
+	MKRAIL(0xC, 1,0),
+	MKCLRRAIL(0, -1,0),
+	MKCLRRAIL(0, 0,-1),
+	MKCLRRAIL(0, 1,-1),
+	MKCLRRAIL(0, 2,0),
 	MKEND
 };
 
 static const AiDefaultRoadBlock _roaddata_ai_3 = {
 	MKHDR(0)
-	MKDEPOT(0,TILE_XY(1,0)),
-	MKSTATION(0x0,TILE_XY(1,1)),
-	MKRAIL(0x6,TILE_XY(0,0)),
-	MKRAIL(0x3,TILE_XY(0,1)),
-	MKCLRRAIL(0,TILE_XY(0,-1)),
-	MKCLRRAIL(0,TILE_XY(-1,0)),
-	MKCLRRAIL(0,TILE_XY(-1,1)),
-	MKCLRRAIL(0,TILE_XY(0,2)),
+	MKDEPOT(0, 1,0),
+	MKSTATION(0x0, 1,1),
+	MKRAIL(0x6, 0,0),
+	MKRAIL(0x3, 0,1),
+	MKCLRRAIL(0, 0,-1),
+	MKCLRRAIL(0, -1,0),
+	MKCLRRAIL(0, -1,1),
+	MKCLRRAIL(0, 0,2),
 	MKEND
 };
 
 static const AiDefaultRoadBlock _roaddata_ai_4 = {
 	MKHDR(1)
-	MKSTATION(0x2,TILE_XY(-1,0)),
-	MKRAIL(0x8,TILE_XY(0,0)),
-	MKCLRRAIL(0,TILE_XY(0,-1)),
-	MKCLRRAIL(0,TILE_XY(1,0)),
-	MKCLRRAIL(0,TILE_XY(0,1)),
+	MKSTATION(0x2, -1,0),
+	MKRAIL(0x8, 0,0),
+	MKCLRRAIL(0, 0,-1),
+	MKCLRRAIL(0, 1,0),
+	MKCLRRAIL(0, 0,1),
 	MKEND
 };
 
 static const AiDefaultRoadBlock _roaddata_ai_5 = {
 	MKHDR(1)
-	MKSTATION(0x3,TILE_XY(0,1)),
-	MKRAIL(0x4,TILE_XY(0,0)),
-	MKCLRRAIL(0,TILE_XY(-1,0)),
-	MKCLRRAIL(0,TILE_XY(0,-1)),
-	MKCLRRAIL(0,TILE_XY(1,0)),
+	MKSTATION(0x3, 0,1),
+	MKRAIL(0x4, 0,0),
+	MKCLRRAIL(0, -1,0),
+	MKCLRRAIL(0, 0,-1),
+	MKCLRRAIL(0, 1,0),
 	MKEND
 };
 
 static const AiDefaultRoadBlock _roaddata_ai_6 = {
 	MKHDR(1)
-	MKSTATION(0x0,TILE_XY(1,1)),
-	MKRAIL(0x2,TILE_XY(0,1)),
-	MKCLRRAIL(0,TILE_XY(0,0)),
-	MKCLRRAIL(0,TILE_XY(-1,0)),
-	MKCLRRAIL(0,TILE_XY(0,2)),
+	MKSTATION(0x0, 1,1),
+	MKRAIL(0x2, 0,1),
+	MKCLRRAIL(0, 0,0),
+	MKCLRRAIL(0, -1,0),
+	MKCLRRAIL(0, 0,2),
 	MKEND
 };
 
 static const AiDefaultRoadBlock _roaddata_ai_7 = {
 	MKHDR(1)
-	MKSTATION(0x1,TILE_XY(1,-1)),
-	MKRAIL(0x1,TILE_XY(1,0)),
-	MKCLRRAIL(0,TILE_XY(0,0)),
-	MKCLRRAIL(0,TILE_XY(1,1)),
-	MKCLRRAIL(0,TILE_XY(2,0)),
+	MKSTATION(0x1, 1,-1),
+	MKRAIL(0x1, 1,0),
+	MKCLRRAIL(0, 0,0),
+	MKCLRRAIL(0, 1,1),
+	MKCLRRAIL(0, 2,0),
 	MKEND
 };
 
@@ -459,16 +459,16 @@
 	NULL
 };
 
-#define MKAIR(a,b) {0,a,b}
+#define MKAIR(a, b, c) {0, a, {b, c}}
 
 static const AiDefaultBlockData _airportdata_ai_0[] = {
-	MKAIR(1, 0),
-	{1, 0, 0},
+	MKAIR(1, 0, 0),
+	{1, 0, {0, 0}},
 };
 
 static const AiDefaultBlockData _airportdata_ai_1[] = {
-	MKAIR(0, 0),
-	{1, 0, 0}
+	MKAIR(0, 0, 0),
+	{1, 0, {0, 0}}
 };
 
 static const AiDefaultBlockData * const _airport_default_block_data[] = {
--- a/table/build_industry.h	Thu Jan 06 08:08:17 2005 +0000
+++ b/table/build_industry.h	Thu Jan 06 11:39:00 2005 +0000
@@ -1,6 +1,6 @@
-#define MK(x,y, m) {TILE_XY(x,y), m}
+#define MK(x,y, m) {{x, y}, m}
 
-#define MKEND {-0x8000, 0}
+#define MKEND {{-0x80, 0}, 0}
 
 static const IndustryTileTable _tile_table_coal_mine_0[] = {
 	MK(1,1, 0),
--- a/table/genland.h	Thu Jan 06 08:08:17 2005 +0000
+++ b/table/genland.h	Thu Jan 06 11:39:00 2005 +0000
@@ -1,7 +1,6 @@
-#define M(x,y) TILE_XY(x,y)
+#define M(x,y) {x, y}
 
-#define MDORD_LAST 99
-static const TileIndexDiff _make_desert_or_rainforest_data[150] = {
+static const TileIndexDiffC _make_desert_or_rainforest_data[] = {
 	M(-5,-6),
 	M(-4,-6),
 	M(-3,-6),
@@ -150,8 +149,7 @@
 	M(6,3),
 	M(-6,2),
 	M(3,6),
-	M(3,-6),
-	MDORD_LAST,
+	M(3,-6)
 };
 
 
--- a/town_cmd.c	Thu Jan 06 08:08:17 2005 +0000
+++ b/town_cmd.c	Thu Jan 06 11:39:00 2005 +0000
@@ -362,17 +362,17 @@
 }
 
 
-static const TileIndexDiff _roadblock_tileadd[4+3] = {
-	TILE_XY(0,-1),
-	TILE_XY(1,0),
-	TILE_XY(0,1),
-	TILE_XY(-1,0),
+static const TileIndexDiffC _roadblock_tileadd[] = {
+	{ 0, -1},
+	{ 1,  0},
+	{ 0,  1},
+	{-1,  0},
 
 	// Store the first 3 elements again.
 	// Lets us rotate without using &3.
-	TILE_XY(0,-1),
-	TILE_XY(1,0),
-	TILE_XY(0,1),
+	{ 0, -1},
+	{ 1,  0},
+	{ 0,  1}
 };
 
 static void TownTickHandler(Town *t)
@@ -448,10 +448,10 @@
 no_slope:
 			// Tile has no slope
 			// Disallow the road if any neighboring tile has a road.
-			if (HASBIT(GetTownRoadMask(TILE_ADD(tile, _roadblock_tileadd[dir+1])), dir^2) ||
-					HASBIT(GetTownRoadMask(TILE_ADD(tile, _roadblock_tileadd[dir+3])), dir^2) ||
-					HASBIT(GetTownRoadMask(TILE_ADD(tile, _roadblock_tileadd[dir+1] + _roadblock_tileadd[dir+2])), dir) ||
-					HASBIT(GetTownRoadMask(TILE_ADD(tile, _roadblock_tileadd[dir+3] + _roadblock_tileadd[dir+2])), dir))
+			if (HASBIT(GetTownRoadMask(TILE_ADD(tile, ToTileIndexDiff(_roadblock_tileadd[dir+1]))), dir^2) ||
+					HASBIT(GetTownRoadMask(TILE_ADD(tile, ToTileIndexDiff(_roadblock_tileadd[dir+3]))), dir^2) ||
+					HASBIT(GetTownRoadMask(TILE_ADD(tile, ToTileIndexDiff(_roadblock_tileadd[dir+1]) + ToTileIndexDiff(_roadblock_tileadd[dir+2]))), dir) ||
+					HASBIT(GetTownRoadMask(TILE_ADD(tile, ToTileIndexDiff(_roadblock_tileadd[dir+3]) + ToTileIndexDiff(_roadblock_tileadd[dir+2]))), dir))
 				return false;
 
 			// Otherwise allow
@@ -556,15 +556,15 @@
 			a = (int)Random() & 3;
 		} while(a == b);
 
-		if (!IsRoadAllowedHere(TILE_ADD(tile,_roadblock_tileadd[a]), a)) {
+		if (!IsRoadAllowedHere(TILE_ADD(tile, ToTileIndexDiff(_roadblock_tileadd[a])), a)) {
 			// A road is not allowed to continue the randomized road,
 			//   return if the road we're trying to build is curved.
 			if ( a != (b^2))
 				return;
 
 			// Return if neither side of the new road is a house
-			if (!IS_TILETYPE(TILE_ADD(tile,_roadblock_tileadd[a+1]), MP_HOUSE) &&
-					!IS_TILETYPE(TILE_ADD(tile,_roadblock_tileadd[a+3]), MP_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))
 				return;
 
 			// That means that the road is only allowed if there is a house
@@ -597,7 +597,7 @@
 			return;
 
 		// This is the tile we will reach if we extend to this direction.
-		tmptile = TILE_ADD(tile,_roadblock_tileadd[i]);
+		tmptile = TILE_ADD(tile, ToTileIndexDiff(_roadblock_tileadd[i]));
 
 		// Don't do it if it reaches to water.
 		if (IS_WATER_TILE(tmptile))
@@ -708,7 +708,7 @@
 		// Select a random bit from the blockmask, walk a step
 		// and continue the search from there.
 		do block = Random() & 3; while (!HASBIT(mask,block));
-		tile += _roadblock_tileadd[block];
+		tile += ToTileIndexDiff(_roadblock_tileadd[block]);
 
 		// Max number of times is checked.
 	} while (--_grow_town_result >= 0);
@@ -732,25 +732,24 @@
 bool GrowTown(Town *t)
 {
 	uint tile;
-	const TileIndexDiff *ptr;
-	int offs;
+	const TileIndexDiffC *ptr;
 	TileInfo ti;
 	byte old_player;
 
-	static const TileIndexDiff _town_coord_mod[] = {
-		TILE_XY(-1,0),
-		TILE_XY(1,1),
-		TILE_XY(1,-1),
-		TILE_XY(-1,-1),
-		TILE_XY(-1,0),
-		TILE_XY(0,2),
-		TILE_XY(2,0),
-		TILE_XY(0,-2),
-		TILE_XY(-1,-1),
-		TILE_XY(-2,2),
-		TILE_XY(2,2),
-		TILE_XY(2,-2),
-		0,
+	static const TileIndexDiffC _town_coord_mod[] = {
+		{-1,  0},
+		{ 1,  1},
+		{ 1, -1},
+		{-1, -1},
+		{-1,  0},
+		{ 0,  2},
+		{ 2,  0},
+		{ 0, -2},
+		{-1, -1},
+		{-2,  2},
+		{ 2,  2},
+		{ 2, -2},
+		{ 0,  0}
 	};
 
 	// Current player is a town
@@ -759,23 +758,19 @@
 
 	// Find a road that we can base the construction on.
 	tile = t->xy;
-	ptr = _town_coord_mod;
-	do {
+	for (ptr = _town_coord_mod; ptr != endof(_town_coord_mod); ++ptr) {
 		if (GetRoadBitsByTile(tile) != 0) {
 			int r = GrowTownAtRoad(t, tile);
 			_current_player = old_player;
 			return r;
 		}
-		offs = *ptr++;
-
-		tile = TILE_ADD(tile, offs);
-	} while (offs);
+		tile = TILE_ADD(tile, ToTileIndexDiff(*ptr));
+	}
 
 	// No road available, try to build a random road block by
 	// clearing some land and then building a road there.
 	tile = t->xy;
-	ptr = _town_coord_mod;
-	do {
+	for (ptr = _town_coord_mod; ptr != endof(_town_coord_mod); ++ptr) {
 		FindLandscapeHeightByTile(&ti, tile);
 
 		// Only work with plain land that not already has a house with map5=0
@@ -786,9 +781,8 @@
 				return true;
 			}
 		}
-		offs = *ptr++;
-		tile = TILE_ADD(tile, offs);
-	} while (offs != 0);
+		tile = TILE_ADD(tile, ToTileIndexDiff(*ptr));
+	}
 
 	_current_player = old_player;
 	return false;
@@ -1085,15 +1079,15 @@
 	Town *t;
 	int i;
 
-	static const TileIndexDiff _tile_add[4] = {
-		TILE_XY(0,0),
-		TILE_XY(0,1) - TILE_XY(0,0),
-		TILE_XY(1,0) - TILE_XY(0,1),
-		TILE_XY(1,1) - TILE_XY(1,0),
+	static const TileIndexDiffC _tile_add[] = {
+		{0    , 0    },
+		{0 - 0, 1 - 0},
+		{1 - 0, 0 - 1},
+		{1 - 1, 1 - 0}
 	};
 
 	for(i=0; i!=4; i++) {
-		tile += _tile_add[i];
+		tile += ToTileIndexDiff(_tile_add[i]);
 
 		t = ClosestTownFromTile(tile, (uint)-1);
 		if (t1 != t)
@@ -1503,41 +1497,36 @@
 static void TownActionBuildStatue(Town *t, int action)
 {
 	// Layouted as an outward spiral
-	static const TileIndexDiff _statue_tiles[] = {
-	  TILE_XY(-1,0), TILE_XY(0,1),  TILE_XY(1,0),  TILE_XY(1,0),
-	  TILE_XY(0,-1), TILE_XY(0,-1), TILE_XY(-1,0), TILE_XY(-1,0),
-	  TILE_XY(-1,0), TILE_XY(0,1),  TILE_XY(0,1),  TILE_XY(0,1),
-	  TILE_XY(1,0),  TILE_XY(1,0),  TILE_XY(1,0),  TILE_XY(1,0),
-	  TILE_XY(0,-1), TILE_XY(0,-1), TILE_XY(0,-1), TILE_XY(0,-1),
-	  TILE_XY(-1,0), TILE_XY(-1,0), TILE_XY(-1,0), TILE_XY(-1,0),
-	  TILE_XY(-1,0), TILE_XY(0,1),  TILE_XY(0,1),  TILE_XY(0,1),
-	  TILE_XY(0,1),  TILE_XY(0,1),  TILE_XY(1,0),  TILE_XY(1,0),
-	  TILE_XY(1,0),  TILE_XY(1,0),  TILE_XY(1,0),  TILE_XY(1,0),
-	  TILE_XY(0,-1), TILE_XY(0,-1), TILE_XY(0,-1), TILE_XY(0,-1),
-	  TILE_XY(0,-1), TILE_XY(0,-1), TILE_XY(-1,0), TILE_XY(-1,0),
-	  TILE_XY(-1,0), TILE_XY(-1,0), TILE_XY(-1,0), TILE_XY(-1,0),
-	  TILE_XY(-1,0), TILE_XY(0,1),  TILE_XY(0,1),  TILE_XY(0,1),
-	  TILE_XY(0,1),  TILE_XY(0,1),  TILE_XY(0,1),  TILE_XY(0,1),
-	  TILE_XY(1,0),  TILE_XY(1,0),  TILE_XY(1,0),  TILE_XY(1,0),
-	  TILE_XY(1,0),  TILE_XY(1,0),  TILE_XY(1,0),  TILE_XY(1,0),
-	  TILE_XY(0,-1), TILE_XY(0,-1), TILE_XY(0,-1), TILE_XY(0,-1),
-	  TILE_XY(0,-1), TILE_XY(0,-1), TILE_XY(0,-1), TILE_XY(0,-1),
-	  TILE_XY(-1,0), TILE_XY(-1,0), TILE_XY(-1,0), TILE_XY(-1,0),
-	  TILE_XY(-1,0), TILE_XY(-1,0), TILE_XY(-1,0), TILE_XY(-1,0),
-	  0,
-    };
-	int offs;
+	static const TileIndexDiffC _statue_tiles[] = {
+		{-1, 0},
+		{ 0, 1},
+		{ 1, 0}, { 1, 0},
+		{ 0,-1}, { 0,-1},
+		{-1, 0}, {-1, 0}, {-1, 0},
+		{ 0, 1}, { 0, 1}, { 0, 1},
+		{ 1, 0}, { 1, 0}, { 1, 0}, { 1, 0},
+		{ 0,-1}, { 0,-1}, { 0,-1}, { 0,-1},
+		{-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0},
+		{ 0, 1}, { 0, 1}, { 0, 1}, { 0, 1}, { 0, 1},
+		{ 1, 0}, { 1, 0}, { 1, 0}, { 1, 0}, { 1, 0}, { 1, 0},
+		{ 0,-1}, { 0,-1}, { 0,-1}, { 0,-1}, { 0,-1}, { 0,-1},
+		{-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0},
+		{ 0, 1}, { 0, 1}, { 0, 1}, { 0, 1}, { 0, 1}, { 0, 1}, { 0, 1},
+		{ 1, 0}, { 1, 0}, { 1, 0}, { 1, 0}, { 1, 0}, { 1, 0}, { 1, 0}, { 1, 0},
+		{ 0,-1}, { 0,-1}, { 0,-1}, { 0,-1}, { 0,-1}, { 0,-1}, { 0,-1}, { 0,-1},
+		{-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0},
+		{ 0, 0}
+	};
 	uint tile = t->xy;
-	const TileIndexDiff *p = _statue_tiles;
+	const TileIndexDiffC *p;
 
 	SETBIT(t->statues, _current_player);
 
-	do {
+	for (p = _statue_tiles; p != endof(_statue_tiles); ++p) {
 		if (DoBuildStatueOfCompany(tile))
 			return;
-		offs = *p++;
-		tile = TILE_ADD(tile, offs);
-	} while (offs);
+		tile = TILE_ADD(tile, ToTileIndexDiff(*p));
+	}
 }
 
 static void TownActionFundBuildings(Town *t, int action)
--- a/tree_cmd.c	Thu Jan 06 08:08:17 2005 +0000
+++ b/tree_cmd.c	Thu Jan 06 11:39:00 2005 +0000
@@ -466,15 +466,15 @@
 	byte m5;
 	uint16 m2;
 
-	static const TileIndexDiff _tileloop_trees_dir[] = {
-		TILE_XY(-1,-1),
-		TILE_XY(0,-1),
-		TILE_XY(1,-1),
-		TILE_XY(-1,0),
-		TILE_XY(1,0),
-		TILE_XY(-1,1),
-		TILE_XY(0,1),
-		TILE_XY(1,1),
+	static const TileIndexDiffC _tileloop_trees_dir[] = {
+		{-1, -1},
+		{ 0, -1},
+		{ 1, -1},
+		{-1,  0},
+		{ 1,  0},
+		{-1,  1},
+		{ 0,  1},
+		{ 1,  1}
 	};
 
 	if (_opt.landscape == LT_DESERT) {
@@ -514,7 +514,7 @@
 			case 2: { /* add a neighbouring tree */
 				byte m3 = _map3_lo[tile];
 
-				tile += _tileloop_trees_dir[Random() & 7];
+				tile += ToTileIndexDiff(_tileloop_trees_dir[Random() & 7]);
 
 				if (!IS_TILETYPE(tile, MP_CLEAR))
 					return;
--- a/unmovable_cmd.c	Thu Jan 06 08:08:17 2005 +0000
+++ b/unmovable_cmd.c	Thu Jan 06 11:39:00 2005 +0000
@@ -224,11 +224,11 @@
 	}
 }
 
-static const TileIndexDiff _tile_add[4] = {
-	TILE_XY(1,0),
-	TILE_XY(0,1),
-	TILE_XY(-1,0),
-	TILE_XY(0,-1),
+static const TileIndexDiffC _tile_add[] = {
+	{ 1,  0},
+	{ 0,  1},
+	{-1,  0},
+	{ 0, -1}
 };
 
 /* checks, if a radio tower is within a 9x9 tile square around tile */
@@ -295,7 +295,7 @@
 		do {
 			if (--j == 0)
 				goto restart;
-			tile = TILE_MASK(tile + _tile_add[dir]);
+			tile = TILE_MASK(tile + ToTileIndexDiff(_tile_add[dir]));
 		} while (!(IS_TILETYPE(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h <= 16));
 
 		assert(tile == TILE_MASK(tile));
--- a/water_cmd.c	Thu Jan 06 08:08:17 2005 +0000
+++ b/water_cmd.c	Thu Jan 06 11:39:00 2005 +0000
@@ -143,7 +143,7 @@
 
 static int32 RemoveShiplift(uint tile, uint32 flags)
 {
-	int delta = TileOffsByDir(_map5[tile] & 3);
+	TileIndexDiff delta = TileOffsByDir(_map5[tile] & 3);
 
 	// make sure no vehicle is on the tile.
 	if (!EnsureNoVehicle(tile) || !EnsureNoVehicle(tile + delta) || !EnsureNoVehicle(tile - delta))
@@ -290,17 +290,17 @@
 	} else if ((m5 & 0x10) == 0x10) {
 		// shiplift
 
-		static const TileIndexDiff _shiplift_tomiddle_offs[12] = {
-			0,0,0,0, // middle
-			TILE_XY(-1, 0),TILE_XY(0, 1),TILE_XY(1, 0),TILE_XY(0, -1), // lower
-			TILE_XY(1, 0),TILE_XY(0, -1),TILE_XY(-1, 0),TILE_XY(0, 1), // upper
+		static const TileIndexDiffC _shiplift_tomiddle_offs[] = {
+			{ 0,  0}, {0,  0}, { 0, 0}, {0,  0}, // middle
+			{-1,  0}, {0,  1}, { 1, 0}, {0, -1}, // lower
+			{ 1,  0}, {0, -1}, {-1, 0}, {0,  1}, // upper
 		};
 
 		if (flags & DC_AUTO) return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED);
 		// don't allow water to delete it.
 		if (_current_player == OWNER_WATER) return CMD_ERROR;
 		// move to the middle tile..
-		return RemoveShiplift(tile + _shiplift_tomiddle_offs[m5 & 0xF], flags);
+		return RemoveShiplift(tile + ToTileIndexDiff(_shiplift_tomiddle_offs[m5 & 0xF]), flags);
 	} else {
 		// ship depot
 		if (flags & DC_AUTO)
@@ -480,23 +480,24 @@
 	/* not used */
 }
 
-static void TileLoopWaterHelper(uint tile, const int16 *offs)
+static void TileLoopWaterHelper(uint tile, const TileIndexDiffC *offs)
 {
 	byte *p;
 
 	p = &_map_type_and_height[tile];
-	tile += offs[0];
+	tile += ToTileIndexDiff(offs[0]);
 
 	// type of this tile mustn't be water already.
-	if (p[offs[0]] >> 4 == MP_WATER)
+	if (p[ToTileIndexDiff(offs[0])] >> 4 == MP_WATER)
 		return;
 
-	if ( (p[offs[1]] | p[offs[2]]) & 0xF )
+	if ((p[ToTileIndexDiff(offs[1])] | p[ToTileIndexDiff(offs[2])]) & 0xF)
 		return;
 
-	if ( (p[offs[3]] | p[offs[4]]) & 0xF ) {
+	if ((p[ToTileIndexDiff(offs[3])] | p[ToTileIndexDiff(offs[4])]) & 0xF) {
 		// make coast..
-		if (p[offs[0]] >> 4 == MP_CLEAR || p[offs[0]] >> 4 == MP_TREES) {
+		if (p[ToTileIndexDiff(offs[0])] >> 4 == MP_CLEAR ||
+				p[ToTileIndexDiff(offs[0])] >> 4 == MP_TREES) {
 			_current_player = OWNER_WATER;
 			if (DoCommandByTile(tile,0,0,DC_EXEC | DC_AUTO, CMD_LANDSCAPE_CLEAR) != CMD_ERROR)
 				ModifyTile(tile, MP_SETTYPE(MP_WATER) | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR | MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR,OWNER_WATER,1);
@@ -573,12 +574,12 @@
 void TileLoop_Water(uint tile)
 {
 	int i;
-	static const TileIndexDiff _tile_loop_offs_array[4][5] = {
+	static const TileIndexDiffC _tile_loop_offs_array[][5] = {
 		// tile to mod																shore?				shore?
-		{TILE_XY(-1,0), TILE_XY(0,0), TILE_XY(0,1), TILE_XY(-1,0), TILE_XY(-1,1)},
-		{TILE_XY(0,1),  TILE_XY(0,1), TILE_XY(1,1), TILE_XY(0,2),  TILE_XY(1,2)},
-		{TILE_XY(1,0),  TILE_XY(1,0), TILE_XY(1,1), TILE_XY(2,0),  TILE_XY(2,1)},
-		{TILE_XY(0,-1), TILE_XY(0,0), TILE_XY(1,0), TILE_XY(0,-1), TILE_XY(1,-1)},
+		{{-1,  0}, {0, 0}, {0, 1}, {-1,  0}, {-1,  1}},
+		{{ 0,  1}, {0, 1}, {1, 1}, { 0,  2}, { 1,  2}},
+		{{ 1,  0}, {1, 0}, {1, 1}, { 2,  0}, { 2,  1}},
+		{{ 0, -1}, {0, 0}, {1, 0}, { 0, -1}, { 1, -1}}
 	};
 
 	if (IS_INT_INSIDE(GET_TILE_X(tile), 1, MapSizeX() - 3 + 1) &&