OpenTTD Source: src/town_map.h File Reference

OpenTTD Source 12.2

Functions
town_map.h File Reference
`#include "road_map.h"`
`#include "house.h"`

Go to the source code of this file.

## Functions
static TownID | GetTownIndex (TileIndex t)
| Get the index of which town this house/street is attached to. More...
static void | SetTownIndex (TileIndex t, TownID index)
| Set the town index for a road or house tile. More...
static HouseID | GetCleanHouseType (TileIndex t)
| Get the type of this house, which is an index into the house spec array without doing any NewGRF related translations. More...
static HouseID | GetHouseType (TileIndex t)
| Get the type of this house, which is an index into the house spec array. More...
static void | SetHouseType (TileIndex t, HouseID house_id)
| Set the house type. More...
static bool | LiftHasDestination (TileIndex t)
| Check if the lift of this animated house has a destination. More...
static void | SetLiftDestination (TileIndex t, byte dest)
| Set the new destination of the lift for this animated house, and activate the LiftHasDestination bit. More...
static byte | GetLiftDestination (TileIndex t)
| Get the current destination for this lift. More...
static void | HaltLift (TileIndex t)
| Stop the lift of this animated house from moving. More...
static byte | GetLiftPosition (TileIndex t)
| Get the position of the lift on this animated house. More...
static void | SetLiftPosition (TileIndex t, byte pos)
| Set the position of the lift on this animated house. More...
static bool | IsHouseCompleted (TileIndex t)
| Get the completion of this house. More...
static void | SetHouseCompleted (TileIndex t, bool status)
| Mark this house as been completed. More...
static byte | GetHouseBuildingStage (TileIndex t)
| House Construction Scheme. More...
static byte | GetHouseConstructionTick (TileIndex t)
| Gets the construction stage of a house. More...
static void | IncHouseConstructionTick (TileIndex 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. More...
static void | ResetHouseAge (TileIndex t)
| Sets the age of the house to zero. More...
static void | IncrementHouseAge (TileIndex t)
| Increments the age of the house. More...
static Year | GetHouseAge (TileIndex t)
| Get the age of the house. More...
static void | SetHouseRandomBits (TileIndex t, byte random)
| Set the random bits for this house. More...
static byte | GetHouseRandomBits (TileIndex t)
| Get the random bits for this house. More...
static void | SetHouseTriggers (TileIndex t, byte triggers)
| Set the activated triggers bits for this house. More...
static byte | GetHouseTriggers (TileIndex t)
| Get the already activated triggers bits for this house. More...
static byte | GetHouseProcessingTime (TileIndex t)
| Get the amount of time remaining before the tile loop processes this tile. More...
static void | SetHouseProcessingTime (TileIndex t, byte time)
| Set the amount of time remaining before the tile loop processes this tile. More...
static void | DecHouseProcessingTime (TileIndex t)
| Decrease the amount of time remaining before the tile loop processes this tile. More...
static void | MakeHouseTile (TileIndex t, TownID tid, byte counter, byte stage, HouseID type, byte random_bits)
| Make the tile a house. More...

## Detailed Description

Accessors for towns

Definition in file town_map.h.

## Function Documentation

## ◆ DecHouseProcessingTime()

static void DecHouseProcessingTime | ( | TileIndex | t | ) |
| inlinestatic

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 336 of file town_map.h.

References _me, IsTileType(), TileExtended::m6, and MP_HOUSE.

## ◆ GetCleanHouseType()

static HouseID GetCleanHouseType | ( | TileIndex | t | ) |
| inlinestatic

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 47 of file town_map.h.

References _m, GB(), IsTileType(), Tile::m4, and MP_HOUSE.

Referenced by GetHouseType(), and UpdateHousesAndTowns().

## ◆ GetHouseAge()

static Year GetHouseAge | ( | TileIndex | t | ) |
| inlinestatic

Get the age of the house.

Parameters

  t | the tile of this house

Precondition
  IsTileType(t, MP_HOUSE)

Returns
  year

Definition at line 249 of file town_map.h.

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

Referenced by HouseScopeResolver::GetVariable().

## ◆ GetHouseBuildingStage()

static byte GetHouseBuildingStage | ( | TileIndex | t | ) |
| inlinestatic

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 183 of file town_map.h.

References IsHouseCompleted(), IsTileType(), and MP_HOUSE.

Referenced by HouseScopeResolver::GetVariable().

## ◆ GetHouseConstructionTick()

static byte GetHouseConstructionTick | ( | TileIndex | t | ) |
| inlinestatic

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 195 of file town_map.h.

References _m, GB(), IsHouseCompleted(), IsTileType(), and MP_HOUSE.

Referenced by MakeSingleHouseBigger().

## ◆ GetHouseProcessingTime()

static byte GetHouseProcessingTime | ( | TileIndex | t | ) |
| inlinestatic

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 313 of file town_map.h.

References _me, GB(), IsTileType(), and MP_HOUSE.

## ◆ GetHouseRandomBits()

static byte GetHouseRandomBits | ( | TileIndex | t | ) |
| inlinestatic

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 275 of file town_map.h.

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

Referenced by HouseScopeResolver::GetRandomBits().

## ◆ GetHouseTriggers()

static byte GetHouseTriggers | ( | TileIndex | t | ) |
| inlinestatic

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 301 of file town_map.h.

References _m, GB(), IsTileType(), and MP_HOUSE.

Referenced by HouseScopeResolver::GetTriggers().

## ◆ GetHouseType()

static HouseID GetHouseType | ( | TileIndex | t | ) |
| inlinestatic

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 59 of file town_map.h.

References GetCleanHouseType(), and GetTranslatedHouseID().

Referenced by AnimateTile_Town(), DrawTile_Town(), GetFoundation_Town(), NIHHouse::GetGRFID(), NIHHouse::GetSpec(), NIHHouse::IsInspectable(), MakeTownHouseBigger(), NIHHouse::Resolve(), SearchNearbyHouseClass(), SearchNearbyHouseGRFID(), SearchNearbyHouseID(), TileLoop_Town(), and WatchedCargoCallback().

## ◆ GetLiftDestination()

static byte GetLiftDestination | ( | TileIndex | t | ) |
| inlinestatic

Get the current destination for this lift.

Parameters

  t | the tile

Returns
  destination

Definition at line 104 of file town_map.h.

References _me, and GB().

## ◆ GetLiftPosition()

static byte GetLiftPosition | ( | TileIndex | t | ) |
| inlinestatic

Get the position of the lift on this animated house.

Parameters

  t | the tile

Returns
  position, from 0 to 36

Definition at line 125 of file town_map.h.

References _me, and GB().

## ◆ GetTownIndex()

static TownID GetTownIndex | ( | TileIndex | t | ) |
| inlinestatic

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 22 of file town_map.h.

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

Referenced by Station::CatchmentCoversTown(), ClosestTownFromTile(), NIHHouse::GetParent(), NIHHouse::SetStringParameters(), TestTownOwnsBridge(), and Town::~Town().

## ◆ HaltLift()

static void HaltLift | ( | TileIndex | t | ) |
| inlinestatic

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 115 of file town_map.h.

References _me, and SB().

## ◆ IncHouseConstructionTick()

static void IncHouseConstructionTick | ( | TileIndex | t | ) |
| inlinestatic

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 208 of file town_map.h.

References _m, AB(), GB(), IsTileType(), MP_HOUSE, SetHouseCompleted(), and TOWN_HOUSE_COMPLETED.

Referenced by MakeSingleHouseBigger().

## ◆ IncrementHouseAge()

static void IncrementHouseAge | ( | TileIndex | t | ) |
| inlinestatic

Increments the age of the house.

Parameters

  t | the tile of this house

Precondition
  IsTileType(t, MP_HOUSE)

Definition at line 237 of file town_map.h.

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

## ◆ IsHouseCompleted()

static bool IsHouseCompleted | ( | TileIndex | t | ) |
| inlinestatic

Get the completion of this house.

Parameters

  t | the tile

Returns
  true if it is, false if it is not

Definition at line 145 of file town_map.h.

References _m, HasBit(), IsTileType(), and MP_HOUSE.

Referenced by GetHouseAge(), GetHouseBuildingStage(), GetHouseConstructionTick(), IncrementHouseAge(), MakeHouseTile(), and ResetHouseAge().

## ◆ LiftHasDestination()

static bool LiftHasDestination | ( | TileIndex | t | ) |
| inlinestatic

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

Parameters

  t | the tile

Returns
  has destination

Definition at line 82 of file town_map.h.

References _me, and HasBit().

## ◆ MakeHouseTile()

static void MakeHouseTile | ( | TileIndex | t,
|  | TownID | tid,
|  | byte | counter,
|  | byte | stage,
|  | HouseID | type,
|  | byte | random_bits
| ) |  |
| inlinestatic

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

Precondition
  IsTileType(t, MP_CLEAR)

Definition at line 352 of file town_map.h.

References _m, IsHouseCompleted(), IsTileType(), Tile::m1, Tile::m2, Tile::m3, Tile::m5, MP_CLEAR, MP_HOUSE, SetAnimationFrame(), SetHouseCompleted(), SetHouseProcessingTime(), SetHouseType(), SetTileType(), and TOWN_HOUSE_COMPLETED.

Referenced by ClearMakeHouseTile().

## ◆ ResetHouseAge()

static void ResetHouseAge | ( | TileIndex | t | ) |
| inlinestatic

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 226 of file town_map.h.

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

## ◆ SetHouseCompleted()

static void SetHouseCompleted | ( | TileIndex | t,
|  | bool | status
| ) |  |
| inlinestatic

Mark this house as been completed.

Parameters

  t | the tile
  status |

Definition at line 156 of file town_map.h.

References _m, IsTileType(), MP_HOUSE, and SB().

Referenced by IncHouseConstructionTick(), and MakeHouseTile().

## ◆ SetHouseProcessingTime()

static void SetHouseProcessingTime | ( | TileIndex | t,
|  | byte | time
| ) |  |
| inlinestatic

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 325 of file town_map.h.

References _me, IsTileType(), MP_HOUSE, and SB().

Referenced by MakeHouseTile().

## ◆ SetHouseRandomBits()

static void SetHouseRandomBits | ( | TileIndex | t,
|  | byte | random
| ) |  |
| inlinestatic

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 262 of file town_map.h.

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

## ◆ SetHouseTriggers()

static void SetHouseTriggers | ( | TileIndex | t,
|  | byte | triggers
| ) |  |
| inlinestatic

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 288 of file town_map.h.

References _m, IsTileType(), MP_HOUSE, and SB().

## ◆ SetHouseType()

static void SetHouseType | ( | TileIndex | t,
|  | HouseID | house_id
| ) |  |
| inlinestatic

Set the house type.

Parameters

  t | the tile
  house_id | the new house type

Precondition
  IsTileType(t, MP_HOUSE)

Definition at line 70 of file town_map.h.

References _m, GB(), IsTileType(), Tile::m4, MP_HOUSE, and SB().

Referenced by MakeHouseTile().

## ◆ SetLiftDestination()

static void SetLiftDestination | ( | TileIndex | t,
|  | byte | dest
| ) |  |
| inlinestatic

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 93 of file town_map.h.

References _me, SB(), and SetBit().

## ◆ SetLiftPosition()

static void SetLiftPosition | ( | TileIndex | t,
|  | byte | pos
| ) |  |
| inlinestatic

Set the position of the lift on this animated house.

Parameters

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

Definition at line 135 of file town_map.h.

References _me, and SB().

## ◆ SetTownIndex()

static void SetTownIndex | ( | TileIndex | t,
|  | TownID | index
| ) |  |
| inlinestatic

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 34 of file town_map.h.

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