OpenTTD Source: src/town_map.h File Reference

OpenTTD Source 15.0-RC2

Functions
town_map.h File Reference

Accessors for towns. More...

`#include "road_map.h"`
`#include "house.h"`
`#include "timer/timer_game_calendar.h"`

Go to the source code of this file.

## Functions
TownID | GetTownIndex (Tile t)
| Get the index of which town this house/street is attached to.
void | SetTownIndex (Tile t, TownID index)
| Set the town index for a road or house tile.
HouseID | GetCleanHouseType (Tile t)
| Get the type of this house, which is an index into the house spec array without doing any NewGRF related translations.
HouseID | GetHouseType (Tile t)
| Get the type of this house, which is an index into the house spec array.
void | SetHouseType (Tile t, HouseID house_id)
| Set the house type.
bool | IsHouseProtected (Tile t)
| Check if the house is protected from removal by towns.
void | SetHouseProtected (Tile t, bool house_protected)
| Set a house as protected from removal by towns.
bool | LiftHasDestination (Tile t)
| Check if the lift of this animated house has a destination.
void | SetLiftDestination (Tile t, uint8_t dest)
| Set the new destination of the lift for this animated house, and activate the LiftHasDestination bit.
uint8_t | GetLiftDestination (Tile t)
| Get the current destination for this lift.
void | HaltLift (Tile t)
| Stop the lift of this animated house from moving.
uint8_t | GetLiftPosition (Tile t)
| Get the position of the lift on this animated house.
void | SetLiftPosition (Tile t, uint8_t pos)
| Set the position of the lift on this animated house.
bool | IsHouseCompleted (Tile t)
| Get the completion of this house.
void | SetHouseCompleted (Tile t, bool status)
| Mark this house as been completed.
uint8_t | GetHouseBuildingStage (Tile t)
| House Construction Scheme.
uint8_t | GetHouseConstructionTick (Tile t)
| Gets the construction stage of a house.
void | IncHouseConstructionTick (Tile t)
| Sets the increment stage of a house It is working with the whole counter + stage 5 bits, making it easier to work: the wraparound is automatic.
void | ResetHouseAge (Tile t)
| Sets the age of the house to zero.
void | IncrementHouseAge (Tile t)
| Increments the age of the house.
TimerGameCalendar::Year | GetHouseAge (Tile t)
| Get the age of the house.
void | SetHouseRandomBits (Tile t, uint8_t random)
| Set the random bits for this house.
uint8_t | GetHouseRandomBits (Tile t)
| Get the random bits for this house.
void | SetHouseRandomTriggers (Tile t, HouseRandomTriggers triggers)
| Set the activated triggers bits for this house.
HouseRandomTriggers | GetHouseRandomTriggers (Tile t)
| Get the already activated triggers bits for this house.
uint8_t | GetHouseProcessingTime (Tile t)
| Get the amount of time remaining before the tile loop processes this tile.
void | SetHouseProcessingTime (Tile t, uint8_t time)
| Set the amount of time remaining before the tile loop processes this tile.
void | DecHouseProcessingTime (Tile t)
| Decrease the amount of time remaining before the tile loop processes this tile.
void | MakeHouseTile (Tile t, TownID tid, uint8_t counter, uint8_t stage, HouseID type, uint8_t random_bits, bool house_protected)
| Make the tile a house.

## Detailed Description

Accessors for towns.

Definition in file town_map.h.

## Function Documentation

## ◆ DecHouseProcessingTime()

void DecHouseProcessingTime | ( | Tile | t | ) |
| inline

Decrease the amount of time remaining before the tile loop processes this tile.

Parameters

  t | the house tile

Precondition
  IsTileType(t, MP_HOUSE)

Definition at line 358 of file town_map.h.

References IsTileType(), Tile::m6(), and MP_HOUSE.

## ◆ GetCleanHouseType()

HouseID GetCleanHouseType | ( | Tile | t | ) |
| inline

Get the type of this house, which is an index into the house spec array without doing any NewGRF related translations.

Parameters

  t | the tile

Precondition
  IsTileType(t, MP_HOUSE)

Returns
  house type

Definition at line 48 of file town_map.h.

References GB(), IsTileType(), Tile::m8(), and MP_HOUSE.

Referenced by GetHouseType(), and UpdateHousesAndTowns().

## ◆ GetHouseAge()

TimerGameCalendar::Year GetHouseAge | ( | Tile | t | ) |
| inline

Get the age of the house.

Parameters

  t | the tile of this house

Precondition
  IsTileType(t, MP_HOUSE)

Returns
  year

Definition at line 271 of file town_map.h.

References IsHouseCompleted(), IsTileType(), Tile::m5(), and MP_HOUSE.

Referenced by HouseScopeResolver::GetVariable(), and TileLoop_Town().

## ◆ GetHouseBuildingStage()

uint8_t GetHouseBuildingStage | ( | Tile | t | ) |
| inline

House Construction Scheme.

Construction counter, for buildings under construction. Incremented on every periodic tile processing. On wraparound, the stage of building in is increased. GetHouseBuildingStage is taking care of the real stages, (as the sprite for the next phase of house building) (Get|Inc)HouseConstructionTick is simply a tick counter between the different stages Gets the building stage of a house Since the stage is used for determining what sprite to use, if the house is complete (and that stage no longer is available), fool the system by returning the TOWN_HOUSE_COMPLETE (3), thus showing a beautiful complete house.

Parameters

  t | the tile of the house to get the building stage of

Precondition
  IsTileType(t, MP_HOUSE)

Returns
  the building stage of the house

Definition at line 205 of file town_map.h.

References GB(), IsHouseCompleted(), IsTileType(), Tile::m5(), MP_HOUSE, and TOWN_HOUSE_COMPLETED.

Referenced by DrawTile_Town(), and HouseScopeResolver::GetVariable().

## ◆ GetHouseConstructionTick()

uint8_t GetHouseConstructionTick | ( | Tile | t | ) |
| inline

Gets the construction stage of a house.

Parameters

  t | the tile of the house to get the construction stage of

Precondition
  IsTileType(t, MP_HOUSE)

Returns
  the construction stage of the house

Definition at line 217 of file town_map.h.

References GB(), IsHouseCompleted(), IsTileType(), Tile::m5(), and MP_HOUSE.

Referenced by AdvanceSingleHouseConstruction().

## ◆ GetHouseProcessingTime()

uint8_t GetHouseProcessingTime | ( | Tile | t | ) |
| inline

Get the amount of time remaining before the tile loop processes this tile.

Parameters

  t | the house tile

Precondition
  IsTileType(t, MP_HOUSE)

Returns
  time remaining

Definition at line 335 of file town_map.h.

References GB(), IsTileType(), Tile::m6(), and MP_HOUSE.

## ◆ GetHouseRandomBits()

uint8_t GetHouseRandomBits | ( | Tile | t | ) |
| inline

Get the random bits for this house.

This is required for newgrf house

Parameters

  t | the tile of this house

Precondition
  IsTileType(t, MP_HOUSE)

Returns
  random bits

Definition at line 297 of file town_map.h.

References IsTileType(), Tile::m1(), and MP_HOUSE.

Referenced by HouseScopeResolver::GetRandomBits().

## ◆ GetHouseRandomTriggers()

HouseRandomTriggers GetHouseRandomTriggers | ( | Tile | t | ) |
| inline

Get the already activated triggers bits for this house.

This is required for newgrf house

Parameters

  t | the tile of this house

Precondition
  IsTileType(t, MP_HOUSE)

Returns
  triggers

Definition at line 323 of file town_map.h.

References GB(), IsTileType(), Tile::m3(), and MP_HOUSE.

Referenced by HouseScopeResolver::GetRandomTriggers().

## ◆ GetHouseType()

HouseID GetHouseType | ( | Tile | t | ) |
| inline

Get the type of this house, which is an index into the house spec array.

Parameters

  t | the tile

Precondition
  IsTileType(t, MP_HOUSE)

Returns
  house type

Definition at line 60 of file town_map.h.

References GetCleanHouseType(), and GetTranslatedHouseID().

Referenced by AdvanceHouseConstruction(), AdvanceSingleHouseConstruction(), AfterLoadGame(), AnimateTile_Town(), ClearTile_Town(), ClearTownHouse(), DoTriggerHouseAnimation_WatchedCargoAccepted(), DrawTile_Town(), NIHHouse::GetBadges(), GetDistanceFromNearbyHouse(), GetFoundation_Town(), NIHHouse::GetGRFID(), NIHHouse::GetSpec(), HouseScopeResolver::GetVariable(), NIHHouse::IsInspectable(), RebuildTownCaches(), NIHHouse::Resolve(), TileLoop_Town(), TriggerHouseAnimation_TileLoop(), and TriggerHouseAnimation_WatchedCargoAccepted().

## ◆ GetLiftDestination()

uint8_t GetLiftDestination | ( | Tile | t | ) |
| inline

Get the current destination for this lift.

Parameters

  t | the tile

Returns
  destination

Definition at line 126 of file town_map.h.

References GB(), and Tile::m7().

Referenced by AnimateTile_Town().

## ◆ GetLiftPosition()

uint8_t GetLiftPosition | ( | Tile | t | ) |
| inline

Get the position of the lift on this animated house.

Parameters

  t | the tile

Returns
  position, from 0 to 36

Definition at line 147 of file town_map.h.

References GB(), and Tile::m6().

Referenced by AnimateTile_Town().

## ◆ GetTownIndex()

TownID GetTownIndex | ( | Tile | t | ) |
| inline

Get the index of which town this house/street is attached to.

Parameters

  t | the tile

Precondition
  IsTileType(t, MP_HOUSE) or IsTileType(t, MP_ROAD) but not a road depot

Returns
  TownID

Definition at line 23 of file town_map.h.

References IsRoadDepot(), IsTileType(), Tile::m2(), MP_HOUSE, and MP_ROAD.

Referenced by Station::CatchmentCoversTown(), ClosestTownFromTile(), CmdBuildSingleRail(), CmdDeleteTown(), CmdRemoveSingleRail(), NIHHouse::GetName(), NIHHouse::GetParent(), GetTileHighlightType(), Station::RemoveFromAllNearbyLists(), TestTownOwnsBridge(), and Town::~Town().

## ◆ HaltLift()

void HaltLift | ( | Tile | t | ) |
| inline

Stop the lift of this animated house from moving.

Clears the first 4 bits of m7 at once, clearing the LiftHasDestination bit and the destination.

Parameters

  t | the tile

Definition at line 137 of file town_map.h.

References Tile::m7(), and SB().

Referenced by AnimateTile_Town().

## ◆ IncHouseConstructionTick()

void IncHouseConstructionTick | ( | Tile | t | ) |
| inline

Sets the increment stage of a house It is working with the whole counter + stage 5 bits, making it easier to work: the wraparound is automatic.

Parameters

  t | the tile of the house to increment the construction stage of

Precondition
  IsTileType(t, MP_HOUSE)

Definition at line 230 of file town_map.h.

References AB(), GB(), IsTileType(), Tile::m5(), MP_HOUSE, SetHouseCompleted(), and TOWN_HOUSE_COMPLETED.

Referenced by AdvanceSingleHouseConstruction().

## ◆ IncrementHouseAge()

void IncrementHouseAge | ( | Tile | t | ) |
| inline

Increments the age of the house.

Parameters

  t | the tile of this house

Precondition
  IsTileType(t, MP_HOUSE)

Definition at line 259 of file town_map.h.

References IsHouseCompleted(), IsTileType(), Tile::m5(), and MP_HOUSE.

## ◆ IsHouseCompleted()

bool IsHouseCompleted | ( | Tile | t | ) |
| inline

Get the completion of this house.

Parameters

  t | the tile

Returns
  true if it is, false if it is not

Definition at line 167 of file town_map.h.

References HasBit(), IsTileType(), Tile::m3(), and MP_HOUSE.

Referenced by AdvanceSingleHouseConstruction(), AfterLoadGame(), ClearTownHouse(), GetHouseAge(), GetHouseBuildingStage(), GetHouseConstructionTick(), IncrementHouseAge(), MakeHouseTile(), RebuildTownCaches(), ResetHouseAge(), and TileLoop_Town().

## ◆ IsHouseProtected()

bool IsHouseProtected | ( | Tile | t | ) |
| inline

Check if the house is protected from removal by towns.

Parameters

  t | The tile.

Returns
  If the house is protected from the town upgrading it.

Definition at line 82 of file town_map.h.

References HasBit(), IsTileType(), Tile::m3(), and MP_HOUSE.

## ◆ LiftHasDestination()

bool LiftHasDestination | ( | Tile | t | ) |
| inline

Check if the lift of this animated house has a destination.

Parameters

  t | the tile

Returns
  has destination

Definition at line 104 of file town_map.h.

References HasBit(), and Tile::m7().

Referenced by AnimateTile_Town(), and TileLoop_Town().

## ◆ MakeHouseTile()

void MakeHouseTile | ( | Tile | t,
|  | TownID | tid,
|  | uint8_t | counter,
|  | uint8_t | stage,
|  | HouseID | type,
|  | uint8_t | random_bits,
|  | bool | house_protected
| ) |  |
| inline

Make the tile a house.

Parameters

  t | tile index
  tid | Town index
  counter | of construction step
  stage | of construction (used for drawing)
  type | of house. Index into house specs array
  random_bits | required for newgrf houses
  house_protected | Whether the house is protected from the town upgrading it.

Precondition
  IsTileType(t, MP_CLEAR)

Definition at line 375 of file town_map.h.

References HouseSpec::Get(), IsHouseCompleted(), IsTileType(), Tile::m1(), Tile::m2(), Tile::m3(), Tile::m5(), Tile::m8(), MP_CLEAR, MP_HOUSE, SB(), SetAnimationFrame(), SetHouseCompleted(), SetHouseProcessingTime(), SetHouseProtected(), SetHouseType(), SetTileType(), and TOWN_HOUSE_COMPLETED.

Referenced by ClearMakeHouseTile().

## ◆ ResetHouseAge()

void ResetHouseAge | ( | Tile | t | ) |
| inline

Sets the age of the house to zero.

Needs to be called after the house is completed. During construction stages the map space is used otherwise.

Parameters

  t | the tile of this house

Precondition
  IsTileType(t, MP_HOUSE) && IsHouseCompleted(t)

Definition at line 248 of file town_map.h.

References IsHouseCompleted(), IsTileType(), Tile::m5(), and MP_HOUSE.

Referenced by AdvanceSingleHouseConstruction().

## ◆ SetHouseCompleted()

void SetHouseCompleted | ( | Tile | t,
|  | bool | status
| ) |  |
| inline

Mark this house as been completed.

Parameters

  t | the tile
  status |

Definition at line 178 of file town_map.h.

References IsTileType(), Tile::m3(), MP_HOUSE, and SB().

Referenced by AfterLoadGame(), IncHouseConstructionTick(), and MakeHouseTile().

## ◆ SetHouseProcessingTime()

void SetHouseProcessingTime | ( | Tile | t,
|  | uint8_t | time
| ) |  |
| inline

Set the amount of time remaining before the tile loop processes this tile.

Parameters

  t | the house tile
  time | the time to be set

Precondition
  IsTileType(t, MP_HOUSE)

Definition at line 347 of file town_map.h.

References IsTileType(), Tile::m6(), MP_HOUSE, and SB().

Referenced by MakeHouseTile().

## ◆ SetHouseProtected()

void SetHouseProtected | ( | Tile | t,
|  | bool | house_protected
| ) |  |
| inline

Set a house as protected from removal by towns.

Parameters

  t | The tile.
  house_protected | Whether the house is protected from the town upgrading it.

Definition at line 93 of file town_map.h.

References IsTileType(), Tile::m3(), MP_HOUSE, and SB().

Referenced by AfterLoadGame(), and MakeHouseTile().

## ◆ SetHouseRandomBits()

void SetHouseRandomBits | ( | Tile | t,
|  | uint8_t | random
| ) |  |
| inline

Set the random bits for this house.

This is required for newgrf house

Parameters

  t | the tile of this house
  random | the new random bits

Precondition
  IsTileType(t, MP_HOUSE)

Definition at line 284 of file town_map.h.

References IsTileType(), Tile::m1(), and MP_HOUSE.

## ◆ SetHouseRandomTriggers()

void SetHouseRandomTriggers | ( | Tile | t,
|  | HouseRandomTriggers | triggers
| ) |  |
| inline

Set the activated triggers bits for this house.

This is required for newgrf house

Parameters

  t | the tile of this house
  triggers | the activated triggers

Precondition
  IsTileType(t, MP_HOUSE)

Definition at line 310 of file town_map.h.

References BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::base(), IsTileType(), Tile::m3(), MP_HOUSE, and SB().

## ◆ SetHouseType()

void SetHouseType | ( | Tile | t,
|  | HouseID | house_id
| ) |  |
| inline

Set the house type.

Parameters

  t | the tile
  house_id | the new house type

Precondition
  IsTileType(t, MP_HOUSE)

Definition at line 71 of file town_map.h.

References IsTileType(), Tile::m8(), MP_HOUSE, and SB().

Referenced by AfterLoadGame(), MakeHouseTile(), and UpdateHousesAndTowns().

## ◆ SetLiftDestination()

void SetLiftDestination | ( | Tile | t,
|  | uint8_t | dest
| ) |  |
| inline

Set the new destination of the lift for this animated house, and activate the LiftHasDestination bit.

Parameters

  t | the tile
  dest | new destination

Definition at line 115 of file town_map.h.

References Tile::m7(), SB(), and SetBit().

Referenced by AnimateTile_Town().

## ◆ SetLiftPosition()

void SetLiftPosition | ( | Tile | t,
|  | uint8_t | pos
| ) |  |
| inline

Set the position of the lift on this animated house.

Parameters

  t | the tile
  pos | position, from 0 to 36

Definition at line 157 of file town_map.h.

References Tile::m6(), and SB().

Referenced by AfterLoadGame(), and AnimateTile_Town().

## ◆ SetTownIndex()

void SetTownIndex | ( | Tile | t,
|  | TownID | index
| ) |  |
| inline

Set the town index for a road or house tile.

Parameters

  t | the tile
  index | the index of the town

Precondition
  IsTileType(t, MP_HOUSE) or IsTileType(t, MP_ROAD) but not a road depot

Definition at line 35 of file town_map.h.

References IsRoadDepot(), IsTileType(), Tile::m2(), MP_HOUSE, and MP_ROAD.

Referenced by AfterLoadGame(), CmdBuildRoad(), GrowTownAtRoad(), RemoveRoad(), and UpdateNearestTownForRoadTiles().