summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-04-23 19:35:36 +0000
committertron <tron@openttd.org>2006-04-23 19:35:36 +0000
commitc1dc517dab10acb049f35e80f94508bbcecf3193 (patch)
tree020949ed699a5b1e636d9d4da8e68db3751bf261
parent8ef2c13c65498dfc39cb80bd1c07589b747fe1e6 (diff)
downloadopenttd-c1dc517dab10acb049f35e80f94508bbcecf3193.tar.xz
(svn r4554) Replace magic numbers by TILE_{HEIGHT,SIZE}
-rw-r--r--clear_cmd.c4
-rw-r--r--disaster_cmd.c22
-rw-r--r--elrail.c10
-rw-r--r--industry_cmd.c10
-rw-r--r--landscape.c4
-rw-r--r--rail_cmd.c24
-rw-r--r--road_cmd.c4
-rw-r--r--roadveh_cmd.c4
-rw-r--r--ship_cmd.c4
-rw-r--r--sound.c6
-rw-r--r--station_cmd.c8
-rw-r--r--town_cmd.c4
-rw-r--r--train_cmd.c6
-rw-r--r--tunnelbridge_cmd.c40
-rw-r--r--unmovable_cmd.c6
-rw-r--r--vehicle.c4
-rw-r--r--viewport.c6
17 files changed, 83 insertions, 83 deletions
diff --git a/clear_cmd.c b/clear_cmd.c
index a680f398a..3a8b69f91 100644
--- a/clear_cmd.c
+++ b/clear_cmd.c
@@ -460,8 +460,8 @@ void DrawClearLandFence(const TileInfo *ti)
byte z = ti->z;
if (ti->tileh & SLOPE_S) {
- z += 8;
- if (ti->tileh == SLOPE_STEEP_S) z += 8;
+ z += TILE_HEIGHT;
+ if (ti->tileh == SLOPE_STEEP_S) z += TILE_HEIGHT;
}
if (GetFenceSW(ti->tile) != 0) {
diff --git a/disaster_cmd.c b/disaster_cmd.c
index da4c3e766..ec1301405 100644
--- a/disaster_cmd.c
+++ b/disaster_cmd.c
@@ -516,8 +516,8 @@ static void DisasterTick_4(Vehicle *v)
v->tick_counter++;
if (v->current_order.station == 1) {
- int x = TileX(v->dest_tile) * TILE_SIZE + 8;
- int y = TileY(v->dest_tile) * TILE_SIZE + 8;
+ int x = TileX(v->dest_tile) * TILE_SIZE + TILE_SIZE / 2;
+ int y = TileY(v->dest_tile) * TILE_SIZE + TILE_SIZE / 2;
if (abs(v->x_pos - x) + abs(v->y_pos - y) >= 8) {
v->direction = GetDirectionTowards(v, x, y);
@@ -715,7 +715,7 @@ static void Disaster0_Init(void)
/* Pick a random place, unless we find
a small airport */
- x = TileX(Random()) * TILE_SIZE + 8;
+ x = TileX(Random()) * TILE_SIZE + TILE_SIZE / 2;
FOR_ALL_STATIONS(st) {
if (st->xy && st->airport_tile != 0 &&
@@ -745,7 +745,7 @@ static void Disaster1_Init(void)
if (v == NULL)
return;
- x = TileX(Random()) * TILE_SIZE + 8;
+ x = TileX(Random()) * TILE_SIZE + TILE_SIZE / 2;
InitializeDisasterVehicle(v, x, 0, 135, DIR_SE, 2);
v->dest_tile = TileXY(MapSizeX() / 2, MapSizeY() / 2);
@@ -845,7 +845,7 @@ static void Disaster4_Init(void)
if (v == NULL) return;
- x = TileX(Random()) * TILE_SIZE + 8;
+ x = TileX(Random()) * TILE_SIZE + TILE_SIZE / 2;
y = MapMaxX() * TILE_SIZE - 1;
InitializeDisasterVehicle(v, x, y, 135, DIR_NW, 9);
@@ -872,13 +872,13 @@ static void Disaster5_Init(void)
if (v == NULL) return;
r = Random();
- x = TileX(r) * TILE_SIZE + 8;
+ x = TileX(r) * TILE_SIZE + TILE_SIZE / 2;
if (r & 0x80000000) {
- y = MapMaxX() * TILE_SIZE - 8 - 1;
+ y = MapMaxX() * TILE_SIZE - TILE_SIZE / 2 - 1;
dir = DIR_NW;
} else {
- y = 8;
+ y = TILE_SIZE / 2;
dir = DIR_SE;
}
InitializeDisasterVehicle(v, x, y, 0, dir, 13);
@@ -896,13 +896,13 @@ static void Disaster6_Init(void)
if (v == NULL) return;
r = Random();
- x = TileX(r) * TILE_SIZE + 8;
+ x = TileX(r) * TILE_SIZE + TILE_SIZE / 2;
if (r & 0x80000000) {
- y = MapMaxX() * TILE_SIZE - 8 - 1;
+ y = MapMaxX() * TILE_SIZE - TILE_SIZE / 2 - 1;
dir = DIR_NW;
} else {
- y = 8;
+ y = TILE_SIZE / 2;
dir = DIR_SE;
}
InitializeDisasterVehicle(v, x, y, 0, dir, 14);
diff --git a/elrail.c b/elrail.c
index 6a1a70580..ada534046 100644
--- a/elrail.c
+++ b/elrail.c
@@ -290,7 +290,7 @@ static void DrawCatenaryRailway(const TileInfo *ti)
sss = &CatenarySpriteData[Wires[tileh_selector][t][PCPconfig]];
AddSortableSpriteToDraw( sss->image, ti->x + sss->x_offset, ti->y + sss->y_offset,
- sss->x_size, sss->y_size, sss->z_size, GetSlopeZ(ti->x + min(sss->x_offset, 15), ti->y + min(sss->y_offset, 15)) + sss->z_offset);
+ sss->x_size, sss->y_size, sss->z_size, GetSlopeZ(ti->x + min(sss->x_offset, TILE_SIZE - 1), ti->y + min(sss->y_offset, TILE_SIZE - 1)) + sss->z_offset);
}
}
}
@@ -325,18 +325,18 @@ static void DrawCatenaryOnBridge(const TileInfo *ti)
/* every other tile needs a pylon on the northern end */
if (num % 2) {
if (axis == AXIS_X) {
- AddSortableSpriteToDraw( pylons_bridge[0 + HASBIT(tlg, 0)], ti->x, ti->y + 4 + 8 * HASBIT(tlg, 0), 1, 1, 10, GetBridgeHeight(ti->tile) + 8);
+ AddSortableSpriteToDraw( pylons_bridge[0 + HASBIT(tlg, 0)], ti->x, ti->y + 4 + 8 * HASBIT(tlg, 0), 1, 1, 10, GetBridgeHeight(ti->tile) + TILE_HEIGHT);
} else {
- AddSortableSpriteToDraw( pylons_bridge[2 + HASBIT(tlg, 1)], ti->x + 4 + 8 * HASBIT(tlg, 1), ti->y, 1, 1, 10, GetBridgeHeight(ti->tile) + 8);
+ AddSortableSpriteToDraw( pylons_bridge[2 + HASBIT(tlg, 1)], ti->x + 4 + 8 * HASBIT(tlg, 1), ti->y, 1, 1, 10, GetBridgeHeight(ti->tile) + TILE_HEIGHT);
}
}
/* need a pylon on the southern end of the bridge */
if (DistanceMax(ti->tile, start) == length) {
if (axis == AXIS_X) {
- AddSortableSpriteToDraw( pylons_bridge[0 + HASBIT(tlg, 0)], ti->x + 16, ti->y + 4 + 8 * HASBIT(tlg, 0), 1, 1, 10, GetBridgeHeight(ti->tile) + 8);
+ AddSortableSpriteToDraw( pylons_bridge[0 + HASBIT(tlg, 0)], ti->x + 16, ti->y + 4 + 8 * HASBIT(tlg, 0), 1, 1, 10, GetBridgeHeight(ti->tile) + TILE_HEIGHT);
} else {
- AddSortableSpriteToDraw( pylons_bridge[2 + HASBIT(tlg, 1)], ti->x + 4 + 8 * HASBIT(tlg, 1), ti->y + 16, 1, 1, 10, GetBridgeHeight(ti->tile) + 8);
+ AddSortableSpriteToDraw( pylons_bridge[2 + HASBIT(tlg, 1)], ti->x + 4 + 8 * HASBIT(tlg, 1), ti->y + 16, 1, 1, 10, GetBridgeHeight(ti->tile) + TILE_HEIGHT);
}
}
}
diff --git a/industry_cmd.c b/industry_cmd.c
index f4031562d..ff66bfd98 100644
--- a/industry_cmd.c
+++ b/industry_cmd.c
@@ -387,7 +387,7 @@ static void DrawTile_Industry(TileInfo *ti)
if (ti->tileh != SLOPE_FLAT) {
AddSortableSpriteToDraw(SPR_FOUNDATION_BASE + ti->tileh, ti->x, ti->y, 16, 16, 7, z);
AddChildSpriteScreen(image, 31, 1);
- z += 8;
+ z += TILE_HEIGHT;
} else {
/* Else draw regular ground */
DrawGroundSprite(image);
@@ -420,7 +420,7 @@ static void DrawTile_Industry(TileInfo *ti)
static uint GetSlopeZ_Industry(const TileInfo* ti)
{
- return ti->z + (ti->tileh == SLOPE_FLAT ? 0 : 8);
+ return ti->z + (ti->tileh == SLOPE_FLAT ? 0 : TILE_HEIGHT);
}
static Slope GetSlopeTileh_Industry(TileIndex tile, Slope tileh)
@@ -702,7 +702,7 @@ static void CreateIndustryEffectSmoke(TileIndex tile)
tileh = GetTileSlope(tile, &z);
x = TileX(tile) * TILE_SIZE;
y = TileY(tile) * TILE_SIZE;
- CreateEffectVehicle(x + 15, y + 14, z + 59 + (tileh != SLOPE_FLAT ? 8 : 0), EV_CHIMNEY_SMOKE);
+ CreateEffectVehicle(x + 15, y + 14, z + 59 + (tileh != SLOPE_FLAT ? TILE_HEIGHT : 0), EV_CHIMNEY_SMOKE);
}
static void MakeIndustryTileBigger(TileIndex tile)
@@ -1177,7 +1177,7 @@ static bool CheckNewIndustry_NULL(TileIndex tile, IndustryType type)
static bool CheckNewIndustry_Forest(TileIndex tile, IndustryType type)
{
if (_opt.landscape == LT_HILLY) {
- if (GetTileZ(tile) < _opt.snow_line + 16U) {
+ if (GetTileZ(tile) < _opt.snow_line + TILE_HEIGHT * 2U) {
_error_message = STR_4831_FOREST_CAN_ONLY_BE_PLANTED;
return false;
}
@@ -1241,7 +1241,7 @@ static bool CheckNewIndustry_Lumbermill(TileIndex tile, IndustryType type)
static bool CheckNewIndustry_BubbleGen(TileIndex tile, IndustryType type)
{
- return GetTileZ(tile) <= 32;
+ return GetTileZ(tile) <= TILE_HEIGHT * 4;
}
typedef bool CheckNewIndustryProc(TileIndex tile, IndustryType type);
diff --git a/landscape.c b/landscape.c
index b5d904275..53c72dfaf 100644
--- a/landscape.c
+++ b/landscape.c
@@ -212,7 +212,7 @@ void DrawFoundation(TileInfo *ti, uint f)
if (sprite_base < SPR_SLOPES_BASE) sprite_base = SPR_FOUNDATION_BASE + 1; // use original slope sprites
AddSortableSpriteToDraw(f - 1 + sprite_base, ti->x, ti->y, 16, 16, 7, ti->z);
- ti->z += 8;
+ ti->z += TILE_HEIGHT;
ti->tileh = SLOPE_FLAT;
OffsetGroundSprite(31, 1);
} else {
@@ -332,7 +332,7 @@ int32 CmdClearArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
// draw explosion animation...
if ((x == sx || x == ex) && (y == sy || y == ey)) {
// big explosion in each corner, or small explosion for single tiles
- CreateEffectVehicleAbove(x * TILE_SIZE + 8, y * TILE_SIZE + 8, 2,
+ CreateEffectVehicleAbove(x * TILE_SIZE + TILE_SIZE / 2, y * TILE_SIZE + TILE_SIZE / 2, 2,
sy == ey && sx == ex ? EV_EXPLOSION_SMALL : EV_EXPLOSION_LARGE
);
}
diff --git a/rail_cmd.c b/rail_cmd.c
index 34f563ec9..5c4dfcf24 100644
--- a/rail_cmd.c
+++ b/rail_cmd.c
@@ -1078,7 +1078,7 @@ static void DrawTrackFence_SE(const TileInfo *ti)
uint32 image = 0x515;
if (ti->tileh != SLOPE_FLAT) image = (ti->tileh & SLOPE_S) ? 0x519 : 0x51B;
AddSortableSpriteToDraw(image | _drawtile_track_palette,
- ti->x, ti->y + 15, 16, 1, 4, ti->z);
+ ti->x, ti->y + TILE_SIZE - 1, 16, 1, 4, ti->z);
}
static void DrawTrackFence_NW_SE(const TileInfo *ti)
@@ -1100,7 +1100,7 @@ static void DrawTrackFence_SW(const TileInfo *ti)
uint32 image = 0x516;
if (ti->tileh != SLOPE_FLAT) image = (ti->tileh & SLOPE_S) ? 0x51A : 0x51C;
AddSortableSpriteToDraw(image | _drawtile_track_palette,
- ti->x + 15, ti->y, 1, 16, 4, ti->z);
+ ti->x + TILE_SIZE - 1, ti->y, 1, 16, 4, ti->z);
}
static void DrawTrackFence_NE_SW(const TileInfo *ti)
@@ -1112,33 +1112,33 @@ static void DrawTrackFence_NE_SW(const TileInfo *ti)
static void DrawTrackFence_NS_1(const TileInfo *ti)
{
int z = ti->z;
- if (ti->tileh & SLOPE_W) z += 8;
+ if (ti->tileh & SLOPE_W) z += TILE_HEIGHT;
AddSortableSpriteToDraw(0x517 | _drawtile_track_palette,
- ti->x + 8, ti->y + 8, 1, 1, 4, z);
+ ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z);
}
static void DrawTrackFence_NS_2(const TileInfo *ti)
{
int z = ti->z;
- if (ti->tileh & SLOPE_E) z += 8;
+ if (ti->tileh & SLOPE_E) z += TILE_HEIGHT;
AddSortableSpriteToDraw(0x517 | _drawtile_track_palette,
- ti->x + 8, ti->y + 8, 1, 1, 4, z);
+ ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z);
}
static void DrawTrackFence_WE_1(const TileInfo *ti)
{
int z = ti->z;
- if (ti->tileh & SLOPE_N) z += 8;
+ if (ti->tileh & SLOPE_N) z += TILE_HEIGHT;
AddSortableSpriteToDraw(0x518 | _drawtile_track_palette,
- ti->x + 8, ti->y + 8, 1, 1, 4, z);
+ ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z);
}
static void DrawTrackFence_WE_2(const TileInfo *ti)
{
int z = ti->z;
- if (ti->tileh & SLOPE_S) z += 8;
+ if (ti->tileh & SLOPE_S) z += TILE_HEIGHT;
AddSortableSpriteToDraw(0x518 | _drawtile_track_palette,
- ti->x + 8, ti->y + 8, 1, 1, 4, z);
+ ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z);
}
static void DetTrackDrawProc_Null(const TileInfo *ti)
@@ -1703,12 +1703,12 @@ static uint GetSlopeZ_Track(const TileInfo* ti)
if (tileh == SLOPE_FLAT) return z;
if (GetRailTileType(ti->tile) == RAIL_TYPE_DEPOT_WAYPOINT) {
- return z + 8;
+ return z + TILE_HEIGHT;
} else {
uint f = GetRailFoundation(ti->tileh, GetTrackBits(ti->tile));
if (f != 0) {
- if (f < 15) return z + 8; // leveled foundation
+ if (f < 15) return z + TILE_HEIGHT; // leveled foundation
tileh = _inclined_tileh[f - 15]; // inclined foundation
}
return z + GetPartialZ(ti->x & 0xF, ti->y & 0xF, tileh);
diff --git a/road_cmd.c b/road_cmd.c
index b4bf40578..b94d58d3e 100644
--- a/road_cmd.c
+++ b/road_cmd.c
@@ -831,12 +831,12 @@ static uint GetSlopeZ_Road(const TileInfo* ti)
uint f = GetRoadFoundation(tileh, GetRoadBits(ti->tile));
if (f != 0) {
- if (f < 15) return z + 8; // leveled foundation
+ if (f < 15) return z + TILE_HEIGHT; // leveled foundation
tileh = _inclined_tileh[f - 15]; // inclined foundation
}
return z + GetPartialZ(ti->x & 0xF, ti->y & 0xF, tileh);
} else {
- return z + 8;
+ return z + TILE_HEIGHT;
}
}
diff --git a/roadveh_cmd.c b/roadveh_cmd.c
index fbe1e454f..64efce814 100644
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -144,8 +144,8 @@ int32 CmdBuildRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
v->owner = _current_player;
v->tile = tile;
- x = TileX(tile) * TILE_SIZE + 8;
- y = TileY(tile) * TILE_SIZE + 8;
+ x = TileX(tile) * TILE_SIZE + TILE_SIZE / 2;
+ y = TileY(tile) * TILE_SIZE + TILE_SIZE / 2;
v->x_pos = x;
v->y_pos = y;
v->z_pos = GetSlopeZ(x,y);
diff --git a/ship_cmd.c b/ship_cmd.c
index 302f58018..3cb66e430 100644
--- a/ship_cmd.c
+++ b/ship_cmd.c
@@ -847,8 +847,8 @@ int32 CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
v->owner = _current_player;
v->tile = tile;
- x = TileX(tile) * TILE_SIZE + 8;
- y = TileY(tile) * TILE_SIZE + 8;
+ x = TileX(tile) * TILE_SIZE + TILE_SIZE / 2;
+ y = TileY(tile) * TILE_SIZE + TILE_SIZE / 2;
v->x_pos = x;
v->y_pos = y;
v->z_pos = GetSlopeZ(x,y);
diff --git a/sound.c b/sound.c
index 0c63825e2..30898cdaf 100644
--- a/sound.c
+++ b/sound.c
@@ -207,9 +207,9 @@ static void SndPlayScreenCoordFx(SoundFx sound, int x, int y)
void SndPlayTileFx(SoundFx sound, TileIndex tile)
{
- /* emits sound from center (+ 8) of the tile */
- int x = TileX(tile) * TILE_SIZE + 8;
- int y = TileY(tile) * TILE_SIZE + 8;
+ /* emits sound from center of the tile */
+ int x = TileX(tile) * TILE_SIZE + TILE_SIZE / 2;
+ int y = TileY(tile) * TILE_SIZE + TILE_SIZE / 2;
Point pt = RemapCoords(x, y, GetSlopeZ(x, y));
SndPlayScreenCoordFx(sound, pt.x, pt.y);
}
diff --git a/station_cmd.c b/station_cmd.c
index 08edf3eb3..801b292d8 100644
--- a/station_cmd.c
+++ b/station_cmd.c
@@ -809,7 +809,7 @@ int32 CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invali
return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
}
cost += _price.terraform;
- flat_z += 8;
+ flat_z += TILE_HEIGHT;
}
// get corresponding flat level and make sure that all parts of the station have the same level.
@@ -2032,7 +2032,7 @@ void StationPickerDrawSprite(int x, int y, RailType railtype, int image)
static uint GetSlopeZ_Station(const TileInfo* ti)
{
- return ti->z + (ti->tileh == SLOPE_FLAT ? 0 : 8);
+ return ti->z + (ti->tileh == SLOPE_FLAT ? 0 : TILE_HEIGHT);
}
static Slope GetSlopeTileh_Station(TileIndex tile, Slope tileh)
@@ -2190,8 +2190,8 @@ static uint32 VehicleEnter_Station(Vehicle *v, TileIndex tile, int x, int y)
y &= 0xF;
if (DiagDirToAxis(dir) != AXIS_X) intswap(x, y);
- if (y == 8) {
- if (dir != DIAGDIR_SE && dir != DIAGDIR_SW) x = ~x & 0xF;
+ if (y == TILE_SIZE / 2) {
+ if (dir != DIAGDIR_SE && dir != DIAGDIR_SW) x = TILE_SIZE - 1 - x;
if (x == 12) return 2 | (station_id << 8); /* enter station */
if (x < 12) {
uint16 spd;
diff --git a/town_cmd.c b/town_cmd.c
index 277fd06b9..359c780b7 100644
--- a/town_cmd.c
+++ b/town_cmd.c
@@ -106,7 +106,7 @@ static void DrawTile_Town(TileInfo *ti)
if (ti->tileh != SLOPE_FLAT) {
AddSortableSpriteToDraw(SPR_FOUNDATION_BASE + ti->tileh, ti->x, ti->y, 16, 16, 7, z);
AddChildSpriteScreen(dcts->sprite_1, 31, 1);
- z += 8;
+ z += TILE_HEIGHT;
} else {
/* Else draw regular ground */
DrawGroundSprite(dcts->sprite_1);
@@ -137,7 +137,7 @@ static void DrawTile_Town(TileInfo *ti)
static uint GetSlopeZ_Town(const TileInfo* ti)
{
- return ti->z + (ti->tileh == SLOPE_FLAT ? 0 : 8);
+ return ti->z + (ti->tileh == SLOPE_FLAT ? 0 : TILE_HEIGHT);
}
static Slope GetSlopeTileh_Town(TileIndex tile, Slope tileh)
diff --git a/train_cmd.c b/train_cmd.c
index f29426ced..0567cee0d 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -2615,7 +2615,7 @@ static bool CheckCompatibleRail(const Vehicle *v, TileIndex tile)
Slope tileh = GetTileSlope(tile, &height);
// correct Z position of a train going under a bridge on slopes
- if (CorrectZ(tileh)) height += 8;
+ if (CorrectZ(tileh)) height += TILE_HEIGHT;
if (v->z_pos != height) return true; // train is going over bridge
}
@@ -3236,7 +3236,7 @@ static bool TrainCheckIfLineEnds(Vehicle *v)
if (GB(ts, 0, 16) != 0) {
/* If we approach a rail-piece which we can't enter, or the back of a depot, don't enter it! */
- if (x + 4 > 15 &&
+ if (x + 4 >= TILE_SIZE &&
(!CheckCompatibleRail(v, tile) ||
(IsTileDepotType(tile, TRANSPORT_RAIL) &&
GetRailDepotDirection(tile) == dir))) {
@@ -3255,7 +3255,7 @@ static bool TrainCheckIfLineEnds(Vehicle *v)
}
return true;
}
- } else if (x + 4 > 15) {
+ } else if (x + 4 >= TILE_SIZE) {
v->cur_speed = 0;
ReverseTrainDirection(v);
return false;
diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c
index da9e84ab2..fc644f20b 100644
--- a/tunnelbridge_cmd.c
+++ b/tunnelbridge_cmd.c
@@ -254,12 +254,12 @@ int32 CmdBuildBridge(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2)
tileh_end = GetTileSlope(tile_end, &z_end);
if (HASBIT(BRIDGE_FULL_LEVELED_FOUNDATION, tileh_start)) {
- z_start += 8;
+ z_start += TILE_HEIGHT;
tileh_start = SLOPE_FLAT;
}
if (HASBIT(BRIDGE_FULL_LEVELED_FOUNDATION, tileh_end)) {
- z_end += 8;
+ z_end += TILE_HEIGHT;
tileh_end = SLOPE_FLAT;
}
@@ -650,7 +650,7 @@ static int32 DoClearBridge(TileIndex tile, uint32 flags)
v = FindVehicleBetween(
tile + delta,
endtile - delta,
- TilePixelHeight(tile) + 8 + GetCorrectTileHeight(tile)
+ TilePixelHeight(tile) + TILE_HEIGHT + GetCorrectTileHeight(tile)
);
if (v != NULL) {
VehicleInTheWayErrMsg(v);
@@ -758,7 +758,7 @@ int32 DoConvertTunnelBridgeRail(TileIndex tile, RailType totype, bool exec)
int32 cost;
uint z = TilePixelHeight(tile);
- z += 8;
+ z += TILE_HEIGHT;
if (!CheckTileOwnership(tile)) return CMD_ERROR;
@@ -807,7 +807,7 @@ uint GetBridgeHeight(TileIndex t)
/* Return the height there (the height of the NORTH CORNER)
* If the end of the bridge is on a tile with all corners except the north corner raised,
* the z coordinate is 1 height level too low. Compensate for that */
- return TilePixelHeight(tile) + (GetTileSlope(tile, NULL) == SLOPE_WSE ? 8 : 0);
+ return TilePixelHeight(tile) + (GetTileSlope(tile, NULL) == SLOPE_WSE ? TILE_HEIGHT : 0);
}
static const byte _bridge_foundations[2][16] = {
@@ -837,20 +837,20 @@ static void DrawBridgePillars(PalSpriteID image, const TileInfo *ti, int x, int
if (_display_opt & DO_TRANS_BUILDINGS) MAKE_TRANSPARENT(image);
p = _tileh_bits[(image & 1) * 2 + (axis == AXIS_X ? 0 : 1)];
- front_height = ti->z + ((ti->tileh & p[0])?8:0);
- back_height = ti->z + ((ti->tileh & p[1])?8:0);
+ front_height = ti->z + (ti->tileh & p[0] ? TILE_HEIGHT : 0);
+ back_height = ti->z + (ti->tileh & p[1] ? TILE_HEIGHT : 0);
if (IsSteepSlope(ti->tileh)) {
- if (!(ti->tileh & p[2])) front_height += 8;
- if (!(ti->tileh & p[3])) back_height += 8;
+ if (!(ti->tileh & p[2])) front_height += TILE_HEIGHT;
+ if (!(ti->tileh & p[3])) back_height += TILE_HEIGHT;
}
- for (; z >= front_height || z >= back_height; z = z - 8) {
+ for (; z >= front_height || z >= back_height; z -= TILE_HEIGHT) {
if (z >= front_height) { // front facing pillar
AddSortableSpriteToDraw(image, x,y, p[4], p[5], 0x28, z);
}
- if (drawfarpillar && z >= back_height && z < i - 8) { // back facing pillar
+ if (drawfarpillar && z >= back_height && z < i - TILE_HEIGHT) { // back facing pillar
AddSortableSpriteToDraw(image, x - p[6], y - p[7], p[4], p[5], 0x28, z);
}
}
@@ -914,7 +914,7 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
DrawGroundSprite(image);
if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC) DrawCatenary(ti);
- AddSortableSpriteToDraw(image+1, ti->x + 15, ti->y + 15, 1, 1, 8, (byte)ti->z);
+ AddSortableSpriteToDraw(image+1, ti->x + TILE_SIZE - 1, ti->y + TILE_SIZE - 1, 1, 1, 8, (byte)ti->z);
} else if (IsBridge(ti->tile)) { // XXX is this necessary?
int base_offset;
@@ -1076,34 +1076,34 @@ static uint GetSlopeZ_TunnelBridge(const TileInfo* ti)
if (5 <= pos && pos <= 10) {
uint delta;
- if (HASBIT(BRIDGE_HORZ_RAMP, tileh)) return z + 8;
+ if (HASBIT(BRIDGE_HORZ_RAMP, tileh)) return z + TILE_HEIGHT;
- if (HASBIT(BRIDGE_FULL_LEVELED_FOUNDATION, tileh)) z += 8;
+ if (HASBIT(BRIDGE_FULL_LEVELED_FOUNDATION, tileh)) z += TILE_HEIGHT;
switch (dir) {
default:
- case DIAGDIR_NE: delta = (15 - x) / 2; break;
+ case DIAGDIR_NE: delta = (TILE_SIZE - 1 - x) / 2; break;
case DIAGDIR_SE: delta = y / 2; break;
case DIAGDIR_SW: delta = x / 2; break;
- case DIAGDIR_NW: delta = (15 - y) / 2; break;
+ case DIAGDIR_NW: delta = (TILE_SIZE - 1 - y) / 2; break;
}
return z + 1 + delta;
} else {
uint f = GetBridgeFoundation(tileh, DiagDirToAxis(dir));
if (f != 0) {
- if (f < 15) return z + 8;
+ if (f < 15) return z + TILE_HEIGHT;
tileh = _inclined_tileh[f - 15];
}
}
} else {
// HACK on the bridge?
- if (_get_z_hint >= z + 8 + (tileh == SLOPE_FLAT ? 0 : 8)) return _get_z_hint;
+ if (_get_z_hint >= z + TILE_HEIGHT + (tileh == SLOPE_FLAT ? 0 : TILE_HEIGHT)) return _get_z_hint;
if (IsTransportUnderBridge(tile)) {
uint f = _bridge_foundations[GetBridgeAxis(tile)][tileh];
if (f != 0) {
- if (f < 15) return z + 8;
+ if (f < 15) return z + TILE_HEIGHT;
tileh = _inclined_tileh[f - 15];
}
}
@@ -1360,7 +1360,7 @@ static uint32 VehicleEnter_TunnelBridge(Vehicle *v, TileIndex tile, int x, int y
uint h;
// Compensate for possible foundation
- if (GetTileSlope(tile, &h) != SLOPE_FLAT) h += 8;
+ if (GetTileSlope(tile, &h) != SLOPE_FLAT) h += TILE_HEIGHT;
if (IsBridgeRamp(tile) ||
myabs(h - v->z_pos) > 2) { // high above the ground -> on the bridge
/* modify speed of vehicle */
diff --git a/unmovable_cmd.c b/unmovable_cmd.c
index 067af3ecc..e6faf9a6b 100644
--- a/unmovable_cmd.c
+++ b/unmovable_cmd.c
@@ -165,7 +165,7 @@ static void DrawTile_Unmovable(TileInfo *ti)
AddSortableSpriteToDraw(
PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)) + PALETTE_MODIFIER_COLOR + SPR_BOUGHT_LAND,
- ti->x+8, ti->y+8, 1, 1, 10, GetSlopeZ(ti->x+8, ti->y+8)
+ ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 10, GetSlopeZ(ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2)
);
break;
@@ -201,7 +201,7 @@ static uint GetSlopeZ_Unmovable(const TileInfo* ti)
if (IsOwnedLand(ti->tile)) {
return ti->z + GetPartialZ(ti->x & 0xF, ti->y & 0xF, ti->tileh);
} else {
- return ti->z + (ti->tileh == SLOPE_FLAT ? 0 : 8);
+ return ti->z + (ti->tileh == SLOPE_FLAT ? 0 : TILE_HEIGHT);
}
}
@@ -341,7 +341,7 @@ void GenerateUnmovables(void)
j = ScaleByMapSize(40); // maximum number of radio towers on the map
do {
tile = RandomTile();
- if (IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == SLOPE_FLAT && h >= 32) {
+ if (IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == SLOPE_FLAT && h >= TILE_HEIGHT * 4) {
if (!checkRadioTowerNearby(tile)) continue;
MakeTransmitter(tile);
if (--j == 0) break;
diff --git a/vehicle.c b/vehicle.c
index 9ab50af98..e2d19b081 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -131,7 +131,7 @@ static void *EnsureNoVehicleProcZ(Vehicle *v, void *data)
const TileInfo *ti = data;
if (v->tile != ti->tile || v->type == VEH_Disaster) return NULL;
- if (!IS_INT_INSIDE(ti->z - v->z_pos, 0, 8 + 1)) return NULL;
+ if (!IS_INT_INSIDE(ti->z - v->z_pos, 0, TILE_HEIGHT + 1)) return NULL;
VehicleInTheWayErrMsg(v);
return v;
@@ -140,7 +140,7 @@ static void *EnsureNoVehicleProcZ(Vehicle *v, void *data)
static inline uint Correct_Z(Slope tileh)
{
// needs z correction for slope-type graphics that have the NORTHERN tile lowered
- return CorrectZ(tileh) ? 8 : 0;
+ return CorrectZ(tileh) ? TILE_HEIGHT : 0;
}
uint GetCorrectTileHeight(TileIndex tile)
diff --git a/viewport.c b/viewport.c
index cc3863cde..239a77d14 100644
--- a/viewport.c
+++ b/viewport.c
@@ -611,8 +611,8 @@ static void DrawTileSelection(const TileInfo *ti)
// Figure out the Z coordinate for the single dot.
byte z = ti->z;
if (ti->tileh & SLOPE_N) {
- z += 8;
- if (ti->tileh == SLOPE_STEEP_N) z += 8;
+ z += TILE_HEIGHT;
+ if (ti->tileh == SLOPE_STEEP_N) z += TILE_HEIGHT;
}
DrawGroundSpriteAt(_cur_dpi->zoom != 2 ? SPR_DOT : SPR_DOT_SMALL, ti->x, ti->y, z);
} else if (_thd.drawstyle & HT_RAIL /*&& _thd.place_mode == VHM_RAIL*/) {
@@ -1759,7 +1759,7 @@ bool ScrollMainWindowTo(int x, int y)
bool ScrollMainWindowToTile(TileIndex tile)
{
- return ScrollMainWindowTo(TileX(tile) * TILE_SIZE + 8, TileY(tile) * TILE_SIZE + 8);
+ return ScrollMainWindowTo(TileX(tile) * TILE_SIZE + TILE_SIZE / 2, TileY(tile) * TILE_SIZE + TILE_SIZE / 2);
}
void SetRedErrorSquare(TileIndex tile)