[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).
This commit is contained in:
David Cernat 2018-04-10 18:22:27 +03:00
parent 72463cfdb6
commit 9697595857

View file

@ -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<ESM::NPC>()->mBase;
@ -855,8 +858,6 @@ void LocalPlayer::setCharacter()
MWBase::Environment::get().getMechanicsManager()->playerLoaded();
}
setEquipment();
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->rebuildAvatar();
}
else
@ -1103,8 +1104,12 @@ void LocalPlayer::setEquipment()
}
}
else
{
// 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);
}