10#ifndef NEWGRF_SPRITEGROUP_H
11#define NEWGRF_SPRITEGROUP_H
32 return _temp_store.GetValue(i);
36enum SpriteGroupType : uint8_t {
43 SGT_INDUSTRY_PRODUCTION,
47typedef uint32_t SpriteGroupID;
59 SpriteGroup(SpriteGroupType type) : nfo_line(0), type(type) {}
69 virtual SpriteID GetResult()
const {
return 0; }
70 virtual uint8_t GetNumResults()
const {
return 0; }
89 std::vector<const SpriteGroup *>
loaded;
108enum DeterministicSpriteGroupSize : uint8_t {
114enum DeterministicSpriteGroupAdjustType : uint8_t {
149 DeterministicSpriteGroupAdjustType type;
171 DeterministicSpriteGroupSize size;
172 bool calculated_result;
173 std::vector<DeterministicSpriteGroupAdjust> adjusts;
174 std::vector<DeterministicSpriteGroupRange> ranges;
185enum RandomizedSpriteGroupCompareMode : uint8_t {
218 uint16_t GetCallbackResult()
const override {
return this->result; }
233 num_sprites(num_sprites),
241 SpriteID GetResult()
const override {
return this->sprite; }
242 uint8_t GetNumResults()
const override {
return this->num_sprites; }
286 virtual uint32_t
GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter,
bool &available)
const;
287 virtual void StorePSA(uint reg, int32_t value);
343 return result !=
nullptr ? result->GetCallbackResult() :
CALLBACK_FAILED;
355 return this->waiting_triggers & ~this->used_triggers;
367 sum |= this->reseed[vsg];
378 this->last_value = 0;
379 this->waiting_triggers = 0;
380 this->used_triggers = 0;
381 memset(this->reseed, 0,
sizeof(this->reseed));
uint8_t CargoID
Cargo slots to indicate a cargo type within a game.
Types related to engines.
#define DECLARE_POSTFIX_INCREMENT(enum_type)
Some enums need to have allowed incrementing (i.e.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
declaration of basic house types and enums
Types related to the industry.
static const int INDUSTRY_NUM_OUTPUTS
Number of cargo types an industry can produce.
static const int INDUSTRY_NUM_INPUTS
Number of cargo types an industry can accept.
@ GSF_INVALID
An invalid spec feature.
Callbacks that NewGRFs could implement.
CallbackID
List of implemented NewGRF callbacks.
@ CBID_NO_CALLBACK
Set when using the callback resolve system, but not to resolve a callback.
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
This file simplyfies and embeds a common mechanism of loading/saving and mapping of grf entities.
Functions related to generic callbacks.
DeterministicSpriteGroupAdjustOperation
@ DSGA_OP_STOP
store a into persistent storage, indexed by b, return a
@ DSGA_OP_ROR
rotate a b positions to the right
@ DSGA_OP_UCMP
(unsigned) comparison (a < b -> 0, a == b = 1, a > b = 2)
@ DSGA_OP_SAR
(signed) a >> b
@ DSGA_OP_STO
store a into temporary storage, indexed by b. return a
@ DSGA_OP_SMOD
(signed) a % b
@ DSGA_OP_UDIV
(unsigned) a / b
@ DSGA_OP_UMAX
(unsigned) max(a, b)
@ DSGA_OP_SMIN
(signed) min(a, b)
@ DSGA_OP_UMOD
(unsigned) a & b
@ DSGA_OP_SHR
(unsigned) a >> b
@ DSGA_OP_SDIV
(signed) a / b
@ DSGA_OP_SCMP
(signed) comparison (a < b -> 0, a == b = 1, a > b = 2)
@ DSGA_OP_UMIN
(unsigned) min(a, b)
@ DSGA_OP_SMAX
(signed) max(a, b)
@ VSG_SCOPE_SELF
Resolved object itself.
@ VSG_SCOPE_PARENT
Related object of the resolved one.
@ VSG_SCOPE_RELATIVE
Relative position (vehicles only)
uint32_t GetRegister(uint i)
Gets the value of a so-called newgrf "register".
Functionality related to the temporary and persistent storage arrays for NewGRFs.
CallbackResultSpriteGroup(uint16_t value)
Creates a spritegroup representing a callback result.
uint8_t parameter
Used for variables between 0x60 and 0x7F inclusive.
const SpriteGroup * Resolve(ResolverObject &object) const override
Base sprite group resolver.
Ground palette sprite of a tile, together with its sprite layout.
Dynamic data of a loaded NewGRF.
uint16_t add_output[INDUSTRY_NUM_OUTPUTS]
Add this much output cargo when successful (unsigned, is indirect in cb version 1+)
CargoID cargo_input[INDUSTRY_NUM_INPUTS]
Which input cargoes to take from (only cb version 2)
uint8_t num_input
How many subtract_input values are valid.
int16_t subtract_input[INDUSTRY_NUM_INPUTS]
Take this much of the input cargo (can be negative, is indirect in cb version 1+)
uint8_t version
Production callback version used, or 0xFF if marked invalid.
uint8_t num_output
How many add_output values are valid.
CargoID cargo_output[INDUSTRY_NUM_OUTPUTS]
Which output cargoes to add to (only cb version 2)
NewGRF supplied spritelayout.
Base class for all PoolItems.
Base class for all pools.
uint8_t lowest_randbit
Look for this in the per-object randomized bitmask:
VarSpriteGroupScope var_scope
Take this object:
const SpriteGroup * Resolve(ResolverObject &object) const override
Base sprite group resolver.
std::vector< const SpriteGroup * > groups
Take the group with appropriate index:
RandomizedSpriteGroupCompareMode cmp_mode
Check for these triggers:
std::vector< const SpriteGroup * > loaded
List of loaded groups (can be SpriteIDs or Callback results)
std::vector< const SpriteGroup * > loading
List of loading groups (can be SpriteIDs or Callback results)
const SpriteGroup * Resolve(ResolverObject &object) const override
Base sprite group resolver.
Interface for SpriteGroup-s to access the gamestate.
const GRFFile * grffile
GRFFile the resolved SpriteGroup belongs to.
virtual uint32_t GetDebugID() const
Get an identifier for the item being resolved.
const SpriteGroup * Resolve()
Resolve SpriteGroup.
uint32_t used_triggers
Subset of cur_triggers, which actually triggered some rerandomisation. (scope independent)
uint32_t waiting_triggers
Waiting triggers to be used by any rerandomisation. (scope independent)
uint32_t callback_param2
Second parameter (var 18) of the callback.
virtual const SpriteGroup * ResolveReal(const RealSpriteGroup *group) const
Get the real sprites of the grf.
uint32_t reseed[VSG_END]
Collects bits to rerandomise while triggering triggers.
uint32_t GetRemainingTriggers() const
Returns the waiting triggers that did not trigger any rerandomisation.
uint32_t GetReseedSum() const
Returns the OR-sum of all bits that need reseeding independent of the scope they were accessed with.
void ResetState()
Resets the dynamic state of the resolver object.
ResolverObject(const GRFFile *grffile, CallbackID callback=CBID_NO_CALLBACK, uint32_t callback_param1=0, uint32_t callback_param2=0)
Resolver constructor.
ScopeResolver default_scope
Default implementation of the grf scope.
CallbackID callback
Callback being resolved.
uint32_t callback_param1
First parameter (var 10) of the callback.
uint32_t last_value
Result of most recent DeterministicSpriteGroup (including procedure calls)
uint16_t ResolveCallback()
Resolve callback.
virtual GrfSpecFeature GetFeature() const
Get the feature number being resolved for.
const SpriteGroup * root_spritegroup
Root SpriteGroup to use for resolving.
virtual ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, uint8_t relative=0)
Get a resolver for the scope.
ResultSpriteGroup(SpriteID sprite, uint8_t num_sprites)
Creates a spritegroup representing a sprite number result.
Interface to query and set values specific to a single VarSpriteGroupScope (action 2 scope).
virtual void StorePSA(uint reg, int32_t value)
Store a value into the persistent storage area (PSA).
virtual uint32_t GetTriggers() const
Get the triggers.
virtual uint32_t GetVariable(uint8_t variable, uint32_t parameter, bool &available) const
Get a variable value.
ResolverObject & ro
Surrounding resolver object.
virtual uint32_t GetRandomBits() const
Get a few random bits.
virtual const SpriteGroup * Resolve(ResolverObject &object) const
Base sprite group resolver.
Class for temporary storage of data.
Action 2 sprite layout for houses, industry tiles, objects and airport tiles.
const DrawTileSprites * ProcessRegisters(uint8_t *stage) const
Process registers and the construction stage into the sprite layout.