mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 06:53:52 +00:00
added support for serialisation of CustomData state
This commit is contained in:
parent
e0537a3253
commit
ec7cb90ca4
3 changed files with 25 additions and 0 deletions
|
@ -367,4 +367,8 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
throw std::runtime_error("class does not support gore");
|
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"
|
#include "ptr.hpp"
|
||||||
|
|
||||||
|
namespace ESM
|
||||||
|
{
|
||||||
|
struct ObjectState;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Ogre
|
namespace Ogre
|
||||||
{
|
{
|
||||||
class Vector3;
|
class Vector3;
|
||||||
|
@ -299,6 +304,14 @@ namespace MWWorld
|
||||||
|
|
||||||
virtual int getSkill(const MWWorld::Ptr& ptr, int skill) const;
|
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);
|
static const Class& get (const std::string& key);
|
||||||
///< If there is no class for this \a key, an exception is thrown.
|
///< If there is no class for this \a key, an exception is thrown.
|
||||||
|
|
||||||
|
|
|
@ -3,16 +3,24 @@
|
||||||
|
|
||||||
#include <components/esm/objectstate.hpp>
|
#include <components/esm/objectstate.hpp>
|
||||||
|
|
||||||
|
#include "ptr.hpp"
|
||||||
|
#include "class.hpp"
|
||||||
|
|
||||||
void MWWorld::LiveCellRefBase::loadImp (const ESM::ObjectState& state)
|
void MWWorld::LiveCellRefBase::loadImp (const ESM::ObjectState& state)
|
||||||
{
|
{
|
||||||
mRef = state.mRef;
|
mRef = state.mRef;
|
||||||
mData = RefData (state);
|
mData = RefData (state);
|
||||||
|
Ptr ptr (this);
|
||||||
|
mClass->readAdditionalState (ptr, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MWWorld::LiveCellRefBase::saveImp (ESM::ObjectState& state) const
|
void MWWorld::LiveCellRefBase::saveImp (ESM::ObjectState& state) const
|
||||||
{
|
{
|
||||||
state.mRef = mRef;
|
state.mRef = mRef;
|
||||||
mData.write (state);
|
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)
|
bool MWWorld::LiveCellRefBase::checkStateImp (const ESM::ObjectState& state)
|
||||||
|
|
Loading…
Reference in a new issue