You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openmw-tes3mp/apps/openmw/mwworld/refdata.cpp

149 lines
2.6 KiB
C++

#include "refdata.hpp"
#include <OgreSceneNode.h>
#include "customdata.hpp"
#include "cellstore.hpp"
namespace MWWorld
{
void RefData::copy (const RefData& refData)
{
mBaseNode = refData.mBaseNode;
mLocals = refData.mLocals;
mHasLocals = refData.mHasLocals;
mEnabled = refData.mEnabled;
mCount = refData.mCount;
mPosition = refData.mPosition;
mCustomData = refData.mCustomData ? refData.mCustomData->clone() : 0;
}
void RefData::cleanup()
{
mBaseNode = 0;
delete mCustomData;
mCustomData = 0;
}
RefData::RefData (const ESM::CellRef& cellRef)
: mBaseNode(0), mHasLocals (false), mEnabled (true), mCount (1), mPosition (cellRef.mPos),
mCustomData (0)
{}
RefData::RefData (const RefData& refData)
: mBaseNode(0), mCustomData (0)
{
try
{
copy (refData);
}
catch (...)
{
cleanup();
throw;
}
}
13 years ago
RefData& RefData::operator= (const RefData& refData)
{
try
{
cleanup();
copy (refData);
}
catch (...)
{
cleanup();
throw;
}
return *this;
}
RefData::~RefData()
{
try
{
cleanup();
}
catch (...)
{}
}
std::string RefData::getHandle()
{
if (!mBaseNode)
return "";
return mBaseNode->getName();
}
Ogre::SceneNode* RefData::getBaseNode()
{
return mBaseNode;
}
void RefData::setBaseNode(Ogre::SceneNode* base)
{
mBaseNode = base;
}
int RefData::getCount() const
{
return mCount;
}
void RefData::setLocals (const ESM::Script& script)
{
if (!mHasLocals)
{
mLocals.configure (script);
mHasLocals = true;
}
}
void RefData::setCount (int count)
{
mCount = count;
}
MWScript::Locals& RefData::getLocals()
{
return mLocals;
}
bool RefData::isEnabled() const
{
return mEnabled;
}
void RefData::enable()
{
mEnabled = true;
}
void RefData::disable()
{
mEnabled = false;
}
ESM::Position& RefData::getPosition()
{
return mPosition;
}
void RefData::setCustomData (CustomData *data)
{
delete mCustomData;
mCustomData = data;
}
CustomData *RefData::getCustomData()
{
return mCustomData;
}
}