2007-03-19 11:27:30 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
|
|
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2008-05-06 15:11:33 +00:00
|
|
|
/** @file newgrf_house.h Functions related to NewGRF houses. */
|
2007-03-19 11:27:30 +00:00
|
|
|
|
|
|
|
#ifndef NEWGRF_HOUSE_H
|
|
|
|
#define NEWGRF_HOUSE_H
|
|
|
|
|
2007-07-25 19:06:29 +00:00
|
|
|
#include "newgrf_callbacks.h"
|
2009-01-04 15:32:25 +00:00
|
|
|
#include "tile_cmd.h"
|
2009-06-26 13:44:14 +00:00
|
|
|
#include "house_type.h"
|
2012-11-10 20:40:05 +00:00
|
|
|
#include "newgrf_spritegroup.h"
|
|
|
|
#include "newgrf_town.h"
|
|
|
|
|
2012-11-10 20:46:39 +00:00
|
|
|
/** Scope resolver for houses. */
|
2012-11-10 20:40:05 +00:00
|
|
|
struct HouseScopeResolver : public ScopeResolver {
|
2012-11-10 20:46:39 +00:00
|
|
|
HouseID house_id; ///< Type of house being queried.
|
|
|
|
TileIndex tile; ///< Tile of this house.
|
2012-11-10 20:40:05 +00:00
|
|
|
Town *town; ///< Town of this house.
|
|
|
|
bool not_yet_constructed; ///< True for construction check.
|
|
|
|
uint16 initial_random_bits; ///< Random bits during construction checks.
|
|
|
|
uint32 watched_cargo_triggers; ///< Cargo types that triggered the watched cargo callback.
|
|
|
|
|
2013-11-24 14:41:19 +00:00
|
|
|
HouseScopeResolver(ResolverObject &ro, HouseID house_id, TileIndex tile, Town *town,
|
2012-11-10 20:40:05 +00:00
|
|
|
bool not_yet_constructed, uint8 initial_random_bits, uint32 watched_cargo_triggers);
|
|
|
|
|
|
|
|
/* virtual */ uint32 GetRandomBits() const;
|
|
|
|
/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
|
|
|
|
/* virtual */ uint32 GetTriggers() const;
|
|
|
|
/* virtual */ void SetTriggers(int triggers) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Resolver object to be used for houses (feature 07 spritegroups). */
|
|
|
|
struct HouseResolverObject : public ResolverObject {
|
|
|
|
HouseScopeResolver house_scope;
|
|
|
|
TownScopeResolver town_scope;
|
|
|
|
|
|
|
|
HouseResolverObject(HouseID house_id, TileIndex tile, Town *town,
|
|
|
|
CallbackID callback = CBID_NO_CALLBACK, uint32 param1 = 0, uint32 param2 = 0,
|
|
|
|
bool not_yet_constructed = false, uint8 initial_random_bits = 0, uint32 watched_cargo_triggers = 0);
|
|
|
|
|
|
|
|
/* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0)
|
|
|
|
{
|
|
|
|
switch (scope) {
|
|
|
|
case VSG_SCOPE_SELF: return &this->house_scope;
|
|
|
|
case VSG_SCOPE_PARENT: return &this->town_scope;
|
2012-11-10 20:45:59 +00:00
|
|
|
default: return ResolverObject::GetScope(scope, relative);
|
2012-11-10 20:40:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2007-03-19 11:27:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Makes class IDs unique to each GRF file.
|
|
|
|
* Houses can be assigned class IDs which are only comparable within the GRF
|
|
|
|
* file they were defined in. This mapping ensures that if two houses have the
|
|
|
|
* same class as defined by the GRF file, the classes are different within the
|
|
|
|
* game. An array of HouseClassMapping structs is created, and the array index
|
|
|
|
* of the struct that matches both the GRF ID and the class ID is the class ID
|
|
|
|
* used in the game.
|
|
|
|
*
|
|
|
|
* Although similar to the HouseIDMapping struct above, this serves a different
|
|
|
|
* purpose. Since the class ID is not saved anywhere, this mapping does not
|
|
|
|
* need to be persistent; it just needs to keep class ids unique.
|
|
|
|
*/
|
|
|
|
struct HouseClassMapping {
|
2011-12-19 17:48:04 +00:00
|
|
|
uint32 grfid; ///< The GRF ID of the file this class belongs to
|
|
|
|
uint8 class_id; ///< The class id within the grf file
|
2007-03-19 11:27:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
HouseClassID AllocateHouseClassID(byte grf_class_id, uint32 grfid);
|
|
|
|
|
|
|
|
void InitializeBuildingCounts();
|
|
|
|
void IncreaseBuildingCount(Town *t, HouseID house_id);
|
|
|
|
void DecreaseBuildingCount(Town *t, HouseID house_id);
|
|
|
|
|
|
|
|
void DrawNewHouseTile(TileInfo *ti, HouseID house_id);
|
|
|
|
void AnimateNewHouseTile(TileIndex tile);
|
2010-08-26 17:01:17 +00:00
|
|
|
void AnimateNewHouseConstruction(TileIndex tile);
|
2007-03-19 11:27:30 +00:00
|
|
|
|
2012-11-10 20:40:05 +00:00
|
|
|
uint16 GetHouseCallback(CallbackID callback, uint32 param1, uint32 param2, HouseID house_id, Town *town, TileIndex tile,
|
|
|
|
bool not_yet_constructed = false, uint8 initial_random_bits = 0, uint32 watched_cargo_triggers = 0);
|
2011-10-31 22:31:40 +00:00
|
|
|
void WatchedCargoCallback(TileIndex tile, uint32 trigger_cargoes);
|
2007-03-19 11:27:30 +00:00
|
|
|
|
|
|
|
bool CanDeleteHouse(TileIndex tile);
|
|
|
|
|
|
|
|
bool NewHouseTileLoop(TileIndex tile);
|
|
|
|
|
2007-11-11 17:58:05 +00:00
|
|
|
enum HouseTrigger {
|
|
|
|
/* The tile of the house has been triggered during the tileloop. */
|
|
|
|
HOUSE_TRIGGER_TILE_LOOP = 0x01,
|
|
|
|
/*
|
|
|
|
* The top tile of a (multitile) building has been triggered during and all
|
|
|
|
* the tileloop other tiles of the same building get the same random value.
|
|
|
|
*/
|
|
|
|
HOUSE_TRIGGER_TILE_LOOP_TOP = 0x02,
|
|
|
|
};
|
|
|
|
void TriggerHouse(TileIndex t, HouseTrigger trigger);
|
|
|
|
|
2007-03-19 11:27:30 +00:00
|
|
|
#endif /* NEWGRF_HOUSE_H */
|