forked from teamnwah/openmw-tes3coop
Erase effects that have expired (Fixes #2134)
This commit is contained in:
parent
cd5d02402f
commit
238325455d
1 changed files with 18 additions and 1 deletions
|
@ -17,18 +17,35 @@ namespace MWMechanics
|
||||||
|
|
||||||
MWWorld::TimeStamp now = MWBase::Environment::get().getWorld()->getTimeStamp();
|
MWWorld::TimeStamp now = MWBase::Environment::get().getWorld()->getTimeStamp();
|
||||||
|
|
||||||
// Erase no longer active spells
|
// Erase no longer active spells and effects
|
||||||
if (mLastUpdate!=now)
|
if (mLastUpdate!=now)
|
||||||
{
|
{
|
||||||
TContainer::iterator iter (mSpells.begin());
|
TContainer::iterator iter (mSpells.begin());
|
||||||
while (iter!=mSpells.end())
|
while (iter!=mSpells.end())
|
||||||
|
{
|
||||||
if (!timeToExpire (iter))
|
if (!timeToExpire (iter))
|
||||||
{
|
{
|
||||||
mSpells.erase (iter++);
|
mSpells.erase (iter++);
|
||||||
rebuild = true;
|
rebuild = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
std::vector<ActiveEffect>& effects = iter->second.mEffects;
|
||||||
|
for (std::vector<ActiveEffect>::iterator effectIt = effects.begin(); effectIt != effects.end();)
|
||||||
|
{
|
||||||
|
MWWorld::TimeStamp start = iter->second.mTimeStamp;
|
||||||
|
MWWorld::TimeStamp end = start + static_cast<double>(effectIt->mDuration)*MWBase::Environment::get().getWorld()->getTimeScaleFactor()/(60*60);
|
||||||
|
if (end <= now)
|
||||||
|
{
|
||||||
|
effectIt = effects.erase(effectIt);
|
||||||
|
rebuild = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
++effectIt;
|
||||||
|
}
|
||||||
++iter;
|
++iter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mLastUpdate = now;
|
mLastUpdate = now;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue