From b6d02d9b148720018ede637024f5a284e4aac3ad Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 22 Nov 2016 16:37:49 +0100 Subject: [PATCH] Fix order of operations when undoing werewolf transformation of an NPC --- apps/openmw/mwmechanics/mechanicsmanagerimp.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 4e57d97712..9588699648 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -1531,27 +1531,23 @@ namespace MWMechanics player->restoreSkillsAttributes(); } - // Equipped items other than WerewolfRobe may reference bones that do not even - // exist with the werewolf object root, so make sure to unequip all items - // *before* we become a werewolf. - MWWorld::InventoryStore& invStore = actor.getClass().getInventoryStore(actor); - invStore.unequipAll(actor); - // Werewolfs can not cast spells, so we need to unset the prepared spell if there is one. if (npcStats.getDrawState() == MWMechanics::DrawState_Spell) npcStats.setDrawState(MWMechanics::DrawState_Nothing); npcStats.setWerewolf(werewolf); + MWWorld::InventoryStore &inv = actor.getClass().getInventoryStore(actor); + if(werewolf) { - MWWorld::InventoryStore &inv = actor.getClass().getInventoryStore(actor); - + inv.unequipAll(actor); inv.equip(MWWorld::InventoryStore::Slot_Robe, inv.ContainerStore::add("werewolfrobe", 1, actor), actor); } else { - actor.getClass().getContainerStore(actor).remove("werewolfrobe", 1, actor); + inv.unequipSlot(MWWorld::InventoryStore::Slot_Robe, actor); + inv.ContainerStore::remove("werewolfrobe", 1, actor); } if(actor == player->getPlayer())