File diff r19737:d7c69e3b4bd4 → r19738:837a139219f0
src/newgrf_house.cpp
Show inline comments
 
@@ -20,48 +20,69 @@
 
#include "company_base.h"
 
#include "town.h"
 
#include "genworld.h"
 
#include "newgrf_animation_base.h"
 
#include "newgrf_cargo.h"
 
#include "station_base.h"
 

	
 
static BuildingCounts<uint32> _building_counts;
 
static HouseClassMapping _class_mapping[HOUSE_CLASS_MAX];
 

	
 
HouseOverrideManager _house_mngr(NEW_HOUSE_OFFSET, HOUSE_MAX, INVALID_HOUSE_ID);
 

	
 

	
 
/**
 
 * Constructor of a house scope resolver.
 
 * @param ro Surrounding resolver.
 
 * @param house_id Houe type being queried.
 
 * @param tile %Tile containing the house.
 
 * @param town %Town containing the house.
 
 * @param not_yet_constructed House is still under construction.
 
 * @param initial_random_bits Random bits during construction checks.
 
 * @param watched_cargo_triggers Cargo types that triggered the watched cargo callback.
 
 */
 
HouseScopeResolver::HouseScopeResolver(ResolverObject *ro, HouseID house_id, TileIndex tile, Town *town,
 
			bool not_yet_constructed, uint8 initial_random_bits, uint32 watched_cargo_triggers)
 
		: ScopeResolver(ro)
 
{
 
	this->house_id = house_id;
 
	this->tile = tile;
 
	this->town = town;
 
	this->not_yet_constructed = not_yet_constructed;
 
	this->initial_random_bits = initial_random_bits;
 
	this->watched_cargo_triggers = watched_cargo_triggers;
 
}
 

	
 
/**
 
 * Retrieve the grf file associated with a house.
 
 * @param house_id House to query.
 
 * @return The associated GRF file (may be \c NULL).
 
 */
 
static const GRFFile *GetHouseSpecGrf(HouseID house_id)
 
{
 
	const HouseSpec *hs  = HouseSpec::Get(house_id);
 
	return (hs != NULL) ? hs->grf_prop.grffile : NULL;
 
}
 

	
 
/**
 
 * Construct a resolver for a house.
 
 * @param house_id House to query.
 
 * @param tile %Tile containing the house.
 
 * @param town %Town containing the house.
 
 * @param callback Callback ID.
 
 * @param param1 First parameter (var 10) of the callback.
 
 * @param param2 Second parameter (var 18) of the callback.
 
 * @param not_yet_constructed House is still under construction.
 
 * @param initial_random_bits Random bits during construction checks.
 
 * @param watched_cargo_triggers Cargo types that triggered the watched cargo callback.
 
 */
 
HouseResolverObject::HouseResolverObject(HouseID house_id, TileIndex tile, Town *town,
 
		CallbackID callback, uint32 param1, uint32 param2,
 
		bool not_yet_constructed, uint8 initial_random_bits, uint32 watched_cargo_triggers)
 
	: ResolverObject(GetHouseSpecGrf(house_id), callback, param1, param2),
 
	house_scope(this, house_id, tile, town, not_yet_constructed, initial_random_bits, watched_cargo_triggers),
 
	town_scope(this, town, not_yet_constructed) // Don't access StorePSA if house is not yet constructed.
 
{
 
}
 

	
 
HouseClassID AllocateHouseClassID(byte grf_class_id, uint32 grfid)
 
{
 
	/* Start from 1 because 0 means that no class has been assigned. */