mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-09-22 11:23:27 -04:00
Merge branch 'derefkarstaag' into 'master'
Don't dereference a potential end iterator See merge request OpenMW/openmw!4912
This commit is contained in:
commit
975e8d7412
@ -340,8 +340,8 @@ namespace MWMechanics
|
||||
// invisibility manually
|
||||
purgeEffect(ptr, ESM::MagicEffect::Invisibility);
|
||||
applyPurges(ptr);
|
||||
ActiveSpellParams* params = initParams(ptr, ActiveSpellParams{ *slot, enchantment, ptr }, context);
|
||||
if (params)
|
||||
const bool added = initParams(ptr, ActiveSpellParams{ *slot, enchantment, ptr }, context);
|
||||
if (added)
|
||||
context.mUpdateSpellWindow = true;
|
||||
}
|
||||
}
|
||||
@ -468,16 +468,15 @@ namespace MWMechanics
|
||||
return false;
|
||||
}
|
||||
|
||||
ActiveSpells::ActiveSpellParams* ActiveSpells::initParams(
|
||||
const MWWorld::Ptr& ptr, const ActiveSpellParams& params, UpdateContext& context)
|
||||
bool ActiveSpells::initParams(const MWWorld::Ptr& ptr, const ActiveSpellParams& params, UpdateContext& context)
|
||||
{
|
||||
mSpells.emplace_back(params).setActiveSpellId(MWBase::Environment::get().getESMStore()->generateId());
|
||||
auto it = mSpells.end();
|
||||
--it;
|
||||
// We instantly apply the effect with a duration of 0 so continuous effects can be purged before truly applying
|
||||
if (context.mUpdate && updateActiveSpell(ptr, 0.f, it, context))
|
||||
return nullptr;
|
||||
return &*it;
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void ActiveSpells::addToSpells(const MWWorld::Ptr& ptr, const ActiveSpellParams& spell, UpdateContext& context)
|
||||
|
@ -131,7 +131,7 @@ namespace MWMechanics
|
||||
bool updateActiveSpell(
|
||||
const MWWorld::Ptr& ptr, float duration, Collection::iterator& spellIt, UpdateContext& context);
|
||||
|
||||
ActiveSpellParams* initParams(const MWWorld::Ptr& ptr, const ActiveSpellParams& params, UpdateContext& context);
|
||||
bool initParams(const MWWorld::Ptr& ptr, const ActiveSpellParams& params, UpdateContext& context);
|
||||
|
||||
public:
|
||||
ActiveSpells();
|
||||
|
Loading…
x
Reference in New Issue
Block a user