mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-13 07:14:31 +00:00
Define LiveCellRefBase functions inside MWWorld namespace block
This commit is contained in:
parent
ca8869042b
commit
4565152b3d
@ -15,104 +15,104 @@
|
|||||||
#include "ptr.hpp"
|
#include "ptr.hpp"
|
||||||
#include "worldmodel.hpp"
|
#include "worldmodel.hpp"
|
||||||
|
|
||||||
MWWorld::LiveCellRefBase::LiveCellRefBase(unsigned int type, const ESM::CellRef& cref)
|
namespace MWWorld
|
||||||
: mClass(&Class::get(type))
|
|
||||||
, mRef(cref)
|
|
||||||
, mData(cref)
|
|
||||||
{
|
{
|
||||||
}
|
LiveCellRefBase::LiveCellRefBase(unsigned int type, const ESM::CellRef& cref)
|
||||||
|
: mClass(&Class::get(type))
|
||||||
MWWorld::LiveCellRefBase::LiveCellRefBase(unsigned int type, const ESM4::Reference& cref)
|
, mRef(cref)
|
||||||
: mClass(&Class::get(type))
|
, mData(cref)
|
||||||
, mRef(cref)
|
|
||||||
, mData(cref)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
MWWorld::LiveCellRefBase::LiveCellRefBase(unsigned int type, const ESM4::ActorCharacter& cref)
|
|
||||||
: mClass(&Class::get(type))
|
|
||||||
, mRef(cref)
|
|
||||||
, mData(cref)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
MWWorld::LiveCellRefBase::~LiveCellRefBase()
|
|
||||||
{
|
|
||||||
MWBase::Environment::get().getWorldModel()->deregisterLiveCellRef(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MWWorld::LiveCellRefBase::loadImp(const ESM::ObjectState& state)
|
|
||||||
{
|
|
||||||
mRef = MWWorld::CellRef(state.mRef);
|
|
||||||
mData = RefData(state, mData.isDeletedByContentFile());
|
|
||||||
|
|
||||||
Ptr ptr(this);
|
|
||||||
|
|
||||||
if (state.mHasLocals)
|
|
||||||
{
|
{
|
||||||
const ESM::RefId& scriptId = mClass->getScript(ptr);
|
}
|
||||||
// Make sure we still have a script. It could have been coming from a content file that is no longer active.
|
|
||||||
if (!scriptId.empty())
|
LiveCellRefBase::LiveCellRefBase(unsigned int type, const ESM4::Reference& cref)
|
||||||
|
: mClass(&Class::get(type))
|
||||||
|
, mRef(cref)
|
||||||
|
, mData(cref)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
LiveCellRefBase::LiveCellRefBase(unsigned int type, const ESM4::ActorCharacter& cref)
|
||||||
|
: mClass(&Class::get(type))
|
||||||
|
, mRef(cref)
|
||||||
|
, mData(cref)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
LiveCellRefBase::~LiveCellRefBase()
|
||||||
|
{
|
||||||
|
MWBase::Environment::get().getWorldModel()->deregisterLiveCellRef(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LiveCellRefBase::loadImp(const ESM::ObjectState& state)
|
||||||
|
{
|
||||||
|
mRef = CellRef(state.mRef);
|
||||||
|
mData = RefData(state, mData.isDeletedByContentFile());
|
||||||
|
|
||||||
|
Ptr ptr(this);
|
||||||
|
|
||||||
|
if (state.mHasLocals)
|
||||||
{
|
{
|
||||||
if (const ESM::Script* script
|
const ESM::RefId& scriptId = mClass->getScript(ptr);
|
||||||
= MWBase::Environment::get().getESMStore()->get<ESM::Script>().search(scriptId))
|
// Make sure we still have a script. It could have been coming from a content file that is no longer active.
|
||||||
|
if (!scriptId.empty())
|
||||||
{
|
{
|
||||||
try
|
if (const ESM::Script* script
|
||||||
|
= MWBase::Environment::get().getESMStore()->get<ESM::Script>().search(scriptId))
|
||||||
{
|
{
|
||||||
mData.setLocals(*script);
|
try
|
||||||
mData.getLocals().read(state.mLocals, scriptId);
|
{
|
||||||
}
|
mData.setLocals(*script);
|
||||||
catch (const std::exception& exception)
|
mData.getLocals().read(state.mLocals, scriptId);
|
||||||
{
|
}
|
||||||
Log(Debug::Error) << "Error: failed to load state for local script " << scriptId
|
catch (const std::exception& exception)
|
||||||
<< " because an exception has been thrown: " << exception.what();
|
{
|
||||||
|
Log(Debug::Error) << "Error: failed to load state for local script " << scriptId
|
||||||
|
<< " because an exception has been thrown: " << exception.what();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mClass->readAdditionalState(ptr, state);
|
||||||
|
|
||||||
|
if (!mRef.getSoul().empty()
|
||||||
|
&& !MWBase::Environment::get().getESMStore()->get<ESM::Creature>().search(mRef.getSoul()))
|
||||||
|
{
|
||||||
|
Log(Debug::Warning) << "Soul '" << mRef.getSoul() << "' not found, removing the soul from soul gem";
|
||||||
|
mRef.setSoul(ESM::RefId());
|
||||||
|
}
|
||||||
|
|
||||||
|
MWBase::Environment::get().getLuaManager()->loadLocalScripts(ptr, state.mLuaScripts);
|
||||||
}
|
}
|
||||||
|
|
||||||
mClass->readAdditionalState(ptr, state);
|
void LiveCellRefBase::saveImp(ESM::ObjectState& state) const
|
||||||
|
|
||||||
if (!mRef.getSoul().empty()
|
|
||||||
&& !MWBase::Environment::get().getESMStore()->get<ESM::Creature>().search(mRef.getSoul()))
|
|
||||||
{
|
{
|
||||||
Log(Debug::Warning) << "Soul '" << mRef.getSoul() << "' not found, removing the soul from soul gem";
|
mRef.writeState(state);
|
||||||
mRef.setSoul(ESM::RefId());
|
|
||||||
|
ConstPtr ptr(this);
|
||||||
|
|
||||||
|
mData.write(state, mClass->getScript(ptr));
|
||||||
|
MWBase::Environment::get().getLuaManager()->saveLocalScripts(
|
||||||
|
Ptr(const_cast<LiveCellRefBase*>(this)), state.mLuaScripts);
|
||||||
|
|
||||||
|
mClass->writeAdditionalState(ptr, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
MWBase::Environment::get().getLuaManager()->loadLocalScripts(ptr, state.mLuaScripts);
|
bool LiveCellRefBase::checkStateImp(const ESM::ObjectState& state)
|
||||||
}
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void MWWorld::LiveCellRefBase::saveImp(ESM::ObjectState& state) const
|
unsigned int LiveCellRefBase::getType() const
|
||||||
{
|
{
|
||||||
mRef.writeState(state);
|
return mClass->getType();
|
||||||
|
}
|
||||||
|
|
||||||
ConstPtr ptr(this);
|
bool LiveCellRefBase::isDeleted() const
|
||||||
|
{
|
||||||
|
return mData.isDeletedByContentFile() || mRef.getCount(false) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
mData.write(state, mClass->getScript(ptr));
|
|
||||||
MWBase::Environment::get().getLuaManager()->saveLocalScripts(
|
|
||||||
Ptr(const_cast<LiveCellRefBase*>(this)), state.mLuaScripts);
|
|
||||||
|
|
||||||
mClass->writeAdditionalState(ptr, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MWWorld::LiveCellRefBase::checkStateImp(const ESM::ObjectState& state)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int MWWorld::LiveCellRefBase::getType() const
|
|
||||||
{
|
|
||||||
return mClass->getType();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MWWorld::LiveCellRefBase::isDeleted() const
|
|
||||||
{
|
|
||||||
return mData.isDeletedByContentFile() || mRef.getCount(false) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace MWWorld
|
|
||||||
{
|
|
||||||
std::string makeDynamicCastErrorMessage(const LiveCellRefBase* value, std::string_view recordType)
|
std::string makeDynamicCastErrorMessage(const LiveCellRefBase* value, std::string_view recordType)
|
||||||
{
|
{
|
||||||
std::stringstream message;
|
std::stringstream message;
|
||||||
|
@ -29,7 +29,7 @@ namespace MWWorld
|
|||||||
/** Information about this instance, such as 3D location and rotation
|
/** Information about this instance, such as 3D location and rotation
|
||||||
* and individual type-dependent data.
|
* and individual type-dependent data.
|
||||||
*/
|
*/
|
||||||
MWWorld::CellRef mRef;
|
CellRef mRef;
|
||||||
|
|
||||||
/** runtime-data */
|
/** runtime-data */
|
||||||
RefData mData;
|
RefData mData;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user