summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcelestar <celestar@openttd.org>2006-04-03 09:07:21 +0000
committercelestar <celestar@openttd.org>2006-04-03 09:07:21 +0000
commit69e1c716e86a855b4379504bbb94a5483a63f43e (patch)
treee106242c0ac31fc61254791e0f6fcfe95db2baad
parent6443c14ebd7ed0f9920673c218eaaa1172076a5f (diff)
downloadopenttd-69e1c716e86a855b4379504bbb94a5483a63f43e.tar.xz
(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
-rw-r--r--bridge_gui.c2
-rw-r--r--clear_cmd.c6
-rw-r--r--industry_cmd.c6
-rw-r--r--landscape.c10
-rw-r--r--main_gui.c2
-rw-r--r--station_cmd.c2
-rw-r--r--tile.c2
-rw-r--r--town_cmd.c2
-rw-r--r--tree_cmd.c7
-rw-r--r--tunnelbridge_cmd.c6
-rw-r--r--unmovable_cmd.c2
-rw-r--r--vehicle.c5
-rw-r--r--water_cmd.c2
-rw-r--r--waypoint.c2
-rw-r--r--window.c14
15 files changed, 37 insertions, 33 deletions
diff --git a/bridge_gui.c b/bridge_gui.c
index a2a04550c..2913853a0 100644
--- a/bridge_gui.c
+++ b/bridge_gui.c
@@ -162,6 +162,6 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, byte bridge_type)
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);
}
}
diff --git a/clear_cmd.c b/clear_cmd.c
index d859a9823..39d253a28 100644
--- a/clear_cmd.c
+++ b/clear_cmd.c
@@ -577,14 +577,14 @@ static void TileLoopClearAlps(TileIndex tile)
/* 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 @@ static void ChangeTileOwner_Clear(TileIndex tile, PlayerID old_player, PlayerID
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 = {
diff --git a/industry_cmd.c b/industry_cmd.c
index 55ca863ca..cf9e38b64 100644
--- a/industry_cmd.c
+++ b/industry_cmd.c
@@ -941,7 +941,7 @@ static void PlantFarmField(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)
return;
}
@@ -1162,7 +1162,7 @@ static bool CheckNewIndustry_Oil(TileIndex tile, int type)
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_Oil(TileIndex tile, int type)
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;
}
diff --git a/landscape.c b/landscape.c
index ad684160a..b1431da0d 100644
--- a/landscape.c
+++ b/landscape.c
@@ -61,7 +61,7 @@ void FindLandscapeHeight(TileInfo *ti, uint x, uint y)
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 @@ int32 CmdClearArea(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
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;
diff --git a/main_gui.c b/main_gui.c
index 2c554d507..3e9fbd908 100644
--- a/main_gui.c
+++ b/main_gui.c
@@ -372,7 +372,7 @@ void ShowRenameWaypointWindow(const Waypoint *wp)
/* 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;
}
diff --git a/station_cmd.c b/station_cmd.c
index 06772f9e4..6c57df84e 100644
--- a/station_cmd.c
+++ b/station_cmd.c
@@ -468,7 +468,7 @@ static void StationInitialize(Station *st, TileIndex tile)
// 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;
diff --git a/tile.c b/tile.c
index 7ab92b664..5b50fe191 100644
--- a/tile.c
+++ b/tile.c
@@ -23,7 +23,7 @@ uint GetTileh(uint n, uint w, uint e, uint s, uint *h)
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;
}
diff --git a/town_cmd.c b/town_cmd.c
index afd0d690c..45b7c94d3 100644
--- a/town_cmd.c
+++ b/town_cmd.c
@@ -228,7 +228,7 @@ void UpdateTownVirtCoord(Town *t)
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,
diff --git a/tree_cmd.c b/tree_cmd.c
index eb87d7766..aeaf4d988 100644
--- a/tree_cmd.c
+++ b/tree_cmd.c
@@ -143,7 +143,8 @@ int32 CmdPlantTree(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
// 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 @@ static void TileLoopTreesAlps(TileIndex tile)
{
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);
diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c
index 612a24821..9d9001515 100644
--- a/tunnelbridge_cmd.c
+++ b/tunnelbridge_cmd.c
@@ -214,8 +214,8 @@ int32 CmdBuildBridge(int x, int y, uint32 flags, uint32 p1, uint32 p2)
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 @@ int32 CmdBuildBridge(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
/* 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 */
diff --git a/unmovable_cmd.c b/unmovable_cmd.c
index 78c958462..6d3c98737 100644
--- a/unmovable_cmd.c
+++ b/unmovable_cmd.c
@@ -389,7 +389,7 @@ restart:
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));
diff --git a/vehicle.c b/vehicle.c
index 303a03253..d8aac3e1b 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -1728,7 +1728,10 @@ static void MaybeReplaceVehicle(Vehicle *v)
* 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;
diff --git a/water_cmd.c b/water_cmd.c
index 5d9ca0ac2..05ba892b7 100644
--- a/water_cmd.c
+++ b/water_cmd.c
@@ -413,7 +413,7 @@ static void DrawTile_Water(TileInfo *ti)
break;
case WATER_COAST:
- assert(ti->tileh < 16);
+ assert(!IsSteepTileh(ti->tileh));
DrawGroundSprite(_water_shore_sprites[ti->tileh]);
break;
diff --git a/waypoint.c b/waypoint.c
index c58556880..f06170370 100644
--- a/waypoint.c
+++ b/waypoint.c
@@ -66,7 +66,7 @@ static Waypoint* AllocateWaypoint(void)
/* 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);
}
diff --git a/window.c b/window.c
index 69f7bb961..c5aa2fde8 100644
--- a/window.c
+++ b/window.c
@@ -1200,12 +1200,12 @@ stop_capt:;
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 @@ stop_capt:;
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;
}