# newgrf_storage.h File Reference

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

`#include "core/alloc_func.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...
## 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.

## 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 19 of file newgrf_storage.cpp.

References _changed_storage_arrays.

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

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 24 of file newgrf_storage.cpp.

References _changed_storage_arrays.

Referenced by _GenerateWorld(), and StateGameLoop().