Changeset - r20910:0cfca604a1aa
[Not reviewed]
master
0 1 0
rubidium - 11 years ago 2013-11-08 22:28:57
rubidium@openttd.org
(svn r25956) -Fix [FS#5772]: temporary persistent storage modifications, e.g. command tests or those from GUI, were not properly reset, creating the possibility of desyncs
1 file changed with 2 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/newgrf_storage.h
Show inline comments
 
@@ -81,13 +81,13 @@ struct PersistentStorageArray : BaseStor
 

	
 
		/* The value hasn't changed, so we pretend nothing happened.
 
		 * Saves a few cycles and such and it's pretty easy to check. */
 
		if (this->storage[pos] == value) return;
 

	
 
		/* We do not have made a backup; lets do so */
 
		if (this->prev_storage != NULL) {
 
		if (this->prev_storage == NULL) {
 
			this->prev_storage = MallocT<TYPE>(SIZE);
 
			memcpy(this->prev_storage, this->storage, sizeof(this->storage));
 

	
 
			/* We only need to register ourselves when we made the backup
 
			 * as that is the only time something will have changed */
 
			AddChangedStorage(this);
 
@@ -118,12 +118,13 @@ struct PersistentStorageArray : BaseStor
 
		assert(this->prev_storage != NULL);
 

	
 
		if (!keep_changes) {
 
			memcpy(this->storage, this->prev_storage, sizeof(this->storage));
 
		}
 
		free(this->prev_storage);
 
		this->prev_storage = NULL;
 
	}
 
};
 

	
 

	
 
/**
 
 * Class for temporary storage of data.
0 comments (0 inline, 0 general)