2014-01-16 11:03:23 +00:00
|
|
|
|
|
|
|
#include "livecellref.hpp"
|
|
|
|
|
|
|
|
#include <components/esm/objectstate.hpp>
|
|
|
|
|
2014-03-22 15:39:24 +00:00
|
|
|
#include "../mwbase/environment.hpp"
|
|
|
|
#include "../mwbase/world.hpp"
|
|
|
|
|
2014-01-30 10:50:13 +00:00
|
|
|
#include "ptr.hpp"
|
|
|
|
#include "class.hpp"
|
2014-03-22 15:39:24 +00:00
|
|
|
#include "esmstore.hpp"
|
2014-01-30 10:50:13 +00:00
|
|
|
|
2014-01-16 11:03:23 +00:00
|
|
|
void MWWorld::LiveCellRefBase::loadImp (const ESM::ObjectState& state)
|
|
|
|
{
|
|
|
|
mRef = state.mRef;
|
|
|
|
mData = RefData (state);
|
2014-03-22 14:00:49 +00:00
|
|
|
|
2014-01-30 10:50:13 +00:00
|
|
|
Ptr ptr (this);
|
2014-03-22 14:00:49 +00:00
|
|
|
|
|
|
|
if (state.mHasLocals)
|
2014-03-22 15:39:24 +00:00
|
|
|
{
|
|
|
|
std::string scriptId = mClass->getScript (ptr);
|
|
|
|
|
|
|
|
mData.setLocals (*MWBase::Environment::get().getWorld()->getStore().
|
|
|
|
get<ESM::Script>().search (scriptId));
|
|
|
|
mData.getLocals().read (state.mLocals, scriptId);
|
|
|
|
}
|
2014-03-22 14:00:49 +00:00
|
|
|
|
2014-01-30 10:50:13 +00:00
|
|
|
mClass->readAdditionalState (ptr, state);
|
2014-01-16 11:03:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MWWorld::LiveCellRefBase::saveImp (ESM::ObjectState& state) const
|
|
|
|
{
|
|
|
|
state.mRef = mRef;
|
2014-03-22 14:00:49 +00:00
|
|
|
|
2014-01-30 10:50:13 +00:00
|
|
|
/// \todo get rid of this cast once const-correct Ptr are available
|
|
|
|
Ptr ptr (const_cast<LiveCellRefBase *> (this));
|
2014-03-22 14:00:49 +00:00
|
|
|
|
|
|
|
mData.write (state, mClass->getScript (ptr));
|
|
|
|
|
2014-01-30 10:50:13 +00:00
|
|
|
mClass->writeAdditionalState (ptr, state);
|
2014-01-16 11:03:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool MWWorld::LiveCellRefBase::checkStateImp (const ESM::ObjectState& state)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|