From 969759585743edc7d4b6c773c8a893e9c1aa29fb Mon Sep 17 00:00:00 2001 From: David Cernat Date: Tue, 10 Apr 2018 18:22:27 +0300 Subject: [PATCH] [Client] Don't equip already equipped items in local setEquipment() This avoids the following error when receiving repeated PlayerBaseInfo packets: "Error in frame: Invalid slot, make sure you are not calling RefData::setCount for a container object" Additionally, only re-equip items as the result of a PlayerBaseInfo packet if resetStats is true (because of its side effect of auto-equipping items for the player). --- apps/openmw/mwmp/LocalPlayer.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index 214821eda..46ea85915 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -841,7 +841,10 @@ void LocalPlayer::setCharacter() MWBase::Environment::get().getWorld()->getPlayer().setBirthSign(birthsign); if (resetStats) + { MWBase::Environment::get().getMechanicsManager()->setPlayerRace(npc.mRace, npc.isMale(), npc.mHead, npc.mHair); + setEquipment(); + } else { ESM::NPC player = *world->getPlayerPtr().get()->mBase; @@ -855,8 +858,6 @@ void LocalPlayer::setCharacter() MWBase::Environment::get().getMechanicsManager()->playerLoaded(); } - setEquipment(); - MWBase::Environment::get().getWindowManager()->getInventoryWindow()->rebuildAvatar(); } else @@ -1103,7 +1104,11 @@ void LocalPlayer::setEquipment() } } else - ptrInventory.equip(slot, it, ptrPlayer); + { + // Don't try to equip an item that is already equipped + if (!ptrInventory.getSlot(slot).isEqual(it)) + ptrInventory.equip(slot, it, ptrPlayer); + } } else ptrInventory.unequipSlot(slot, ptrPlayer);