(svn r3990) Remove another call to FindLandscapeHeight()
authortron
Mon, 20 Mar 2006 13:34:01 +0000
changeset 3277 f48206e08ff0
parent 3276 fa7cc2225ca4
child 3278 6b23f9b14baa
(svn r3990) Remove another call to FindLandscapeHeight()
road_cmd.c
--- a/road_cmd.c	Sun Mar 19 19:56:57 2006 +0000
+++ b/road_cmd.c	Mon Mar 20 13:34:01 2006 +0000
@@ -84,7 +84,6 @@
 	// 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 @@
 	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 @@
 		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 @@
 			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;
 					}