mirror of
https://github.com/TES3MP/TES3MP.git
synced 2025-09-27 23:21:20 -04:00
[Client] Send Container packets when buying or selling items at merchant
This commit is contained in:
parent
a378b254f8
commit
27b9357478
@ -111,7 +111,37 @@ MWWorld::Ptr ContainerItemModel::copyItem (const ItemStack& item, size_t count,
|
|||||||
const MWWorld::Ptr& source = mItemSources[mItemSources.size()-1];
|
const MWWorld::Ptr& source = mItemSources[mItemSources.size()-1];
|
||||||
if (item.mBase.getContainerStore() == &source.getClass().getContainerStore(source))
|
if (item.mBase.getContainerStore() == &source.getClass().getContainerStore(source))
|
||||||
throw std::runtime_error("Item to copy needs to be from a different container!");
|
throw std::runtime_error("Item to copy needs to be from a different container!");
|
||||||
return *source.getClass().getContainerStore(source).add(item.mBase, count, source, allowAutoEquip);
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Send an ID_CONTAINER packet every time an item is added to a container here
|
||||||
|
*/
|
||||||
|
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
||||||
|
objectList->reset();
|
||||||
|
objectList->packetOrigin = mwmp::PACKET_ORIGIN::CLIENT_GAMEPLAY;
|
||||||
|
objectList->cell = *source.getCell()->getCell();
|
||||||
|
objectList->action = mwmp::BaseObjectList::ADD;
|
||||||
|
objectList->containerSubAction = mwmp::BaseObjectList::NONE;
|
||||||
|
mwmp::BaseObject baseObject = objectList->getBaseObject(source);
|
||||||
|
objectList->addContainerItem(baseObject, item.mBase, count, 0);
|
||||||
|
objectList->addObject(baseObject);
|
||||||
|
objectList->sendContainer();
|
||||||
|
/*
|
||||||
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp change (major)
|
||||||
|
|
||||||
|
Instead of unilaterally adding the item to this source's ContainerStore on this
|
||||||
|
client and returning the resulting Ptr, rely on the server to handle the item
|
||||||
|
transfer and just return the original item Ptr as a placeholder return value
|
||||||
|
*/
|
||||||
|
return item.mBase;
|
||||||
|
/*
|
||||||
|
End of tes3mp change (major)
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContainerItemModel::removeItem (const ItemStack& item, size_t count)
|
void ContainerItemModel::removeItem (const ItemStack& item, size_t count)
|
||||||
@ -126,7 +156,38 @@ void ContainerItemModel::removeItem (const ItemStack& item, size_t count)
|
|||||||
{
|
{
|
||||||
if (stacks(*it, item.mBase))
|
if (stacks(*it, item.mBase))
|
||||||
{
|
{
|
||||||
toRemove -= store.remove(*it, toRemove, source);
|
/*
|
||||||
|
Start of tes3mp change (major)
|
||||||
|
|
||||||
|
Send an ID_CONTAINER packet every time an item is removed here and prevent any
|
||||||
|
unilateral item removal on this client, as long as this isn't the player's
|
||||||
|
currently open container and doesn't require the drag and drop logic dealt with
|
||||||
|
in MWGui::ContainerWindow instead
|
||||||
|
*/
|
||||||
|
mwmp::CurrentContainer *currentContainer = &mwmp::Main::get().getLocalPlayer()->currentContainer;
|
||||||
|
|
||||||
|
if (currentContainer->refNum != source.getCellRef().getRefNum().mIndex ||
|
||||||
|
currentContainer->mpNum != source.getCellRef().getMpNum())
|
||||||
|
{
|
||||||
|
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
||||||
|
objectList->reset();
|
||||||
|
objectList->packetOrigin = mwmp::PACKET_ORIGIN::CLIENT_GAMEPLAY;
|
||||||
|
objectList->cell = *source.getCell()->getCell();
|
||||||
|
objectList->action = mwmp::BaseObjectList::REMOVE;
|
||||||
|
objectList->containerSubAction = mwmp::BaseObjectList::NONE;
|
||||||
|
mwmp::BaseObject baseObject = objectList->getBaseObject(source);
|
||||||
|
objectList->addContainerItem(baseObject, *it, it->getRefData().getCount(), toRemove);
|
||||||
|
objectList->addObject(baseObject);
|
||||||
|
objectList->sendContainer();
|
||||||
|
|
||||||
|
toRemove -= it->getRefData().getCount();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
toRemove -= store.remove(*it, toRemove, source);
|
||||||
|
/*
|
||||||
|
End of tes3mp change (major)
|
||||||
|
*/
|
||||||
|
|
||||||
if (toRemove <= 0)
|
if (toRemove <= 0)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user