File diff r18218:2a27481f55c8 → r18219:9a85d923ce33
src/saveload/gamelog_sl.cpp
Show inline comments
 
@@ -8,12 +8,13 @@
 
 */
 

	
 
/** @file gamelog_sl.cpp Code handling saving and loading of gamelog data */
 

	
 
#include "../stdafx.h"
 
#include "../gamelog_internal.h"
 
#include "../fios.h"
 

	
 
#include "saveload.h"
 

	
 
static const SaveLoad _glog_action_desc[] = {
 
	SLE_VAR(LoggedAction, tick,              SLE_UINT16),
 
	SLE_END()
 
@@ -98,21 +99,21 @@ static const SaveLoad * const _glog_desc
 
	_glog_grfbug_desc,
 
	_glog_emergency_desc,
 
};
 

	
 
assert_compile(lengthof(_glog_desc) == GLCT_END);
 

	
 
static void Load_GLOG()
 
static void Load_GLOG_common(LoggedAction *&gamelog_action, uint &gamelog_actions)
 
{
 
	assert(_gamelog_action == NULL);
 
	assert(_gamelog_actions == 0);
 
	assert(gamelog_action == NULL);
 
	assert(gamelog_actions == 0);
 

	
 
	GamelogActionType at;
 
	while ((at = (GamelogActionType)SlReadByte()) != GLAT_NONE) {
 
		_gamelog_action = ReallocT(_gamelog_action, _gamelog_actions + 1);
 
		LoggedAction *la = &_gamelog_action[_gamelog_actions++];
 
		gamelog_action = ReallocT(gamelog_action, gamelog_actions + 1);
 
		LoggedAction *la = &gamelog_action[gamelog_actions++];
 

	
 
		la->at = at;
 

	
 
		SlObject(la, _glog_action_desc); // has to be saved after 'DATE'!
 
		la->change = NULL;
 
		la->changes = 0;
 
@@ -162,10 +163,19 @@ static void Save_GLOG()
 
		}
 
		SlWriteByte(GLCT_NONE);
 
	}
 
	SlWriteByte(GLAT_NONE);
 
}
 

	
 
static void Load_GLOG()
 
{
 
	Load_GLOG_common(_gamelog_action, _gamelog_actions);
 
}
 

	
 
static void Check_GLOG()
 
{
 
	Load_GLOG_common(_load_check_data.gamelog_action, _load_check_data.gamelog_actions);
 
}
 

	
 
extern const ChunkHandler _gamelog_chunk_handlers[] = {
 
	{ 'GLOG', Save_GLOG, Load_GLOG, NULL, NULL, CH_RIFF | CH_LAST }
 
	{ 'GLOG', Save_GLOG, Load_GLOG, NULL, Check_GLOG, CH_RIFF | CH_LAST }
 
};