OpenTTD Source 20250521-master-g82876c25e0
|
Implementation of NewGRF houses. More...
#include "stdafx.h"
#include "debug.h"
#include "landscape.h"
#include "newgrf_badge.h"
#include "newgrf_house.h"
#include "newgrf_spritegroup.h"
#include "newgrf_town.h"
#include "newgrf_sound.h"
#include "company_func.h"
#include "company_base.h"
#include "town.h"
#include "genworld.h"
#include "newgrf_animation_base.h"
#include "newgrf_cargo.h"
#include "station_base.h"
#include "safeguards.h"
Go to the source code of this file.
Data Structures | |
struct | HouseAnimationBase |
Helper class for animation control. More... | |
Functions | |
static const GRFFile * | GetHouseSpecGrf (HouseID house_id) |
Retrieve the grf file associated with a house. | |
void | ResetHouses () |
void | ResetHouseClassIDs () |
HouseClassID | AllocateHouseClassID (uint8_t grf_class_id, uint32_t grfid) |
void | InitializeBuildingCounts (Town *t) |
Initialise building counts for a town. | |
void | InitializeBuildingCounts () |
Initialise global building counts and all town building counts. | |
std::span< const uint > | GetBuildingHouseIDCounts () |
Get read-only span of total HouseID building counts. | |
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. | |
static uint32_t | GetNumHouses (HouseID house_id, const Town *town) |
static uint32_t | GetNearbyTileInformation (uint8_t parameter, TileIndex tile, bool grf_version8) |
Get information about a nearby tile. | |
static uint32_t | GetDistanceFromNearbyHouse (uint8_t parameter, TileIndex start_tile, HouseID start_house) |
This function will activate a search around a central tile, looking for some houses that fit the requested characteristics. | |
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, uint8_t initial_random_bits, CargoTypes watched_cargo_triggers, int view) |
static void | DrawTileLayout (const TileInfo *ti, const DrawTileSpriteSpan &dts, uint8_t stage, HouseID house_id) |
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. | |
static uint16_t | GetSimpleHouseCallback (CallbackID callback, uint32_t param1, uint32_t param2, const HouseSpec *spec, Town *town, TileIndex tile, CargoTypes extra_data) |
void | AnimateNewHouseTile (TileIndex tile) |
void | TriggerHouseAnimation_ConstructionStageChanged (TileIndex tile, bool first_call) |
bool | CanDeleteHouse (TileIndex tile) |
static void | TriggerHouseAnimation_TileLoop (TileIndex tile, bool sync, uint16_t random_bits) |
Call the tile loop animation trigger for houses, if enabled. | |
bool | NewHouseTileLoop (TileIndex tile) |
static void | DoTriggerHouseRandomisation (TileIndex tile, HouseRandomTrigger trigger, uint8_t base_random, bool first) |
void | TriggerHouseRandomisation (TileIndex t, HouseRandomTrigger trigger) |
static void | DoTriggerHouseAnimation_WatchedCargoAccepted (TileIndex tile, TileIndex origin, CargoTypes trigger_cargoes, uint16_t random) |
Run the watched cargo accepted callback for a single house tile. | |
void | TriggerHouseAnimation_WatchedCargoAccepted (TileIndex tile, CargoTypes trigger_cargoes) |
Run watched cargo accepted callback for a house. | |
Variables | |
static BuildingCounts< uint32_t > | _building_counts {} |
static std::vector< HouseClassMapping > | _class_mapping {} |
HouseOverrideManager | _house_mngr (NEW_HOUSE_OFFSET, NUM_HOUSES, INVALID_HOUSE_ID) |
const HouseSpec | _original_house_specs [NEW_HOUSE_OFFSET] |
std::vector< HouseSpec > | _house_specs |
Implementation of NewGRF houses.
Definition in file newgrf_house.cpp.
HouseClassID AllocateHouseClassID | ( | uint8_t | grf_class_id, |
uint32_t | grfid | ||
) |
Definition at line 138 of file newgrf_house.cpp.
void AnimateNewHouseTile | ( | TileIndex | tile | ) |
Definition at line 571 of file newgrf_house.cpp.
bool CanDeleteHouse | ( | TileIndex | tile | ) |
Definition at line 588 of file newgrf_house.cpp.
DecreaseBuildingCount() Decrease the number of a building when it is deleted.
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().
|
static |
Run the watched cargo accepted callback for a single house tile.
tile | The house tile. |
origin | The triggering tile. |
trigger_cargoes | Cargo types that triggered the callback. |
random | Random bits. |
Definition at line 723 of file newgrf_house.cpp.
References CBID_HOUSE_ANIMATION_TRIGGER_WATCHED_CARGO_ACCEPTED, AnimationBase< HouseAnimationBase, HouseSpec, Town, CargoTypes, GetSimpleHouseCallback, TileAnimationFrameAnimationHelper< Town > >::ChangeAnimationFrame(), HouseSpec::Get(), GetHouseType(), TileIndexToTileIndexDiffC(), TileIndexDiffC::x, and TileIndexDiffC::y.
Referenced by TriggerHouseAnimation_WatchedCargoAccepted().
|
static |
Definition at line 662 of file newgrf_house.cpp.
Definition at line 489 of file newgrf_house.cpp.
Draw representation of a house tile for GUI purposes.
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().
|
static |
Definition at line 464 of file newgrf_house.cpp.
std::span< const uint > GetBuildingHouseIDCounts | ( | ) |
Get read-only span of total HouseID building counts.
Definition at line 180 of file newgrf_house.cpp.
Referenced by HousePickerCallbacks::FillUsedItems().
|
static |
This function will activate a search around a central tile, looking for some houses that fit the requested characteristics.
parameter | that is given by the callback. bits 0..6 radius of the search bits 7..8 search type i.e.: 0 = houseID/ 1 = classID/ 2 = grfID |
start_tile | TileIndex from which to start the search |
start_house | the HouseID that is associated to the house, the callback is called for |
Definition at line 270 of file newgrf_house.cpp.
References HouseSpec::class_id, DistanceManhattan(), GB(), HouseSpec::Get(), GetHouseNorthPart(), GetHouseType(), HouseSpec::grf_prop, GRFFilePropsBase::grfid, GRFFilePropsBase::HasGrfFile(), IsTileType(), GRFFilePropsBase::local_id, and MP_HOUSE.
Referenced by HouseScopeResolver::GetVariable().
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, | ||
uint8_t | initial_random_bits, | ||
CargoTypes | watched_cargo_triggers, | ||
int | view | ||
) |
Definition at line 456 of file newgrf_house.cpp.
Retrieve the grf file associated with a house.
house_id | House to query. |
nullptr
). Definition at line 38 of file newgrf_house.cpp.
References HouseSpec::Get(), HouseSpec::grf_prop, and GRFFilePropsBase::grffile.
|
static |
Get information about a nearby tile.
parameter | from callback. It's in fact a pair of coordinates |
tile | TileIndex from which the callback was initiated |
grf_version8 | True, if we are dealing with a new NewGRF which uses GRF version >= 8. |
Definition at line 254 of file newgrf_house.cpp.
References GetNearbyTile(), and GetNearbyTileInformation().
Referenced by GetNearbyTileInformation().
Definition at line 235 of file newgrf_house.cpp.
|
static |
Definition at line 557 of file newgrf_house.cpp.
IncreaseBuildingCount() Increase the count of a building when it has been added by a town.
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().
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().
void InitializeBuildingCounts | ( | Town * | t | ) |
Initialise building counts for a town.
t | Town cache to initialise. |
Definition at line 153 of file newgrf_house.cpp.
References TownCache::building_counts, Town::cache, and HouseSpec::Specs().
bool NewHouseTileLoop | ( | TileIndex | tile | ) |
Definition at line 624 of file newgrf_house.cpp.
void ResetHouseClassIDs | ( | ) |
Definition at line 130 of file newgrf_house.cpp.
void ResetHouses | ( | ) |
Definition at line 81 of file newgrf_house.cpp.
void TriggerHouseAnimation_ConstructionStageChanged | ( | TileIndex | tile, |
bool | first_call | ||
) |
Definition at line 579 of file newgrf_house.cpp.
|
static |
Call the tile loop animation trigger for houses, if enabled.
tile | House tile |
sync | Whether to call the synchronized or the unsynchronized trigger. |
random_bits | Shared random bits for the synchronized trigger. |
Definition at line 612 of file newgrf_house.cpp.
References AnimationTriggerTileLoop, HouseSpec::callback_mask, CBID_HOUSE_ANIMATION_TRIGGER_TILE_LOOP, AnimationBase< HouseAnimationBase, HouseSpec, Town, CargoTypes, GetSimpleHouseCallback, TileAnimationFrameAnimationHelper< Town > >::ChangeAnimationFrame(), HouseSpec::extra_flags, GB(), HouseSpec::Get(), GetHouseType(), Random, SynchronisedCallback1B, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().
void TriggerHouseAnimation_WatchedCargoAccepted | ( | TileIndex | tile, |
CargoTypes | trigger_cargoes | ||
) |
Run watched cargo accepted callback for a house.
tile | House tile. |
trigger_cargoes | Triggering cargo types. |
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().
void TriggerHouseRandomisation | ( | TileIndex | t, |
HouseRandomTrigger | trigger | ||
) |
Definition at line 711 of file newgrf_house.cpp.
|
static |
Definition at line 28 of file newgrf_house.cpp.
|
static |
Definition at line 29 of file newgrf_house.cpp.
std::vector<HouseSpec> _house_specs |
Definition at line 45 of file newgrf_house.cpp.