forked from teamnwah/openmw-tes3coop
Prevent respawned references from being added to the scene twice in certain cases (Fixes #3864)
This commit is contained in:
parent
eac2e52841
commit
d24286273b
2 changed files with 15 additions and 7 deletions
|
@ -38,6 +38,8 @@ Objects::~Objects()
|
||||||
|
|
||||||
void Objects::insertBegin(const MWWorld::Ptr& ptr)
|
void Objects::insertBegin(const MWWorld::Ptr& ptr)
|
||||||
{
|
{
|
||||||
|
assert(mObjects.find(ptr) == mObjects.end());
|
||||||
|
|
||||||
osg::ref_ptr<osg::Group> cellnode;
|
osg::ref_ptr<osg::Group> cellnode;
|
||||||
|
|
||||||
CellMap::iterator found = mCellSceneNodes.find(ptr.getCell());
|
CellMap::iterator found = mCellSceneNodes.find(ptr.getCell());
|
||||||
|
@ -90,9 +92,8 @@ void Objects::insertCreature(const MWWorld::Ptr &ptr, const std::string &mesh, b
|
||||||
else
|
else
|
||||||
anim = new CreatureAnimation(ptr, mesh, mResourceSystem);
|
anim = new CreatureAnimation(ptr, mesh, mResourceSystem);
|
||||||
|
|
||||||
|
if (mObjects.insert(std::make_pair(ptr, anim)).second)
|
||||||
ptr.getClass().getContainerStore(ptr).setContListener(static_cast<ActorAnimation*>(anim.get()));
|
ptr.getClass().getContainerStore(ptr).setContListener(static_cast<ActorAnimation*>(anim.get()));
|
||||||
|
|
||||||
mObjects.insert(std::make_pair(ptr, anim));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Objects::insertNPC(const MWWorld::Ptr &ptr)
|
void Objects::insertNPC(const MWWorld::Ptr &ptr)
|
||||||
|
@ -102,10 +103,11 @@ void Objects::insertNPC(const MWWorld::Ptr &ptr)
|
||||||
|
|
||||||
osg::ref_ptr<NpcAnimation> anim (new NpcAnimation(ptr, osg::ref_ptr<osg::Group>(ptr.getRefData().getBaseNode()), mResourceSystem));
|
osg::ref_ptr<NpcAnimation> anim (new NpcAnimation(ptr, osg::ref_ptr<osg::Group>(ptr.getRefData().getBaseNode()), mResourceSystem));
|
||||||
|
|
||||||
|
if (mObjects.insert(std::make_pair(ptr, anim)).second)
|
||||||
|
{
|
||||||
ptr.getClass().getInventoryStore(ptr).setInvListener(anim.get(), ptr);
|
ptr.getClass().getInventoryStore(ptr).setInvListener(anim.get(), ptr);
|
||||||
ptr.getClass().getInventoryStore(ptr).setContListener(anim.get());
|
ptr.getClass().getInventoryStore(ptr).setContListener(anim.get());
|
||||||
|
}
|
||||||
mObjects.insert(std::make_pair(ptr, anim));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Objects::removeObject (const MWWorld::Ptr& ptr)
|
bool Objects::removeObject (const MWWorld::Ptr& ptr)
|
||||||
|
|
|
@ -54,6 +54,12 @@ namespace
|
||||||
void addObject(const MWWorld::Ptr& ptr, MWPhysics::PhysicsSystem& physics,
|
void addObject(const MWWorld::Ptr& ptr, MWPhysics::PhysicsSystem& physics,
|
||||||
MWRender::RenderingManager& rendering)
|
MWRender::RenderingManager& rendering)
|
||||||
{
|
{
|
||||||
|
if (ptr.getRefData().getBaseNode() || physics.getActor(ptr))
|
||||||
|
{
|
||||||
|
std::cerr << "Warning: Tried to add " << ptr.getCellRef().getRefId() << " to the scene twice" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
bool useAnim = ptr.getClass().useAnim();
|
bool useAnim = ptr.getClass().useAnim();
|
||||||
std::string model = ptr.getClass().getModel(ptr);
|
std::string model = ptr.getClass().getModel(ptr);
|
||||||
if (useAnim)
|
if (useAnim)
|
||||||
|
|
Loading…
Reference in a new issue