1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-09 03:39:14 +00:00
OpenMW/apps/openmw/mwgui/referenceinterface.cpp
scrawl 8bf1149cec Fix activation not working sometimes
The current player cell was only being updated when the reference was not empty, causing it
to incorrectly detect a cell change the first time something was activated in a newly visited cell, immediately closing the opened dialogue again.
2013-04-21 21:24:48 +02:00

37 lines
935 B
C++

#include "referenceinterface.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp"
#include "../mwworld/player.hpp"
namespace MWGui
{
ReferenceInterface::ReferenceInterface()
: mCurrentPlayerCell(NULL)
{
}
ReferenceInterface::~ReferenceInterface()
{
}
void ReferenceInterface::checkReferenceAvailable()
{
MWWorld::Ptr::CellStore* playerCell = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell();
// check if player has changed cell, or count of the reference has become 0
if ((playerCell != mCurrentPlayerCell && mCurrentPlayerCell != NULL)
|| (!mPtr.isEmpty() && mPtr.getRefData().getCount() == 0))
{
if (!mPtr.isEmpty())
{
mPtr = MWWorld::Ptr();
onReferenceUnavailable();
}
}
mCurrentPlayerCell = playerCell;
}
}