OpenTTD Source 20260711-master-g3fb3006dff
newgrf_spritegroup.h File Reference

Action 2 handling. More...

#include "core/pool_type.hpp"
#include "town_type.h"
#include "engine_type.h"
#include "house_type.h"
#include "industry_type.h"
#include "newgrf_callbacks.h"
#include "newgrf_generic.h"
#include "newgrf_storage.h"
#include "newgrf_commons.h"

Go to the source code of this file.

Data Structures

struct  SpriteGroup
 Common wrapper for all the different sprite group types. More...
struct  SpecializedSpriteGroup< T >
 Class defining some overloaded accessors so we don't have to cast SpriteGroups that often. More...
struct  RealSpriteGroup
 'Real' sprite groups contain a list of other result or callback sprite groups. More...
struct  DeterministicSpriteGroupAdjust
struct  DeterministicSpriteGroupResult
struct  DeterministicSpriteGroupRange
struct  DeterministicSpriteGroup
struct  RandomizedSpriteGroup
struct  CallbackResultSpriteGroup
 This contains a callback result. More...
struct  ResultSpriteGroup
 A result sprite group returns the first SpriteID and the number of sprites in the set. More...
struct  TileLayoutSpriteGroup
 Action 2 sprite layout for houses, industry tiles, objects and airport tiles. More...
struct  IndustryProductionSpriteGroup
struct  ScopeResolver
 Interface to query and set values specific to a single VarSpriteGroupScope (action 2 scope). More...
struct  ResolverObject
 Interface for #SpriteGroup-s to access the gamestate. More...
struct  SpecializedResolverObject< RandomTriggers >
 Specialization of ResolverObject with type-safe access to RandomTriggers. More...

Typedefs

using CallbackResult = uint16_t
using ResolverResult = std::variant<std::monostate, CallbackResult, const ResultSpriteGroup *, const TileLayoutSpriteGroup *, const IndustryProductionSpriteGroup *>
 Result of resolving sprite groups:
using SpriteGroupID = PoolID<uint32_t, struct SpriteGroupIDTag, 1U << 30, 0xFFFFFFFF>
using SpriteGroupPool = Pool<SpriteGroup, SpriteGroupID, 1024, PoolType::Data>

Enumerations

enum class  VarSpriteGroupScope : uint8_t { Self , Parent , Relative , End }
 Shared by deterministic and random groups. More...
enum class  DeterministicSpriteGroupSize : uint8_t { Byte , Word , DWord }
 Deterministic sprite group variable size. More...
enum class  DeterministicSpriteGroupAdjustType : uint8_t { None , Div , Mod }
 Deterministic sprite group adjust type. More...
enum class  DeterministicSpriteGroupAdjustOperation : uint8_t {
  Add , Sub , SMin , SMax ,
  UMin , UMax , SDiv , SMod ,
  UDiv , UMod , Mul , And ,
  Or , Xor , Sto , Rst ,
  Stop , Ror , SCmp , UCmp ,
  Shl , Shr , Sar
}
 Deterministic sprite group adjust operation. More...
enum class  RandomizedSpriteGroupCompareMode : uint8_t { Any , All }
 Randomized sprite group comparisation mode. More...

Variables

SpriteGroupPool _spritegroup_pool

Detailed Description

Action 2 handling.

Definition in file newgrf_spritegroup.h.

Typedef Documentation

◆ CallbackResult

using CallbackResult = uint16_t

Definition at line 29 of file newgrf_spritegroup.h.

◆ ResolverResult

using ResolverResult = std::variant<std::monostate, CallbackResult, const ResultSpriteGroup *, const TileLayoutSpriteGroup *, const IndustryProductionSpriteGroup *>

Result of resolving sprite groups:

Definition at line 37 of file newgrf_spritegroup.h.

◆ SpriteGroupID

using SpriteGroupID = PoolID<uint32_t, struct SpriteGroupIDTag, 1U << 30, 0xFFFFFFFF>

Definition at line 42 of file newgrf_spritegroup.h.

◆ SpriteGroupPool

using SpriteGroupPool = Pool<SpriteGroup, SpriteGroupID, 1024, PoolType::Data>

Definition at line 43 of file newgrf_spritegroup.h.

Enumeration Type Documentation

◆ DeterministicSpriteGroupAdjustOperation

enum class DeterministicSpriteGroupAdjustOperation : uint8_t
strong

Deterministic sprite group adjust operation.

Enumerator
Add 

a + b

Sub 

a - b

SMin 

(signed) min(a, b)

SMax 

(signed) max(a, b)

UMin 

(unsigned) min(a, b)

UMax 

(unsigned) max(a, b)

SDiv 

(signed) a / b

SMod 

(signed) a % b

UDiv 

(unsigned) a / b

UMod 

(unsigned) a & b

Mul 

a * b

And 

a & b

Or 

a | b

Xor 

a ^ b

Sto 

store a into temporary storage, indexed by b. return a

Rst 

return b

Stop 

store a into persistent storage, indexed by b, return a

Ror 

rotate a b positions to the right

SCmp 

(signed) comparison (a < b -> 0, a == b = 1, a > b = 2)

UCmp 

(unsigned) comparison (a < b -> 0, a == b = 1, a > b = 2)

Shl 

a << b

Shr 

(unsigned) a >> b

Sar 

(signed) a >> b

Definition at line 141 of file newgrf_spritegroup.h.

◆ DeterministicSpriteGroupAdjustType

enum class DeterministicSpriteGroupAdjustType : uint8_t
strong

Deterministic sprite group adjust type.

Enumerator
None 

No adjustment.

Div 

Apply divide adjustment to value.

Mod 

Apply modulus adjustment to value.

Definition at line 134 of file newgrf_spritegroup.h.

◆ DeterministicSpriteGroupSize

enum class DeterministicSpriteGroupSize : uint8_t
strong

Deterministic sprite group variable size.

Enumerator
Byte 

Treat variable as a Byte.

Word 

Treat variable as a Word.

DWord 

Treat variable as a DWord.

Definition at line 127 of file newgrf_spritegroup.h.

◆ RandomizedSpriteGroupCompareMode

enum class RandomizedSpriteGroupCompareMode : uint8_t
strong

Randomized sprite group comparisation mode.

Enumerator
Any 

Match if any bit is triggered.

All 

Match if all bits are triggered.

Definition at line 213 of file newgrf_spritegroup.h.

◆ VarSpriteGroupScope

enum class VarSpriteGroupScope : uint8_t
strong

Shared by deterministic and random groups.

Enumerator
Self 

Resolved object itself.

Parent 

Related object of the resolved one.

Relative 

Relative position (vehicles only).

End 

End marker.

Definition at line 118 of file newgrf_spritegroup.h.