MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / CanBuildHouseHere

Function CanBuildHouseHere

src/town_cmd.cpp:2587–2601  ·  view source on GitHub ↗

* Check if a house can be built here, based on slope, whether there's a bridge above, and if we can clear the land. * @param tile The tile to check. * @param noslope Are foundations prohibited for this house? * @return true iff house can be built here. */

Source from the content-addressed store, hash-verified

2585 * @return true iff house can be built here.
2586 */
2587static inline bool CanBuildHouseHere(TileIndex tile, bool noslope)
2588{
2589 /* cannot build on these slopes... */
2590 Slope slope = GetTileSlope(tile);
2591 if ((noslope && slope != SLOPE_FLAT) || IsSteepSlope(slope)) return false;
2592
2593 /* at least one RoadTypes allow building the house here? */
2594 if (!RoadTypesAllowHouseHere(tile)) return false;
2595
2596 /* building under a bridge? */
2597 if (IsBridgeAbove(tile)) return false;
2598
2599 /* can we clear the land? */
2600 return Command<CMD_LANDSCAPE_CLEAR>::Do({DoCommandFlag::Auto, DoCommandFlag::NoWater}, tile).Succeeded();
2601}
2602
2603
2604/**

Callers 2

CheckBuildHouseSameZFunction · 0.85
TryBuildTownHouseFunction · 0.85

Calls 5

GetTileSlopeFunction · 0.85
IsSteepSlopeFunction · 0.85
RoadTypesAllowHouseHereFunction · 0.85
IsBridgeAboveFunction · 0.85
SucceededMethod · 0.80

Tested by

no test coverage detected