mirror of https://github.com/OpenTTD/OpenTTD
(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
parent
3aa1e38be6
commit
cc87f682b9
|
@ -162,6 +162,6 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, byte bridge_type)
|
||||||
w->vscroll.cap = 4;
|
w->vscroll.cap = 4;
|
||||||
w->vscroll.count = (byte)j;
|
w->vscroll.count = (byte)j;
|
||||||
} else {
|
} 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -577,14 +577,14 @@ static void TileLoopClearAlps(TileIndex tile)
|
||||||
/* distance from snow line, in steps of 8 */
|
/* distance from snow line, in steps of 8 */
|
||||||
int k = GetTileZ(tile) - _opt.snow_line;
|
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 (!IsClearGround(tile, CL_SNOW)) return;
|
||||||
if (GetClearDensity(tile) == 0) SetClearGroundDensity(tile, CL_GRASS, 3);
|
if (GetClearDensity(tile) == 0) SetClearGroundDensity(tile, CL_GRASS, 3);
|
||||||
} else {
|
} else {
|
||||||
if (!IsClearGround(tile, CL_SNOW)) {
|
if (!IsClearGround(tile, CL_SNOW)) {
|
||||||
SetClearGroundDensity(tile, CL_SNOW, 0);
|
SetClearGroundDensity(tile, CL_SNOW, 0);
|
||||||
} else {
|
} else {
|
||||||
uint density = min((uint)(k + 8) / 8, 3);
|
uint density = min((uint)(k + TILE_HEIGHT) / TILE_HEIGHT, 3);
|
||||||
|
|
||||||
if (GetClearDensity(tile) < density) {
|
if (GetClearDensity(tile) < density) {
|
||||||
AddClearDensity(tile, 1);
|
AddClearDensity(tile, 1);
|
||||||
|
@ -738,7 +738,7 @@ static void ChangeTileOwner_Clear(TileIndex tile, PlayerID old_player, PlayerID
|
||||||
|
|
||||||
void InitializeClearLand(void)
|
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 = {
|
const TileTypeProcs _tile_type_clear_procs = {
|
||||||
|
|
|
@ -941,7 +941,7 @@ static void PlantFarmField(TileIndex tile)
|
||||||
int type;
|
int type;
|
||||||
|
|
||||||
if (_opt.landscape == LT_HILLY) {
|
if (_opt.landscape == LT_HILLY) {
|
||||||
if (GetTileZ(tile) + 16 >= _opt.snow_line)
|
if (GetTileZ(tile) + TILE_HEIGHT * 2 >= _opt.snow_line)
|
||||||
return;
|
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 && _ignore_restrictions) return true;
|
||||||
if (_game_mode == GM_EDITOR && type != IT_OIL_RIG) return true;
|
if (_game_mode == GM_EDITOR && type != IT_OIL_RIG) return true;
|
||||||
if ((type != IT_OIL_RIG || TileHeight(tile) == 0) &&
|
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;
|
_error_message = STR_483B_CAN_ONLY_BE_POSITIONED;
|
||||||
return false;
|
return false;
|
||||||
|
@ -1171,7 +1171,7 @@ static bool CheckNewIndustry_Oil(TileIndex tile, int type)
|
||||||
static bool CheckNewIndustry_Farm(TileIndex tile, int type)
|
static bool CheckNewIndustry_Farm(TileIndex tile, int type)
|
||||||
{
|
{
|
||||||
if (_opt.landscape == LT_HILLY) {
|
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;
|
_error_message = STR_0239_SITE_UNSUITABLE;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
10
landscape.c
10
landscape.c
|
@ -61,7 +61,7 @@ void FindLandscapeHeight(TileInfo *ti, uint x, uint y)
|
||||||
ti->x = x;
|
ti->x = x;
|
||||||
ti->y = y;
|
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->tileh = 0;
|
||||||
ti->type = MP_VOID;
|
ti->type = MP_VOID;
|
||||||
ti->tile = 0;
|
ti->tile = 0;
|
||||||
|
@ -302,16 +302,16 @@ int32 CmdClearArea(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
|
||||||
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||||
|
|
||||||
// make sure sx,sy are smaller than ex,ey
|
// make sure sx,sy are smaller than ex,ey
|
||||||
sx = TileX(p1) * 16;
|
sx = TileX(p1) * TILE_SIZE;
|
||||||
sy = TileY(p1) * 16;
|
sy = TileY(p1) * TILE_SIZE;
|
||||||
if (ex < sx) intswap(ex, sx);
|
if (ex < sx) intswap(ex, sx);
|
||||||
if (ey < sy) intswap(ey, sy);
|
if (ey < sy) intswap(ey, sy);
|
||||||
|
|
||||||
money = GetAvailableMoneyForCommand();
|
money = GetAvailableMoneyForCommand();
|
||||||
cost = 0;
|
cost = 0;
|
||||||
|
|
||||||
for (x = sx; x <= ex; x += 16) {
|
for (x = sx; x <= ex; x += TILE_SIZE) {
|
||||||
for (y = sy; y <= ey; y += 16) {
|
for (y = sy; y <= ey; y += TILE_SIZE) {
|
||||||
ret = DoCommandByTile(TileVirtXY(x, y), 0, 0, flags & ~DC_EXEC, CMD_LANDSCAPE_CLEAR);
|
ret = DoCommandByTile(TileVirtXY(x, y), 0, 0, flags & ~DC_EXEC, CMD_LANDSCAPE_CLEAR);
|
||||||
if (CmdFailed(ret)) continue;
|
if (CmdFailed(ret)) continue;
|
||||||
cost += ret;
|
cost += ret;
|
||||||
|
|
|
@ -372,7 +372,7 @@ void ShowRenameWaypointWindow(const Waypoint *wp)
|
||||||
/* Are we allowed to change the name of the waypoint? */
|
/* Are we allowed to change the name of the waypoint? */
|
||||||
if (!CheckTileOwnership(wp->xy)) {
|
if (!CheckTileOwnership(wp->xy)) {
|
||||||
ShowErrorMessage(_error_message, STR_CANT_CHANGE_WAYPOINT_NAME,
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -468,7 +468,7 @@ static void StationInitialize(Station *st, TileIndex tile)
|
||||||
// st = Station to update for.
|
// st = Station to update for.
|
||||||
static void UpdateStationVirtCoord(Station *st)
|
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;
|
pt.y -= 32;
|
||||||
if (st->facilities & FACIL_AIRPORT && st->airport_type == AT_OILRIG) pt.y -= 16;
|
if (st->facilities & FACIL_AIRPORT && st->airport_type == AT_OILRIG) pt.y -= 16;
|
||||||
|
|
2
tile.c
2
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 ((s -= min) != 0) r += (--s << 4) + 2;
|
||||||
if ((w -= min) != 0) r += (--w << 4) + 1;
|
if ((w -= min) != 0) r += (--w << 4) + 1;
|
||||||
|
|
||||||
if (h != NULL) *h = min * 8;
|
if (h != NULL) *h = min * TILE_HEIGHT;
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
|
@ -228,7 +228,7 @@ void UpdateTownVirtCoord(Town *t)
|
||||||
Point pt;
|
Point pt;
|
||||||
|
|
||||||
MarkTownSignDirty(t);
|
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(0, t->index);
|
||||||
SetDParam(1, t->population);
|
SetDParam(1, t->population);
|
||||||
UpdateViewportSignPos(&t->sign, pt.x, pt.y - 24,
|
UpdateViewportSignPos(&t->sign, pt.x, pt.y - 24,
|
||||||
|
|
|
@ -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
|
// make sure sx,sy are smaller than ex,ey
|
||||||
sx = TileX(p2);
|
sx = TileX(p2);
|
||||||
sy = TileY(p2);
|
sy = TileY(p2);
|
||||||
ex /= 16; ey /= 16;
|
ex /= TILE_SIZE;
|
||||||
|
ey /= TILE_SIZE;
|
||||||
if (ex < sx) intswap(ex, sx);
|
if (ex < sx) intswap(ex, sx);
|
||||||
if (ey < sy) intswap(ey, sy);
|
if (ey < sy) intswap(ey, sy);
|
||||||
|
|
||||||
|
@ -405,11 +406,11 @@ static void TileLoopTreesAlps(TileIndex tile)
|
||||||
{
|
{
|
||||||
int k = GetTileZ(tile) - _opt.snow_line;
|
int k = GetTileZ(tile) - _opt.snow_line;
|
||||||
|
|
||||||
if (k < -8) {
|
if (k < -TILE_HEIGHT) {
|
||||||
if (GetTreeGround(tile) != TR_SNOW_DESERT) return;
|
if (GetTreeGround(tile) != TR_SNOW_DESERT) return;
|
||||||
SetTreeGroundDensity(tile, TR_GRASS, 0);
|
SetTreeGroundDensity(tile, TR_GRASS, 0);
|
||||||
} else {
|
} 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) {
|
if (GetTreeGround(tile) != TR_SNOW_DESERT || GetTreeDensity(tile) != density) {
|
||||||
SetTreeGroundDensity(tile, TR_SNOW_DESERT, density);
|
SetTreeGroundDensity(tile, TR_SNOW_DESERT, density);
|
||||||
|
|
|
@ -214,8 +214,8 @@ int32 CmdBuildBridge(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
transport = TRANSPORT_RAIL;
|
transport = TRANSPORT_RAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
sx = TileX(p1) * 16;
|
sx = TileX(p1) * TILE_SIZE;
|
||||||
sy = TileY(p1) * 16;
|
sy = TileY(p1) * TILE_SIZE;
|
||||||
|
|
||||||
/* check if valid, and make sure that (x,y) are smaller than (sx,sy) */
|
/* check if valid, and make sure that (x,y) are smaller than (sx,sy) */
|
||||||
if (x == sx) {
|
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 */
|
/* 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);
|
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 */
|
/* retrieve landscape height and ensure it's on land */
|
||||||
|
|
|
@ -389,7 +389,7 @@ restart:
|
||||||
do {
|
do {
|
||||||
if (--j == 0) goto restart;
|
if (--j == 0) goto restart;
|
||||||
tile = TILE_MASK(tile + TileOffsByDir(dir));
|
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));
|
assert(tile == TILE_MASK(tile));
|
||||||
|
|
||||||
|
|
|
@ -1728,7 +1728,10 @@ static void MaybeReplaceVehicle(Vehicle *v)
|
||||||
* If it's not a train, the value is unused
|
* 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
|
* round up to the length of the tiles used for the train instead of the train length instead
|
||||||
* Useful when newGRF uses custom length */
|
* 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;
|
_current_player = v->owner;
|
||||||
|
|
|
@ -413,7 +413,7 @@ static void DrawTile_Water(TileInfo *ti)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WATER_COAST:
|
case WATER_COAST:
|
||||||
assert(ti->tileh < 16);
|
assert(!IsSteepTileh(ti->tileh));
|
||||||
DrawGroundSprite(_water_shore_sprites[ti->tileh]);
|
DrawGroundSprite(_water_shore_sprites[ti->tileh]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ static Waypoint* AllocateWaypoint(void)
|
||||||
/* Update the sign for the waypoint */
|
/* Update the sign for the waypoint */
|
||||||
static void UpdateWaypointSign(Waypoint* wp)
|
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);
|
SetDParam(0, wp->index);
|
||||||
UpdateViewportSignPos(&wp->sign, pt.x, pt.y - 0x20, STR_WAYPOINT_VIEWPORT);
|
UpdateViewportSignPos(&wp->sign, pt.x, pt.y - 0x20, STR_WAYPOINT_VIEWPORT);
|
||||||
}
|
}
|
||||||
|
|
14
window.c
14
window.c
|
@ -1200,12 +1200,12 @@ stop_capt:;
|
||||||
y += (dy >> 1) << 4;
|
y += (dy >> 1) << 4;
|
||||||
|
|
||||||
if (dy & 1) {
|
if (dy & 1) {
|
||||||
x += 16;
|
x += TILE_SIZE;
|
||||||
sub += 2;
|
sub += 2;
|
||||||
if (sub > 3) {
|
if (sub > 3) {
|
||||||
sub -= 4;
|
sub -= 4;
|
||||||
x -= 16;
|
x -= TILE_SIZE;
|
||||||
y += 16;
|
y += TILE_SIZE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1217,16 +1217,16 @@ stop_capt:;
|
||||||
x = -hvx;
|
x = -hvx;
|
||||||
sub = 0;
|
sub = 0;
|
||||||
}
|
}
|
||||||
if (x > (int)MapMaxX() * 16 - hvx) {
|
if (x > (int)MapMaxX() * TILE_SIZE - hvx) {
|
||||||
x = MapMaxX() * 16 - hvx;
|
x = MapMaxX() * TILE_SIZE - hvx;
|
||||||
sub = 0;
|
sub = 0;
|
||||||
}
|
}
|
||||||
if (y < -hvy) {
|
if (y < -hvy) {
|
||||||
y = -hvy;
|
y = -hvy;
|
||||||
sub = 0;
|
sub = 0;
|
||||||
}
|
}
|
||||||
if (y > (int)MapMaxY() * 16 - hvy) {
|
if (y > (int)MapMaxY() * TILE_SIZE - hvy) {
|
||||||
y = MapMaxY() * 16 - hvy;
|
y = MapMaxY() * TILE_SIZE - hvy;
|
||||||
sub = 0;
|
sub = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue