Functions | Variables

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 "core/pool_func.hpp"
#include "core/endian_func.hpp"
#include "debug.h"
#include <set>

Go to the source code of this file.

Functions

void AddChangedPersistentStorage (BasePersistentStorageArray *storage)
 Add the changed storage array to the list of changed arrays.
void ClearPersistentStorageChanges (bool keep_changes)
 Clear the changes made since the last ClearStorageChanges.

Variables

PersistentStoragePool _persistent_storage_pool ("PersistentStorage")
static std::set
< BasePersistentStorageArray * > * 
_changed_storage_arrays = new std::set<BasePersistentStorageArray*>
 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 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 39 of file newgrf_storage.cpp.

References _changed_storage_arrays.

Referenced by PersistentStorageArray< int32, 16 >::StoreValue().

void ClearPersistentStorageChanges ( 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 54 of file newgrf_storage.cpp.

References _changed_storage_arrays, BSWAP32(), and DEBUG.

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