mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-21 14:09:39 +00:00
added customdata base class (issue #185)
This commit is contained in:
parent
7439c83623
commit
baf9cff21d
4 changed files with 50 additions and 3 deletions
|
@ -46,7 +46,7 @@ add_openmw_dir (mwsound
|
||||||
add_openmw_dir (mwworld
|
add_openmw_dir (mwworld
|
||||||
refdata world physicssystem scene environment globals class action nullaction actionteleport
|
refdata world physicssystem scene environment globals class action nullaction actionteleport
|
||||||
containerstore actiontalk actiontake containerstore manualref containerutil player cellfunctors
|
containerstore actiontalk actiontake containerstore manualref containerutil player cellfunctors
|
||||||
cells localscripts
|
cells localscripts customdata
|
||||||
)
|
)
|
||||||
|
|
||||||
add_openmw_dir (mwclass
|
add_openmw_dir (mwclass
|
||||||
|
|
17
apps/openmw/mwworld/customdata.hpp
Normal file
17
apps/openmw/mwworld/customdata.hpp
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#ifndef GAME_MWWORLD_CUSTOMDATA_H
|
||||||
|
#define GAME_MWWORLD_CUSTOMDATA_H
|
||||||
|
|
||||||
|
namespace MWWorld
|
||||||
|
{
|
||||||
|
/// \brief Base class for the MW-class-specific part of RefData
|
||||||
|
class CustomData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual ~CustomData() {}
|
||||||
|
|
||||||
|
virtual CustomData *clone() const = 0;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,6 +1,8 @@
|
||||||
|
|
||||||
#include "refdata.hpp"
|
#include "refdata.hpp"
|
||||||
|
|
||||||
|
#include "customdata.hpp"
|
||||||
|
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
{
|
{
|
||||||
void RefData::copy (const RefData& refData)
|
void RefData::copy (const RefData& refData)
|
||||||
|
@ -16,19 +18,25 @@ namespace MWWorld
|
||||||
mNpcStats = refData.mNpcStats;
|
mNpcStats = refData.mNpcStats;
|
||||||
mMovement = refData.mMovement;
|
mMovement = refData.mMovement;
|
||||||
mContainerStore = refData.mContainerStore;
|
mContainerStore = refData.mContainerStore;
|
||||||
|
|
||||||
|
mCustomData = refData.mCustomData ? refData.mCustomData->clone() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefData::cleanup()
|
void RefData::cleanup()
|
||||||
{
|
{
|
||||||
mBaseNode = 0;
|
mBaseNode = 0;
|
||||||
|
|
||||||
|
delete mCustomData;
|
||||||
|
mCustomData = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefData::RefData (const ESMS::CellRef& cellRef)
|
RefData::RefData (const ESMS::CellRef& cellRef)
|
||||||
: mBaseNode(0), mHasLocals (false), mEnabled (true), mCount (1), mPosition (cellRef.pos)
|
: mBaseNode(0), mHasLocals (false), mEnabled (true), mCount (1), mPosition (cellRef.pos),
|
||||||
|
mCustomData (0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
RefData::RefData (const RefData& refData)
|
RefData::RefData (const RefData& refData)
|
||||||
: mBaseNode(0)
|
: mBaseNode(0), mCustomData (0)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -145,4 +153,15 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
return mPosition;
|
return mPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RefData::setCustomData (CustomData *data)
|
||||||
|
{
|
||||||
|
delete mCustomData;
|
||||||
|
mCustomData = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomData *RefData::getCustomData()
|
||||||
|
{
|
||||||
|
return mCustomData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,8 @@ namespace ESM
|
||||||
|
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
{
|
{
|
||||||
|
class CustomData;
|
||||||
|
|
||||||
class RefData
|
class RefData
|
||||||
{
|
{
|
||||||
Ogre::SceneNode* mBaseNode;
|
Ogre::SceneNode* mBaseNode;
|
||||||
|
@ -36,6 +38,8 @@ namespace MWWorld
|
||||||
|
|
||||||
ESM::Position mPosition;
|
ESM::Position mPosition;
|
||||||
|
|
||||||
|
CustomData *mCustomData;
|
||||||
|
|
||||||
// we are using shared pointer here to avoid having to create custom copy-constructor,
|
// we are using shared pointer here to avoid having to create custom copy-constructor,
|
||||||
// assignment operator and destructor. As a consequence though copying a RefData object
|
// assignment operator and destructor. As a consequence though copying a RefData object
|
||||||
// manually will probably give unexcepted results. This is not a problem since RefData
|
// manually will probably give unexcepted results. This is not a problem since RefData
|
||||||
|
@ -95,6 +99,13 @@ namespace MWWorld
|
||||||
boost::shared_ptr<ContainerStore<RefData> >& getContainerStore();
|
boost::shared_ptr<ContainerStore<RefData> >& getContainerStore();
|
||||||
|
|
||||||
ESM::Position& getPosition();
|
ESM::Position& getPosition();
|
||||||
|
|
||||||
|
void setCustomData (CustomData *data);
|
||||||
|
///< Set custom data (potentially replacing old custom data). The ownership of \æ data is
|
||||||
|
/// transferred to this.
|
||||||
|
|
||||||
|
CustomData *getCustomData();
|
||||||
|
///< May return a 0-pointer. The ownership of the return data object is not transferred.
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue