Files
@ r28486:aff297ed5a05
Branch filter:
Location: cpp/openttd-patchpack/source/src/newgrf_house.h - annotation
r28486:aff297ed5a05
5.1 KiB
text/x-c
Codechange: Allow constexpr NWidgetPart construction.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r9111:983de9c5a848 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r7327:28855024ff6c r10571:99cb9a95b4cf r12239:4ede50b8e95b r19727:37cdfa4a6a38 r19727:37cdfa4a6a38 r19727:37cdfa4a6a38 r19738:837a139219f0 r19727:37cdfa4a6a38 r19738:837a139219f0 r19738:837a139219f0 r19727:37cdfa4a6a38 r19727:37cdfa4a6a38 r27737:728d55b97775 r22867:9bff1c966805 r19727:37cdfa4a6a38 r22756:8ffd1846f871 r22756:8ffd1846f871 r22756:8ffd1846f871 r22756:8ffd1846f871 r22756:8ffd1846f871 r22756:8ffd1846f871 r22756:8ffd1846f871 r22756:8ffd1846f871 r22756:8ffd1846f871 r22756:8ffd1846f871 r21008:be2e3d3c935b r27737:728d55b97775 r22756:8ffd1846f871 r22756:8ffd1846f871 r22756:8ffd1846f871 r22756:8ffd1846f871 r19727:37cdfa4a6a38 r27737:728d55b97775 r27942:f7389062d120 r27737:728d55b97775 r19727:37cdfa4a6a38 r19727:37cdfa4a6a38 r19727:37cdfa4a6a38 r19727:37cdfa4a6a38 r19727:37cdfa4a6a38 r19727:37cdfa4a6a38 r19727:37cdfa4a6a38 r19727:37cdfa4a6a38 r27737:728d55b97775 r27737:728d55b97775 r19727:37cdfa4a6a38 r23497:a0ab44ebd2fa r19727:37cdfa4a6a38 r19727:37cdfa4a6a38 r19727:37cdfa4a6a38 r19727:37cdfa4a6a38 r19737:d7c69e3b4bd4 r19727:37cdfa4a6a38 r19727:37cdfa4a6a38 r24069:49625df81342 r24069:49625df81342 r27737:728d55b97775 r19727:37cdfa4a6a38 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r27737:728d55b97775 r27737:728d55b97775 r6332:7393965b5322 r6332:7393965b5322 r27889:87ac6e837ad9 r27737:728d55b97775 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r15929:5d5037945a0e r6332:7393965b5322 r27737:728d55b97775 r27737:728d55b97775 r22867:9bff1c966805 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r7861:9082dbb3187c r7861:9082dbb3187c r7861:9082dbb3187c r7861:9082dbb3187c r7861:9082dbb3187c r7861:9082dbb3187c r7861:9082dbb3187c r7861:9082dbb3187c r7861:9082dbb3187c r7861:9082dbb3187c r7861:9082dbb3187c r6332:7393965b5322 | /*
* 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/>.
*/
/** @file newgrf_house.h Functions related to NewGRF houses. */
#ifndef NEWGRF_HOUSE_H
#define NEWGRF_HOUSE_H
#include "newgrf_callbacks.h"
#include "tile_cmd.h"
#include "house_type.h"
#include "newgrf_spritegroup.h"
#include "newgrf_town.h"
/** Scope resolver for houses. */
struct HouseScopeResolver : public ScopeResolver {
HouseID house_id; ///< Type of house being queried.
TileIndex tile; ///< Tile of this house.
Town *town; ///< Town of this house.
bool not_yet_constructed; ///< True for construction check.
uint16_t initial_random_bits; ///< Random bits during construction checks.
CargoTypes watched_cargo_triggers; ///< Cargo types that triggered the watched cargo callback.
/**
* Constructor of a house scope resolver.
* @param ro Surrounding resolver.
* @param house_id House 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(ResolverObject &ro, HouseID house_id, TileIndex tile, Town *town,
bool not_yet_constructed, uint8_t initial_random_bits, CargoTypes watched_cargo_triggers)
: ScopeResolver(ro), house_id(house_id), tile(tile), town(town), not_yet_constructed(not_yet_constructed),
initial_random_bits(initial_random_bits), watched_cargo_triggers(watched_cargo_triggers)
{
}
uint32_t GetRandomBits() const override;
uint32_t GetVariable(byte variable, [[maybe_unused]] uint32_t parameter, bool *available) const override;
uint32_t GetTriggers() const override;
};
/** 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_t param1 = 0, uint32_t param2 = 0,
bool not_yet_constructed = false, uint8_t initial_random_bits = 0, CargoTypes watched_cargo_triggers = 0);
ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override
{
switch (scope) {
case VSG_SCOPE_SELF: return &this->house_scope;
case VSG_SCOPE_PARENT: return &this->town_scope;
default: return ResolverObject::GetScope(scope, relative);
}
}
GrfSpecFeature GetFeature() const override;
uint32_t GetDebugID() const override;
};
/**
* 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 {
uint32_t grfid; ///< The GRF ID of the file this class belongs to
uint8_t class_id; ///< The class id within the grf file
};
void ResetHouseClassIDs();
HouseClassID AllocateHouseClassID(byte grf_class_id, uint32_t 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);
void AnimateNewHouseConstruction(TileIndex tile);
uint16_t GetHouseCallback(CallbackID callback, uint32_t param1, uint32_t param2, HouseID house_id, Town *town, TileIndex tile,
bool not_yet_constructed = false, uint8_t initial_random_bits = 0, CargoTypes watched_cargo_triggers = 0);
void WatchedCargoCallback(TileIndex tile, CargoTypes trigger_cargoes);
bool CanDeleteHouse(TileIndex tile);
bool NewHouseTileLoop(TileIndex tile);
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);
#endif /* NEWGRF_HOUSE_H */
|