(svn r25849) -Codechange: Introduce IsTileFlat to not compute full slope information for situations when we only want to know if a tile is flat or not (cirdan, LordAro)

This commit is contained in:
zuu
2013-10-12 22:07:58 +00:00
parent b35b8aa5bb
commit dfb5663313
11 changed files with 51 additions and 27 deletions

View File

@@ -303,7 +303,7 @@ CommandCost CmdBuildObject(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
switch (type) {
case OBJECT_TRANSMITTER:
case OBJECT_LIGHTHOUSE:
if (GetTileSlope(tile) != SLOPE_FLAT) return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED);
if (!IsTileFlat(tile)) return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED);
break;
case OBJECT_OWNED_LAND:
@@ -673,7 +673,7 @@ void GenerateObjects()
TileIndex tile = RandomTile();
int h;
if (IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == SLOPE_FLAT && h >= 4 && !IsBridgeAbove(tile)) {
if (IsTileType(tile, MP_CLEAR) && IsTileFlat(tile, &h) && h >= 4 && !IsBridgeAbove(tile)) {
TileIndex t = tile;
if (CircularTileSearch(&t, 9, HasTransmitter, NULL)) continue;
@@ -710,7 +710,7 @@ void GenerateObjects()
for (int j = 0; j < 19; j++) {
int h;
if (IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == SLOPE_FLAT && h <= 2 && !IsBridgeAbove(tile)) {
if (IsTileType(tile, MP_CLEAR) && IsTileFlat(tile, &h) && h <= 2 && !IsBridgeAbove(tile)) {
BuildObject(OBJECT_LIGHTHOUSE, tile);
IncreaseGeneratingWorldProgress(GWP_OBJECT);
lighthouses_to_build--;