[Client] Use correct count for items in equipment packets

Previously, throwing weapon sync was completely broken for players, as the count for their equipped throwing weapons was never set and – as a result – defaulted to a count of 1 on other clients. As a result, any time a player threw a dart, they would then appear as having switched to hand-to-hand for other players.

Moreover, the count of equipped items was mistakenly based on the total count of items with that refId in the inventory. As a result, if – for example – I equipped 1 Daedric Longsword and had 4 others in my inventory, my DedicatedPlayer on other clients would equip a Daedric Longsword with a count of 5. If I was overencumbered by having that many Daedric Longswords on me and then dropped 4 of them, allowing myself to move again, my DedicatedPlayer would still walk around with 5 Daedric Longswords and lack animations due to still being overencumbered on the other clients.

These problems were less prevalent for actors, but their equipment updating code has also been changed to match that of players.
0.6.3
David Cernat 7 years ago
parent b249162ca1
commit 20caea083a

@ -964,7 +964,7 @@ namespace MWMechanics
Start of tes3mp change (major)
We need DedicatedPlayers and DedicatedActors to not automatically
equip their light-emitting items, so additions conditions have been
equip their light-emitting items, so additional conditions have been
added for them
*/
if (!isPlayer && !mwmp::PlayerList::isDedicatedPlayer(ptr) && !mwmp::Main::get().getCellController()->isDedicatedActor(ptr))

@ -193,8 +193,8 @@ void LocalActor::updateEquipment(bool forceUpdate)
MWWorld::InventoryStore &invStore = ptr.getClass().getInventoryStore(ptr);
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; slot++)
{
MWWorld::ContainerStoreIterator it = invStore.getSlot(slot);
auto &item = equipedItems[slot];
MWWorld::ContainerStoreIterator it = invStore.getSlot(slot);
if (it != invStore.end())
{
@ -205,16 +205,8 @@ void LocalActor::updateEquipment(bool forceUpdate)
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());
item.enchantmentCharge = it->getCellRef().getEnchantmentCharge();
item.count = it->getRefData().getCount();
}
}
else if (!item.refId.empty())
@ -223,6 +215,7 @@ void LocalActor::updateEquipment(bool forceUpdate)
item.refId = "";
item.count = 0;
item.charge = 0;
item.enchantmentCharge = -1;
}
}

@ -471,17 +471,7 @@ void LocalPlayer::updateEquipment(bool forceUpdate)
item.refId = it->getCellRef().getRefId();
item.charge = it->getCellRef().getCharge();
item.enchantmentCharge = it->getCellRef().getEnchantmentCharge();
if (slot == MWWorld::InventoryStore::Slot_CarriedRight)
{
MWMechanics::WeaponType weaptype;
MWMechanics::getActiveWeapon(ptrPlayer.getClass().getCreatureStats(ptrPlayer),
ptrPlayer.getClass().getInventoryStore(ptrPlayer), &weaptype);
if (weaptype != MWMechanics::WeapType_Thrown)
item.count = 1;
}
else
item.count = invStore.count(it->getCellRef().getRefId());
item.count = it->getRefData().getCount();
}
}
else if (!item.refId.empty())

Loading…
Cancel
Save