1
0
forked from 0ad/0ad

Minor enhancements to serialization test mode

This was SVN commit r10449.
This commit is contained in:
Ykkrosh 2011-10-28 13:18:16 +00:00
parent f31a8f7181
commit 23ae535a1e
2 changed files with 11 additions and 5 deletions

View File

@ -336,7 +336,7 @@ void CSimulation2Impl::Update(int turnLength, const std::vector<SimulationComman
* on anything that's not serialized).
*/
const bool serializationTestDebugDump = false; // set true to save human-readable state dumps, for debugging (but slow)
const bool serializationTestDebugDump = false; // set true to save human-readable state dumps before an error is detected, for debugging (but slow)
const bool serializationTestHash = true; // set true to save and compare hash of state
SerializationTestState primaryStateBefore;
@ -408,8 +408,6 @@ void CSimulation2Impl::Update(int turnLength, const std::vector<SimulationComman
SerializationTestState primaryStateAfter;
ENSURE(m_ComponentManager.SerializeState(primaryStateAfter.state));
if (serializationTestDebugDump)
ENSURE(m_ComponentManager.DumpDebugState(primaryStateAfter.debug, false));
if (serializationTestHash)
ENSURE(m_ComponentManager.ComputeStateHash(primaryStateAfter.hash, false));
@ -418,14 +416,16 @@ void CSimulation2Impl::Update(int turnLength, const std::vector<SimulationComman
SerializationTestState secondaryStateAfter;
ENSURE(secondaryComponentManager.SerializeState(secondaryStateAfter.state));
if (serializationTestDebugDump)
ENSURE(secondaryComponentManager.DumpDebugState(secondaryStateAfter.debug, false));
if (serializationTestHash)
ENSURE(secondaryComponentManager.ComputeStateHash(secondaryStateAfter.hash, false));
if (primaryStateAfter.state.str() != secondaryStateAfter.state.str() ||
primaryStateAfter.hash != secondaryStateAfter.hash)
{
// Only do the (slow) dumping now we know we're going to need to report it
ENSURE(m_ComponentManager.DumpDebugState(primaryStateAfter.debug, false));
ENSURE(secondaryComponentManager.DumpDebugState(secondaryStateAfter.debug, false));
ReportSerializationFailure(&primaryStateBefore, &primaryStateAfter, &secondaryStateBefore, &secondaryStateAfter);
}
}
@ -565,6 +565,11 @@ void CSimulation2::EnableOOSLog()
m->m_EnableOOSLog = true;
}
void CSimulation2::EnableSerializationTest()
{
m->m_EnableSerializationTest = true;
}
entity_id_t CSimulation2::AddEntity(const std::wstring& templateName)
{
return m->m_ComponentManager.AddEntity(templateName, m->m_ComponentManager.AllocateNewEntity());

View File

@ -52,6 +52,7 @@ public:
~CSimulation2();
void EnableOOSLog();
void EnableSerializationTest();
/**
* Load all scripts in the specified directory (non-recursively),