(svn r4249) -Codechange: Replace more occurences of 16 by TILE_SIZE and of 8 by TILE_HEIGHT. Reverted one change from the previous commit because it was faulty
authorcelestar
Mon, 03 Apr 2006 09:07:21 +0000
changeset 3422 12cdb13ddb56
parent 3421 8ab76c47c72c
child 3423 03e0e97abf41
(svn r4249) -Codechange: Replace more occurences of 16 by TILE_SIZE and of 8 by TILE_HEIGHT. Reverted one change from the previous commit because it was faulty
bridge_gui.c
clear_cmd.c
industry_cmd.c
landscape.c
main_gui.c
station_cmd.c
tile.c
town_cmd.c
tree_cmd.c
tunnelbridge_cmd.c
unmovable_cmd.c
vehicle.c
water_cmd.c
waypoint.c
window.c
--- a/bridge_gui.c	Mon Apr 03 05:32:11 2006 +0000
+++ b/bridge_gui.c	Mon Apr 03 09:07:21 2006 +0000
@@ -162,6 +162,6 @@
 		w->vscroll.cap = 4;
 		w->vscroll.count = (byte)j;
 	} else {
-		ShowErrorMessage(errmsg, STR_5015_CAN_T_BUILD_BRIDGE_HERE, TileX(end) * 16, TileY(end) * 16);
+		ShowErrorMessage(errmsg, STR_5015_CAN_T_BUILD_BRIDGE_HERE, TileX(end) * TILE_SIZE, TileY(end) * TILE_SIZE);
 	}
 }
--- a/clear_cmd.c	Mon Apr 03 05:32:11 2006 +0000
+++ b/clear_cmd.c	Mon Apr 03 09:07:21 2006 +0000
@@ -577,14 +577,14 @@
 	/* distance from snow line, in steps of 8 */
 	int k = GetTileZ(tile) - _opt.snow_line;
 
-	if (k < -8) { // well below the snow line
+	if (k < -TILE_HEIGHT) { // well below the snow line
 		if (!IsClearGround(tile, CL_SNOW)) return;
 		if (GetClearDensity(tile) == 0) SetClearGroundDensity(tile, CL_GRASS, 3);
 	} else {
 		if (!IsClearGround(tile, CL_SNOW)) {
 			SetClearGroundDensity(tile, CL_SNOW, 0);
 		} else {
-			uint density = min((uint)(k + 8) / 8, 3);
+			uint density = min((uint)(k + TILE_HEIGHT) / TILE_HEIGHT, 3);
 
 			if (GetClearDensity(tile) < density) {
 				AddClearDensity(tile, 1);
@@ -738,7 +738,7 @@
 
 void InitializeClearLand(void)
 {
-	_opt.snow_line = _patches.snow_line_height * 8;
+	_opt.snow_line = _patches.snow_line_height * TILE_HEIGHT;
 }
 
 const TileTypeProcs _tile_type_clear_procs = {
--- a/industry_cmd.c	Mon Apr 03 05:32:11 2006 +0000
+++ b/industry_cmd.c	Mon Apr 03 09:07:21 2006 +0000
@@ -941,7 +941,7 @@
 	int type;
 
 	if (_opt.landscape == LT_HILLY) {
-		if (GetTileZ(tile) + 16 >= _opt.snow_line)
+		if (GetTileZ(tile) + TILE_HEIGHT * 2 >= _opt.snow_line)
 			return;
 	}
 
@@ -1162,7 +1162,7 @@
 	if (_game_mode == GM_EDITOR && _ignore_restrictions) return true;
 	if (_game_mode == GM_EDITOR && type != IT_OIL_RIG)   return true;
 	if ((type != IT_OIL_RIG || TileHeight(tile) == 0) &&
-			DistanceFromEdge(TILE_ADDXY(tile, 1, 1)) < TILE_SIZE)   return true;
+			DistanceFromEdge(TILE_ADDXY(tile, 1, 1)) < 16)   return true;
 
 	_error_message = STR_483B_CAN_ONLY_BE_POSITIONED;
 	return false;
@@ -1171,7 +1171,7 @@
 static bool CheckNewIndustry_Farm(TileIndex tile, int type)
 {
 	if (_opt.landscape == LT_HILLY) {
-		if (GetTileZ(tile) + 16 >= _opt.snow_line) {
+		if (GetTileZ(tile) + TILE_HEIGHT * 2 >= _opt.snow_line) {
 			_error_message = STR_0239_SITE_UNSUITABLE;
 			return false;
 		}
--- a/landscape.c	Mon Apr 03 05:32:11 2006 +0000
+++ b/landscape.c	Mon Apr 03 09:07:21 2006 +0000
@@ -61,7 +61,7 @@
 	ti->x = x;
 	ti->y = y;
 
-	if (x >= MapMaxX() * 16 - 1 || y >= MapMaxY() * 16 - 1) {
+	if (x >= MapMaxX() * TILE_SIZE - 1 || y >= MapMaxY() * TILE_SIZE - 1) {
 		ti->tileh = 0;
 		ti->type = MP_VOID;
 		ti->tile = 0;
@@ -302,16 +302,16 @@
 	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
 
 	// make sure sx,sy are smaller than ex,ey
-	sx = TileX(p1) * 16;
-	sy = TileY(p1) * 16;
+	sx = TileX(p1) * TILE_SIZE;
+	sy = TileY(p1) * TILE_SIZE;
 	if (ex < sx) intswap(ex, sx);
 	if (ey < sy) intswap(ey, sy);
 
 	money = GetAvailableMoneyForCommand();
 	cost = 0;
 
-	for (x = sx; x <= ex; x += 16) {
-		for (y = sy; y <= ey; y += 16) {
+	for (x = sx; x <= ex; x += TILE_SIZE) {
+		for (y = sy; y <= ey; y += TILE_SIZE) {
 			ret = DoCommandByTile(TileVirtXY(x, y), 0, 0, flags & ~DC_EXEC, CMD_LANDSCAPE_CLEAR);
 			if (CmdFailed(ret)) continue;
 			cost += ret;
--- a/main_gui.c	Mon Apr 03 05:32:11 2006 +0000
+++ b/main_gui.c	Mon Apr 03 09:07:21 2006 +0000
@@ -372,7 +372,7 @@
 	/* Are we allowed to change the name of the waypoint? */
 	if (!CheckTileOwnership(wp->xy)) {
 		ShowErrorMessage(_error_message, STR_CANT_CHANGE_WAYPOINT_NAME,
-			TileX(wp->xy) * 16, TileY(wp->xy) * 16);
+			TileX(wp->xy) * TILE_SIZE, TileY(wp->xy) * TILE_SIZE);
 		return;
 	}
 
--- a/station_cmd.c	Mon Apr 03 05:32:11 2006 +0000
+++ b/station_cmd.c	Mon Apr 03 09:07:21 2006 +0000
@@ -468,7 +468,7 @@
 // st = Station to update for.
 static void UpdateStationVirtCoord(Station *st)
 {
-	Point pt = RemapCoords2(TileX(st->xy) * 16, TileY(st->xy) * 16);
+	Point pt = RemapCoords2(TileX(st->xy) * TILE_SIZE, TileY(st->xy) * TILE_SIZE);
 
 	pt.y -= 32;
 	if (st->facilities & FACIL_AIRPORT && st->airport_type == AT_OILRIG) pt.y -= 16;
--- a/tile.c	Mon Apr 03 05:32:11 2006 +0000
+++ b/tile.c	Mon Apr 03 09:07:21 2006 +0000
@@ -23,7 +23,7 @@
 	if ((s -= min) != 0) r += (--s << 4) + 2;
 	if ((w -= min) != 0) r += (--w << 4) + 1;
 
-	if (h != NULL) *h = min * 8;
+	if (h != NULL) *h = min * TILE_HEIGHT;
 
 	return r;
 }
--- a/town_cmd.c	Mon Apr 03 05:32:11 2006 +0000
+++ b/town_cmd.c	Mon Apr 03 09:07:21 2006 +0000
@@ -228,7 +228,7 @@
 	Point pt;
 
 	MarkTownSignDirty(t);
-	pt = RemapCoords2(TileX(t->xy) * 16, TileY(t->xy) * 16);
+	pt = RemapCoords2(TileX(t->xy) * TILE_SIZE, TileY(t->xy) * TILE_SIZE);
 	SetDParam(0, t->index);
 	SetDParam(1, t->population);
 	UpdateViewportSignPos(&t->sign, pt.x, pt.y - 24,
--- a/tree_cmd.c	Mon Apr 03 05:32:11 2006 +0000
+++ b/tree_cmd.c	Mon Apr 03 09:07:21 2006 +0000
@@ -143,7 +143,8 @@
 	// make sure sx,sy are smaller than ex,ey
 	sx = TileX(p2);
 	sy = TileY(p2);
-	ex /= 16; ey /= 16;
+	ex /= TILE_SIZE;
+	ey /= TILE_SIZE;
 	if (ex < sx) intswap(ex, sx);
 	if (ey < sy) intswap(ey, sy);
 
@@ -405,11 +406,11 @@
 {
 	int k = GetTileZ(tile) - _opt.snow_line;
 
-	if (k < -8) {
+	if (k < -TILE_HEIGHT) {
 		if (GetTreeGround(tile) != TR_SNOW_DESERT) return;
 		SetTreeGroundDensity(tile, TR_GRASS, 0);
 	} else {
-		uint density = min((uint)(k + 8) / 8, 3);
+		uint density = min((uint)(k + TILE_HEIGHT) / TILE_HEIGHT, 3);
 
 		if (GetTreeGround(tile) != TR_SNOW_DESERT || GetTreeDensity(tile) != density) {
 			SetTreeGroundDensity(tile, TR_SNOW_DESERT, density);
--- a/tunnelbridge_cmd.c	Mon Apr 03 05:32:11 2006 +0000
+++ b/tunnelbridge_cmd.c	Mon Apr 03 09:07:21 2006 +0000
@@ -214,8 +214,8 @@
 		transport = TRANSPORT_RAIL;
 	}
 
-	sx = TileX(p1) * 16;
-	sy = TileY(p1) * 16;
+	sx = TileX(p1) * TILE_SIZE;
+	sy = TileY(p1) * TILE_SIZE;
 
 	/* check if valid, and make sure that (x,y) are smaller than (sx,sy) */
 	if (x == sx) {
@@ -236,7 +236,7 @@
 	}
 
 	/* set and test bridge length, availability */
-	bridge_len = ((sx + sy - x - y) >> 4) - 1;
+	bridge_len = ((sx + sy - x - y) / TILE_SIZE) - 1;
 	if (!CheckBridge_Stuff(bridge_type, bridge_len)) return_cmd_error(STR_5015_CAN_T_BUILD_BRIDGE_HERE);
 
 	/* retrieve landscape height and ensure it's on land */
--- a/unmovable_cmd.c	Mon Apr 03 05:32:11 2006 +0000
+++ b/unmovable_cmd.c	Mon Apr 03 09:07:21 2006 +0000
@@ -389,7 +389,7 @@
 		do {
 			if (--j == 0) goto restart;
 			tile = TILE_MASK(tile + TileOffsByDir(dir));
-		} while (!(IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h <= 16));
+		} while (!(IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h <= TILE_HEIGHT * 2));
 
 		assert(tile == TILE_MASK(tile));
 
--- a/vehicle.c	Mon Apr 03 05:32:11 2006 +0000
+++ b/vehicle.c	Mon Apr 03 09:07:21 2006 +0000
@@ -1728,7 +1728,10 @@
 	 * If it's not a train, the value is unused
 	 * round up to the length of the tiles used for the train instead of the train length instead
 	 * Useful when newGRF uses custom length */
-	uint16 old_total_length = (v->type == VEH_Train) ? ((v->u.rail.cached_total_length + 15 )/ 16)* 16 : -1;
+	uint16 old_total_length = (v->type == VEH_Train ?
+		(v->u.rail.cached_total_length + TILE_SIZE - 1) / TILE_SIZE * TILE_SIZE :
+		-1
+	);
 
 
 	_current_player = v->owner;
--- a/water_cmd.c	Mon Apr 03 05:32:11 2006 +0000
+++ b/water_cmd.c	Mon Apr 03 09:07:21 2006 +0000
@@ -413,7 +413,7 @@
 			break;
 
 		case WATER_COAST:
-			assert(ti->tileh < 16);
+			assert(!IsSteepTileh(ti->tileh));
 			DrawGroundSprite(_water_shore_sprites[ti->tileh]);
 			break;
 
--- a/waypoint.c	Mon Apr 03 05:32:11 2006 +0000
+++ b/waypoint.c	Mon Apr 03 09:07:21 2006 +0000
@@ -66,7 +66,7 @@
 /* Update the sign for the waypoint */
 static void UpdateWaypointSign(Waypoint* wp)
 {
-	Point pt = RemapCoords2(TileX(wp->xy) * 16, TileY(wp->xy) * 16);
+	Point pt = RemapCoords2(TileX(wp->xy) * TILE_SIZE, TileY(wp->xy) * TILE_SIZE);
 	SetDParam(0, wp->index);
 	UpdateViewportSignPos(&wp->sign, pt.x, pt.y - 0x20, STR_WAYPOINT_VIEWPORT);
 }
--- a/window.c	Mon Apr 03 05:32:11 2006 +0000
+++ b/window.c	Mon Apr 03 09:07:21 2006 +0000
@@ -1200,12 +1200,12 @@
 		y += (dy >> 1) << 4;
 
 		if (dy & 1) {
-			x += 16;
+			x += TILE_SIZE;
 			sub += 2;
 			if (sub > 3) {
 				sub -= 4;
-				x -= 16;
-				y += 16;
+				x -= TILE_SIZE;
+				y += TILE_SIZE;
 			}
 		}
 
@@ -1217,16 +1217,16 @@
 			x = -hvx;
 			sub = 0;
 		}
-		if (x > (int)MapMaxX() * 16 - hvx) {
-			x = MapMaxX() * 16 - hvx;
+		if (x > (int)MapMaxX() * TILE_SIZE - hvx) {
+			x = MapMaxX() * TILE_SIZE - hvx;
 			sub = 0;
 		}
 		if (y < -hvy) {
 			y = -hvy;
 			sub = 0;
 		}
-		if (y > (int)MapMaxY() * 16 - hvy) {
-			y = MapMaxY() * 16 - hvy;
+		if (y > (int)MapMaxY() * TILE_SIZE - hvy) {
+			y = MapMaxY() * TILE_SIZE - hvy;
 			sub = 0;
 		}