Savegame loading optimization

c++11
scrawl 10 years ago
parent 4eaaa5e855
commit 4637750601

@ -798,12 +798,8 @@ namespace MWClass
const ESM::CreatureState& state2 = dynamic_cast<const ESM::CreatureState&> (state);
ensureCustomData(ptr);
// If we do the following instead we get a sizable speedup, but this causes compatibility issues
// with 0.30 savegames, where some state in CreatureStats was not saved yet,
// and therefore needs to be loaded from ESM records. TODO: re-enable this in a future release.
/*
if (state.mVersion > 0)
{
if (!ptr.getRefData().getCustomData())
{
// Create a CustomData, but don't fill it from ESM records (not needed)
@ -818,7 +814,9 @@ namespace MWClass
ptr.getRefData().setCustomData (data.release());
}
*/
}
else
ensureCustomData(ptr); // in openmw 0.30 savegames not all state was saved yet, so need to load it regardless.
CreatureCustomData& customData = dynamic_cast<CreatureCustomData&> (*ptr.getRefData().getCustomData());

@ -1233,18 +1233,17 @@ namespace MWClass
const ESM::NpcState& state2 = dynamic_cast<const ESM::NpcState&> (state);
ensureCustomData(ptr);
// If we do the following instead we get a sizable speedup, but this causes compatibility issues
// with 0.30 savegames, where some state in CreatureStats was not saved yet,
// and therefore needs to be loaded from ESM records. TODO: re-enable this in a future release.
/*
if (state.mVersion > 0)
{
if (!ptr.getRefData().getCustomData())
{
// Create a CustomData, but don't fill it from ESM records (not needed)
std::auto_ptr<NpcCustomData> data (new NpcCustomData);
ptr.getRefData().setCustomData (data.release());
}
*/
}
else
ensureCustomData(ptr); // in openmw 0.30 savegames not all state was saved yet, so need to load it regardless.
NpcCustomData& customData = dynamic_cast<NpcCustomData&> (*ptr.getRefData().getCustomData());

@ -6,6 +6,8 @@
void ESM::ObjectState::load (ESMReader &esm)
{
mVersion = esm.getVer();
mRef.loadData(esm);
mHasLocals = 0;

@ -29,7 +29,9 @@ namespace ESM
// Is there any class-specific state following the ObjectState
bool mHasCustomState;
ObjectState() : mHasCustomState(true)
unsigned int mVersion;
ObjectState() : mHasCustomState(true), mVersion(0)
{}
/// @note Does not load the CellRef ID, it should already be loaded before calling this method

Loading…
Cancel
Save