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