[Client] Simplify updateEquipment for LocalPlayer & LocalActor

0.6.1
Koncord 8 years ago
parent 596f42e408
commit 9519c467eb

@ -195,24 +195,28 @@ void LocalActor::updateEquipment(bool forceUpdate)
MWWorld::ContainerStoreIterator it = invStore.getSlot(slot);
auto &item = equipedItems[slot];
if (it != invStore.end() && !::Misc::StringUtils::ciEqual(it->getCellRef().getRefId(), item.refId))
if (it != invStore.end())
{
equipmentChanged = true;
item.refId = it->getCellRef().getRefId();
item.charge = it->getCellRef().getCharge();
if (slot == MWWorld::InventoryStore::Slot_CarriedRight)
auto &cellRef = it->getCellRef();
if (!::Misc::StringUtils::ciEqual(cellRef.getRefId(), item.refId))
{
MWMechanics::WeaponType weaptype;
auto &_class = ptr.getClass();
MWMechanics::getActiveWeapon(_class.getCreatureStats(ptr), _class.getInventoryStore(ptr), &weaptype);
if (weaptype != MWMechanics::WeapType_Thrown)
item.count = 1;
equipmentChanged = true;
item.refId = cellRef.getRefId();
item.charge = cellRef.getCharge();
if (slot == MWWorld::InventoryStore::Slot_CarriedRight)
{
MWMechanics::WeaponType weaptype;
auto &_class = ptr.getClass();
MWMechanics::getActiveWeapon(_class.getCreatureStats(ptr), _class.getInventoryStore(ptr), &weaptype);
if (weaptype != MWMechanics::WeapType_Thrown)
item.count = 1;
}
else
item.count = invStore.count(cellRef.getRefId());
}
else
item.count = invStore.count(it->getCellRef().getRefId());
}
else if (it == invStore.end() && !item.refId.empty())
else if (!item.refId.empty())
{
equipmentChanged = true;
item.refId = "";

@ -407,29 +407,34 @@ void LocalPlayer::updateEquipment(bool forceUpdate)
MWWorld::InventoryStore &invStore = player.getClass().getInventoryStore(player);
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; slot++)
{
auto &item = equipedItems[slot];
MWWorld::ContainerStoreIterator it = invStore.getSlot(slot);
if (it != invStore.end() && !::Misc::StringUtils::ciEqual(it->getCellRef().getRefId(), equipedItems[slot].refId))
if (it != invStore.end())
{
equipmentChanged = true;
equipedItems[slot].refId = it->getCellRef().getRefId();
equipedItems[slot].charge = it->getCellRef().getCharge();
if (slot == MWWorld::InventoryStore::Slot_CarriedRight)
if (!::Misc::StringUtils::ciEqual(it->getCellRef().getRefId(), equipedItems[slot].refId))
{
MWMechanics::WeaponType weaptype;
MWMechanics::getActiveWeapon(player.getClass().getCreatureStats(player), player.getClass().getInventoryStore(player), &weaptype);
if (weaptype != MWMechanics::WeapType_Thrown)
equipedItems[slot].count = 1;
equipmentChanged = true;
item.refId = it->getCellRef().getRefId();
item.charge = it->getCellRef().getCharge();
if (slot == MWWorld::InventoryStore::Slot_CarriedRight)
{
MWMechanics::WeaponType weaptype;
MWMechanics::getActiveWeapon(player.getClass().getCreatureStats(player),
player.getClass().getInventoryStore(player), &weaptype);
if (weaptype != MWMechanics::WeapType_Thrown)
item.count = 1;
}
else
item.count = invStore.count(it->getCellRef().getRefId());
}
else
equipedItems[slot].count = invStore.count(it->getCellRef().getRefId());
}
else if (it == invStore.end() && !equipedItems[slot].refId.empty())
else if (!item.refId.empty())
{
equipmentChanged = true;
equipedItems[slot].refId = "";
equipedItems[slot].count = 0;
equipedItems[slot].charge = 0;
item.refId = "";
item.count = 0;
item.charge = 0;
}
}

Loading…
Cancel
Save