mirror of https://github.com/OpenTTD/OpenTTD
(svn r11171) -Fix [FS#1257]: disable autoslope for automatically changed stuff (like towns and industries) and enable it in the scenario editor. Patch by frosch.
parent
7455676941
commit
a85e18c922
|
@ -36,7 +36,9 @@ static inline bool AutoslopeCheckForEntranceEdge(TileIndex tile, uint z_new, Slo
|
||||||
*/
|
*/
|
||||||
static inline bool AutoslopeEnabled()
|
static inline bool AutoslopeEnabled()
|
||||||
{
|
{
|
||||||
return (_patches.autoslope && IsValidPlayer(_current_player) && !_is_old_ai_player);
|
return (_patches.autoslope &&
|
||||||
|
((IsValidPlayer(_current_player) && !_is_old_ai_player) ||
|
||||||
|
(_current_player == OWNER_NONE && _game_mode == GM_EDITOR)));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* AUTOSLOPE_H */
|
#endif /* AUTOSLOPE_H */
|
||||||
|
|
|
@ -1336,15 +1336,26 @@ static bool CheckIfCanLevelIndustryPlatform(TileIndex tile, uint32 flags, const
|
||||||
/* Check if we don't leave the map */
|
/* Check if we don't leave the map */
|
||||||
if (TileX(cur_tile) == 0 || TileY(cur_tile) == 0 || TileX(cur_tile) + size_x >= MapMaxX() || TileY(cur_tile) + size_y >= MapMaxY()) return false;
|
if (TileX(cur_tile) == 0 || TileY(cur_tile) == 0 || TileX(cur_tile) + size_x >= MapMaxX() || TileY(cur_tile) + size_y >= MapMaxY()) return false;
|
||||||
|
|
||||||
|
/* _current_player is OWNER_NONE for randomly generated industries and in editor, or the player who funded or prospected the industry.
|
||||||
|
* Perform terraforming as OWNER_TOWN to disable autoslope. */
|
||||||
|
PlayerID old_player = _current_player;
|
||||||
|
_current_player = OWNER_TOWN;
|
||||||
|
|
||||||
BEGIN_TILE_LOOP(tile_walk, size_x, size_y, cur_tile) {
|
BEGIN_TILE_LOOP(tile_walk, size_x, size_y, cur_tile) {
|
||||||
curh = TileHeight(tile_walk);
|
curh = TileHeight(tile_walk);
|
||||||
if (curh != h) {
|
if (curh != h) {
|
||||||
/* This tile needs terraforming. Check if we can do that without
|
/* This tile needs terraforming. Check if we can do that without
|
||||||
* damaging the surroundings too much. */
|
* damaging the surroundings too much. */
|
||||||
if (!CheckCanTerraformSurroundingTiles(tile_walk, h, 0)) return false;
|
if (!CheckCanTerraformSurroundingTiles(tile_walk, h, 0)) {
|
||||||
|
_current_player = old_player;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
/* This is not 100% correct check, but the best we can do without modifying the map.
|
/* This is not 100% correct check, but the best we can do without modifying the map.
|
||||||
* What is missing, is if the difference in height is more than 1.. */
|
* What is missing, is if the difference in height is more than 1.. */
|
||||||
if (CmdFailed(DoCommand(tile_walk, SLOPE_N, (curh > h) ? 0 : 1, flags & ~DC_EXEC, CMD_TERRAFORM_LAND))) return false;
|
if (CmdFailed(DoCommand(tile_walk, SLOPE_N, (curh > h) ? 0 : 1, flags & ~DC_EXEC, CMD_TERRAFORM_LAND))) {
|
||||||
|
_current_player = old_player;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} END_TILE_LOOP(tile_walk, size_x, size_y, cur_tile)
|
} END_TILE_LOOP(tile_walk, size_x, size_y, cur_tile)
|
||||||
|
|
||||||
|
@ -1362,6 +1373,7 @@ static bool CheckIfCanLevelIndustryPlatform(TileIndex tile, uint32 flags, const
|
||||||
} END_TILE_LOOP(tile_walk, size_x, size_y, cur_tile)
|
} END_TILE_LOOP(tile_walk, size_x, size_y, cur_tile)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_current_player = old_player;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue