Changeset - r21090:ad4f8144ed92
[Not reviewed]
master
0 5 0
frosch - 10 years ago 2013-12-23 18:09:03
frosch@openttd.org
(svn r26174) -Codechange: Rename BaseStorageArray to BasePersistentStorageArray
5 files changed with 20 insertions and 20 deletions:
0 comments (0 inline, 0 general)
src/command.cpp
Show inline comments
 
@@ -597,7 +597,7 @@ bool DoCommandP(TileIndex tile, uint32 p
 
 * @param cmd   the command cost to return.
 
 * @param clear whether to keep the storage changes or not.
 
 */
 
#define return_dcpi(cmd, clear) { _docommand_recursive = 0; ClearStorageChanges(clear); return cmd; }
 
#define return_dcpi(cmd, clear) { _docommand_recursive = 0; ClearPersistentStorageChanges(clear); return cmd; }
 

	
 
/*!
 
 * Helper function for the toplevel network safe docommand function for the current company.
 
@@ -661,7 +661,7 @@ CommandCost DoCommandPInternal(TileIndex
 
	/* Test the command. */
 
	_cleared_object_areas.Clear();
 
	SetTownRatingTestMode(true);
 
	ClearStorageChanges(false);
 
	ClearPersistentStorageChanges(false);
 
	CommandCost res = proc(tile, flags, p1, p2, text);
 
	SetTownRatingTestMode(false);
 

	
 
@@ -705,7 +705,7 @@ CommandCost DoCommandPInternal(TileIndex
 
	/* Actually try and execute the command. If no cost-type is given
 
	 * use the construction one */
 
	_cleared_object_areas.Clear();
 
	ClearStorageChanges(false);
 
	ClearPersistentStorageChanges(false);
 
	CommandCost res2 = proc(tile, flags | DC_EXEC, p1, p2, text);
 

	
 
	if (cmd_id == CMD_COMPANY_CTRL) {
src/genworld.cpp
Show inline comments
 
@@ -141,7 +141,7 @@ static void _GenerateWorld(void *)
 
			}
 
		}
 

	
 
		ClearStorageChanges(true);
 
		ClearPersistentStorageChanges(true);
 

	
 
		/* These are probably pointless when inside the scenario editor. */
 
		SetGeneratingWorldProgress(GWP_GAME_INIT, 3);
src/newgrf_storage.cpp
Show inline comments
 
@@ -18,12 +18,12 @@ PersistentStoragePool _persistent_storag
 
INSTANTIATE_POOL_METHODS(PersistentStorage)
 

	
 
/** The changed storage arrays */
 
static std::set<BaseStorageArray*> *_changed_storage_arrays = new std::set<BaseStorageArray*>;
 
static std::set<BasePersistentStorageArray*> *_changed_storage_arrays = new std::set<BasePersistentStorageArray*>;
 

	
 
/**
 
 * Remove references to use.
 
 */
 
BaseStorageArray::~BaseStorageArray()
 
BasePersistentStorageArray::~BasePersistentStorageArray()
 
{
 
	_changed_storage_arrays->erase(this);
 
}
 
@@ -34,7 +34,7 @@ BaseStorageArray::~BaseStorageArray()
 
 * arrays, which saves quite a few clears, etc. after callbacks.
 
 * @param storage the array that has changed
 
 */
 
void AddChangedStorage(BaseStorageArray *storage)
 
void AddChangedPersistentStorage(BasePersistentStorageArray *storage)
 
{
 
	_changed_storage_arrays->insert(storage);
 
}
 
@@ -49,10 +49,10 @@ void AddChangedStorage(BaseStorageArray 
 
 *  - reverting to the previous version
 
 * @param keep_changes do we save or revert the changes since the last #ClearChanges?
 
 */
 
void ClearStorageChanges(bool keep_changes)
 
void ClearPersistentStorageChanges(bool keep_changes)
 
{
 
	/* Loop over all changes arrays */
 
	for (std::set<BaseStorageArray*>::iterator it = _changed_storage_arrays->begin(); it != _changed_storage_arrays->end(); it++) {
 
	for (std::set<BasePersistentStorageArray*>::iterator it = _changed_storage_arrays->begin(); it != _changed_storage_arrays->end(); it++) {
 
		(*it)->ClearChanges(keep_changes);
 
	}
 

	
src/newgrf_storage.h
Show inline comments
 
@@ -15,11 +15,11 @@
 
#include "core/pool_type.hpp"
 

	
 
/**
 
 * Base class for all NewGRF storage arrays. Nothing fancy, only here
 
 * so we have a generalised class to use.
 
 * Base class for all persistent NewGRF storage arrays. Nothing fancy, only here
 
 * so we have a generalised access to the virtual methods.
 
 */
 
struct BaseStorageArray {
 
	virtual ~BaseStorageArray();
 
struct BasePersistentStorageArray {
 
	virtual ~BasePersistentStorageArray();
 

	
 
	/**
 
	 * Clear the changes made since the last #ClearChanges.
 
@@ -38,7 +38,7 @@ struct BaseStorageArray {
 
 * @tparam SIZE the size of the array.
 
 */
 
template <typename TYPE, uint SIZE>
 
struct PersistentStorageArray : BaseStorageArray {
 
struct PersistentStorageArray : BasePersistentStorageArray {
 
	TYPE storage[SIZE]; ///< Memory to for the storage array
 
	TYPE *prev_storage; ///< Memory to store "old" states so we can revert them on the performance of test cases for commands etc.
 

	
 
@@ -83,7 +83,7 @@ struct PersistentStorageArray : BaseStor
 

	
 
			/* We only need to register ourselves when we made the backup
 
			 * as that is the only time something will have changed */
 
			AddChangedStorage(this);
 
			AddChangedPersistentStorage(this);
 
		}
 

	
 
		this->storage[pos] = value;
 
@@ -183,8 +183,8 @@ struct TemporaryStorageArray {
 
	}
 
};
 

	
 
void AddChangedStorage(BaseStorageArray *storage);
 
void ClearStorageChanges(bool keep_changes);
 
void AddChangedPersistentStorage(BasePersistentStorageArray *storage);
 
void ClearPersistentStorageChanges(bool keep_changes);
 

	
 

	
 
typedef PersistentStorageArray<int32, 16> OldPersistentStorage;
src/openttd.cpp
Show inline comments
 
@@ -1352,7 +1352,7 @@ void StateGameLoop()
 
	}
 
	if (HasModalProgress()) return;
 

	
 
	ClearStorageChanges(false);
 
	ClearPersistentStorageChanges(false);
 

	
 
	Layouter::ReduceLineCache();
 

	
 
@@ -1360,7 +1360,7 @@ void StateGameLoop()
 
		RunTileLoop();
 
		CallVehicleTicks();
 
		CallLandscapeTick();
 
		ClearStorageChanges(true);
 
		ClearPersistentStorageChanges(true);
 
		UpdateLandscapingLimits();
 

	
 
		CallWindowTickEvent();
 
@@ -1384,7 +1384,7 @@ void StateGameLoop()
 
		RunTileLoop();
 
		CallVehicleTicks();
 
		CallLandscapeTick();
 
		ClearStorageChanges(true);
 
		ClearPersistentStorageChanges(true);
 

	
 
		AI::GameLoop();
 
		Game::GameLoop();
0 comments (0 inline, 0 general)