# newgrf_house.cpp File Reference

`#include "stdafx.h"`
`#include "openttd.h"`
`#include "variables.h"`
`#include "debug.h"`
`#include "viewport_func.h"`
`#include "landscape.h"`
`#include "town.h"`
`#include "town_map.h"`
`#include "sprite.h"`
`#include "newgrf.h"`
`#include "newgrf_house.h"`
`#include "newgrf_spritegroup.h"`
`#include "newgrf_callbacks.h"`
`#include "newgrf_town.h"`
`#include "newgrf_sound.h"`
`#include "newgrf_commons.h"`
`#include "transparency.h"`
`#include "functions.h"`
`#include "player_func.h"`
`#include "table/strings.h"`
`#include "table/sprites.h"`
`#include "table/town_land.h"`

Go to the source code of this file.

## Functions
HouseOverrideManager | _house_mngr (NEW_HOUSE_OFFSET, HOUSE_MAX, INVALID_HOUSE_ID)
TileIndex | GetHouseNorthPart (HouseID &house)
| Determines if a given HouseID is part of a multitile house.
void | UpdateHousesAndTowns ()
| Check and update town and house values.
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 | GetGRFParameter (HouseID house_id, byte parameter)
uint32 | GetNearbyTileInformation (byte parameter, TileIndex tile)
static uint32 | HouseGetVariable (const ResolverObject *object, byte variable, byte parameter, bool *available)
| HouseGetVariable():.
static const SpriteGroup * | HouseResolveReal (const ResolverObject *object, const SpriteGroup *group)
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)
void | DrawTileLayout (const TileInfo *ti, const SpriteGroup *group, byte stage, HouseID house_id)
void | DrawNewHouseTile (TileInfo *ti, HouseID house_id)
void | AnimateNewHouseTile (TileIndex tile)
void | ChangeHouseAnimationFrame (TileIndex tile, uint16 callback_result)
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)
## Variables
static BuildingCounts | _building_counts
static HouseClassMapping | _class_mapping [HOUSE_CLASS_MAX]

## Detailed Description

Definition in file newgrf_house.cpp.

## Function Documentation

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 138 of file newgrf_house.cpp.

TileIndex GetHouseNorthPart | ( | HouseID & | house | ) |

Determines if a given HouseID is part of a multitile house.

The given ID is set to the ID of the north tile and the TileDiff to the north tile is returned.

Parameters:

  | house | Is changed to the HouseID of the north tile of the same house

Returns:
  TileDiff from the tile of the given HouseID to the north tile

Definition at line 1986 of file town_cmd.cpp.

References TileDiffXY().

Referenced by UpdateHousesAndTowns().

static uint32 HouseGetVariable | ( | const ResolverObject * | object,
|  | byte | variable,
|  | byte | parameter,
|  | bool * | available |
| ) |  |  | `[static]`

HouseGetVariable():.

Used by the resolver to get values for feature 07 deterministic spritegroups.

Definition at line 204 of file newgrf_house.cpp.

References Clamp(), GetHouseAnimationFrame(), GetHouseBuildingStage(), GetHouseConstructionYear(), GetNearbyTileInformation(), GetTerrainType(), GetTownRadiusGroup(), IsTileType(), MP_HOUSE, TileX(), TileY(), and TownGetVariable().

Referenced by NewHouseResolver().

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 110 of file newgrf_house.cpp.

Referenced by ClearMakeHouseTile(), and UpdateHousesAndTowns().

static void NewHouseResolver | ( | ResolverObject * | res,
|  | HouseID | house_id,
|  | TileIndex | tile,
|  | Town * | town |
| ) |  |  | `[static]`

NewHouseResolver():.

Returns a resolver object to be used with feature 07 spritegroups.

Definition at line 273 of file newgrf_house.cpp.

References CBID_NO_CALLBACK, and HouseGetVariable().

void UpdateHousesAndTowns | ( |  | ) |

Check and update town and house values.

Checked are the HouseIDs. Updated are the town population the number of houses per town, the town radius and the max passengers of the town.

Definition at line 43 of file newgrf_house.cpp.

References GetHouseNorthPart(), GetHouseType(), GetTownByTile(), IncreaseBuildingCount(), IsHouseCompleted(), IsTileType(), MapSize(), MP_HOUSE, and SetHouseType().

Referenced by ReloadNewGRFData().