# newgrf_storage.cpp File Reference

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

`#include "stdafx.h"`
`#include "newgrf_storage.h"`
`#include <set>`

Go to the source code of this file.

## 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.
## Variables
static std::set < BaseStorageArray * > | _changed_storage_arrays
| The changed storage arrays.

## Detailed Description

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

Definition in file newgrf_storage.cpp.

## 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().