include local variable state in saved games

actorid
Marc Zinnschlag 11 years ago
parent 4d80bc009a
commit 6bd3b3ee78

@ -10,16 +10,24 @@ void MWWorld::LiveCellRefBase::loadImp (const ESM::ObjectState& state)
{
mRef = state.mRef;
mData = RefData (state);
Ptr ptr (this);
if (state.mHasLocals)
mData.setLocals (state.mLocals, mClass->getScript (ptr));
mClass->readAdditionalState (ptr, state);
}
void MWWorld::LiveCellRefBase::saveImp (ESM::ObjectState& state) const
{
state.mRef = mRef;
mData.write (state);
/// \todo get rid of this cast once const-correct Ptr are available
Ptr ptr (const_cast<LiveCellRefBase *> (this));
mData.write (state, mClass->getScript (ptr));
mClass->writeAdditionalState (ptr, state);
}

@ -76,9 +76,13 @@ namespace MWWorld
}
}
void RefData::write (ESM::ObjectState& objectState) const
void RefData::write (ESM::ObjectState& objectState, const std::string& scriptId) const
{
objectState.mHasLocals = false;
objectState.mHasLocals = mHasLocals;
if (mHasLocals)
mLocals.write (objectState.mLocals, scriptId);
objectState.mEnabled = mEnabled;
objectState.mCount = mCount;
objectState.mPosition = mPosition;
@ -148,6 +152,12 @@ namespace MWWorld
}
}
void RefData::setLocals (const ESM::Locals& locals, const std::string& scriptId)
{
mHasLocals = true;
mLocals.read (locals, scriptId);
}
void RefData::setCount (int count)
{
if(count == 0)

@ -64,9 +64,9 @@ namespace MWWorld
~RefData();
void write (ESM::ObjectState& objectState) const;
///< Ignores local variables and custom data (not enough context available here to
/// perform these operations).
void write (ESM::ObjectState& objectState, const std::string& scriptId = "") const;
///< Ignores custom data (not enough context available here to
/// perform this operations).
RefData& operator= (const RefData& refData);
@ -83,6 +83,8 @@ namespace MWWorld
void setLocals (const ESM::Script& script);
void setLocals (const ESM::Locals& locals, const std::string& scriptId);
void setCount (int count);
/// Set object count (an object pile is a simple object with a count >1).
///

Loading…
Cancel
Save