1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-07-08 02:11:36 +00:00

Define LiveCellRefBase functions inside MWWorld namespace block

This commit is contained in:
elsid 2024-06-15 00:31:43 +02:00
parent ca8869042b
commit 4565152b3d
No known key found for this signature in database
GPG key ID: 4DE04C198CBA7625
2 changed files with 83 additions and 83 deletions

View file

@ -15,35 +15,37 @@
#include "ptr.hpp" #include "ptr.hpp"
#include "worldmodel.hpp" #include "worldmodel.hpp"
MWWorld::LiveCellRefBase::LiveCellRefBase(unsigned int type, const ESM::CellRef& cref) namespace MWWorld
{
LiveCellRefBase::LiveCellRefBase(unsigned int type, const ESM::CellRef& cref)
: mClass(&Class::get(type)) : mClass(&Class::get(type))
, mRef(cref) , mRef(cref)
, mData(cref) , mData(cref)
{ {
} }
MWWorld::LiveCellRefBase::LiveCellRefBase(unsigned int type, const ESM4::Reference& cref) LiveCellRefBase::LiveCellRefBase(unsigned int type, const ESM4::Reference& cref)
: mClass(&Class::get(type)) : mClass(&Class::get(type))
, mRef(cref) , mRef(cref)
, mData(cref) , mData(cref)
{ {
} }
MWWorld::LiveCellRefBase::LiveCellRefBase(unsigned int type, const ESM4::ActorCharacter& cref) LiveCellRefBase::LiveCellRefBase(unsigned int type, const ESM4::ActorCharacter& cref)
: mClass(&Class::get(type)) : mClass(&Class::get(type))
, mRef(cref) , mRef(cref)
, mData(cref) , mData(cref)
{ {
} }
MWWorld::LiveCellRefBase::~LiveCellRefBase() LiveCellRefBase::~LiveCellRefBase()
{ {
MWBase::Environment::get().getWorldModel()->deregisterLiveCellRef(*this); MWBase::Environment::get().getWorldModel()->deregisterLiveCellRef(*this);
} }
void MWWorld::LiveCellRefBase::loadImp(const ESM::ObjectState& state) void LiveCellRefBase::loadImp(const ESM::ObjectState& state)
{ {
mRef = MWWorld::CellRef(state.mRef); mRef = CellRef(state.mRef);
mData = RefData(state, mData.isDeletedByContentFile()); mData = RefData(state, mData.isDeletedByContentFile());
Ptr ptr(this); Ptr ptr(this);
@ -83,7 +85,7 @@ void MWWorld::LiveCellRefBase::loadImp(const ESM::ObjectState& state)
MWBase::Environment::get().getLuaManager()->loadLocalScripts(ptr, state.mLuaScripts); MWBase::Environment::get().getLuaManager()->loadLocalScripts(ptr, state.mLuaScripts);
} }
void MWWorld::LiveCellRefBase::saveImp(ESM::ObjectState& state) const void LiveCellRefBase::saveImp(ESM::ObjectState& state) const
{ {
mRef.writeState(state); mRef.writeState(state);
@ -96,23 +98,21 @@ void MWWorld::LiveCellRefBase::saveImp(ESM::ObjectState& state) const
mClass->writeAdditionalState(ptr, state); mClass->writeAdditionalState(ptr, state);
} }
bool MWWorld::LiveCellRefBase::checkStateImp(const ESM::ObjectState& state) bool LiveCellRefBase::checkStateImp(const ESM::ObjectState& state)
{ {
return true; return true;
} }
unsigned int MWWorld::LiveCellRefBase::getType() const unsigned int LiveCellRefBase::getType() const
{ {
return mClass->getType(); return mClass->getType();
} }
bool MWWorld::LiveCellRefBase::isDeleted() const bool LiveCellRefBase::isDeleted() const
{ {
return mData.isDeletedByContentFile() || mRef.getCount(false) == 0; 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;

View file

@ -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;