forked from teamnwah/openmw-tes3coop
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
|
||||
refdata world physicssystem scene environment globals class action nullaction actionteleport
|
||||
containerstore actiontalk actiontake containerstore manualref containerutil player cellfunctors
|
||||
cells localscripts
|
||||
cells localscripts customdata
|
||||
)
|
||||
|
||||
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 "customdata.hpp"
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
void RefData::copy (const RefData& refData)
|
||||
|
@ -16,19 +18,25 @@ namespace MWWorld
|
|||
mNpcStats = refData.mNpcStats;
|
||||
mMovement = refData.mMovement;
|
||||
mContainerStore = refData.mContainerStore;
|
||||
|
||||
mCustomData = refData.mCustomData ? refData.mCustomData->clone() : 0;
|
||||
}
|
||||
|
||||
void RefData::cleanup()
|
||||
{
|
||||
mBaseNode = 0;
|
||||
|
||||
delete mCustomData;
|
||||
mCustomData = 0;
|
||||
}
|
||||
|
||||
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)
|
||||
: mBaseNode(0)
|
||||
: mBaseNode(0), mCustomData (0)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -145,4 +153,15 @@ namespace MWWorld
|
|||
{
|
||||
return mPosition;
|
||||
}
|
||||
|
||||
void RefData::setCustomData (CustomData *data)
|
||||
{
|
||||
delete mCustomData;
|
||||
mCustomData = data;
|
||||
}
|
||||
|
||||
CustomData *RefData::getCustomData()
|
||||
{
|
||||
return mCustomData;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@ namespace ESM
|
|||
|
||||
namespace MWWorld
|
||||
{
|
||||
class CustomData;
|
||||
|
||||
class RefData
|
||||
{
|
||||
Ogre::SceneNode* mBaseNode;
|
||||
|
@ -36,6 +38,8 @@ namespace MWWorld
|
|||
|
||||
ESM::Position mPosition;
|
||||
|
||||
CustomData *mCustomData;
|
||||
|
||||
// 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
|
||||
// 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();
|
||||
|
||||
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