1
0
Fork 0

(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE

release/0.5
celestar 2006-04-03 05:32:11 +00:00
parent a6403bd50a
commit 3aa1e38be6
13 changed files with 103 additions and 103 deletions

View File

@ -178,8 +178,8 @@ int32 CmdBuildAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
v->tile = tile; v->tile = tile;
// u->tile = 0; // u->tile = 0;
x = TileX(tile) * 16 + 5; x = TileX(tile) * TILE_SIZE + 5;
y = TileY(tile) * 16 + 3; y = TileY(tile) * TILE_SIZE + 3;
v->x_pos = u->x_pos = x; v->x_pos = u->x_pos = x;
v->y_pos = u->y_pos = y; v->y_pos = u->y_pos = y;
@ -765,8 +765,8 @@ static bool AircraftController(Vehicle *v)
if (tile == 0) tile = st->xy; if (tile == 0) tile = st->xy;
// xy of destination // xy of destination
x = TileX(tile) * 16; x = TileX(tile) * TILE_SIZE;
y = TileY(tile) * 16; y = TileY(tile) * TILE_SIZE;
} }
// get airport moving data // get airport moving data

View File

@ -317,7 +317,7 @@ byte GetCommandFlags(uint cmd) {return _command_proc_table[cmd & 0xFF].flags;}
int32 DoCommandByTile(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc) int32 DoCommandByTile(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc)
{ {
return DoCommand(TileX(tile) * 16, TileY(tile) * 16, p1, p2, flags, procc); return DoCommand(TileX(tile) * TILE_SIZE, TileY(tile) * TILE_SIZE, p1, p2, flags, procc);
} }
@ -401,8 +401,8 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
bool notest; bool notest;
StringID error_part1; StringID error_part1;
int x = TileX(tile) * 16; int x = TileX(tile) * TILE_SIZE;
int y = TileY(tile) * 16; int y = TileY(tile) * TILE_SIZE;
/* Do not even think about executing out-of-bounds tile-commands */ /* Do not even think about executing out-of-bounds tile-commands */
if (tile >= MapSize()) { if (tile >= MapSize()) {

View File

@ -191,7 +191,7 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
0); 0);
} }
} }
if (v->y_pos >= ((int)MapSizeY() + 9) * 16 - 1) if (v->y_pos >= ((int)MapSizeY() + 9) * TILE_SIZE - 1)
DeleteDisasterVeh(v); DeleteDisasterVeh(v);
return; return;
} }
@ -266,9 +266,9 @@ static void DisasterTick_UFO(Vehicle *v)
if (v->current_order.station == 0) { if (v->current_order.station == 0) {
// fly around randomly // fly around randomly
int x = TileX(v->dest_tile) * 16; int x = TileX(v->dest_tile) * TILE_SIZE;
int y = TileY(v->dest_tile) * 16; int y = TileY(v->dest_tile) * TILE_SIZE;
if (abs(x - v->x_pos) + abs(y - v->y_pos) >= 16) { if (abs(x - v->x_pos) + abs(y - v->y_pos) >= TILE_SIZE) {
v->direction = GetDirectionTowards(v, x, y); v->direction = GetDirectionTowards(v, x, y);
GetNewVehiclePos(v, &gp); GetNewVehiclePos(v, &gp);
SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
@ -299,7 +299,7 @@ static void DisasterTick_UFO(Vehicle *v)
dist = abs(v->x_pos - u->x_pos) + abs(v->y_pos - u->y_pos); dist = abs(v->x_pos - u->x_pos) + abs(v->y_pos - u->y_pos);
if (dist < 16 && !(u->vehstatus&VS_HIDDEN) && u->breakdown_ctr==0) { if (dist < TILE_SIZE && !(u->vehstatus&VS_HIDDEN) && u->breakdown_ctr==0) {
u->breakdown_ctr = 3; u->breakdown_ctr = 3;
u->breakdown_delay = 140; u->breakdown_delay = 140;
} }
@ -308,7 +308,7 @@ static void DisasterTick_UFO(Vehicle *v)
GetNewVehiclePos(v, &gp); GetNewVehiclePos(v, &gp);
z = v->z_pos; z = v->z_pos;
if (dist <= 16 && z > u->z_pos) z--; if (dist <= TILE_SIZE && z > u->z_pos) z--;
SetDisasterVehiclePos(v, gp.x, gp.y, z); SetDisasterVehiclePos(v, gp.x, gp.y, z);
if (z <= u->z_pos && (u->vehstatus&VS_HIDDEN)==0) { if (z <= u->z_pos && (u->vehstatus&VS_HIDDEN)==0) {
@ -365,8 +365,8 @@ static void DisasterTick_2(Vehicle *v)
if (v->current_order.station == 2) { if (v->current_order.station == 2) {
if (!(v->tick_counter&3)) { if (!(v->tick_counter&3)) {
Industry *i = GetIndustry(v->dest_tile); Industry *i = GetIndustry(v->dest_tile);
int x = TileX(i->xy) * 16; int x = TileX(i->xy) * TILE_SIZE;
int y = TileY(i->xy) * 16; int y = TileY(i->xy) * TILE_SIZE;
uint32 r = Random(); uint32 r = Random();
CreateEffectVehicleAbove( CreateEffectVehicleAbove(
@ -397,10 +397,10 @@ static void DisasterTick_2(Vehicle *v)
TileIndex tile; TileIndex tile;
uint ind; uint ind;
x = v->x_pos - 15*16; x = v->x_pos - 15 * TILE_SIZE;
y = v->y_pos; y = v->y_pos;
if ( (uint)x > MapMaxX() * 16-1) if ( (uint)x > MapMaxX() * TILE_SIZE - 1)
return; return;
tile = TileVirtXY(x, y); tile = TileVirtXY(x, y);
@ -429,7 +429,7 @@ static void DisasterTick_3(Vehicle *v)
GetNewVehiclePos(v, &gp); GetNewVehiclePos(v, &gp);
SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
if (gp.x > (int)MapSizeX() * 16 + 9*16 - 1) { if (gp.x > (int)MapSizeX() * TILE_SIZE + 9 * TILE_SIZE - 1) {
DeleteDisasterVeh(v); DeleteDisasterVeh(v);
return; return;
} }
@ -437,8 +437,8 @@ static void DisasterTick_3(Vehicle *v)
if (v->current_order.station == 2) { if (v->current_order.station == 2) {
if (!(v->tick_counter&3)) { if (!(v->tick_counter&3)) {
Industry *i = GetIndustry(v->dest_tile); Industry *i = GetIndustry(v->dest_tile);
int x = TileX(i->xy) * 16; int x = TileX(i->xy) * TILE_SIZE;
int y = TileY(i->xy) * 16; int y = TileY(i->xy) * TILE_SIZE;
uint32 r = Random(); uint32 r = Random();
CreateEffectVehicleAbove( CreateEffectVehicleAbove(
@ -469,10 +469,10 @@ static void DisasterTick_3(Vehicle *v)
TileIndex tile; TileIndex tile;
uint ind; uint ind;
x = v->x_pos - 15*16; x = v->x_pos - 15 * TILE_SIZE;
y = v->y_pos; y = v->y_pos;
if ( (uint)x > MapMaxX() * 16-1) if ( (uint)x > MapMaxX() * TILE_SIZE - 1)
return; return;
tile = TileVirtXY(x, y); tile = TileVirtXY(x, y);
@ -516,8 +516,8 @@ static void DisasterTick_4(Vehicle *v)
v->tick_counter++; v->tick_counter++;
if (v->current_order.station == 1) { if (v->current_order.station == 1) {
int x = TileX(v->dest_tile) * 16 + 8; int x = TileX(v->dest_tile) * TILE_SIZE + 8;
int y = TileY(v->dest_tile) * 16 + 8; int y = TileY(v->dest_tile) * TILE_SIZE + 8;
if (abs(v->x_pos - x) + abs(v->y_pos - y) >= 8) { if (abs(v->x_pos - x) + abs(v->y_pos - y) >= 8) {
v->direction = GetDirectionTowards(v, x, y); v->direction = GetDirectionTowards(v, x, y);
@ -536,7 +536,7 @@ static void DisasterTick_4(Vehicle *v)
FOR_ALL_VEHICLES(u) { FOR_ALL_VEHICLES(u) {
if (u->type == VEH_Train || u->type == VEH_Road) { if (u->type == VEH_Train || u->type == VEH_Road) {
if (abs(u->x_pos - v->x_pos) + abs(u->y_pos - v->y_pos) <= 12*16) { if (abs(u->x_pos - v->x_pos) + abs(u->y_pos - v->y_pos) <= 12 * TILE_SIZE) {
u->breakdown_ctr = 5; u->breakdown_ctr = 5;
u->breakdown_delay = 0xF0; u->breakdown_delay = 0xF0;
} }
@ -556,7 +556,7 @@ static void DisasterTick_4(Vehicle *v)
return; return;
} }
InitializeDisasterVehicle(u, -6 * 16, v->y_pos, 135, DIR_SW, 11); InitializeDisasterVehicle(u, -6 * TILE_SIZE, v->y_pos, 135, DIR_SW, 11);
u->u.disaster.unk2 = v->index; u->u.disaster.unk2 = v->index;
w = ForceAllocateSpecialVehicle(); w = ForceAllocateSpecialVehicle();
@ -564,13 +564,13 @@ static void DisasterTick_4(Vehicle *v)
return; return;
u->next = w; u->next = w;
InitializeDisasterVehicle(w, -6 * 16, v->y_pos, 0, DIR_SW, 12); InitializeDisasterVehicle(w, -6 * TILE_SIZE, v->y_pos, 0, DIR_SW, 12);
w->vehstatus |= VS_DISASTER; w->vehstatus |= VS_DISASTER;
} else if (v->current_order.station < 1) { } else if (v->current_order.station < 1) {
int x = TileX(v->dest_tile) * 16; int x = TileX(v->dest_tile) * TILE_SIZE;
int y = TileY(v->dest_tile) * 16; int y = TileY(v->dest_tile) * TILE_SIZE;
if (abs(x - v->x_pos) + abs(y - v->y_pos) >= 16) { if (abs(x - v->x_pos) + abs(y - v->y_pos) >= TILE_SIZE) {
v->direction = GetDirectionTowards(v, x, y); v->direction = GetDirectionTowards(v, x, y);
GetNewVehiclePos(v, &gp); GetNewVehiclePos(v, &gp);
SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
@ -610,14 +610,14 @@ static void DisasterTick_4b(Vehicle *v)
GetNewVehiclePos(v, &gp); GetNewVehiclePos(v, &gp);
SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
if (gp.x > (int)MapSizeX() * 16 + 9*16 - 1) { if (gp.x > (int)MapSizeX() * TILE_SIZE + 9 * TILE_SIZE - 1) {
DeleteDisasterVeh(v); DeleteDisasterVeh(v);
return; return;
} }
if (v->current_order.station == 0) { if (v->current_order.station == 0) {
u = GetVehicle(v->u.disaster.unk2); u = GetVehicle(v->u.disaster.unk2);
if (abs(v->x_pos - u->x_pos) > 16) if (abs(v->x_pos - u->x_pos) > TILE_SIZE)
return; return;
v->current_order.station = 1; v->current_order.station = 1;
@ -715,13 +715,13 @@ static void Disaster0_Init(void)
/* Pick a random place, unless we find /* Pick a random place, unless we find
a small airport */ a small airport */
x = TileX(Random()) * 16 + 8; x = TileX(Random()) * TILE_SIZE + 8;
FOR_ALL_STATIONS(st) { FOR_ALL_STATIONS(st) {
if (st->xy && st->airport_tile != 0 && if (st->xy && st->airport_tile != 0 &&
st->airport_type <= 1 && st->airport_type <= 1 &&
IS_HUMAN_PLAYER(st->owner)) { IS_HUMAN_PLAYER(st->owner)) {
x = (TileX(st->xy) + 2) * 16; x = (TileX(st->xy) + 2) * TILE_SIZE;
break; break;
} }
} }
@ -745,7 +745,7 @@ static void Disaster1_Init(void)
if (v == NULL) if (v == NULL)
return; return;
x = TileX(Random()) * 16 + 8; x = TileX(Random()) * TILE_SIZE + 8;
InitializeDisasterVehicle(v, x, 0, 135, DIR_SE, 2); InitializeDisasterVehicle(v, x, 0, 135, DIR_SE, 2);
v->dest_tile = TileXY(MapSizeX() / 2, MapSizeY() / 2); v->dest_tile = TileXY(MapSizeX() / 2, MapSizeY() / 2);
@ -783,8 +783,8 @@ static void Disaster2_Init(void)
if (v == NULL) if (v == NULL)
return; return;
x = (MapSizeX() + 9) * 16 - 1; x = (MapSizeX() + 9) * TILE_SIZE - 1;
y = TileY(found->xy) * 16 + 37; y = TileY(found->xy) * TILE_SIZE + 37;
InitializeDisasterVehicle(v, x, y, 135, DIR_NE, 4); InitializeDisasterVehicle(v, x, y, 135, DIR_NE, 4);
@ -819,8 +819,8 @@ static void Disaster3_Init(void)
if (v == NULL) if (v == NULL)
return; return;
x = -16 * 16; x = -16 * TILE_SIZE;
y = TileY(found->xy) * 16 + 37; y = TileY(found->xy) * TILE_SIZE + 37;
InitializeDisasterVehicle(v, x, y, 135, DIR_SW, 6); InitializeDisasterVehicle(v, x, y, 135, DIR_SW, 6);
@ -845,9 +845,9 @@ static void Disaster4_Init(void)
if (v == NULL) return; if (v == NULL) return;
x = TileX(Random()) * 16 + 8; x = TileX(Random()) * TILE_SIZE + 8;
y = MapMaxX() * 16 - 1; y = MapMaxX() * TILE_SIZE - 1;
InitializeDisasterVehicle(v, x, y, 135, DIR_NW, 9); InitializeDisasterVehicle(v, x, y, 135, DIR_NW, 9);
v->dest_tile = TileXY(MapSizeX() / 2, MapSizeY() / 2); v->dest_tile = TileXY(MapSizeX() / 2, MapSizeY() / 2);
v->age = 0; v->age = 0;
@ -872,10 +872,10 @@ static void Disaster5_Init(void)
if (v == NULL) return; if (v == NULL) return;
r = Random(); r = Random();
x = TileX(r) * 16 + 8; x = TileX(r) * TILE_SIZE + 8;
if (r & 0x80000000) { if (r & 0x80000000) {
y = MapMaxX() * 16 - 8 - 1; y = MapMaxX() * TILE_SIZE - 8 - 1;
dir = DIR_NW; dir = DIR_NW;
} else { } else {
y = 8; y = 8;
@ -896,10 +896,10 @@ static void Disaster6_Init(void)
if (v == NULL) return; if (v == NULL) return;
r = Random(); r = Random();
x = TileX(r) * 16 + 8; x = TileX(r) * TILE_SIZE + 8;
if (r & 0x80000000) { if (r & 0x80000000) {
y = MapMaxX() * 16 - 8 - 1; y = MapMaxX() * TILE_SIZE - 8 - 1;
dir = DIR_NW; dir = DIR_NW;
} else { } else {
y = 8; y = 8;

View File

@ -1448,7 +1448,7 @@ int LoadUnloadVehicle(Vehicle *v)
if (v->type == VEH_Train) { if (v->type == VEH_Train) {
// Each platform tile is worth 2 rail vehicles. // Each platform tile is worth 2 rail vehicles.
int overhang = v->u.rail.cached_total_length - GetStationPlatforms(st, v->tile) * 16; int overhang = v->u.rail.cached_total_length - GetStationPlatforms(st, v->tile) * TILE_SIZE;
if (overhang > 0) { if (overhang > 0) {
unloading_time <<= 1; unloading_time <<= 1;
unloading_time += (overhang * unloading_time) / 8; unloading_time += (overhang * unloading_time) / 8;

View File

@ -734,8 +734,8 @@ static void TileLoopIndustry_BubbleGenerator(TileIndex tile)
dir = Random() & 3; dir = Random() & 3;
v = CreateEffectVehicleAbove( v = CreateEffectVehicleAbove(
TileX(tile) * 16 + _tileloop_ind_case_161[dir + 0], TileX(tile) * TILE_SIZE + _tileloop_ind_case_161[dir + 0],
TileY(tile) * 16 + _tileloop_ind_case_161[dir + 4], TileY(tile) * TILE_SIZE + _tileloop_ind_case_161[dir + 4],
_tileloop_ind_case_161[dir + 8], _tileloop_ind_case_161[dir + 8],
EV_BUBBLE EV_BUBBLE
); );
@ -819,7 +819,7 @@ static void TileLoop_Industry(TileIndex tile)
break; break;
case 49: case 49:
CreateEffectVehicleAbove(TileX(tile) * 16 + 6, TileY(tile) * 16 + 6, 43, EV_SMOKE); CreateEffectVehicleAbove(TileX(tile) * TILE_SIZE + 6, TileY(tile) * TILE_SIZE + 6, 43, EV_SMOKE);
break; break;
@ -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)) < 16) return true; DistanceFromEdge(TILE_ADDXY(tile, 1, 1)) < TILE_SIZE) return true;
_error_message = STR_483B_CAN_ONLY_BE_POSITIONED; _error_message = STR_483B_CAN_ONLY_BE_POSITIONED;
return false; return false;

View File

@ -711,7 +711,7 @@ void DrawStationCoverageAreaText(int sx, int sy, uint mask, int rad) {
TileIndex tile = TileVirtXY(_thd.pos.x, _thd.pos.y); TileIndex tile = TileVirtXY(_thd.pos.x, _thd.pos.y);
AcceptedCargo accepts; AcceptedCargo accepts;
if (tile < MapSize()) { if (tile < MapSize()) {
GetAcceptanceAroundTiles(accepts, tile, _thd.size.x / 16, _thd.size.y / 16 , rad); GetAcceptanceAroundTiles(accepts, tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE , rad);
DrawStationCoverageText(accepts, sx, sy, mask); DrawStationCoverageText(accepts, sx, sy, mask);
} }
} }

View File

@ -943,8 +943,8 @@ static void TileLoop_Road(TileIndex tile)
SndPlayTileFx(SND_21_JACKHAMMER, tile); SndPlayTileFx(SND_21_JACKHAMMER, tile);
CreateEffectVehicleAbove( CreateEffectVehicleAbove(
TileX(tile) * 16 + 7, TileX(tile) * TILE_SIZE + 7,
TileY(tile) * 16 + 7, TileY(tile) * TILE_SIZE + 7,
0, 0,
EV_BULLDOZER); EV_BULLDOZER);
MarkTileDirtyByTile(tile); MarkTileDirtyByTile(tile);

View File

@ -141,8 +141,8 @@ int32 CmdBuildRoadVeh(int x, int y, uint32 flags, uint32 p1, uint32 p2)
v->owner = _current_player; v->owner = _current_player;
v->tile = tile; v->tile = tile;
x = TileX(tile) * 16 + 8; x = TileX(tile) * TILE_SIZE + 8;
y = TileY(tile) * 16 + 8; y = TileY(tile) * TILE_SIZE + 8;
v->x_pos = x; v->x_pos = x;
v->y_pos = y; v->y_pos = y;
v->z_pos = GetSlopeZ(x,y); v->z_pos = GetSlopeZ(x,y);
@ -1211,8 +1211,8 @@ static void RoadVehController(Vehicle *v)
rd2 = _roadveh_data_2[dir]; rd2 = _roadveh_data_2[dir];
rdp = _road_drive_data[(_opt.road_side << 4) + rd2]; rdp = _road_drive_data[(_opt.road_side << 4) + rd2];
x = TileX(v->tile) * 16 + (rdp[6].x & 0xF); x = TileX(v->tile) * TILE_SIZE + (rdp[6].x & 0xF);
y = TileY(v->tile) * 16 + (rdp[6].y & 0xF); y = TileY(v->tile) * TILE_SIZE + (rdp[6].y & 0xF);
if (RoadVehFindCloseTo(v, x, y, v->direction) != NULL) return; if (RoadVehFindCloseTo(v, x, y, v->direction) != NULL) return;
@ -1299,8 +1299,8 @@ again:
rdp = _road_drive_data[(dir + (_opt.road_side << 4)) ^ v->u.road.overtaking]; rdp = _road_drive_data[(dir + (_opt.road_side << 4)) ^ v->u.road.overtaking];
x = TileX(tile) * 16 + rdp[0].x; x = TileX(tile) * TILE_SIZE + rdp[0].x;
y = TileY(tile) * 16 + rdp[0].y; y = TileY(tile) * TILE_SIZE + rdp[0].y;
newdir = RoadVehGetSlidingDirection(v, x, y); newdir = RoadVehGetSlidingDirection(v, x, y);
if (RoadVehFindCloseTo(v, x, y, newdir) != NULL) return; if (RoadVehFindCloseTo(v, x, y, newdir) != NULL) return;
@ -1360,8 +1360,8 @@ again:
tmp = (_opt.road_side << 4) + dir; tmp = (_opt.road_side << 4) + dir;
rdp = _road_drive_data[tmp]; rdp = _road_drive_data[tmp];
x = TileX(v->tile) * 16 + rdp[1].x; x = TileX(v->tile) * TILE_SIZE + rdp[1].x;
y = TileY(v->tile) * 16 + rdp[1].y; y = TileY(v->tile) * TILE_SIZE + rdp[1].y;
newdir = RoadVehGetSlidingDirection(v, x, y); newdir = RoadVehGetSlidingDirection(v, x, y);
if (RoadVehFindCloseTo(v, x, y, newdir) != NULL) return; if (RoadVehFindCloseTo(v, x, y, newdir) != NULL) return;

View File

@ -854,8 +854,8 @@ int32 CmdBuildShip(int x, int y, uint32 flags, uint32 p1, uint32 p2)
v->owner = _current_player; v->owner = _current_player;
v->tile = tile; v->tile = tile;
x = TileX(tile) * 16 + 8; x = TileX(tile) * TILE_SIZE + 8;
y = TileY(tile) * 16 + 8; y = TileY(tile) * TILE_SIZE + 8;
v->x_pos = x; v->x_pos = x;
v->y_pos = y; v->y_pos = y;
v->z_pos = GetSlopeZ(x,y); v->z_pos = GetSlopeZ(x,y);

View File

@ -623,8 +623,8 @@ static void DrawSmallMap(DrawPixelInfo *dpi, Window *w, int type, bool show_town
} }
} }
tile_x = WP(w,smallmap_d).scroll_x / 16; tile_x = WP(w,smallmap_d).scroll_x / TILE_SIZE;
tile_y = WP(w,smallmap_d).scroll_y / 16; tile_y = WP(w,smallmap_d).scroll_y / TILE_SIZE;
dx = dpi->left + WP(w,smallmap_d).subscroll; dx = dpi->left + WP(w,smallmap_d).subscroll;
tile_x -= dx / 4; tile_x -= dx / 4;
@ -701,8 +701,8 @@ skip_column:
(v->vehstatus & (VS_HIDDEN | VS_UNCLICKABLE)) == 0) { (v->vehstatus & (VS_HIDDEN | VS_UNCLICKABLE)) == 0) {
// Remap into flat coordinates. // Remap into flat coordinates.
Point pt = RemapCoords( Point pt = RemapCoords(
(v->x_pos - WP(w,smallmap_d).scroll_x) / 16, (v->x_pos - WP(w,smallmap_d).scroll_x) / TILE_SIZE,
(v->y_pos - WP(w,smallmap_d).scroll_y) / 16, (v->y_pos - WP(w,smallmap_d).scroll_y) / TILE_SIZE,
0); 0);
x = pt.x; x = pt.x;
y = pt.y; y = pt.y;
@ -746,8 +746,8 @@ skip_column:
if (t->xy != 0) { if (t->xy != 0) {
// Remap the town coordinate // Remap the town coordinate
Point pt = RemapCoords( Point pt = RemapCoords(
(int)(TileX(t->xy) * 16 - WP(w, smallmap_d).scroll_x) / 16, (int)(TileX(t->xy) * TILE_SIZE - WP(w, smallmap_d).scroll_x) / TILE_SIZE,
(int)(TileY(t->xy) * 16 - WP(w, smallmap_d).scroll_y) / 16, (int)(TileY(t->xy) * TILE_SIZE - WP(w, smallmap_d).scroll_y) / TILE_SIZE,
0); 0);
x = pt.x - WP(w,smallmap_d).subscroll + 3 - (t->sign.width_2 >> 1); x = pt.x - WP(w,smallmap_d).subscroll + 3 - (t->sign.width_2 >> 1);
y = pt.y; y = pt.y;
@ -776,10 +776,10 @@ skip_column:
x = vp->virtual_left - pt.x; x = vp->virtual_left - pt.x;
y = vp->virtual_top - pt.y; y = vp->virtual_top - pt.y;
x2 = (x + vp->virtual_width) / 16; x2 = (x + vp->virtual_width) / TILE_SIZE;
y2 = (y + vp->virtual_height) / 16; y2 = (y + vp->virtual_height) / TILE_SIZE;
x /= 16; x /= TILE_SIZE;
y /= 16; y /= TILE_SIZE;
x -= WP(w,smallmap_d).subscroll; x -= WP(w,smallmap_d).subscroll;
x2 -= WP(w,smallmap_d).subscroll; x2 -= WP(w,smallmap_d).subscroll;

View File

@ -208,8 +208,8 @@ static void SndPlayScreenCoordFx(SoundFx sound, int x, int y)
void SndPlayTileFx(SoundFx sound, TileIndex tile) void SndPlayTileFx(SoundFx sound, TileIndex tile)
{ {
/* emits sound from center (+ 8) of the tile */ /* emits sound from center (+ 8) of the tile */
int x = TileX(tile) * 16 + 8; int x = TileX(tile) * TILE_SIZE + 8;
int y = TileY(tile) * 16 + 8; int y = TileY(tile) * TILE_SIZE + 8;
Point pt = RemapCoords(x, y, GetSlopeZ(x, y)); Point pt = RemapCoords(x, y, GetSlopeZ(x, y));
SndPlayScreenCoordFx(sound, pt.x, pt.y); SndPlayScreenCoordFx(sound, pt.x, pt.y);
} }

View File

@ -367,7 +367,7 @@ static VehicleID _vehicle_position_hash[0x1000];
void *VehicleFromPos(TileIndex tile, void *data, VehicleFromPosProc *proc) void *VehicleFromPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
{ {
int x,y,x2,y2; int x,y,x2,y2;
Point pt = RemapCoords(TileX(tile) * 16, TileY(tile) * 16, 0); Point pt = RemapCoords(TileX(tile) * TILE_SIZE, TileY(tile) * TILE_SIZE, 0);
x2 = ((pt.x + 104) & 0x1F80) >> 7; x2 = ((pt.x + 104) & 0x1F80) >> 7;
x = ((pt.x - 174) & 0x1F80) >> 7; x = ((pt.x - 174) & 0x1F80) >> 7;

View File

@ -135,8 +135,8 @@ void AssignWindowViewport(Window *w, int x, int y,
veh = GetVehicle(WP(w, vp_d).follow_vehicle); veh = GetVehicle(WP(w, vp_d).follow_vehicle);
pt = MapXYZToViewport(vp, veh->x_pos, veh->y_pos, veh->z_pos); pt = MapXYZToViewport(vp, veh->x_pos, veh->y_pos, veh->z_pos);
} else { } else {
uint x = TileX(follow_flags) * 16; uint x = TileX(follow_flags) * TILE_SIZE;
uint y = TileY(follow_flags) * 16; uint y = TileY(follow_flags) * TILE_SIZE;
WP(w, vp_d).follow_vehicle = INVALID_VEHICLE; WP(w, vp_d).follow_vehicle = INVALID_VEHICLE;
pt = MapXYZToViewport(vp, x, y, GetSlopeZ(x, y)); pt = MapXYZToViewport(vp, x, y, GetSlopeZ(x, y));
@ -310,7 +310,7 @@ static Point TranslateXYToTileCoord(const ViewPort *vp, int x, int y)
pt.x = a+z; pt.x = a+z;
pt.y = b+z; pt.y = b+z;
if ((uint)pt.x >= MapMaxX() * 16 || (uint)pt.y >= MapMaxY() * 16) { if ((uint)pt.x >= MapMaxX() * TILE_SIZE || (uint)pt.y >= MapMaxY() * TILE_SIZE) {
pt.x = pt.y = -1; pt.x = pt.y = -1;
} }
@ -1349,8 +1349,8 @@ void UpdateViewportPosition(Window *w)
vx = -x + y * 2; vx = -x + y * 2;
vy = x + y * 2; vy = x + y * 2;
// clamp to size of map // clamp to size of map
vx = clamp(vx, 0 * 4, MapMaxX() * 16 * 4); vx = clamp(vx, 0 * 4, MapMaxX() * TILE_SIZE * 4);
vy = clamp(vy, 0 * 4, MapMaxY() * 16 * 4); vy = clamp(vy, 0 * 4, MapMaxY() * TILE_SIZE * 4);
// Convert map coordinates to viewport coordinates // Convert map coordinates to viewport coordinates
x = (-vx + vy) / 2; x = (-vx + vy) / 2;
y = ( vx + vy) / 4; y = ( vx + vy) / 4;
@ -1420,7 +1420,7 @@ void MarkAllViewportsDirty(int left, int top, int right, int bottom)
void MarkTileDirtyByTile(TileIndex tile) void MarkTileDirtyByTile(TileIndex tile)
{ {
Point pt = RemapCoords(TileX(tile) * 16, TileY(tile) * 16, GetTileZ(tile)); Point pt = RemapCoords(TileX(tile) * TILE_SIZE, TileY(tile) * TILE_SIZE, GetTileZ(tile));
MarkAllViewportsDirty( MarkAllViewportsDirty(
pt.x - 31, pt.x - 31,
pt.y - 122, pt.y - 122,
@ -1434,8 +1434,8 @@ void MarkTileDirty(int x, int y)
uint z = 0; uint z = 0;
Point pt; Point pt;
if (IS_INT_INSIDE(x, 0, MapSizeX() * 16) && if (IS_INT_INSIDE(x, 0, MapSizeX() * TILE_SIZE) &&
IS_INT_INSIDE(y, 0, MapSizeY() * 16)) IS_INT_INSIDE(y, 0, MapSizeY() * TILE_SIZE))
z = GetTileZ(TileVirtXY(x, y)); z = GetTileZ(TileVirtXY(x, y));
pt = RemapCoords(x, y, z); pt = RemapCoords(x, y, z);
@ -1473,9 +1473,9 @@ static void SetSelectionTilesDirty(void)
int y_bk = y; int y_bk = y;
do { do {
MarkTileDirty(x, y); MarkTileDirty(x, y);
} while ( (y+=16) != y_size); } while ( (y += TILE_SIZE) != y_size);
y = y_bk; y = y_bk;
} while ( (x+=16) != x_size); } while ( (x += TILE_SIZE) != x_size);
} }
@ -1801,7 +1801,7 @@ bool ScrollMainWindowTo(int x, int y)
bool ScrollMainWindowToTile(TileIndex tile) bool ScrollMainWindowToTile(TileIndex tile)
{ {
return ScrollMainWindowTo(TileX(tile) * 16 + 8, TileY(tile) * 16 + 8); return ScrollMainWindowTo(TileX(tile) * TILE_SIZE + 8, TileY(tile) * TILE_SIZE + 8);
} }
void SetRedErrorSquare(TileIndex tile) void SetRedErrorSquare(TileIndex tile)
@ -1819,18 +1819,18 @@ void SetRedErrorSquare(TileIndex tile)
void SetTileSelectSize(int w, int h) void SetTileSelectSize(int w, int h)
{ {
_thd.new_size.x = w * 16; _thd.new_size.x = w * TILE_SIZE;
_thd.new_size.y = h * 16; _thd.new_size.y = h * TILE_SIZE;
_thd.new_outersize.x = 0; _thd.new_outersize.x = 0;
_thd.new_outersize.y = 0; _thd.new_outersize.y = 0;
} }
void SetTileSelectBigSize(int ox, int oy, int sx, int sy) void SetTileSelectBigSize(int ox, int oy, int sx, int sy)
{ {
_thd.offs.x = ox * 16; _thd.offs.x = ox * TILE_SIZE;
_thd.offs.y = oy * 16; _thd.offs.y = oy * TILE_SIZE;
_thd.new_outersize.x = sx * 16; _thd.new_outersize.x = sx * TILE_SIZE;
_thd.new_outersize.y = sy * 16; _thd.new_outersize.y = sy * TILE_SIZE;
} }
/* returns the best autorail highlight type from map coordinates */ /* returns the best autorail highlight type from map coordinates */
@ -1860,8 +1860,8 @@ void UpdateTileSelection(void)
if (y1 >= y2) intswap(y1,y2); if (y1 >= y2) intswap(y1,y2);
_thd.new_pos.x = x1; _thd.new_pos.x = x1;
_thd.new_pos.y = y1; _thd.new_pos.y = y1;
_thd.new_size.x = x2 - x1 + 16; _thd.new_size.x = x2 - x1 + TILE_SIZE;
_thd.new_size.y = y2 - y1 + 16; _thd.new_size.y = y2 - y1 + TILE_SIZE;
_thd.new_drawstyle = _thd.next_drawstyle; _thd.new_drawstyle = _thd.next_drawstyle;
} }
} else if (_thd.place_mode != VHM_NONE) { } else if (_thd.place_mode != VHM_NONE) {
@ -1908,10 +1908,10 @@ void UpdateTileSelection(void)
void VpStartPlaceSizing(TileIndex tile, int user) void VpStartPlaceSizing(TileIndex tile, int user)
{ {
_thd.userdata = user; _thd.userdata = user;
_thd.selend.x = TileX(tile) * 16; _thd.selend.x = TileX(tile) * TILE_SIZE;
_thd.selstart.x = TileX(tile) * 16; _thd.selstart.x = TileX(tile) * TILE_SIZE;
_thd.selend.y = TileY(tile) * 16; _thd.selend.y = TileY(tile) * TILE_SIZE;
_thd.selstart.y = TileY(tile) * 16; _thd.selstart.y = TileY(tile) * TILE_SIZE;
if (_thd.place_mode == VHM_RECT) { if (_thd.place_mode == VHM_RECT) {
_thd.place_mode = VHM_SPECIAL; _thd.place_mode = VHM_SPECIAL;
_thd.next_drawstyle = HT_RECT; _thd.next_drawstyle = HT_RECT;
@ -1932,10 +1932,10 @@ void VpSetPlaceSizingLimit(int limit)
void VpSetPresizeRange(uint from, uint to) void VpSetPresizeRange(uint from, uint to)
{ {
_thd.selend.x = TileX(to) * 16; _thd.selend.x = TileX(to) * TILE_SIZE;
_thd.selend.y = TileY(to) * 16; _thd.selend.y = TileY(to) * TILE_SIZE;
_thd.selstart.x = TileX(from) * 16; _thd.selstart.x = TileX(from) * TILE_SIZE;
_thd.selstart.y = TileY(from) * 16; _thd.selstart.y = TileY(from) * TILE_SIZE;
_thd.next_drawstyle = HT_RECT; _thd.next_drawstyle = HT_RECT;
} }