added support for serialisation of CustomData state

actorid
Marc Zinnschlag 11 years ago
parent e0537a3253
commit ec7cb90ca4

@ -367,4 +367,8 @@ namespace MWWorld
{
throw std::runtime_error("class does not support gore");
}
void Class::readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state) const {}
void Class::writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state) const {}
}

@ -9,6 +9,11 @@
#include "ptr.hpp"
namespace ESM
{
struct ObjectState;
}
namespace Ogre
{
class Vector3;
@ -299,6 +304,14 @@ namespace MWWorld
virtual int getSkill(const MWWorld::Ptr& ptr, int skill) const;
virtual void readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state)
const;
///< Read additional state from \a state into \a ptr.
virtual void writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state)
const;
///< Write additional state from \a ptr into \a state.
static const Class& get (const std::string& key);
///< If there is no class for this \a key, an exception is thrown.

@ -3,16 +3,24 @@
#include <components/esm/objectstate.hpp>
#include "ptr.hpp"
#include "class.hpp"
void MWWorld::LiveCellRefBase::loadImp (const ESM::ObjectState& state)
{
mRef = state.mRef;
mData = RefData (state);
Ptr ptr (this);
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));
mClass->writeAdditionalState (ptr, state);
}
bool MWWorld::LiveCellRefBase::checkStateImp (const ESM::ObjectState& state)

Loading…
Cancel
Save