forked from mirror/openmw-tes3mp
[Client] Fix loss of player items in ContainerStore::unstack()
Previously, unstacking items for a player led to a PlayerInventory packet being sent about the items' removal. This change makes it so both a packet about their re-addition and their removal are sent instead, cancelling each other out, which is inelegant, but arguably preferable to complicating the sending of PlayerInventory packets again.
This commit is contained in:
parent
5e38e8abdb
commit
f853368641
1 changed files with 19 additions and 0 deletions
|
@ -194,6 +194,25 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::unstack(const Ptr &ptr,
|
|||
if (ptr.getRefData().getCount() <= count)
|
||||
return end();
|
||||
MWWorld::ContainerStoreIterator it = addNewStack(ptr, ptr.getRefData().getCount()-count);
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_PLAYER_INVENTORY packet every time an item stack gets added for a player here
|
||||
*/
|
||||
Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||
|
||||
if (container == player && this == &player.getClass().getContainerStore(player))
|
||||
{
|
||||
mwmp::LocalPlayer *localPlayer = mwmp::Main::get().getLocalPlayer();
|
||||
|
||||
if (!localPlayer->isReceivingInventory)
|
||||
localPlayer->sendItemChange(ptr, ptr.getRefData().getCount() - count, mwmp::InventoryChanges::ADD);
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
const std::string script = it->getClass().getScript(*it);
|
||||
if (!script.empty())
|
||||
MWBase::Environment::get().getWorld()->getLocalScripts().add(script, *it);
|
||||
|
|
Loading…
Reference in a new issue