summaryrefslogtreecommitdiff
path: root/road_cmd.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-03-20 13:34:01 +0000
committertron <tron@openttd.org>2006-03-20 13:34:01 +0000
commiteb85fcb57be49632786491dcc226abe7bbf05eb9 (patch)
tree8a85a75fb8ce9109582fd9cc4283a411803978e9 /road_cmd.c
parent0a91b283d62d6f957af5ba87eb6144cb5b61045f (diff)
downloadopenttd-eb85fcb57be49632786491dcc226abe7bbf05eb9.tar.xz
(svn r3990) Remove another call to FindLandscapeHeight()
Diffstat (limited to 'road_cmd.c')
-rw-r--r--road_cmd.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/road_cmd.c b/road_cmd.c
index 363ecfaa6..69aa1e724 100644
--- a/road_cmd.c
+++ b/road_cmd.c
@@ -84,7 +84,6 @@ int32 CmdRemoveRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
// cost for removing inner/edge -roads
static const uint16 road_remove_cost[2] = {50, 18};
- TileInfo ti;
int32 cost;
TileIndex tile;
PlayerID owner;
@@ -100,8 +99,7 @@ int32 CmdRemoveRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (p1 >> 4) return CMD_ERROR;
pieces = p1;
- FindLandscapeHeight(&ti, x, y);
- tile = ti.tile;
+ tile = TileVirtXY(x, y);
if (!IsTileType(tile, MP_STREET) && !IsTileType(tile, MP_TUNNELBRIDGE)) return CMD_ERROR;
@@ -117,12 +115,9 @@ int32 CmdRemoveRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
t = NULL;
}
- // allow deleting road under bridge
- if (ti.type != MP_TUNNELBRIDGE && !EnsureNoVehicle(tile)) return CMD_ERROR;
-
if (!CheckAllowRemoveRoad(tile, pieces, &edge_road)) return CMD_ERROR;
- switch (ti.type) {
+ switch (GetTileType(tile)) {
case MP_TUNNELBRIDGE:
if (!EnsureNoVehicleZ(tile, TilePixelHeight(tile))) return CMD_ERROR;
@@ -144,16 +139,19 @@ int32 CmdRemoveRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
return cost;
case MP_STREET:
+ if (!EnsureNoVehicle(tile)) return CMD_ERROR;
+
// check if you're allowed to remove the street owned by a town
// removal allowance depends on difficulty setting
if (!CheckforTownRating(flags, t, ROAD_REMOVE)) return CMD_ERROR;
- switch (GetRoadType(ti.tile)) {
+ switch (GetRoadType(tile)) {
case ROAD_NORMAL: {
- RoadBits present = GetRoadBits(ti.tile);
+ RoadBits present = GetRoadBits(tile);
RoadBits c = pieces;
- if (ti.tileh != 0 && (present == ROAD_Y || present == ROAD_X)) {
+ if (GetTileSlope(tile, NULL) != 0 &&
+ (present == ROAD_Y || present == ROAD_X)) {
c |= (c & 0xC) >> 2;
c |= (c & 0x3) << 2;
}