Data Structures | Defines | Typedefs | Functions | Variables

newgrf_storage.h File Reference

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

#include "core/pool_type.hpp"

Go to the source code of this file.

Data Structures

struct  BaseStorageArray
 Base class for all 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...

Defines

#define FOR_ALL_STORAGES_FROM(var, start)   FOR_ALL_ITEMS_FROM(PersistentStorage, storage_index, var, start)
#define FOR_ALL_STORAGES(var)   FOR_ALL_STORAGES_FROM(var, 0)

Typedefs

typedef PersistentStorageArray
< int32, 16 > 
OldPersistentStorage
typedef uint32 PersistentStorageID
typedef Pool
< PersistentStorage,
PersistentStorageID, 1, 0xFF000 > 
PersistentStoragePool

Functions

void AddChangedStorage (BaseStorageArray *storage)
 Add the changed storage array to the list of changed arrays.
void ClearStorageChanges (bool keep_changes)
 Clear the changes made since the last ClearStorageChanges.
 assert_compile (cpp_lengthof(OldPersistentStorage, storage)==cpp_lengthof(PersistentStorage, storage))

Variables

PersistentStoragePool _persistent_storage_pool

Detailed Description

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

Definition in file newgrf_storage.h.


Function Documentation

void AddChangedStorage ( BaseStorageArray 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 37 of file newgrf_storage.cpp.

References _changed_storage_arrays.

Referenced by TemporaryStorageArray< TYPE, SIZE >::StoreValue(), and PersistentStorageArray< int32, 16 >::StoreValue().

void ClearStorageChanges ( bool  keep_changes  ) 

Clear the changes made since the last ClearStorageChanges.

This is done for *all* storages that have been registered to with AddChangedStorage since the previous ClearStorageChanges.

This can be done in two ways:

  • saving the changes permanently
  • reverting to the previous version
    Parameters:
    keep_changes do we save or revert the changes since the last ClearChanges?

Definition at line 52 of file newgrf_storage.cpp.

References _changed_storage_arrays.

Referenced by _GenerateWorld(), DoCommandPInternal(), and StateGameLoop().