OpenTTD Source 20241224-master-gf74b0cf984
BasePersistentStorageArray Struct Referenceabstract

Base class for all persistent NewGRF storage arrays. More...

#include <newgrf_storage.h>

Inheritance diagram for BasePersistentStorageArray:
PersistentStorageArray< int32_t, 256 > PersistentStorageArray< TYPE, SIZE > PersistentStorage

Public Member Functions

virtual ~BasePersistentStorageArray ()
 Remove references to use.
 

Static Public Member Functions

static void SwitchMode (PersistentStorageMode mode, bool ignore_prev_mode=false)
 Clear temporary changes made since the last call to SwitchMode, and set whether subsequent changes shall be persistent or temporary.
 

Data Fields

uint32_t grfid
 GRFID associated to this persistent storage. A value of zero means "default".
 
uint8_t feature
 NOSAVE: Used to identify in the owner of the array in debug output.
 
TileIndex tile
 NOSAVE: Used to identify in the owner of the array in debug output.
 

Protected Member Functions

virtual void ClearChanges ()=0
 Discard temporary changes.
 

Static Protected Member Functions

static bool AreChangesPersistent ()
 Check whether currently changes to the storage shall be persistent or temporary till the next call to ClearChanges().
 

Static Private Attributes

static bool gameloop
 
static bool command
 
static bool testmode
 

Detailed Description

Base class for all persistent NewGRF storage arrays.

Nothing fancy, only here so we have a generalised access to the virtual methods.

Definition at line 33 of file newgrf_storage.h.

Constructor & Destructor Documentation

◆ ~BasePersistentStorageArray()

BasePersistentStorageArray::~BasePersistentStorageArray ( )
virtual

Remove references to use.

Definition at line 31 of file newgrf_storage.cpp.

References _changed_storage_arrays.

Member Function Documentation

◆ AreChangesPersistent()

static bool BasePersistentStorageArray::AreChangesPersistent ( )
inlinestaticprotected

Check whether currently changes to the storage shall be persistent or temporary till the next call to ClearChanges().

Definition at line 52 of file newgrf_storage.h.

Referenced by PersistentStorageArray< TYPE, SIZE >::StoreValue().

◆ ClearChanges()

virtual void BasePersistentStorageArray::ClearChanges ( )
protectedpure virtual

Discard temporary changes.

Implemented in PersistentStorageArray< TYPE, SIZE >, and PersistentStorageArray< int32_t, 256 >.

◆ SwitchMode()

void BasePersistentStorageArray::SwitchMode ( PersistentStorageMode  mode,
bool  ignore_prev_mode = false 
)
static

Clear temporary changes made since the last call to SwitchMode, and set whether subsequent changes shall be persistent or temporary.

Parameters
modeMode switch affecting temporary/persistent changes.
ignore_prev_modeDisable some sanity checks for exceptional call circumstances.

Definition at line 54 of file newgrf_storage.cpp.

References _changed_storage_arrays, BSWAP32(), Debug, PSM_ENTER_COMMAND, PSM_ENTER_GAMELOOP, PSM_ENTER_TESTMODE, PSM_LEAVE_COMMAND, PSM_LEAVE_GAMELOOP, and PSM_LEAVE_TESTMODE.

Referenced by _GenerateWorld(), CommandHelperBase::InternalExecutePrepTest(), CommandHelperBase::InternalExecuteProcessResult(), CommandHelperBase::InternalExecuteValidateTestAndPrepExec(), and StateGameLoop().

Field Documentation

◆ command

bool BasePersistentStorageArray::command
staticprivate

Definition at line 56 of file newgrf_storage.h.

◆ feature

uint8_t BasePersistentStorageArray::feature

NOSAVE: Used to identify in the owner of the array in debug output.

Definition at line 35 of file newgrf_storage.h.

Referenced by PersistentStorage::PersistentStorage().

◆ gameloop

bool BasePersistentStorageArray::gameloop
staticprivate

Definition at line 55 of file newgrf_storage.h.

◆ grfid

uint32_t BasePersistentStorageArray::grfid

GRFID associated to this persistent storage. A value of zero means "default".

Definition at line 34 of file newgrf_storage.h.

Referenced by PersistentStorage::PersistentStorage().

◆ testmode

bool BasePersistentStorageArray::testmode
staticprivate

Definition at line 57 of file newgrf_storage.h.

◆ tile

TileIndex BasePersistentStorageArray::tile

NOSAVE: Used to identify in the owner of the array in debug output.

Definition at line 36 of file newgrf_storage.h.

Referenced by PersistentStorage::PersistentStorage().


The documentation for this struct was generated from the following files: