mirror of
https://github.com/OpenMW/openmw.git
synced 2025-05-10 06:41:25 +00:00
Savegame loading optimization
This commit is contained in:
parent
4eaaa5e855
commit
4637750601
4 changed files with 28 additions and 27 deletions
|
@ -798,12 +798,8 @@ namespace MWClass
|
||||||
|
|
||||||
const ESM::CreatureState& state2 = dynamic_cast<const ESM::CreatureState&> (state);
|
const ESM::CreatureState& state2 = dynamic_cast<const ESM::CreatureState&> (state);
|
||||||
|
|
||||||
ensureCustomData(ptr);
|
if (state.mVersion > 0)
|
||||||
|
{
|
||||||
// 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 (!ptr.getRefData().getCustomData())
|
if (!ptr.getRefData().getCustomData())
|
||||||
{
|
{
|
||||||
// Create a CustomData, but don't fill it from ESM records (not needed)
|
// Create a CustomData, but don't fill it from ESM records (not needed)
|
||||||
|
@ -818,7 +814,9 @@ namespace MWClass
|
||||||
|
|
||||||
ptr.getRefData().setCustomData (data.release());
|
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());
|
CreatureCustomData& customData = dynamic_cast<CreatureCustomData&> (*ptr.getRefData().getCustomData());
|
||||||
|
|
||||||
|
|
|
@ -1233,18 +1233,17 @@ namespace MWClass
|
||||||
|
|
||||||
const ESM::NpcState& state2 = dynamic_cast<const ESM::NpcState&> (state);
|
const ESM::NpcState& state2 = dynamic_cast<const ESM::NpcState&> (state);
|
||||||
|
|
||||||
ensureCustomData(ptr);
|
if (state.mVersion > 0)
|
||||||
// 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 (!ptr.getRefData().getCustomData())
|
if (!ptr.getRefData().getCustomData())
|
||||||
{
|
{
|
||||||
// Create a CustomData, but don't fill it from ESM records (not needed)
|
// Create a CustomData, but don't fill it from ESM records (not needed)
|
||||||
std::auto_ptr<NpcCustomData> data (new NpcCustomData);
|
std::auto_ptr<NpcCustomData> data (new NpcCustomData);
|
||||||
ptr.getRefData().setCustomData (data.release());
|
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());
|
NpcCustomData& customData = dynamic_cast<NpcCustomData&> (*ptr.getRefData().getCustomData());
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
void ESM::ObjectState::load (ESMReader &esm)
|
void ESM::ObjectState::load (ESMReader &esm)
|
||||||
{
|
{
|
||||||
|
mVersion = esm.getVer();
|
||||||
|
|
||||||
mRef.loadData(esm);
|
mRef.loadData(esm);
|
||||||
|
|
||||||
mHasLocals = 0;
|
mHasLocals = 0;
|
||||||
|
|
|
@ -29,7 +29,9 @@ namespace ESM
|
||||||
// Is there any class-specific state following the ObjectState
|
// Is there any class-specific state following the ObjectState
|
||||||
bool mHasCustomState;
|
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
|
/// @note Does not load the CellRef ID, it should already be loaded before calling this method
|
||||||
|
|
Loading…
Reference in a new issue