forked from mirror/openmw-tes3mp
replaced container store in ref data with new custom data implementation
This commit is contained in:
parent
b0256cea34
commit
c081160591
8 changed files with 63 additions and 73 deletions
|
@ -6,9 +6,39 @@
|
|||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/containerstore.hpp"
|
||||
#include "../mwworld/customdata.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
struct CustomData : public MWWorld::CustomData
|
||||
{
|
||||
MWWorld::ContainerStore<MWWorld::RefData> mContainerStore;
|
||||
|
||||
virtual MWWorld::CustomData *clone() const;
|
||||
};
|
||||
|
||||
MWWorld::CustomData *CustomData::clone() const
|
||||
{
|
||||
return new CustomData (*this);
|
||||
}
|
||||
}
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
void Container::ensureCustomData (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
if (!ptr.getRefData().getCustomData())
|
||||
{
|
||||
std::auto_ptr<CustomData> data (new CustomData);
|
||||
|
||||
// \todo add initial container content
|
||||
|
||||
// store
|
||||
ptr.getRefData().setCustomData (data.release());
|
||||
}
|
||||
}
|
||||
|
||||
void Container::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Container, MWWorld::RefData> *ref =
|
||||
|
@ -50,17 +80,9 @@ namespace MWClass
|
|||
MWWorld::ContainerStore<MWWorld::RefData>& Container::getContainerStore (const MWWorld::Ptr& ptr)
|
||||
const
|
||||
{
|
||||
if (!ptr.getRefData().getContainerStore().get())
|
||||
{
|
||||
boost::shared_ptr<MWWorld::ContainerStore<MWWorld::RefData> > store (
|
||||
new MWWorld::ContainerStore<MWWorld::RefData>);
|
||||
ensureCustomData (ptr);
|
||||
|
||||
// TODO add initial content
|
||||
|
||||
ptr.getRefData().getContainerStore() = store;
|
||||
}
|
||||
|
||||
return *ptr.getRefData().getContainerStore();
|
||||
return dynamic_cast<CustomData&> (*ptr.getRefData().getCustomData()).mContainerStore;
|
||||
}
|
||||
|
||||
std::string Container::getScript (const MWWorld::Ptr& ptr) const
|
||||
|
|
|
@ -8,6 +8,8 @@ namespace MWClass
|
|||
{
|
||||
class Container : public MWWorld::Class
|
||||
{
|
||||
void ensureCustomData (const MWWorld::Ptr& ptr) const;
|
||||
|
||||
public:
|
||||
|
||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||
|
|
|
@ -4,19 +4,20 @@
|
|||
#include <components/esm/loadcrea.hpp>
|
||||
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
#include "../mwmechanics/mechanicsmanager.hpp"
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/actiontalk.hpp"
|
||||
#include "../mwworld/environment.hpp"
|
||||
#include "../mwworld/customdata.hpp"
|
||||
|
||||
#include "../mwmechanics/mechanicsmanager.hpp"
|
||||
#include "../mwworld/containerstore.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
struct CustomData : public MWWorld::CustomData
|
||||
{
|
||||
MWMechanics::CreatureStats mCreatureStats;
|
||||
MWWorld::ContainerStore<MWWorld::RefData> mContainerStore;
|
||||
|
||||
virtual MWWorld::CustomData *clone() const;
|
||||
};
|
||||
|
@ -52,6 +53,8 @@ namespace MWClass
|
|||
|
||||
data->mCreatureStats.mLevel = ref->base->data.level;
|
||||
|
||||
// \todo add initial container content
|
||||
|
||||
// store
|
||||
ptr.getRefData().setCustomData (data.release());
|
||||
}
|
||||
|
@ -67,18 +70,8 @@ namespace MWClass
|
|||
|
||||
void Creature::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||
{
|
||||
|
||||
/*ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Creature>();
|
||||
|
||||
assert (ref->base != NULL);
|
||||
const std::string &model = ref->base->model;
|
||||
|
||||
if (!model.empty())
|
||||
{*/
|
||||
MWRender::Actors& actors = renderingInterface.getActors();
|
||||
actors.insertCreature(ptr);
|
||||
|
||||
MWRender::Actors& actors = renderingInterface.getActors();
|
||||
actors.insertCreature(ptr);
|
||||
}
|
||||
|
||||
void Creature::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
|
||||
|
@ -92,7 +85,6 @@ namespace MWClass
|
|||
if(!model.empty()){
|
||||
physics.insertActorPhysics(ptr, "meshes\\" + model);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Creature::enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
|
||||
|
@ -129,17 +121,9 @@ namespace MWClass
|
|||
MWWorld::ContainerStore<MWWorld::RefData>& Creature::getContainerStore (const MWWorld::Ptr& ptr)
|
||||
const
|
||||
{
|
||||
if (!ptr.getRefData().getContainerStore().get())
|
||||
{
|
||||
boost::shared_ptr<MWWorld::ContainerStore<MWWorld::RefData> > store (
|
||||
new MWWorld::ContainerStore<MWWorld::RefData>);
|
||||
ensureCustomData (ptr);
|
||||
|
||||
// TODO add initial content
|
||||
|
||||
ptr.getRefData().getContainerStore() = store;
|
||||
}
|
||||
|
||||
return *ptr.getRefData().getContainerStore();
|
||||
return dynamic_cast<CustomData&> (*ptr.getRefData().getCustomData()).mContainerStore;
|
||||
}
|
||||
|
||||
std::string Creature::getScript (const MWWorld::Ptr& ptr) const
|
||||
|
|
|
@ -9,14 +9,14 @@
|
|||
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
#include "../mwmechanics/npcstats.hpp"
|
||||
#include "../mwmechanics/movement.hpp"
|
||||
#include "../mwmechanics/mechanicsmanager.hpp"
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/actiontalk.hpp"
|
||||
#include "../mwworld/environment.hpp"
|
||||
#include "../mwworld/world.hpp"
|
||||
#include "../mwmechanics/movement.hpp"
|
||||
|
||||
#include "../mwmechanics/mechanicsmanager.hpp"
|
||||
#include "../mwworld/containerstore.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -28,6 +28,7 @@ namespace
|
|||
MWMechanics::NpcStats mNpcStats;
|
||||
MWMechanics::CreatureStats mCreatureStats;
|
||||
MWMechanics::Movement mMovement;
|
||||
MWWorld::ContainerStore<MWWorld::RefData> mContainerStore;
|
||||
|
||||
virtual MWWorld::CustomData *clone() const;
|
||||
};
|
||||
|
@ -74,6 +75,8 @@ namespace MWClass
|
|||
|
||||
data->mCreatureStats.mLevel = ref->base->npdt52.level;
|
||||
|
||||
// \todo add initial container content
|
||||
|
||||
// store
|
||||
ptr.getRefData().setCustomData (data.release());
|
||||
}
|
||||
|
@ -155,17 +158,9 @@ namespace MWClass
|
|||
MWWorld::ContainerStore<MWWorld::RefData>& Npc::getContainerStore (const MWWorld::Ptr& ptr)
|
||||
const
|
||||
{
|
||||
if (!ptr.getRefData().getContainerStore().get())
|
||||
{
|
||||
boost::shared_ptr<MWWorld::ContainerStore<MWWorld::RefData> > store (
|
||||
new MWWorld::ContainerStore<MWWorld::RefData>);
|
||||
ensureCustomData (ptr);
|
||||
|
||||
// TODO add initial content
|
||||
|
||||
ptr.getRefData().getContainerStore() = store;
|
||||
}
|
||||
|
||||
return *ptr.getRefData().getContainerStore();
|
||||
return dynamic_cast<CustomData&> (*ptr.getRefData().getCustomData()).mContainerStore;
|
||||
}
|
||||
|
||||
std::string Npc::getScript (const MWWorld::Ptr& ptr) const
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
#include <boost/any.hpp>
|
||||
|
||||
#include <components/esm/loadcell.hpp>
|
||||
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "refdata.hpp"
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
|
||||
#include "refdata.hpp"
|
||||
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "customdata.hpp"
|
||||
|
||||
namespace MWWorld
|
||||
|
@ -14,8 +16,6 @@ namespace MWWorld
|
|||
mCount = refData.mCount;
|
||||
mPosition = refData.mPosition;
|
||||
|
||||
mContainerStore = refData.mContainerStore;
|
||||
|
||||
mCustomData = refData.mCustomData ? refData.mCustomData->clone() : 0;
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ namespace MWWorld
|
|||
mCustomData = 0;
|
||||
}
|
||||
|
||||
RefData::RefData (const ESMS::CellRef& cellRef)
|
||||
RefData::RefData (const ESM::CellRef& cellRef)
|
||||
: mBaseNode(0), mHasLocals (false), mEnabled (true), mCount (1), mPosition (cellRef.pos),
|
||||
mCustomData (0)
|
||||
{}
|
||||
|
@ -126,11 +126,6 @@ namespace MWWorld
|
|||
mEnabled = true;
|
||||
}
|
||||
|
||||
boost::shared_ptr<ContainerStore<RefData> >& RefData::getContainerStore()
|
||||
{
|
||||
return mContainerStore;
|
||||
}
|
||||
|
||||
ESM::Position& RefData::getPosition()
|
||||
{
|
||||
return mPosition;
|
||||
|
|
|
@ -3,17 +3,16 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include <Ogre.h>
|
||||
|
||||
#include "../mwscript/locals.hpp"
|
||||
#include <components/esm/defs.hpp>
|
||||
|
||||
#include "containerstore.hpp"
|
||||
#include "../mwscript/locals.hpp"
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
class Script;
|
||||
class CellRef;
|
||||
}
|
||||
|
||||
namespace MWWorld
|
||||
|
@ -36,12 +35,6 @@ namespace MWWorld
|
|||
|
||||
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
|
||||
// are never copied outside of container operations.
|
||||
boost::shared_ptr<ContainerStore<RefData> > mContainerStore;
|
||||
|
||||
void copy (const RefData& refData);
|
||||
|
||||
void cleanup();
|
||||
|
@ -51,7 +44,7 @@ namespace MWWorld
|
|||
/// @param cellRef Used to copy constant data such as position into this class where it can
|
||||
/// be altered without effecting the original data. This makes it possible
|
||||
/// to reset the position as the orignal data is still held in the CellRef
|
||||
RefData (const ESMS::CellRef& cellRef);
|
||||
RefData (const ESM::CellRef& cellRef);
|
||||
|
||||
RefData (const RefData& refData);
|
||||
|
||||
|
@ -82,8 +75,6 @@ namespace MWWorld
|
|||
|
||||
void disable();
|
||||
|
||||
boost::shared_ptr<ContainerStore<RefData> >& getContainerStore();
|
||||
|
||||
ESM::Position& getPosition();
|
||||
|
||||
void setCustomData (CustomData *data);
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
|
||||
#include "store.hpp"
|
||||
#include "components/esm/records.hpp"
|
||||
#include "components/esm/loadcell.hpp"
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
|
Loading…
Reference in a new issue