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

Function GetHouseNorthPart

src/town_cmd.cpp:3025–3043  ·  view source on GitHub ↗

* Determines if a given HouseID is part of a multitile house. * The given ID is set to the ID of the north tile and the TileDiff to the north tile is returned. * * @param house Is changed to the HouseID of the north tile of the same house * @return TileDiff from the tile of the given HouseID to the north tile */

Source from the content-addressed store, hash-verified

3023 * @return TileDiff from the tile of the given HouseID to the north tile
3024 */
3025TileIndexDiff GetHouseNorthPart(HouseID &house)
3026{
3027 if (house >= 3) { // house id 0,1,2 MUST be single tile houses, or this code breaks.
3028 if (HouseSpec::Get(house - 1)->building_flags.Test(BuildingFlag::Size2x1)) {
3029 house--;
3030 return TileDiffXY(-1, 0);
3031 } else if (HouseSpec::Get(house - 1)->building_flags.Any(BUILDING_2_TILES_Y)) {
3032 house--;
3033 return TileDiffXY(0, -1);
3034 } else if (HouseSpec::Get(house - 2)->building_flags.Any(BUILDING_HAS_4_TILES)) {
3035 house -= 2;
3036 return TileDiffXY(-1, 0);
3037 } else if (HouseSpec::Get(house - 3)->building_flags.Any(BUILDING_HAS_4_TILES)) {
3038 house -= 3;
3039 return TileDiffXY(-1, -1);
3040 }
3041 }
3042 return TileDiffXY(0, 0);
3043}
3044
3045/**
3046 * Clear a town house.

Callers 6

ClearTownHouseFunction · 0.85
TerraformTile_TownFunction · 0.85
RebuildTownCachesFunction · 0.85
UpdateHousesAndTownsFunction · 0.85

Calls 3

TileDiffXYFunction · 0.85
TestMethod · 0.80
AnyMethod · 0.80

Tested by

no test coverage detected