OpenTTD Source: src/newgrf_house.h File Reference

OpenTTD Source 15.3

Data Structures | Functions
newgrf_house.h File Reference

Functions related to NewGRF houses. More...

`#include "newgrf_callbacks.h"`
`#include "tile_cmd.h"`
`#include "house_type.h"`
`#include "newgrf_spritegroup.h"`
`#include "newgrf_town.h"`

Go to the source code of this file.

## Data Structures
struct | HouseScopeResolver
| Scope resolver for houses. More...
struct | HouseResolverObject
| Resolver object to be used for houses (feature 07 spritegroups). More...
struct | HouseClassMapping
| Makes class IDs unique to each GRF file. More...

## Functions
void | ResetHouseClassIDs ()
HouseClassID | AllocateHouseClassID (uint8_t grf_class_id, uint32_t grfid)
void | InitializeBuildingCounts ()
| Initialise global building counts and all town building counts.
void | InitializeBuildingCounts (Town *t)
| Initialise building counts for a town.
void | IncreaseBuildingCount (Town *t, HouseID house_id)
| IncreaseBuildingCount() Increase the count of a building when it has been added by a town.
void | DecreaseBuildingCount (Town *t, HouseID house_id)
| DecreaseBuildingCount() Decrease the number of a building when it is deleted.
std::span< const uint > | GetBuildingHouseIDCounts ()
| Get read-only span of total HouseID building counts.
void | DrawNewHouseTile (TileInfo *ti, HouseID house_id)
void | DrawNewHouseTileInGUI (int x, int y, const HouseSpec *spec, HouseID house_id, int view)
| Draw representation of a house tile for GUI purposes.
void | AnimateNewHouseTile (TileIndex tile)
void | TriggerHouseAnimation_ConstructionStageChanged (TileIndex tile, bool first_call)
void | TriggerHouseAnimation_WatchedCargoAccepted (TileIndex tile, CargoTypes trigger_cargoes)
| Run watched cargo accepted callback for a house.
uint16_t | GetHouseCallback (CallbackID callback, uint32_t param1, uint32_t param2, HouseID house_id, Town *town, TileIndex tile, std::span< int32_t > regs100={}, bool not_yet_constructed=false, uint8_t initial_random_bits=0, CargoTypes watched_cargo_triggers=0, int view=0)
bool | CanDeleteHouse (TileIndex tile)
bool | NewHouseTileLoop (TileIndex tile)
void | TriggerHouseRandomisation (TileIndex t, HouseRandomTrigger trigger)

## Detailed Description

Functions related to NewGRF houses.

Definition in file newgrf_house.h.

## Function Documentation

## ◆ AllocateHouseClassID()

HouseClassID AllocateHouseClassID | ( | uint8_t | grf_class_id,
|  | uint32_t | grfid
| ) |  |

Definition at line 138 of file newgrf_house.cpp.

## ◆ AnimateNewHouseTile()

void AnimateNewHouseTile | ( | TileIndex | tile | ) |

Definition at line 571 of file newgrf_house.cpp.

## ◆ CanDeleteHouse()

bool CanDeleteHouse | ( | TileIndex | tile | ) |

Definition at line 588 of file newgrf_house.cpp.

## ◆ DecreaseBuildingCount()

void DecreaseBuildingCount | ( | Town * | t,
|  | HouseID | house_id
| ) |  |

DecreaseBuildingCount() Decrease the number of a building when it is deleted.

Parameters

  t | The town that the building was built in
  house_id | The id of the house being removed

Definition at line 210 of file newgrf_house.cpp.

References TownCache::building_counts, Town::cache, HouseSpec::class_id, and HouseSpec::Get().

Referenced by DoClearTownHouseHelper().

## ◆ DrawNewHouseTile()

void DrawNewHouseTile | ( | TileInfo * | ti,
|  | HouseID | house_id
| ) |  |

Definition at line 489 of file newgrf_house.cpp.

## ◆ DrawNewHouseTileInGUI()

void DrawNewHouseTileInGUI | ( | int | x,
|  | int | y,
|  | const HouseSpec * | spec,
|  | HouseID | house_id,
|  | int | view
| ) |  |

Draw representation of a house tile for GUI purposes.

Parameters

  x | Position x of image.
  y | Position y of image.
  spec | House spec to draw.
  house_id | House ID to draw.
  view | The house's 'view'.

Definition at line 524 of file newgrf_house.cpp.

References CALLBACK_FAILED, HouseSpec::callback_mask, CBID_HOUSE_COLOUR, CBID_NO_CALLBACK, Colour, DrawNewGRFTileSeqInGUI(), DrawSprite(), GB(), GetColourPalette(), DrawTileSprites::ground, GroundSpritePaletteTransform(), HasBit(), INVALID_TILE, PalSpriteID::pal, TileLayoutSpriteGroup::ProcessRegisters(), HouseSpec::random_colour, PalSpriteID::sprite, SPRITE_MODIFIER_CUSTOM_SPRITE, SPRITE_WIDTH, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and TOWN_HOUSE_COMPLETED.

Referenced by DrawHouseInGUI().

## ◆ GetBuildingHouseIDCounts()

std::span< const uint > GetBuildingHouseIDCounts | ( |  | ) |

Get read-only span of total HouseID building counts.

Returns
  span of HouseID building counts.

Definition at line 180 of file newgrf_house.cpp.

Referenced by HousePickerCallbacks::FillUsedItems().

## ◆ GetHouseCallback()

uint16_t GetHouseCallback | ( | CallbackID | callback,
|  | uint32_t | param1,
|  | uint32_t | param2,
|  | HouseID | house_id,
|  | Town * | town,
|  | TileIndex | tile,
|  | std::span< int32_t > | regs100 = `{}`,
|  | bool | not_yet_constructed = `false`,
|  | uint8_t | initial_random_bits = `0`,
|  | CargoTypes | watched_cargo_triggers = `0`,
|  | int | view = `0`
| ) |  |

Definition at line 456 of file newgrf_house.cpp.

## ◆ IncreaseBuildingCount()

void IncreaseBuildingCount | ( | Town * | t,
|  | HouseID | house_id
| ) |  |

IncreaseBuildingCount() Increase the count of a building when it has been added by a town.

Parameters

  t | The town that the building is being built in
  house_id | The id of the house being added

Definition at line 191 of file newgrf_house.cpp.

References TownCache::building_counts, Town::cache, HouseSpec::class_id, and HouseSpec::Get().

Referenced by ClearMakeHouseTile(), and RebuildTownCaches().

## ◆ InitializeBuildingCounts() [1/2]

void InitializeBuildingCounts | ( |  | ) |

Initialise global building counts and all town building counts.

Definition at line 164 of file newgrf_house.cpp.

References InitializeBuildingCounts(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_town_pool >::Iterate(), and HouseSpec::Specs().

Referenced by DoCreateTown(), GenerateWorld(), InitializeBuildingCounts(), and RebuildTownCaches().

## ◆ InitializeBuildingCounts() [2/2]

void InitializeBuildingCounts | ( | Town * | t | ) |

Initialise building counts for a town.

Parameters

  t | Town cache to initialise.

Definition at line 153 of file newgrf_house.cpp.

References TownCache::building_counts, Town::cache, and HouseSpec::Specs().

## ◆ NewHouseTileLoop()

bool NewHouseTileLoop | ( | TileIndex | tile | ) |

Definition at line 624 of file newgrf_house.cpp.

## ◆ ResetHouseClassIDs()

void ResetHouseClassIDs | ( |  | ) |

Definition at line 130 of file newgrf_house.cpp.

## ◆ TriggerHouseAnimation_ConstructionStageChanged()

void TriggerHouseAnimation_ConstructionStageChanged | ( | TileIndex | tile,
|  | bool | first_call
| ) |  |

Definition at line 579 of file newgrf_house.cpp.

## ◆ TriggerHouseAnimation_WatchedCargoAccepted()

void TriggerHouseAnimation_WatchedCargoAccepted | ( | TileIndex | tile,
|  | CargoTypes | trigger_cargoes
| ) |  |

Run watched cargo accepted callback for a house.

Parameters

  tile | House tile.
  trigger_cargoes | Triggering cargo types.

Precondition
  IsTileType(t, MP_HOUSE)

Definition at line 736 of file newgrf_house.cpp.

References BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Any(), HouseSpec::building_flags, DoTriggerHouseAnimation_WatchedCargoAccepted(), HouseSpec::Get(), GetHouseNorthPart(), GetHouseType(), IsTileType(), MP_HOUSE, Random, TileAddXY(), and HouseSpec::watched_cargoes.

Referenced by TriggerWatchedCargoCallbacks().

## ◆ TriggerHouseRandomisation()

void TriggerHouseRandomisation | ( | TileIndex | t,
|  | HouseRandomTrigger | trigger
| ) |  |

Definition at line 711 of file newgrf_house.cpp.