From f56711f443bdf3b90cd2cf4bd894f58747834dc1 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 25 Sep 2014 18:00:32 +0200 Subject: [PATCH] Fix crash caused by teleportation spells (Fixes #1904) --- apps/openmw/mwmechanics/actors.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 7045a7168..fb387afea 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -1175,14 +1175,26 @@ namespace MWMechanics iter->second->updateContinuousVfx(); // Animation/movement update + CharacterController* playerCharacter = NULL; for(PtrControllerMap::iterator iter(mActors.begin()); iter != mActors.end(); ++iter) { if (iter->first.getClass().getCreatureStats(iter->first).getMagicEffects().get( ESM::MagicEffect::Paralyze).getMagnitude() > 0) iter->second->skipAnim(); + + // Handle player last, in case a cell transition occurs by casting a teleportation spell + // (would invalidate the iterator) + if (iter->first.getCellRef().getRefId() == "player") + { + playerCharacter = iter->second; + continue; + } iter->second->update(duration); } + if (playerCharacter) + playerCharacter->update(duration); + for(PtrControllerMap::iterator iter(mActors.begin()); iter != mActors.end(); ++iter) { const MWWorld::Class &cls = iter->first.getClass();