Implementation of NewGRF houses. More...
#include "stdafx.h"
#include "debug.h"
#include "viewport_func.h"
#include "landscape.h"
#include "newgrf.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 "sprite.h"
#include "genworld.h"
#include "newgrf_animation_base.h"
#include "newgrf_cargo.h"
#include "station_base.h"
Go to the source code of this file.
Data Structures | |
struct | SearchNearbyHouseData |
Structure with user-data for SearchNearbyHouseXXX - functions. More... | |
struct | HouseAnimationBase |
Helper class for animation control. More... | |
Functions | |
HouseClassID | AllocateHouseClassID (byte grf_class_id, uint32 grfid) |
void | InitializeBuildingCounts () |
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 | HouseGetRandomBits (const ResolverObject *object) |
static uint32 | HouseGetTriggers (const ResolverObject *object) |
static void | HouseSetTriggers (const ResolverObject *object, int triggers) |
static uint32 | GetNumHouses (HouseID house_id, const Town *town) |
static uint32 | GetNearbyTileInformation (byte parameter, TileIndex tile, bool grf_version8) |
Get information about a nearby tile. | |
static bool | SearchNearbyHouseID (TileIndex tile, void *user_data) |
Callback function to search a house by its HouseID. | |
static bool | SearchNearbyHouseClass (TileIndex tile, void *user_data) |
Callback function to search a house by its classID. | |
static bool | SearchNearbyHouseGRFID (TileIndex tile, void *user_data) |
Callback function to search a house by its grfID. | |
static uint32 | GetDistanceFromNearbyHouse (uint8 parameter, TileIndex tile, HouseID house) |
This function will activate a search around a central tile, looking for some houses that fit the requested characteristics. | |
static uint32 | HouseGetVariable (const ResolverObject *object, byte variable, uint32 parameter, bool *available) |
HouseGetVariable(): | |
static const SpriteGroup * | HouseResolveReal (const ResolverObject *object, const RealSpriteGroup *group) |
void | HouseStorePSA (ResolverObject *object, uint pos, int32 value) |
Store a value into the persistent storage of the object's parent. | |
static void | NewHouseResolver (ResolverObject *res, HouseID house_id, TileIndex tile, Town *town) |
NewHouseResolver(): | |
uint16 | GetHouseCallback (CallbackID callback, uint32 param1, uint32 param2, HouseID house_id, Town *town, TileIndex tile, bool not_yet_constructed, uint8 initial_random_bits, uint32 watched_cargo_triggers) |
static void | DrawTileLayout (const TileInfo *ti, const TileLayoutSpriteGroup *group, byte stage, HouseID house_id) |
void | DrawNewHouseTile (TileInfo *ti, HouseID house_id) |
uint16 | GetSimpleHouseCallback (CallbackID callback, uint32 param1, uint32 param2, const HouseSpec *spec, Town *town, TileIndex tile, uint32 extra_data) |
void | AnimateNewHouseTile (TileIndex tile) |
void | AnimateNewHouseConstruction (TileIndex tile) |
bool | CanDeleteHouse (TileIndex tile) |
static void | AnimationControl (TileIndex tile, uint16 random_bits) |
bool | NewHouseTileLoop (TileIndex tile) |
static void | DoTriggerHouse (TileIndex tile, HouseTrigger trigger, byte base_random, bool first) |
void | TriggerHouse (TileIndex t, HouseTrigger trigger) |
void | DoWatchedCargoCallback (TileIndex tile, TileIndex origin, uint32 trigger_cargoes, uint16 random) |
Run the watched cargo accepted callback for a single house tile. | |
void | WatchedCargoCallback (TileIndex tile, uint32 trigger_cargoes) |
Run watched cargo accepted callback for a house. | |
void | GetHouseResolver (ResolverObject *ro, uint index) |
Resolve a house's spec and such so we can get a variable. | |
Variables | |
static BuildingCounts< uint32 > | _building_counts |
static HouseClassMapping | _class_mapping [HOUSE_CLASS_MAX] |
HouseOverrideManager | _house_mngr (NEW_HOUSE_OFFSET, HOUSE_MAX, INVALID_HOUSE_ID) |
Implementation of NewGRF houses.
Definition in 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 84 of file newgrf_house.cpp.
References _loaded_newgrf_features, Town::building_counts, HouseSpec::class_id, and GRFLoadedFeatures::has_newhouses.
Referenced by DoClearTownHouseHelper().
void DoWatchedCargoCallback | ( | TileIndex | tile, | |
TileIndex | origin, | |||
uint32 | trigger_cargoes, | |||
uint16 | random | |||
) |
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 679 of file newgrf_house.cpp.
References CBID_HOUSE_WATCHED_CARGO_ACCEPTED, AnimationBase< HouseAnimationBase, HouseSpec, Town, uint32, GetSimpleHouseCallback >::ChangeAnimationFrame(), GetHouseType(), TileIndexToTileIndexDiffC(), TileIndexDiffC::x, and TileIndexDiffC::y.
Referenced by WatchedCargoCallback().
static uint32 GetDistanceFromNearbyHouse | ( | uint8 | parameter, | |
TileIndex | tile, | |||
HouseID | house | |||
) | [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 | |
tile | TileIndex from which to start the search | |
house | the HouseID that is associated to the house, the callback is called for |
Definition at line 235 of file newgrf_house.cpp.
References CircularTileSearch(), DistanceManhattan(), GB(), GetHouseNorthPart(), SearchNearbyHouseData::hs, lengthof, and SearchNearbyHouseData::north_tile.
Referenced by HouseGetVariable().
void GetHouseResolver | ( | ResolverObject * | ro, | |
uint | index | |||
) |
Resolve a house's spec and such so we can get a variable.
ro | The resolver object to fill. | |
index | The house tile to get the data from. |
Definition at line 720 of file newgrf_house.cpp.
References GetHouseType(), and NewHouseResolver().
static uint32 GetNearbyTileInformation | ( | byte | parameter, | |
TileIndex | tile, | |||
bool | grf_version8 | |||
) | [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 142 of file newgrf_house.cpp.
References GetNearbyTile(), and GetNearbyTileInformation().
static uint32 HouseGetVariable | ( | const ResolverObject * | object, | |
byte | variable, | |||
uint32 | parameter, | |||
bool * | available | |||
) | [static] |
Used by the resolver to get values for feature 07 deterministic spritegroups.
Definition at line 264 of file newgrf_house.cpp.
References _generating_world, GoodsEntry::acceptance_pickup, SmallVector< T, S >::Begin(), HouseSpec::class_id, CT_INVALID, DEBUG, SmallVector< T, S >::End(), GB(), GoodsEntry::GES_ACCEPTED_BIGTICK, GoodsEntry::GES_CURRENT_MONTH, GoodsEntry::GES_EVER_ACCEPTED, GoodsEntry::GES_LAST_MONTH, GetAnimationFrame(), GetDistanceFromNearbyHouse(), OverrideManagerBase::GetGRFID(), GetHouseAge(), GetHouseBuildingStage(), GetHouseType(), OverrideManagerBase::GetID(), GetNearbyTile(), GetNearbyTileInformation(), GetRegister(), GetTerrainType(), GetTownRadiusGroup(), Station::goods, HouseSpec::grf_prop, GRFFilePropsBase< Tcnt >::grffile, ResolverObject::grffile, HasBit(), IsTileType(), GRFFilePropsBase< Tcnt >::local_id, MP_HOUSE, ResolverObject::scope, SetBit(), TILE_MASK, TileDiffXY(), TileHash2Bit(), TileX(), TileY(), TownGetVariable(), and VSG_SCOPE_PARENT.
void HouseStorePSA | ( | ResolverObject * | object, | |
uint | pos, | |||
int32 | value | |||
) |
Store a value into the persistent storage of the object's parent.
object | Object that we want to query. | |
pos | Position in the persistent storage to use. | |
value | Value to store. |
Definition at line 403 of file newgrf_house.cpp.
References ResolverObject::grffile, ResolverObject::scope, TownStorePSA(), and VSG_SCOPE_PARENT.
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 63 of file newgrf_house.cpp.
References _loaded_newgrf_features, Town::building_counts, HouseSpec::class_id, and GRFLoadedFeatures::has_newhouses.
Referenced by ClearMakeHouseTile(), and UpdateHousesAndTowns().
static void NewHouseResolver | ( | ResolverObject * | res, | |
HouseID | house_id, | |||
TileIndex | tile, | |||
Town * | town | |||
) | [static] |
Returns a resolver object to be used with feature 07 spritegroups.
Definition at line 417 of file newgrf_house.cpp.
References HouseSpec::grf_prop, GRFFilePropsBase< Tcnt >::grffile, ResolverObject::grffile, and ResolverObject::ResetState().
Referenced by GetHouseResolver().
static bool SearchNearbyHouseClass | ( | TileIndex | tile, | |
void * | user_data | |||
) | [static] |
Callback function to search a house by its classID.
tile | TileIndex to be examined | |
user_data | SearchNearbyHouseData |
Definition at line 184 of file newgrf_house.cpp.
References HouseSpec::class_id, GetHouseNorthPart(), GetHouseType(), HouseSpec::grf_prop, GRFFilePropsBase< Tcnt >::grffile, SearchNearbyHouseData::hs, IsTileType(), MP_HOUSE, and SearchNearbyHouseData::north_tile.
static bool SearchNearbyHouseGRFID | ( | TileIndex | tile, | |
void * | user_data | |||
) | [static] |
Callback function to search a house by its grfID.
tile | TileIndex to be examined | |
user_data | SearchNearbyHouseData |
Definition at line 208 of file newgrf_house.cpp.
References GetHouseNorthPart(), GetHouseType(), HouseSpec::grf_prop, GRFFilePropsBase< Tcnt >::grffile, SearchNearbyHouseData::hs, IsTileType(), MP_HOUSE, and SearchNearbyHouseData::north_tile.
static bool SearchNearbyHouseID | ( | TileIndex | tile, | |
void * | user_data | |||
) | [static] |
Callback function to search a house by its HouseID.
tile | TileIndex to be examined | |
user_data | SearchNearbyHouseData |
Definition at line 160 of file newgrf_house.cpp.
References GetHouseNorthPart(), GetHouseType(), HouseSpec::grf_prop, GRFFilePropsBase< Tcnt >::grffile, SearchNearbyHouseData::hs, IsTileType(), GRFFilePropsBase< Tcnt >::local_id, MP_HOUSE, and SearchNearbyHouseData::north_tile.
void WatchedCargoCallback | ( | TileIndex | tile, | |
uint32 | trigger_cargoes | |||
) |
Run watched cargo accepted callback for a house.
tile | House tile. | |
trigger_cargoes | Triggering cargo types. |
Definition at line 692 of file newgrf_house.cpp.
References HouseSpec::building_flags, DoWatchedCargoCallback(), GetHouseNorthPart(), GetHouseType(), IsTileType(), MP_HOUSE, TILE_ADDXY, and HouseSpec::watched_cargoes.
Referenced by TriggerWatchedCargoCallbacks().