OpenTTD Source: src/newgrf_spritegroup.h Source File

OpenTTD Source 15.0-RC2

newgrf_spritegroup.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#ifndef NEWGRF_SPRITEGROUP_H
11#define NEWGRF_SPRITEGROUP_H
12
13#include "core/pool_type.hpp"
14#include "town_type.h"
15#include "engine_type.h"
16#include "house_type.h"
17#include "industry_type.h"
18
19#include "newgrf_callbacks.h"
20#include "newgrf_generic.h"
21#include "newgrf_storage.h"
22#include "newgrf_commons.h"
23
24struct SpriteGroup;
25struct ResultSpriteGroup;
26struct TileLayoutSpriteGroup;
27struct IndustryProductionSpriteGroup;
28struct ResolverObject;
29using CallbackResult = uint16_t;
30
37 using ResolverResult = std::variant<std::monostate, CallbackResult, const ResultSpriteGroup *, const TileLayoutSpriteGroup *, const IndustryProductionSpriteGroup *>;
38
39/* SPRITE_WIDTH is 24. ECS has roughly 30 sprite groups per real sprite.
40 * Adding an 'extra' margin would be assuming 64 sprite groups per real
41 * sprite. 64 = 2^6, so 2^30 should be enough (for now) */
42using SpriteGroupID = PoolID<uint32_t, struct SpriteGroupIDTag, 1U << 30, 0xFFFFFFFF>;
43using SpriteGroupPool = Pool<SpriteGroup, SpriteGroupID, 1024, PoolType::Data>;
44extern SpriteGroupPool _spritegroup_pool;
45
46/* Common wrapper for all the different sprite group types */
47 struct SpriteGroup : SpriteGroupPool::PoolItem<&_spritegroup_pool> {
48protected:
49 SpriteGroup() {} // Not `= default` as that resets PoolItem->index.
51 virtual ResolverResult Resolve(ResolverObject &object) const = 0;
52
53public:
54 virtual ~SpriteGroup() = default;
55
56 uint32_t nfo_line = 0;
57
58 static ResolverResult Resolve(const SpriteGroup *group, ResolverObject &object, bool top_level = true);
59};
60
61
62/* 'Real' sprite groups contain a list of other result or callback sprite
63 * groups. */
64 struct RealSpriteGroup : SpriteGroup {
65 RealSpriteGroup() : SpriteGroup() {}
66
67 /* Loaded = in motion, loading = not moving
68 * Each group contains several spritesets, for various loading stages */
69
70 /* XXX: For stations the meaning is different - loaded is for stations
71 * with small amount of cargo whilst loading is for stations with a lot
72 * of da stuff. */
73
74 std::vector<const SpriteGroup *> loaded{};
75 std::vector<const SpriteGroup *> loading{};
76
77protected:
78 ResolverResult Resolve(ResolverObject &object) const override;
79};
80
81/* Shared by deterministic and random groups. */
82 enum VarSpriteGroupScope : uint8_t {
83 VSG_BEGIN,
84
85 VSG_SCOPE_SELF = VSG_BEGIN,
86 VSG_SCOPE_PARENT,
87 VSG_SCOPE_RELATIVE,
88
89 VSG_END
90};
91 DECLARE_INCREMENT_DECREMENT_OPERATORS(VarSpriteGroupScope)
92
93enum DeterministicSpriteGroupSize : uint8_t {
94 DSG_SIZE_BYTE,
95 DSG_SIZE_WORD,
96 DSG_SIZE_DWORD,
97};
98
99enum DeterministicSpriteGroupAdjustType : uint8_t {
100 DSGA_TYPE_NONE,
101 DSGA_TYPE_DIV,
102 DSGA_TYPE_MOD,
103};
104
105 enum DeterministicSpriteGroupAdjustOperation : uint8_t {
106 DSGA_OP_ADD,
107 DSGA_OP_SUB,
108 DSGA_OP_SMIN,
109 DSGA_OP_SMAX,
110 DSGA_OP_UMIN,
111 DSGA_OP_UMAX,
112 DSGA_OP_SDIV,
113 DSGA_OP_SMOD,
114 DSGA_OP_UDIV,
115 DSGA_OP_UMOD,
116 DSGA_OP_MUL,
117 DSGA_OP_AND,
118 DSGA_OP_OR,
119 DSGA_OP_XOR,
120 DSGA_OP_STO,
121 DSGA_OP_RST,
122 DSGA_OP_STOP,
123 DSGA_OP_ROR,
124 DSGA_OP_SCMP,
125 DSGA_OP_UCMP,
126 DSGA_OP_SHL,
127 DSGA_OP_SHR,
128 DSGA_OP_SAR,
129};
130
131
132 struct DeterministicSpriteGroupAdjust {
133 DeterministicSpriteGroupAdjustOperation operation{};
134 DeterministicSpriteGroupAdjustType type{};
135 uint8_t variable = 0;
136 uint8_t parameter = 0;
137 uint8_t shift_num = 0;
138 uint32_t and_mask = 0;
139 uint32_t add_val = 0;
140 uint32_t divmod_val = 0;
141 const SpriteGroup *subroutine = nullptr;
142};
143
144
145 struct DeterministicSpriteGroupResult {
146 bool calculated_result = false;
147 const SpriteGroup *group = nullptr;
148
149 bool operator==(const DeterministicSpriteGroupResult &) const = default;
150};
151
152 struct DeterministicSpriteGroupRange {
153 DeterministicSpriteGroupResult result;
154 uint32_t low = 0;
155 uint32_t high = 0;
156};
157
158
159 struct DeterministicSpriteGroup : SpriteGroup {
160 DeterministicSpriteGroup() : SpriteGroup() {}
161
162 VarSpriteGroupScope var_scope{};
163 DeterministicSpriteGroupSize size{};
164 std::vector<DeterministicSpriteGroupAdjust> adjusts{};
165 std::vector<DeterministicSpriteGroupRange> ranges{}; // Dynamically allocated
166
167 /* Dynamically allocated, this is the sole owner */
168 DeterministicSpriteGroupResult default_result;
169
170 const SpriteGroup *error_group = nullptr; // was first range, before sorting ranges
171
172protected:
173 ResolverResult Resolve(ResolverObject &object) const override;
174};
175
176enum RandomizedSpriteGroupCompareMode : uint8_t {
177 RSG_CMP_ANY,
178 RSG_CMP_ALL,
179};
180
181 struct RandomizedSpriteGroup : SpriteGroup {
182 RandomizedSpriteGroup() : SpriteGroup() {}
183
184 VarSpriteGroupScope var_scope{};
185
186 RandomizedSpriteGroupCompareMode cmp_mode{};
187 uint8_t triggers = 0;
188 uint8_t count = 0;
189
190 uint8_t lowest_randbit = 0;
191
192 std::vector<const SpriteGroup *> groups{};
193
194protected:
195 ResolverResult Resolve(ResolverObject &object) const override;
196};
197
198
199/* This contains a callback result. A failed callback has a value of
200 * CALLBACK_FAILED */
201 struct CallbackResultSpriteGroup : SpriteGroup {
206 explicit CallbackResultSpriteGroup(CallbackResult value) : SpriteGroup(), result(value) {}
207
208 CallbackResult result = 0;
209
210protected:
211 ResolverResult Resolve(ResolverObject &object) const override;
212};
213
214
215/* A result sprite group returns the first SpriteID and the number of
216 * sprites in the set */
217 struct ResultSpriteGroup : SpriteGroup {
224 ResultSpriteGroup(SpriteID sprite, uint8_t num_sprites) : SpriteGroup(), num_sprites(num_sprites), sprite(sprite) {}
225
226 uint8_t num_sprites = 0;
227 SpriteID sprite = 0;
228
229protected:
230 ResolverResult Resolve(ResolverObject &) const override { return this; }
231};
232
236 struct TileLayoutSpriteGroup : SpriteGroup {
237 TileLayoutSpriteGroup() : SpriteGroup() {}
238
239 NewGRFSpriteLayout dts{};
240
241 SpriteLayoutProcessor ProcessRegisters(const ResolverObject &object, uint8_t *stage) const;
242
243protected:
244 ResolverResult Resolve(ResolverObject &) const override { return this; }
245};
246
247 struct IndustryProductionSpriteGroup : SpriteGroup {
248 IndustryProductionSpriteGroup() : SpriteGroup() {}
249
250 uint8_t version = 0;
251 uint8_t num_input = 0;
252 std::array<int16_t, INDUSTRY_NUM_INPUTS> subtract_input{};
253 std::array<CargoType, INDUSTRY_NUM_INPUTS> cargo_input{};
254 uint8_t num_output = 0;
255 std::array<uint16_t, INDUSTRY_NUM_OUTPUTS> add_output{};
256 std::array<CargoType, INDUSTRY_NUM_OUTPUTS> cargo_output{};
257 uint8_t again = 0;
258
259protected:
260 ResolverResult Resolve(ResolverObject &) const override { return this; }
261};
262
269 struct ScopeResolver {
270 ResolverObject &ro;
271
272 ScopeResolver(ResolverObject &ro) : ro(ro) {}
273 virtual ~ScopeResolver() = default;
274
275 virtual uint32_t GetRandomBits() const;
276 virtual uint32_t GetRandomTriggers() const;
277
278 virtual uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const;
279 virtual void StorePSA(uint reg, int32_t value);
280};
281
288 struct ResolverObject {
289private:
290 static TemporaryStorageArray<int32_t, 0x110> temp_store;
291
292public:
300 ResolverObject(const GRFFile *grffile, CallbackID callback = CBID_NO_CALLBACK, uint32_t callback_param1 = 0, uint32_t callback_param2 = 0)
301 : default_scope(*this), callback(callback), callback_param1(callback_param1), callback_param2(callback_param2), grffile(grffile), root_spritegroup(nullptr)
302 {
303 }
304
305 virtual ~ResolverObject() = default;
306
307 ResolverResult DoResolve()
308 {
309 temp_store.ClearChanges();
310 this->last_value = 0;
311 this->used_random_triggers = 0;
312 this->reseed.fill(0);
313 return SpriteGroup::Resolve(this->root_spritegroup, *this);
314 }
315
316 ScopeResolver default_scope;
317
324 inline int32_t GetRegister(uint i) const
325 {
326 return temp_store.GetValue(i);
327 }
328
335 inline void SetRegister(uint i, int32_t value)
336 {
337 temp_store.StoreValue(i, value);
338 }
339
340 CallbackID callback{};
341 uint32_t callback_param1 = 0;
342 uint32_t callback_param2 = 0;
343
344 uint32_t last_value = 0;
345
346protected:
347 uint32_t waiting_random_triggers = 0;
348 uint32_t used_random_triggers = 0;
349public:
350 std::array<uint32_t, VSG_END> reseed;
351
352 const GRFFile *grffile = nullptr;
353 const SpriteGroup *root_spritegroup = nullptr;
354
360 template <class TSpriteGroup>
361 inline const TSpriteGroup *Resolve()
362 {
363 auto result = this->DoResolve();
364 const auto *group = std::get_if<const TSpriteGroup *>(&result);
365 if (group == nullptr) return nullptr;
366 return *group;
367 }
368
376 inline void ResolveRerandomisation()
377 {
378 /* The Resolve result has no meaning.
379 * It can be a SpriteSet, a callback result, or even an invalid SpriteGroup reference (nullptr). */
380 this->DoResolve();
381 }
382
388 inline CallbackResult ResolveCallback(std::span<int32_t> regs100)
389 {
390 auto result = this->DoResolve();
391 const auto *value = std::get_if<CallbackResult>(&result);
392 if (value == nullptr) return CALLBACK_FAILED;
393 for (uint i = 0; i < regs100.size(); ++i) {
394 regs100[i] = this->GetRegister(0x100 + i);
395 }
396 return *value;
397 }
398
399 virtual const SpriteGroup *ResolveReal(const RealSpriteGroup &group) const;
400
401 virtual ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, uint8_t relative = 0);
402
406 uint32_t GetWaitingRandomTriggers() const
407 {
408 return this->waiting_random_triggers;
409 }
410
414 void AddUsedRandomTriggers(uint32_t triggers)
415 {
416 this->used_random_triggers |= triggers;
417 }
418
424 uint32_t GetReseedSum() const
425 {
426 uint32_t sum = 0;
427 for (VarSpriteGroupScope vsg = VSG_BEGIN; vsg < VSG_END; vsg++) {
428 sum |= this->reseed[vsg];
429 }
430 return sum;
431 }
432
437 virtual GrfSpecFeature GetFeature() const { return GSF_INVALID; }
443 virtual uint32_t GetDebugID() const { return 0; }
444};
445
449template <class RandomTriggers>
450 struct SpecializedResolverObject : public ResolverObject {
451 using ResolverObject::ResolverObject;
452
457 void SetWaitingRandomTriggers(RandomTriggers triggers)
458 {
459 this->waiting_random_triggers = triggers.base();
460 }
461
466 RandomTriggers GetUsedRandomTriggers() const
467 {
468 return static_cast<RandomTriggers>(this->used_random_triggers);
469 }
470};
471
472#endif /* NEWGRF_SPRITEGROUP_H */
SpriteLayoutProcessor
Add dynamic register values to a sprite layout.
Definition newgrf_commons.h:142
engine_type.h
Types related to engines.
DECLARE_INCREMENT_DECREMENT_OPERATORS
#define DECLARE_INCREMENT_DECREMENT_OPERATORS(enum_type)
For some enums it is useful to have pre/post increment/decrement operators.
Definition enum_type.hpp:63
SpriteID
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition gfx_type.h:17
house_type.h
declaration of basic house types and enums
industry_type.h
Types related to the industry.
GrfSpecFeature
GrfSpecFeature
Definition newgrf.h:68
GSF_INVALID
@ GSF_INVALID
An invalid spec feature.
Definition newgrf.h:99
newgrf_callbacks.h
Callbacks that NewGRFs could implement.
CallbackID
CallbackID
List of implemented NewGRF callbacks.
Definition newgrf_callbacks.h:22
CBID_NO_CALLBACK
@ CBID_NO_CALLBACK
Set when using the callback resolve system, but not to resolve a callback.
Definition newgrf_callbacks.h:24
CALLBACK_FAILED
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
Definition newgrf_callbacks.h:439
newgrf_commons.h
This file simplifies and embeds a common mechanism of loading/saving and mapping of grf entities.
newgrf_generic.h
Functions related to generic callbacks.
DeterministicSpriteGroupAdjustOperation
DeterministicSpriteGroupAdjustOperation
Definition newgrf_spritegroup.h:105
DSGA_OP_OR
@ DSGA_OP_OR
a | b
Definition newgrf_spritegroup.h:118
DSGA_OP_XOR
@ DSGA_OP_XOR
a ^ b
Definition newgrf_spritegroup.h:119
DSGA_OP_SUB
@ DSGA_OP_SUB
a - b
Definition newgrf_spritegroup.h:107
DSGA_OP_STOP
@ DSGA_OP_STOP
store a into persistent storage, indexed by b, return a
Definition newgrf_spritegroup.h:122
DSGA_OP_ROR
@ DSGA_OP_ROR
rotate a b positions to the right
Definition newgrf_spritegroup.h:123
DSGA_OP_SHL
@ DSGA_OP_SHL
a << b
Definition newgrf_spritegroup.h:126
DSGA_OP_UCMP
@ DSGA_OP_UCMP
(unsigned) comparison (a < b -> 0, a == b = 1, a > b = 2)
Definition newgrf_spritegroup.h:125
DSGA_OP_MUL
@ DSGA_OP_MUL
a * b
Definition newgrf_spritegroup.h:116
DSGA_OP_SAR
@ DSGA_OP_SAR
(signed) a >> b
Definition newgrf_spritegroup.h:128
DSGA_OP_STO
@ DSGA_OP_STO
store a into temporary storage, indexed by b. return a
Definition newgrf_spritegroup.h:120
DSGA_OP_SMOD
@ DSGA_OP_SMOD
(signed) a % b
Definition newgrf_spritegroup.h:113
DSGA_OP_UDIV
@ DSGA_OP_UDIV
(unsigned) a / b
Definition newgrf_spritegroup.h:114
DSGA_OP_UMAX
@ DSGA_OP_UMAX
(unsigned) max(a, b)
Definition newgrf_spritegroup.h:111
DSGA_OP_SMIN
@ DSGA_OP_SMIN
(signed) min(a, b)
Definition newgrf_spritegroup.h:108
DSGA_OP_ADD
@ DSGA_OP_ADD
a + b
Definition newgrf_spritegroup.h:106
DSGA_OP_UMOD
@ DSGA_OP_UMOD
(unsigned) a & b
Definition newgrf_spritegroup.h:115
DSGA_OP_SHR
@ DSGA_OP_SHR
(unsigned) a >> b
Definition newgrf_spritegroup.h:127
DSGA_OP_RST
@ DSGA_OP_RST
return b
Definition newgrf_spritegroup.h:121
DSGA_OP_AND
@ DSGA_OP_AND
a & b
Definition newgrf_spritegroup.h:117
DSGA_OP_SDIV
@ DSGA_OP_SDIV
(signed) a / b
Definition newgrf_spritegroup.h:112
DSGA_OP_SCMP
@ DSGA_OP_SCMP
(signed) comparison (a < b -> 0, a == b = 1, a > b = 2)
Definition newgrf_spritegroup.h:124
DSGA_OP_UMIN
@ DSGA_OP_UMIN
(unsigned) min(a, b)
Definition newgrf_spritegroup.h:110
DSGA_OP_SMAX
@ DSGA_OP_SMAX
(signed) max(a, b)
Definition newgrf_spritegroup.h:109
VarSpriteGroupScope
VarSpriteGroupScope
Definition newgrf_spritegroup.h:82
VSG_SCOPE_SELF
@ VSG_SCOPE_SELF
Resolved object itself.
Definition newgrf_spritegroup.h:85
VSG_SCOPE_PARENT
@ VSG_SCOPE_PARENT
Related object of the resolved one.
Definition newgrf_spritegroup.h:86
VSG_SCOPE_RELATIVE
@ VSG_SCOPE_RELATIVE
Relative position (vehicles only)
Definition newgrf_spritegroup.h:87
ResolverResult
std::variant< std::monostate, CallbackResult, const ResultSpriteGroup *, const TileLayoutSpriteGroup *, const IndustryProductionSpriteGroup * > ResolverResult
Result of resolving sprite groups:
Definition newgrf_spritegroup.h:37
newgrf_storage.h
Functionality related to the temporary and persistent storage arrays for NewGRFs.
pool_type.hpp
Definition of Pool, structure used to access PoolItems, and PoolItem, base structure for Vehicle,...
CallbackResultSpriteGroup
Definition newgrf_spritegroup.h:201
CallbackResultSpriteGroup::Resolve
ResolverResult Resolve(ResolverObject &object) const override
Base sprite group resolver.
Definition newgrf_spritegroup.cpp:269
CallbackResultSpriteGroup::CallbackResultSpriteGroup
CallbackResultSpriteGroup(CallbackResult value)
Creates a spritegroup representing a callback result.
Definition newgrf_spritegroup.h:206
DeterministicSpriteGroupAdjust
Definition newgrf_spritegroup.h:132
DeterministicSpriteGroupAdjust::parameter
uint8_t parameter
Used for variables between 0x60 and 0x7F inclusive.
Definition newgrf_spritegroup.h:136
DeterministicSpriteGroupRange
Definition newgrf_spritegroup.h:152
DeterministicSpriteGroupResult
Definition newgrf_spritegroup.h:145
DeterministicSpriteGroup
Definition newgrf_spritegroup.h:159
DeterministicSpriteGroup::Resolve
ResolverResult Resolve(ResolverObject &object) const override
Base sprite group resolver.
Definition newgrf_spritegroup.cpp:186
GRFFile
Dynamic data of a loaded NewGRF.
Definition newgrf.h:114
IndustryProductionSpriteGroup
Definition newgrf_spritegroup.h:247
IndustryProductionSpriteGroup::add_output
std::array< uint16_t, INDUSTRY_NUM_OUTPUTS > add_output
Add this much output cargo when successful (unsigned, is indirect in cb version 1+)
Definition newgrf_spritegroup.h:255
IndustryProductionSpriteGroup::cargo_output
std::array< CargoType, INDUSTRY_NUM_OUTPUTS > cargo_output
Which output cargoes to add to (only cb version 2)
Definition newgrf_spritegroup.h:256
IndustryProductionSpriteGroup::cargo_input
std::array< CargoType, INDUSTRY_NUM_INPUTS > cargo_input
Which input cargoes to take from (only cb version 2)
Definition newgrf_spritegroup.h:253
IndustryProductionSpriteGroup::subtract_input
std::array< int16_t, INDUSTRY_NUM_INPUTS > subtract_input
Take this much of the input cargo (can be negative, is indirect in cb version 1+)
Definition newgrf_spritegroup.h:252
IndustryProductionSpriteGroup::num_input
uint8_t num_input
How many subtract_input values are valid.
Definition newgrf_spritegroup.h:251
IndustryProductionSpriteGroup::version
uint8_t version
Production callback version used, or 0xFF if marked invalid.
Definition newgrf_spritegroup.h:250
IndustryProductionSpriteGroup::num_output
uint8_t num_output
How many add_output values are valid.
Definition newgrf_spritegroup.h:254
IndustryProductionSpriteGroup::Resolve
ResolverResult Resolve(ResolverObject &) const override
Base sprite group resolver.
Definition newgrf_spritegroup.h:260
NewGRFSpriteLayout
NewGRF supplied spritelayout.
Definition newgrf_commons.h:113
PoolID
Templated helper to make a PoolID a single POD value.
Definition pool_type.hpp:43
Pool::PoolItem
Base class for all PoolItems.
Definition pool_type.hpp:285
Pool
Base class for all pools.
Definition pool_type.hpp:133
RandomizedSpriteGroup
Definition newgrf_spritegroup.h:181
RandomizedSpriteGroup::lowest_randbit
uint8_t lowest_randbit
Look for this in the per-object randomized bitmask:
Definition newgrf_spritegroup.h:190
RandomizedSpriteGroup::var_scope
VarSpriteGroupScope var_scope
Take this object:
Definition newgrf_spritegroup.h:184
RandomizedSpriteGroup::groups
std::vector< const SpriteGroup * > groups
Take the group with appropriate index:
Definition newgrf_spritegroup.h:192
RandomizedSpriteGroup::Resolve
ResolverResult Resolve(ResolverObject &object) const override
Base sprite group resolver.
Definition newgrf_spritegroup.cpp:249
RandomizedSpriteGroup::cmp_mode
RandomizedSpriteGroupCompareMode cmp_mode
Check for these triggers:
Definition newgrf_spritegroup.h:186
RealSpriteGroup
Definition newgrf_spritegroup.h:64
RealSpriteGroup::Resolve
ResolverResult Resolve(ResolverObject &object) const override
Base sprite group resolver.
Definition newgrf_spritegroup.cpp:274
RealSpriteGroup::loaded
std::vector< const SpriteGroup * > loaded
List of loaded groups (can be SpriteIDs or Callback results)
Definition newgrf_spritegroup.h:74
RealSpriteGroup::loading
std::vector< const SpriteGroup * > loading
List of loading groups (can be SpriteIDs or Callback results)
Definition newgrf_spritegroup.h:75
ResolverObject
Interface for SpriteGroup-s to access the gamestate.
Definition newgrf_spritegroup.h:288
ResolverObject::grffile
const GRFFile * grffile
GRFFile the resolved SpriteGroup belongs to.
Definition newgrf_spritegroup.h:352
ResolverObject::GetDebugID
virtual uint32_t GetDebugID() const
Get an identifier for the item being resolved.
Definition newgrf_spritegroup.h:443
ResolverObject::SetRegister
void SetRegister(uint i, int32_t value)
Sets the value of a so-called newgrf "register".
Definition newgrf_spritegroup.h:335
ResolverObject::GetWaitingRandomTriggers
uint32_t GetWaitingRandomTriggers() const
Used by RandomizedSpriteGroup: Triggers for rerandomisation.
Definition newgrf_spritegroup.h:406
ResolverObject::AddUsedRandomTriggers
void AddUsedRandomTriggers(uint32_t triggers)
Used by RandomizedSpriteGroup: Consume triggers.
Definition newgrf_spritegroup.h:414
ResolverObject::callback_param2
uint32_t callback_param2
Second parameter (var 18) of the callback.
Definition newgrf_spritegroup.h:342
ResolverObject::Resolve
const TSpriteGroup * Resolve()
Resolve SpriteGroup.
Definition newgrf_spritegroup.h:361
ResolverObject::used_random_triggers
uint32_t used_random_triggers
Subset of cur_triggers, which actually triggered some rerandomisation. (scope independent)
Definition newgrf_spritegroup.h:348
ResolverObject::GetRegister
int32_t GetRegister(uint i) const
Gets the value of a so-called newgrf "register".
Definition newgrf_spritegroup.h:324
ResolverObject::GetReseedSum
uint32_t GetReseedSum() const
Returns the OR-sum of all bits that need reseeding independent of the scope they were accessed with.
Definition newgrf_spritegroup.h:424
ResolverObject::ResolverObject
ResolverObject(const GRFFile *grffile, CallbackID callback=CBID_NO_CALLBACK, uint32_t callback_param1=0, uint32_t callback_param2=0)
Resolver constructor.
Definition newgrf_spritegroup.h:300
ResolverObject::default_scope
ScopeResolver default_scope
Default implementation of the grf scope.
Definition newgrf_spritegroup.h:316
ResolverObject::callback
CallbackID callback
Callback being resolved.
Definition newgrf_spritegroup.h:340
ResolverObject::callback_param1
uint32_t callback_param1
First parameter (var 10) of the callback.
Definition newgrf_spritegroup.h:341
ResolverObject::ResolveReal
virtual const SpriteGroup * ResolveReal(const RealSpriteGroup &group) const
Get the real sprites of the grf.
Definition newgrf_spritegroup.cpp:121
ResolverObject::last_value
uint32_t last_value
Result of most recent DeterministicSpriteGroup (including procedure calls)
Definition newgrf_spritegroup.h:344
ResolverObject::GetFeature
virtual GrfSpecFeature GetFeature() const
Get the feature number being resolved for.
Definition newgrf_spritegroup.h:437
ResolverObject::ResolveRerandomisation
void ResolveRerandomisation()
Resolve bits to be rerandomised.
Definition newgrf_spritegroup.h:376
ResolverObject::root_spritegroup
const SpriteGroup * root_spritegroup
Root SpriteGroup to use for resolving.
Definition newgrf_spritegroup.h:353
ResolverObject::GetScope
virtual ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, uint8_t relative=0)
Get a resolver for the scope.
Definition newgrf_spritegroup.cpp:133
ResolverObject::waiting_random_triggers
uint32_t waiting_random_triggers
Waiting triggers to be used by any rerandomisation. (scope independent)
Definition newgrf_spritegroup.h:347
ResolverObject::ResolveCallback
CallbackResult ResolveCallback(std::span< int32_t > regs100)
Resolve callback.
Definition newgrf_spritegroup.h:388
ResolverObject::reseed
std::array< uint32_t, VSG_END > reseed
Collects bits to rerandomise while triggering triggers.
Definition newgrf_spritegroup.h:350
ResultSpriteGroup
Definition newgrf_spritegroup.h:217
ResultSpriteGroup::Resolve
ResolverResult Resolve(ResolverObject &) const override
Base sprite group resolver.
Definition newgrf_spritegroup.h:230
ResultSpriteGroup::ResultSpriteGroup
ResultSpriteGroup(SpriteID sprite, uint8_t num_sprites)
Creates a spritegroup representing a sprite number result.
Definition newgrf_spritegroup.h:224
ScopeResolver
Interface to query and set values specific to a single VarSpriteGroupScope (action 2 scope).
Definition newgrf_spritegroup.h:269
ScopeResolver::StorePSA
virtual void StorePSA(uint reg, int32_t value)
Store a value into the persistent storage area (PSA).
Definition newgrf_spritegroup.cpp:114
ScopeResolver::GetVariable
virtual uint32_t GetVariable(uint8_t variable, uint32_t parameter, bool &available) const
Get a variable value.
Definition newgrf_spritegroup.cpp:104
ScopeResolver::ro
ResolverObject & ro
Surrounding resolver object.
Definition newgrf_spritegroup.h:270
ScopeResolver::GetRandomTriggers
virtual uint32_t GetRandomTriggers() const
Get the triggers.
Definition newgrf_spritegroup.cpp:92
ScopeResolver::GetRandomBits
virtual uint32_t GetRandomBits() const
Get a few random bits.
Definition newgrf_spritegroup.cpp:83
SpecializedResolverObject
Specialization of ResolverObject with type-safe access to RandomTriggers.
Definition newgrf_spritegroup.h:450
SpecializedResolverObject::SetWaitingRandomTriggers
void SetWaitingRandomTriggers(RandomTriggers triggers)
Set waiting triggers for rerandomisation.
Definition newgrf_spritegroup.h:457
SpecializedResolverObject::GetUsedRandomTriggers
RandomTriggers GetUsedRandomTriggers() const
Get the triggers, which were "consumed" by some rerandomisation.
Definition newgrf_spritegroup.h:466
SpriteGroup
Definition newgrf_spritegroup.h:47
SpriteGroup::Resolve
virtual ResolverResult Resolve(ResolverObject &object) const =0
Base sprite group resolver.
TemporaryStorageArray
Class for temporary storage of data.
Definition newgrf_storage.h:133
TemporaryStorageArray::GetValue
TYPE GetValue(uint pos) const
Gets the value from a given position.
Definition newgrf_storage.h:160
TemporaryStorageArray::StoreValue
void StoreValue(uint pos, int32_t value)
Stores some value at a given position.
Definition newgrf_storage.h:146
TileLayoutSpriteGroup
Action 2 sprite layout for houses, industry tiles, objects and airport tiles.
Definition newgrf_spritegroup.h:236
TileLayoutSpriteGroup::ProcessRegisters
SpriteLayoutProcessor ProcessRegisters(const ResolverObject &object, uint8_t *stage) const
Process registers and the construction stage into the sprite layout.
Definition newgrf_spritegroup.cpp:290
TileLayoutSpriteGroup::Resolve
ResolverResult Resolve(ResolverObject &) const override
Base sprite group resolver.
Definition newgrf_spritegroup.h:244
town_type.h
Types related to towns.