diff options
author | tron <tron@openttd.org> | 2005-06-25 06:15:43 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2005-06-25 06:15:43 +0000 |
commit | 61f6f07edd837728d72e83daa0a4b8893ec77307 (patch) | |
tree | 3374c2cd95704c5e34c2a7c62b0ba647c4002e7f | |
parent | cea090af09fbee47ef4eea01190ba8eb8e17aef8 (diff) | |
download | openttd-61f6f07edd837728d72e83daa0a4b8893ec77307.tar.xz |
(svn r2486) Turn TILE_FROM_XY into an inline function and rename it to TileVirtXY
-rw-r--r-- | aircraft_cmd.c | 2 | ||||
-rw-r--r-- | clear_cmd.c | 6 | ||||
-rw-r--r-- | command.c | 4 | ||||
-rw-r--r-- | disaster_cmd.c | 8 | ||||
-rw-r--r-- | graph_gui.c | 2 | ||||
-rw-r--r-- | industry_cmd.c | 2 | ||||
-rw-r--r-- | landscape.c | 8 | ||||
-rw-r--r-- | map.h | 6 | ||||
-rw-r--r-- | misc_gui.c | 2 | ||||
-rw-r--r-- | pathfind.c | 2 | ||||
-rw-r--r-- | rail_cmd.c | 16 | ||||
-rw-r--r-- | rail_gui.c | 8 | ||||
-rw-r--r-- | road_cmd.c | 4 | ||||
-rw-r--r-- | roadveh_cmd.c | 4 | ||||
-rw-r--r-- | ship_cmd.c | 2 | ||||
-rw-r--r-- | station_cmd.c | 8 | ||||
-rw-r--r-- | town_cmd.c | 2 | ||||
-rw-r--r-- | train_cmd.c | 8 | ||||
-rw-r--r-- | unmovable_cmd.c | 2 | ||||
-rw-r--r-- | vehicle.c | 6 | ||||
-rw-r--r-- | viewport.c | 14 | ||||
-rw-r--r-- | water_cmd.c | 4 | ||||
-rw-r--r-- | waypoint.c | 4 | ||||
-rw-r--r-- | window.c | 2 |
24 files changed, 65 insertions, 61 deletions
diff --git a/aircraft_cmd.c b/aircraft_cmd.c index aa9f82225..7d15fa9f5 100644 --- a/aircraft_cmd.c +++ b/aircraft_cmd.c @@ -169,7 +169,7 @@ int32 CmdBuildAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2) int32 value; Vehicle *vl[3], *v, *u, *w; UnitID unit_num; - TileIndex tile = TILE_FROM_XY(x,y); + TileIndex tile = TileVirtXY(x, y); const AircraftVehicleInfo *avi; Engine *e; diff --git a/clear_cmd.c b/clear_cmd.c index 2aa18001b..27ce96091 100644 --- a/clear_cmd.c +++ b/clear_cmd.c @@ -236,7 +236,7 @@ int32 CmdTerraformLand(int x, int y, uint32 flags, uint32 p1, uint32 p2) ts.modheight = modheight_data; ts.tile_table = tile_table_data; - tile = TILE_FROM_XY(x,y); + tile = TileVirtXY(x, y); /* Make an extra check for map-bounds cause we add tiles to the originating tile */ if (tile + TILE_XY(1,1) > MapSize()) return CMD_ERROR; @@ -394,7 +394,7 @@ int32 CmdPurchaseLandArea(int x, int y, uint32 flags, uint32 p1, uint32 p2) SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); - tile = TILE_FROM_XY(x,y); + tile = TileVirtXY(x, y); if (!EnsureNoVehicle(tile)) return CMD_ERROR; @@ -450,7 +450,7 @@ int32 CmdSellLandArea(int x, int y, uint32 flags, uint32 p1, uint32 p2) SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); - tile = TILE_FROM_XY(x,y); + tile = TileVirtXY(x, y); if (!IsTileType(tile, MP_UNMOVABLE) || _map5[tile] != 3) return CMD_ERROR; if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) return CMD_ERROR; @@ -325,7 +325,7 @@ int32 DoCommand(int x, int y, uint32 p1, uint32 p2, uint32 flags, uint procc) CommandProc *proc; /* Do not even think about executing out-of-bounds tile-commands */ - if (TILE_FROM_XY(x,y) > MapSize()) { + if (TileVirtXY(x, y) > MapSize()) { _cmd_text = NULL; return CMD_ERROR; } @@ -336,7 +336,7 @@ int32 DoCommand(int x, int y, uint32 p1, uint32 p2, uint32 flags, uint procc) _error_message = INVALID_STRING_ID; // update last build coord of player if ( (x|y) != 0 && _current_player < MAX_PLAYERS) { - GetPlayer(_current_player)->last_build_coordinate = TILE_FROM_XY(x,y); + GetPlayer(_current_player)->last_build_coordinate = TileVirtXY(x, y); } } diff --git a/disaster_cmd.c b/disaster_cmd.c index f5dcd1080..7ff17c1f1 100644 --- a/disaster_cmd.c +++ b/disaster_cmd.c @@ -76,7 +76,7 @@ static void InitializeDisasterVehicle(Vehicle *v, int x, int y, byte z, byte dir v->x_pos = x; v->y_pos = y; v->z_pos = z; - v->tile = TILE_FROM_XY(x,y); + v->tile = TileVirtXY(x, y); v->direction = direction; v->subtype = subtype; v->x_offs = -1; @@ -111,7 +111,7 @@ static void SetDisasterVehiclePos(Vehicle *v, int x, int y, byte z) v->x_pos = x; v->y_pos = y; v->z_pos = z; - v->tile = TILE_FROM_XY(x,y); + v->tile = TileVirtXY(x, y); DisasterVehicleUpdateImage(v); VehiclePositionChanged(v); @@ -398,7 +398,7 @@ static void DisasterTick_2(Vehicle *v) if ( (uint)x > MapMaxX() * 16-1) return; - tile = TILE_FROM_XY(x,y); + tile = TileVirtXY(x, y); if (!IsTileType(tile, MP_INDUSTRY)) return; @@ -469,7 +469,7 @@ static void DisasterTick_3(Vehicle *v) if ( (uint)x > MapMaxX() * 16-1) return; - tile = TILE_FROM_XY(x,y); + tile = TileVirtXY(x, y); if (!IsTileType(tile, MP_INDUSTRY)) return; diff --git a/graph_gui.c b/graph_gui.c index 0cdde9de0..1ad309211 100644 --- a/graph_gui.c +++ b/graph_gui.c @@ -1206,7 +1206,7 @@ static void SignListWndProc(Window *w, WindowEvent *e) return; ss = GetSign(_sign_sort[id_v]); - ScrollMainWindowToTile(TILE_FROM_XY(ss->x, ss->y)); + ScrollMainWindowToTile(TileVirtXY(ss->x, ss->y)); } break; } } break; diff --git a/industry_cmd.c b/industry_cmd.c index cae8eb698..761e506fe 100644 --- a/industry_cmd.c +++ b/industry_cmd.c @@ -1555,7 +1555,7 @@ int32 CmdBuildIndustry(int x, int y, uint32 flags, uint32 p1, uint32 p2) { Town *t; Industry *i; - TileIndex tile = TILE_FROM_XY(x,y); + TileIndex tile = TileVirtXY(x, y); int num; const IndustryTileTable * const *itt; const IndustryTileTable *it; diff --git a/landscape.c b/landscape.c index 095393def..122f22f5c 100644 --- a/landscape.c +++ b/landscape.c @@ -73,7 +73,7 @@ void FindLandscapeHeight(TileInfo *ti, uint x, uint y) return; } - FindLandscapeHeightByTile(ti, TILE_FROM_XY(x,y)); + FindLandscapeHeightByTile(ti, TileVirtXY(x, y)); } uint GetPartialZ(int x, int y, int corners) @@ -284,7 +284,7 @@ void GetTileDesc(TileIndex tile, TileDesc *td) */ int32 CmdLandscapeClear(int x, int y, uint32 flags, uint32 p1, uint32 p2) { - TileIndex tile = TILE_FROM_XY(x, y); + TileIndex tile = TileVirtXY(x, y); SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); @@ -318,7 +318,7 @@ int32 CmdClearArea(int ex, int ey, uint32 flags, uint32 p1, uint32 p2) for (x = sx; x <= ex; x += 16) { for (y = sy; y <= ey; y += 16) { - ret = DoCommandByTile(TILE_FROM_XY(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; cost += ret; success = true; @@ -328,7 +328,7 @@ int32 CmdClearArea(int ex, int ey, uint32 flags, uint32 p1, uint32 p2) _additional_cash_required = ret; return cost - ret; } - DoCommandByTile(TILE_FROM_XY(x,y), 0, 0, flags, CMD_LANDSCAPE_CLEAR); + DoCommandByTile(TileVirtXY(x, y), 0, 0, flags, CMD_LANDSCAPE_CLEAR); // draw explosion animation... if ((x == sx || x == ex) && (y == sy || y == ey)) { @@ -3,7 +3,6 @@ #include "stdafx.h" -#define TILE_FROM_XY(x,y) (TileIndex)((((y) >> 4) << MapLogX()) + ((x) >> 4)) #define TILE_XY(x,y) (((y) << MapLogX()) + (x)) #define TILE_MASK(x) ((x) & ((1 << (MapLogX() + MapLogY())) - 1)) @@ -37,6 +36,11 @@ uint ScaleByMapSize1D(uint); // Scale relative to the circumference of the map typedef uint32 TileIndex; +static inline TileIndex TileVirtXY(uint x, uint y) +{ + return (y >> 4 << MapLogX()) + (x >> 4); +} + typedef enum { OWNER_TOWN = 0xf, // a town owns the tile OWNER_NONE = 0x10, // nobody owns the tile diff --git a/misc_gui.c b/misc_gui.c index 624b122b5..11261de4a 100644 --- a/misc_gui.c +++ b/misc_gui.c @@ -701,7 +701,7 @@ void DrawStationCoverageAreaText(int sx, int sy, uint mask, int rad) { int y = _thd.pos.y; uint accepts[NUM_CARGO]; if (x != -1) { - GetAcceptanceAroundTiles(accepts, TILE_FROM_XY(x, y), _thd.size.x /16, _thd.size.y /16 , rad); + GetAcceptanceAroundTiles(accepts, TileVirtXY(x, y), _thd.size.x / 16, _thd.size.y / 16 , rad); DrawStationCoverageText(accepts, sx, sy, mask); } } diff --git a/pathfind.c b/pathfind.c index 83afa7a9c..9134b3030 100644 --- a/pathfind.c +++ b/pathfind.c @@ -230,7 +230,7 @@ FindLengthOfTunnelResult FindLengthOfTunnel(TileIndex tile, int direction) x += _get_tunlen_inc[direction]; y += _get_tunlen_inc[direction+1]; - tile = TILE_FROM_XY(x,y); + tile = TileVirtXY(x, y); if (IsTileType(tile, MP_TUNNELBRIDGE) && (_map5[tile] & 0xF0) == 0 && // tunnel entrance/exit diff --git a/rail_cmd.c b/rail_cmd.c index 43999b604..7b65f655c 100644 --- a/rail_cmd.c +++ b/rail_cmd.c @@ -266,7 +266,7 @@ int32 CmdBuildSingleRail(int x, int y, uint32 flags, uint32 p1, uint32 p2) if (!ValParamRailtype(p1) || !ValParamTrackOrientation(track)) return CMD_ERROR; - tile = TILE_FROM_XY(x, y); + tile = TileVirtXY(x, y); tileh = GetTileSlope(tile, NULL); m5 = _map5[tile]; trackbit = TrackToTrackBits(track); @@ -410,7 +410,7 @@ int32 CmdRemoveSingleRail(int x, int y, uint32 flags, uint32 p1, uint32 p2) SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); - tile = TILE_FROM_XY(x, y); + tile = TileVirtXY(x, y); tileh = GetTileSlope(tile, NULL); if (!IsTileType(tile, MP_TUNNELBRIDGE) && !IsTileType(tile, MP_STREET) && !IsTileType(tile, MP_RAILWAY)) @@ -588,7 +588,7 @@ static int32 CmdRailTrackHelper(int x, int y, uint32 flags, uint32 p1, uint32 p2 if (CmdFailed(ValidateAutoDrag(&trackdir, x, y, ex, ey))) return CMD_ERROR; - if (flags & DC_EXEC) SndPlayTileFx(SND_20_SPLAT_2, TILE_FROM_XY(x,y)); + if (flags & DC_EXEC) SndPlayTileFx(SND_20_SPLAT_2, TileVirtXY(x, y)); for(;;) { ret = DoCommand(x, y, p2 & 0x3, TrackdirToTrack(trackdir), flags, (mode == 0) ? CMD_BUILD_SINGLE_RAIL : CMD_REMOVE_SINGLE_RAIL); @@ -638,7 +638,7 @@ int32 CmdRemoveRailroadTrack(int x, int y, uint32 flags, uint32 p1, uint32 p2) int32 CmdBuildTrainDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2) { Depot *d; - TileIndex tile = TILE_FROM_XY(x,y); + TileIndex tile = TileVirtXY(x, y); int32 cost, ret; uint tileh; @@ -694,7 +694,7 @@ int32 CmdBuildTrainDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2) */ int32 CmdBuildSingleSignal(int x, int y, uint32 flags, uint32 p1, uint32 p2) { - TileIndex tile = TILE_FROM_XY(x, y); + TileIndex tile = TileVirtXY(x, y); bool semaphore; bool pre_signal; Track track = (Track)(p1 & 0x7); @@ -819,7 +819,7 @@ static int32 CmdSignalTrackHelper(int x, int y, uint32 flags, uint32 p1, uint32 int ex, ey; int32 ret, total_cost, signal_ctr; byte signals; - TileIndex tile = TILE_FROM_XY(x, y); + TileIndex tile = TileVirtXY(x, y); bool error = true; int mode = p2 & 0x1; @@ -910,7 +910,7 @@ int32 CmdBuildSignalTrack(int x, int y, uint32 flags, uint32 p1, uint32 p2) */ int32 CmdRemoveSingleSignal(int x, int y, uint32 flags, uint32 p1, uint32 p2) { - TileIndex tile = TILE_FROM_XY(x, y); + TileIndex tile = TileVirtXY(x, y); Track track = (Track)(p1 & 0x7); if (!ValParamTrackOrientation(track) || !IsTileType(tile, MP_RAILWAY) || !EnsureNoVehicle(tile)) @@ -1003,7 +1003,7 @@ int32 CmdConvertRail(int ex, int ey, uint32 flags, uint32 p1, uint32 p2) for (x = sx; x <= ex; x += TILE_SIZE) { for (y = sy; y <= ey; y += TILE_SIZE) { - TileIndex tile = TILE_FROM_XY(x,y); + TileIndex tile = TileVirtXY(x, y); DoConvertRailProc *proc; if (IsTileType(tile, MP_RAILWAY)) proc = DoConvertRail; diff --git a/rail_gui.c b/rail_gui.c index f72b1354a..b87d1f00d 100644 --- a/rail_gui.c +++ b/rail_gui.c @@ -314,7 +314,7 @@ static void BuildRailClick_Landscaping(Window *w) static void DoRailroadTrack(int mode) { - DoCommandP(TILE_FROM_XY(_thd.selstart.x, _thd.selstart.y), TILE_FROM_XY(_thd.selend.x, _thd.selend.y), _cur_railtype | (mode << 4), NULL, + DoCommandP(TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), _cur_railtype | (mode << 4), NULL, _remove_button_clicked ? CMD_REMOVE_RAILROAD_TRACK | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1012_CAN_T_REMOVE_RAILROAD_TRACK) : CMD_BUILD_RAILROAD_TRACK | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1011_CAN_T_BUILD_RAILROAD_TRACK) @@ -327,7 +327,7 @@ static void HandleAutodirPlacement(void) int trackstat = thd->drawstyle & 0xF; // 0..5 if (thd->drawstyle & HT_RAIL) { // one tile case - GenericPlaceRail(TILE_FROM_XY(thd->selend.x, thd->selend.y), trackstat); + GenericPlaceRail(TileVirtXY(thd->selend.x, thd->selend.y), trackstat); return; } @@ -340,13 +340,13 @@ static void HandleAutoSignalPlacement(void) byte trackstat = thd->drawstyle & 0xF; // 0..5 if (thd->drawstyle == HT_RECT) { // one tile case - GenericPlaceSignals(TILE_FROM_XY(thd->selend.x, thd->selend.y)); + GenericPlaceSignals(TileVirtXY(thd->selend.x, thd->selend.y)); return; } // _patches.drag_signals_density is given as a parameter such that each user in a network // game can specify his/her own signal density - DoCommandP(TILE_FROM_XY(thd->selstart.x, thd->selstart.y), TILE_FROM_XY(thd->selend.x, thd->selend.y), + DoCommandP(TileVirtXY(thd->selstart.x, thd->selstart.y), TileVirtXY(thd->selend.x, thd->selend.y), (_ctrl_pressed ? 1 << 3 : 0) | (trackstat << 4) | (_patches.drag_signals_density << 24), CcPlaySound1E, (_remove_button_clicked ? CMD_REMOVE_SIGNAL_TRACK | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1013_CAN_T_REMOVE_SIGNALS_FROM) : diff --git a/road_cmd.c b/road_cmd.c index e1208fe0f..9724a9892 100644 --- a/road_cmd.c +++ b/road_cmd.c @@ -518,7 +518,7 @@ int32 CmdBuildLongRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2) if (p1 > MapSize()) return CMD_ERROR; start_tile = p1; - end_tile = TILE_FROM_XY(x, y); + end_tile = TileVirtXY(x, y); /* Only drag in X or Y direction dictated by the direction variable */ if (!HASBIT(p2, 2) && TileY(start_tile) != TileY(end_tile)) return CMD_ERROR; // x-axis @@ -572,7 +572,7 @@ int32 CmdRemoveLongRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2) if (p1 > MapSize()) return CMD_ERROR; start_tile = p1; - end_tile = TILE_FROM_XY(x, y); + end_tile = TileVirtXY(x, y); /* Only drag in X or Y direction dictated by the direction variable */ if (!HASBIT(p2, 2) && TileY(start_tile) != TileY(end_tile)) return CMD_ERROR; // x-axis diff --git a/roadveh_cmd.c b/roadveh_cmd.c index f2458072c..cf88344c6 100644 --- a/roadveh_cmd.c +++ b/roadveh_cmd.c @@ -120,7 +120,7 @@ int32 CmdBuildRoadVeh(int x, int y, uint32 flags, uint32 p1, uint32 p2) int32 cost; Vehicle *v; UnitID unit_num; - TileIndex tile = TILE_FROM_XY(x,y); + TileIndex tile = TileVirtXY(x, y); Engine *e; if (!IsEngineBuildable(p1, VEH_Road)) return CMD_ERROR; @@ -789,7 +789,7 @@ static Vehicle *RoadVehFindCloseTo(Vehicle *v, int x, int y, byte dir) rvf.y = y; rvf.dir = dir; rvf.veh = v; - u = VehicleFromPos(TILE_FROM_XY(x,y), &rvf, (VehicleFromPosProc*)EnumCheckRoadVehClose); + u = VehicleFromPos(TileVirtXY(x, y), &rvf, (VehicleFromPosProc*)EnumCheckRoadVehClose); // This code protects a roadvehicle from being blocked for ever // If more than 1480 / 74 days a road vehicle is blocked, it will diff --git a/ship_cmd.c b/ship_cmd.c index 2f173b9c4..5db2b2b63 100644 --- a/ship_cmd.c +++ b/ship_cmd.c @@ -866,7 +866,7 @@ int32 CmdBuildShip(int x, int y, uint32 flags, uint32 p1, uint32 p2) int32 value; Vehicle *v; UnitID unit_num; - TileIndex tile = TILE_FROM_XY(x,y); + TileIndex tile = TileVirtXY(x, y); Engine *e; if (!IsEngineBuildable(p1, VEH_Ship)) return CMD_ERROR; diff --git a/station_cmd.c b/station_cmd.c index aad0cf6a2..4766e62ad 100644 --- a/station_cmd.c +++ b/station_cmd.c @@ -942,7 +942,7 @@ int32 CmdBuildRailroadStation(int x, int y, uint32 flags, uint32 p1, uint32 p2) SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); - tile_org = TILE_FROM_XY(x, y); + tile_org = TileVirtXY(x, y); /* Does the authority allow this? */ if (!(flags & DC_NO_TOWN_RATING) && !CheckIfAuthorityAllows(tile_org)) return CMD_ERROR; @@ -1125,7 +1125,7 @@ restart: */ int32 CmdRemoveFromRailroadStation(int x, int y, uint32 flags, uint32 p1, uint32 p2) { - TileIndex tile = TILE_FROM_XY(x, y); + TileIndex tile = TileVirtXY(x, y); Station *st; SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); @@ -1451,7 +1451,7 @@ int32 CmdBuildRoadStop(int x, int y, uint32 flags, uint32 p1, uint32 p2) SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); - tile = TILE_FROM_XY(x,y); + tile = TileVirtXY(x, y); if (!(flags & DC_NO_TOWN_RATING) && !CheckIfAuthorityAllows(tile)) return CMD_ERROR; @@ -1675,7 +1675,7 @@ int32 CmdBuildAirport(int x, int y, uint32 flags, uint32 p1, uint32 p2) /* Check if a valid, buildable airport was chosen for construction */ if (p1 > lengthof(_airport_map5_tiles) || !HASBIT(GetValidAirports(), p1)) return CMD_ERROR; - tile = TILE_FROM_XY(x,y); + tile = TileVirtXY(x, y); if (!(flags & DC_NO_TOWN_RATING) && !CheckIfAuthorityAllows(tile)) return CMD_ERROR; diff --git a/town_cmd.c b/town_cmd.c index 1ca61d6c6..2f30999d3 100644 --- a/town_cmd.c +++ b/town_cmd.c @@ -1023,7 +1023,7 @@ static Town *AllocateTown(void) */ int32 CmdBuildTown(int x, int y, uint32 flags, uint32 p1, uint32 p2) { - TileIndex tile = TILE_FROM_XY(x,y); + TileIndex tile = TileVirtXY(x, y); TileInfo ti; Town *t; uint32 townnameparts; diff --git a/train_cmd.c b/train_cmd.c index a01fafc7d..1e230bc14 100644 --- a/train_cmd.c +++ b/train_cmd.c @@ -596,7 +596,7 @@ int32 CmdBuildRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2) Vehicle *v, *u; UnitID unit_num; Engine *e; - TileIndex tile = TILE_FROM_XY(x,y); + TileIndex tile = TileVirtXY(x, y); /* Check if the engine-type is valid (for the player) */ if (!IsEngineBuildable(p1, VEH_Train)) return CMD_ERROR; @@ -2366,7 +2366,7 @@ static byte AfterSetTrainPos(Vehicle *v, bool new_tile) CLRBIT(v->u.rail.flags, VRF_GOINGDOWN); if (new_z != old_z) { - TileIndex tile = TILE_FROM_XY(v->x_pos, v->y_pos); + TileIndex tile = TileVirtXY(v->x_pos, v->y_pos); // XXX workaround, whole UP/DOWN detection needs overhaul if (!IsTileType(tile, MP_TUNNELBRIDGE) || (_map5[tile] & 0x80) != 0) @@ -2582,13 +2582,13 @@ static void CheckTrainCollision(Vehicle *v) if (v->u.rail.track == 0x80) return; - assert(v->u.rail.track == 0x40 || TILE_FROM_XY(v->x_pos, v->y_pos) == v->tile); + assert(v->u.rail.track == 0x40 || TileVirtXY(v->x_pos, v->y_pos) == v->tile); tcc.v = v; tcc.v_skip = v->next; /* find colliding vehicle */ - realcoll = VehicleFromPos(TILE_FROM_XY(v->x_pos, v->y_pos), &tcc, FindTrainCollideEnum); + realcoll = VehicleFromPos(TileVirtXY(v->x_pos, v->y_pos), &tcc, FindTrainCollideEnum); if (realcoll == NULL) return; diff --git a/unmovable_cmd.c b/unmovable_cmd.c index b2b684ec0..c8ae9b8dd 100644 --- a/unmovable_cmd.c +++ b/unmovable_cmd.c @@ -61,7 +61,7 @@ int32 DestroyCompanyHQ(TileIndex tile, uint32 flags) extern int32 CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, int *); int32 CmdBuildCompanyHQ(int x, int y, uint32 flags, uint32 p1, uint32 p2) { - TileIndex tile = TILE_FROM_XY(x,y); + TileIndex tile = TileVirtXY(x, y); Player *p = GetPlayer(_current_player); int cost; @@ -592,7 +592,7 @@ static void ChimneySmokeTick(Vehicle *v) BeginVehicleMove(v); - tile = TILE_FROM_XY(v->x_pos, v->y_pos); + tile = TileVirtXY(v->x_pos, v->y_pos); if (!IsTileType(tile, MP_INDUSTRY)) { EndVehicleMove(v); DeleteVehicle(v); @@ -1094,7 +1094,7 @@ static void BubbleTick(Vehicle *v) et++; SndPlayVehicleFx(SND_31_EXTRACT, v); - tile = TILE_FROM_XY(v->x_pos, v->y_pos); + tile = TileVirtXY(v->x_pos, v->y_pos); if (IsTileType(tile, MP_INDUSTRY) && _map5[tile] == 0xA2) { AddAnimatedTile(tile); @@ -1703,7 +1703,7 @@ bool GetNewVehiclePos(Vehicle *v, GetNewVehiclePosResult *gp) gp->x = x; gp->y = y; gp->old_tile = v->tile; - gp->new_tile = TILE_FROM_XY(x,y); + gp->new_tile = TileVirtXY(x, y); return gp->old_tile == gp->new_tile; } diff --git a/viewport.c b/viewport.c index 45615dee4..64b171f2a 100644 --- a/viewport.c +++ b/viewport.c @@ -684,7 +684,7 @@ static void DrawTileSelection(const TileInfo *ti) } else if (IsPartOfAutoLine(ti->x, ti->y)) { // autorail highlighting long line int dir = _thd.drawstyle & ~0xF0; - TileIndex start = TILE_FROM_XY(_thd.selstart.x, _thd.selstart.y); + TileIndex start = TileVirtXY(_thd.selstart.x, _thd.selstart.y); int diffx, diffy; int side; @@ -1443,7 +1443,7 @@ void MarkTileDirty(int x, int y) Point pt; if (IS_INT_INSIDE(x, 0, MapSizeX() * 16) && IS_INT_INSIDE(y, 0, MapSizeY() * 16)) - z = GetTileZ(TILE_FROM_XY(x,y)); + z = GetTileZ(TileVirtXY(x, y)); pt = RemapCoords(x, y, z); MarkAllViewportsDirty( @@ -1699,7 +1699,7 @@ static void CheckClickOnLandscape(ViewPort *vp, int x, int y) { Point pt = TranslateXYToTileCoord(vp,x,y); - if (pt.x != -1) ClickTile(TILE_FROM_XY(pt.x, pt.y)); + if (pt.x != -1) ClickTile(TileVirtXY(pt.x, pt.y)); } void HandleClickOnTrain(Vehicle *v); @@ -1783,7 +1783,7 @@ void PlaceObject(void) if ((w = GetCallbackWnd()) != NULL) { e.event = WE_PLACE_OBJ; e.place.pt = pt; - e.place.tile = TILE_FROM_XY(pt.x, pt.y); + e.place.tile = TileVirtXY(pt.x, pt.y); w->wndproc(w, &e); } } @@ -2027,7 +2027,7 @@ static void CalcRaildirsDrawstyle(TileHighlightData *thd, int x, int y, int meth w = myabs(dx) + 16; h = myabs(dy) + 16; - if (TILE_FROM_XY(thd->selstart.x, thd->selstart.y) == TILE_FROM_XY(x,y)) { // check if we're only within one tile + if (TileVirtXY(thd->selstart.x, thd->selstart.y) == TileVirtXY(x, y)) { // check if we're only within one tile if(method == VPM_RAILDIRS) b = GetAutorailHT(x, y); else // rect for autosignals on one tile @@ -2187,8 +2187,8 @@ bool VpHandlePlaceSizingDrag(void) // and call the mouseup event. e.event = WE_PLACE_MOUSEUP; e.place.pt = _thd.selend; - e.place.tile = TILE_FROM_XY(e.place.pt.x, e.place.pt.y); - e.place.starttile = TILE_FROM_XY(_thd.selstart.x, _thd.selstart.y); + e.place.tile = TileVirtXY(e.place.pt.x, e.place.pt.y); + e.place.starttile = TileVirtXY(_thd.selstart.x, _thd.selstart.y); w->wndproc(w, &e); return false; diff --git a/water_cmd.c b/water_cmd.c index 4fe546cef..2fd6d732f 100644 --- a/water_cmd.c +++ b/water_cmd.c @@ -38,7 +38,7 @@ int32 CmdBuildShipDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2) if (p1 > 3) return CMD_ERROR; - tile = TILE_FROM_XY(x,y); + tile = TileVirtXY(x, y); if (!EnsureNoVehicle(tile)) return CMD_ERROR; tile2 = tile + (p1 ? TILE_XY(0,1) : TILE_XY(1,0)); @@ -166,7 +166,7 @@ static void MarkTilesAroundDirty(TileIndex tile) */ int32 CmdBuildLock(int x, int y, uint32 flags, uint32 p1, uint32 p2) { - TileIndex tile = TILE_FROM_XY(x,y); + TileIndex tile = TileVirtXY(x, y); uint tileh; SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); diff --git a/waypoint.c b/waypoint.c index 64bfa73cd..7122013f4 100644 --- a/waypoint.c +++ b/waypoint.c @@ -155,7 +155,7 @@ static Waypoint *FindDeletedWaypointCloseTo(TileIndex tile) */ int32 CmdBuildTrainWaypoint(int x, int y, uint32 flags, uint32 p1, uint32 p2) { - TileIndex tile = TILE_FROM_XY(x, y); + TileIndex tile = TileVirtXY(x, y); Waypoint *wp; uint tileh; uint dir; @@ -285,7 +285,7 @@ int32 RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove) */ int32 CmdRemoveTrainWaypoint(int x, int y, uint32 flags, uint32 p1, uint32 p2) { - TileIndex tile = TILE_FROM_XY(x,y); + TileIndex tile = TileVirtXY(x, y); SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); return RemoveTrainWaypoint(tile, flags, true); } @@ -767,7 +767,7 @@ static void HandlePlacePresize(void) _thd.selend.x = -1; return; } - e.place.tile = TILE_FROM_XY(e.place.pt.x, e.place.pt.y); + e.place.tile = TileVirtXY(e.place.pt.x, e.place.pt.y); e.event = WE_PLACE_PRESIZE; w->wndproc(w, &e); } |