# HG changeset patch # User celestar # Date 1144077492 0 # Node ID 0ada2e3118262a1d7277da5c5f1c99624e81bbe6 # Parent 4e0d2ea104b39e93ac6ce81db6bd8b41326b0e38 (svn r4263) -Codechange: Road building no longer uses FindLandscapeHeight. Last occurence of FindLandscapeTile in the tile-specific functions gone. Thanks to Tron for doing lots of work in this direction diff -r 4e0d2ea104b3 -r 0ada2e311826 road_cmd.c --- a/road_cmd.c Mon Apr 03 15:11:17 2006 +0000 +++ b/road_cmd.c Mon Apr 03 15:18:12 2006 +0000 @@ -277,12 +277,12 @@ */ int32 CmdBuildRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2) { - TileInfo ti; int32 cost = 0; int32 ret; RoadBits existing = 0; RoadBits pieces; TileIndex tile; + byte tileh; SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); @@ -291,10 +291,10 @@ if ((p1 >> 4) || (_current_player < MAX_PLAYERS && p2 != 0) || !IsTownIndex(p2)) return CMD_ERROR; pieces = p1; - FindLandscapeHeight(&ti, x, y); - tile = ti.tile; + tile = TileVirtXY(x, y); + tileh = GetTileSlope(tile, NULL); - switch (ti.type) { + switch (GetTileType(tile)) { case MP_STREET: switch (GetRoadType(tile)) { case ROAD_NORMAL: @@ -320,13 +320,13 @@ case MP_RAILWAY: { Axis roaddir; - if (IsSteepTileh(ti.tileh)) { // very steep tile + if (IsSteepTileh(tileh)) { // very steep tile return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); } #define M(x) (1 << (x)) /* Level crossings may only be built on these slopes */ - if (!HASBIT(M(14) | M(13) | M(11) | M(10) | M(7) | M(5) | M(0), ti.tileh)) { + if (!HASBIT(M(14) | M(13) | M(11) | M(10) | M(7) | M(5) | M(0), tileh)) { return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); } #undef M @@ -357,7 +357,7 @@ case MP_TUNNELBRIDGE: /* check for flat land */ - if (IsSteepTileh(ti.tileh)) { // very steep tile + if (IsSteepTileh(tileh)) { // very steep tile return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); } @@ -393,14 +393,14 @@ cost += ret; } - ret = CheckRoadSlope(ti.tileh, &pieces, existing); + ret = CheckRoadSlope(tileh, &pieces, existing); if (CmdFailed(ret)) return_cmd_error(STR_1800_LAND_SLOPED_IN_WRONG_DIRECTION); if (ret != 0 && (!_patches.build_on_slopes || _is_old_ai_player)) { return CMD_ERROR; } cost += ret; - if (ti.type == MP_STREET) { + if (IsTileType(tile, MP_STREET)) { // Don't put the pieces that already exist pieces &= ComplementRoadBits(existing); } @@ -408,7 +408,7 @@ cost += CountRoadBits(pieces) * _price.build_road; if (flags & DC_EXEC) { - if (ti.type == MP_STREET) { + if (IsTileType(tile, MP_STREET)) { SetRoadBits(tile, existing | pieces); } else { MakeRoadNormal(tile, _current_player, pieces, p2);