mirror of
https://github.com/TES3MP/TES3MP.git
synced 2025-09-30 16:45:17 -04:00
[Client] Simplify updateEquipment for LocalPlayer & LocalActor
This commit is contained in:
parent
596f42e408
commit
9519c467eb
@ -195,24 +195,28 @@ void LocalActor::updateEquipment(bool forceUpdate)
|
|||||||
MWWorld::ContainerStoreIterator it = invStore.getSlot(slot);
|
MWWorld::ContainerStoreIterator it = invStore.getSlot(slot);
|
||||||
auto &item = equipedItems[slot];
|
auto &item = equipedItems[slot];
|
||||||
|
|
||||||
if (it != invStore.end() && !::Misc::StringUtils::ciEqual(it->getCellRef().getRefId(), item.refId))
|
if (it != invStore.end())
|
||||||
{
|
{
|
||||||
equipmentChanged = true;
|
auto &cellRef = it->getCellRef();
|
||||||
|
if (!::Misc::StringUtils::ciEqual(cellRef.getRefId(), item.refId))
|
||||||
item.refId = it->getCellRef().getRefId();
|
|
||||||
item.charge = it->getCellRef().getCharge();
|
|
||||||
if (slot == MWWorld::InventoryStore::Slot_CarriedRight)
|
|
||||||
{
|
{
|
||||||
MWMechanics::WeaponType weaptype;
|
equipmentChanged = true;
|
||||||
auto &_class = ptr.getClass();
|
|
||||||
MWMechanics::getActiveWeapon(_class.getCreatureStats(ptr), _class.getInventoryStore(ptr), &weaptype);
|
item.refId = cellRef.getRefId();
|
||||||
if (weaptype != MWMechanics::WeapType_Thrown)
|
item.charge = cellRef.getCharge();
|
||||||
item.count = 1;
|
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;
|
equipmentChanged = true;
|
||||||
item.refId = "";
|
item.refId = "";
|
||||||
|
@ -407,29 +407,34 @@ void LocalPlayer::updateEquipment(bool forceUpdate)
|
|||||||
MWWorld::InventoryStore &invStore = player.getClass().getInventoryStore(player);
|
MWWorld::InventoryStore &invStore = player.getClass().getInventoryStore(player);
|
||||||
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; slot++)
|
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; slot++)
|
||||||
{
|
{
|
||||||
|
auto &item = equipedItems[slot];
|
||||||
MWWorld::ContainerStoreIterator it = invStore.getSlot(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;
|
if (!::Misc::StringUtils::ciEqual(it->getCellRef().getRefId(), equipedItems[slot].refId))
|
||||||
|
|
||||||
equipedItems[slot].refId = it->getCellRef().getRefId();
|
|
||||||
equipedItems[slot].charge = it->getCellRef().getCharge();
|
|
||||||
if (slot == MWWorld::InventoryStore::Slot_CarriedRight)
|
|
||||||
{
|
{
|
||||||
MWMechanics::WeaponType weaptype;
|
equipmentChanged = true;
|
||||||
MWMechanics::getActiveWeapon(player.getClass().getCreatureStats(player), player.getClass().getInventoryStore(player), &weaptype);
|
|
||||||
if (weaptype != MWMechanics::WeapType_Thrown)
|
item.refId = it->getCellRef().getRefId();
|
||||||
equipedItems[slot].count = 1;
|
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;
|
equipmentChanged = true;
|
||||||
equipedItems[slot].refId = "";
|
item.refId = "";
|
||||||
equipedItems[slot].count = 0;
|
item.count = 0;
|
||||||
equipedItems[slot].charge = 0;
|
item.charge = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user