OpenTTD Source: src/newgrf_storage.h File Reference

OpenTTD Source 15.0-RC2

Data Structures | Typedefs | Enumerations | Functions | Variables
newgrf_storage.h File Reference

Functionality related to the temporary and persistent storage arrays for NewGRFs. More...

`#include "core/pool_type.hpp"`
`#include "newgrf.h"`
`#include "tile_type.h"`

Go to the source code of this file.

## Data Structures
struct | BasePersistentStorageArray
| Base class for all persistent NewGRF storage arrays. More...
struct | PersistentStorageArray< TYPE, SIZE >
| Class for persistent storage of data. More...
struct | TemporaryStorageArray< TYPE, SIZE >
| Class for temporary storage of data. More...
struct | PersistentStorage
| Class for pooled persistent storage of data. More...

## Typedefs
typedef PersistentStorageArray< int32_t, 16 > | OldPersistentStorage
using | PersistentStorageID = PoolID< uint32_t, struct PersistentStorageIDTag, 0xFF000, 0xFFFFF >
using | PersistentStoragePool = Pool< PersistentStorage, PersistentStorageID, 1 >

## Enumerations
enum | PersistentStorageMode : uint8_t { PSM_ENTER_GAMELOOP , PSM_LEAVE_GAMELOOP , PSM_ENTER_COMMAND , PSM_LEAVE_COMMAND , PSM_ENTER_TESTMODE , PSM_LEAVE_TESTMODE }
| Mode switches to the behaviour of persistent storage array. More...

## Functions
void | AddChangedPersistentStorage (BasePersistentStorageArray *storage)
| Add the changed storage array to the list of changed arrays.

## Variables
PersistentStoragePool | _persistent_storage_pool

## Detailed Description

Functionality related to the temporary and persistent storage arrays for NewGRFs.

Definition in file newgrf_storage.h.

## Typedef Documentation

## ◆ OldPersistentStorage

typedef PersistentStorageArray<int32_t, 16> OldPersistentStorage

Definition at line 187 of file newgrf_storage.h.

## ◆ PersistentStorageID

using PersistentStorageID = PoolID<uint32_t, struct PersistentStorageIDTag, 0xFF000, 0xFFFFF>

Definition at line 189 of file newgrf_storage.h.

## ◆ PersistentStoragePool

using PersistentStoragePool = Pool<PersistentStorage, PersistentStorageID, 1>

Definition at line 192 of file newgrf_storage.h.

## Enumeration Type Documentation

## ◆ PersistentStorageMode

enum PersistentStorageMode : uint8_t

Mode switches to the behaviour of persistent storage array.

Enumerator
PSM_ENTER_GAMELOOP | Enter the gameloop, changes will be permanent.
PSM_LEAVE_GAMELOOP | Leave the gameloop, changes will be temporary.
PSM_ENTER_COMMAND | Enter command scope, changes will be permanent.
PSM_LEAVE_COMMAND | Leave command scope, revert to previous mode.
PSM_ENTER_TESTMODE | Enter command test mode, changes will be temporary.
PSM_LEAVE_TESTMODE | Leave command test mode, revert to previous mode.

Definition at line 20 of file newgrf_storage.h.

## Function Documentation

## ◆ AddChangedPersistentStorage()

void AddChangedPersistentStorage | ( | BasePersistentStorageArray * | storage | ) |

Add the changed storage array to the list of changed arrays.

This is done so we only have to revert/save the changed arrays, which saves quite a few clears, etc. after callbacks.

Parameters

  storage | the array that has changed

Definition at line 41 of file newgrf_storage.cpp.

References _changed_storage_arrays.

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