mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-05 17:49:42 +00:00
[Client] Use item model's items for Container packet sent from Take All
Previously, a Container packet sent when using the Take All button included all the items in the container, not just all the items in the container window seen on the client. This was a problem when stealing from actors, as the container window does not give access to all of their items.
This commit is contained in:
parent
abdaedd752
commit
a95099cd03
3 changed files with 36 additions and 12 deletions
|
@ -297,27 +297,33 @@ namespace MWGui
|
|||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Trigger crimes related to the attempted taking of these items, if applicable
|
||||
|
||||
Send an ID_CONTAINER packet every time the Take All button is used on
|
||||
a container
|
||||
*/
|
||||
for (size_t i = 0; i < mModel->getItemCount(); ++i)
|
||||
{
|
||||
const ItemStack& item = mModel->getItem(i);
|
||||
|
||||
if (!onTakeItem(item, item.mCount))
|
||||
break;
|
||||
}
|
||||
|
||||
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
||||
objectList->reset();
|
||||
objectList->packetOrigin = mwmp::CLIENT_GAMEPLAY;
|
||||
objectList->cell = *mPtr.getCell()->getCell();
|
||||
objectList->action = mwmp::BaseObjectList::REMOVE;
|
||||
objectList->containerSubAction = mwmp::BaseObjectList::TAKE_ALL;
|
||||
objectList->addEntireContainer(mPtr);
|
||||
objectList->sendContainer();
|
||||
mwmp::BaseObject baseObject = objectList->getBaseObjectFromPtr(mPtr);
|
||||
|
||||
for (size_t i = 0; i < mModel->getItemCount(); ++i)
|
||||
{
|
||||
const ItemStack& item = mModel->getItem(i);
|
||||
|
||||
// Trigger crimes related to the attempted taking of these items, if applicable
|
||||
if (!onTakeItem(item, item.mCount))
|
||||
break;
|
||||
|
||||
objectList->addContainerItem(baseObject, item, item.mCount, item.mCount);
|
||||
}
|
||||
|
||||
if (baseObject.containerItems.size() > 0)
|
||||
{
|
||||
objectList->addBaseObject(baseObject);
|
||||
objectList->sendContainer();
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
|
|
@ -112,6 +112,22 @@ void ObjectList::addContainerItem(mwmp::BaseObject& baseObject, const MWWorld::P
|
|||
baseObject.containerItems.push_back(containerItem);
|
||||
}
|
||||
|
||||
void ObjectList::addContainerItem(mwmp::BaseObject& baseObject, const MWGui::ItemStack& itemStack, int itemCount, int actionCount)
|
||||
{
|
||||
mwmp::ContainerItem containerItem;
|
||||
containerItem.refId = itemStack.mBase.getCellRef().getRefId();
|
||||
containerItem.count = itemCount;
|
||||
containerItem.charge = itemStack.mBase.getCellRef().getCharge();
|
||||
containerItem.enchantmentCharge = itemStack.mBase.getCellRef().getEnchantmentCharge();
|
||||
containerItem.soul = itemStack.mBase.getCellRef().getSoul();
|
||||
containerItem.actionCount = actionCount;
|
||||
|
||||
LOG_APPEND(TimedLog::LOG_VERBOSE, "--- Adding container item %s to packet with count %i and actionCount %i",
|
||||
containerItem.refId.c_str(), itemCount, actionCount);
|
||||
|
||||
baseObject.containerItems.push_back(containerItem);
|
||||
}
|
||||
|
||||
void ObjectList::addContainerItem(mwmp::BaseObject& baseObject, const std::string itemId, int itemCount, int actionCount)
|
||||
{
|
||||
mwmp::ContainerItem containerItem;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define OPENMW_OBJECTLIST_HPP
|
||||
|
||||
#include <components/openmw-mp/Base/BaseObject.hpp>
|
||||
#include "../mwgui/itemmodel.hpp"
|
||||
#include "../mwworld/worldimp.hpp"
|
||||
#include <RakNetTypes.h>
|
||||
|
||||
|
@ -20,6 +21,7 @@ namespace mwmp
|
|||
void addBaseObject(BaseObject baseObject);
|
||||
mwmp::BaseObject getBaseObjectFromPtr(const MWWorld::Ptr& ptr);
|
||||
void addContainerItem(mwmp::BaseObject& baseObject, const MWWorld::Ptr& itemPtr, int itemCount, int actionCount);
|
||||
void addContainerItem(mwmp::BaseObject& baseObject, const MWGui::ItemStack& itemStack, int itemCount, int actionCount);
|
||||
void addContainerItem(mwmp::BaseObject& baseObject, const std::string itemId, int itemCount, int actionCount);
|
||||
void addEntireContainer(const MWWorld::Ptr& ptr);
|
||||
|
||||
|
|
Loading…
Reference in a new issue