[General] Send item owner in ID_CONTAINER

coverity_scan^2
David Cernat 8 years ago
parent ad3eac624f
commit d8a9a5f6c9

@ -117,6 +117,7 @@ namespace MWGui
containerItem.count = itemPtr.getRefData().getCount();
containerItem.charge = itemPtr.getCellRef().getCharge();
containerItem.goldValue = itemPtr.getCellRef().getGoldValue();
containerItem.owner = itemPtr.getCellRef().getOwner();
containerItem.actionCount = count;
event->addContainerItem(containerItem);
event->containerChanges.action = mwmp::ContainerChanges::REMOVE;
@ -168,11 +169,14 @@ namespace MWGui
worldObject.refNumIndex = mPtr.getCellRef().getRefNum().mIndex;
event->addObject(worldObject);
MWWorld::Ptr itemPtr = mDragAndDrop->mItem.mBase;
mwmp::ContainerItem containerItem;
containerItem.refId = mDragAndDrop->mItem.mBase.getCellRef().getRefId();
containerItem.count = mDragAndDrop->mItem.mBase.getRefData().getCount();
containerItem.charge = mDragAndDrop->mItem.mBase.getCellRef().getCharge();
containerItem.goldValue = mDragAndDrop->mItem.mBase.getCellRef().getGoldValue();
containerItem.refId = itemPtr.getCellRef().getRefId();
containerItem.count = itemPtr.getRefData().getCount();
containerItem.charge = itemPtr.getCellRef().getCharge();
containerItem.goldValue = itemPtr.getCellRef().getGoldValue();
containerItem.owner = itemPtr.getCellRef().getOwner();
event->addContainerItem(containerItem);
event->containerChanges.action = mwmp::ContainerChanges::ADD;

@ -76,6 +76,10 @@ void WorldEvent::editContainer(MWWorld::CellStore* cellStore)
for (unsigned int i = 0; i < containerChanges.count; i++)
{
ContainerItem containerItem = containerChanges.items.at(i);
MWWorld::Ptr ownerPtr = MWBase::Environment::get().getWorld()->searchPtr(containerItem.owner, false);
if (ownerPtr.isEmpty())
ownerPtr = MWBase::Environment::get().getWorld()->getPlayerPtr();
if (action == ContainerChanges::ADD || action == ContainerChanges::SET)
{
@ -91,7 +95,7 @@ void WorldEvent::editContainer(MWWorld::CellStore* cellStore)
newPtr.getCellRef().setGoldValue(containerItem.goldValue);
containerStore.add(newPtr, containerItem.count, mwmp::Players::getPlayer(guid)->getPtr(), true);
containerStore.add(newPtr, containerItem.count, ownerPtr, true);
}
else if (action == ContainerChanges::REMOVE)
{
@ -103,9 +107,10 @@ void WorldEvent::editContainer(MWWorld::CellStore* cellStore)
{
if (iter->getCellRef().getCharge() == containerItem.charge &&
iter->getCellRef().getGoldValue() == containerItem.goldValue &&
iter->getRefData().getCount() == containerItem.count)
iter->getRefData().getCount() == containerItem.count &&
iter->getCellRef().getOwner() == containerItem.owner)
{
containerStore.remove(*iter, containerItem.actionCount, mwmp::Players::getPlayer(guid)->getPtr());
containerStore.remove(*iter, containerItem.actionCount, ownerPtr);
}
}
}
@ -478,9 +483,9 @@ void WorldEvent::setMemberShorts()
worldObject.shortVal);
// Mimic the way a Ptr is fetched in InterpreterContext for similar situations
MWWorld::Ptr ptrFound = MWBase::Environment::get().getWorld()->getPtr(worldObject.refId, false);
MWWorld::Ptr ptrFound = MWBase::Environment::get().getWorld()->searchPtr(worldObject.refId, false);
if (ptrFound)
if (!ptrFound.isEmpty())
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Found %s, %i",
ptrFound.getCellRef().getRefId().c_str(),

@ -39,6 +39,7 @@ namespace mwmp
int charge;
int goldValue;
std::string owner;
int actionCount;
inline bool operator==(const ContainerItem& rhs)

@ -64,6 +64,7 @@ void PacketContainer::Packet(RakNet::BitStream *bs, BaseEvent *event, bool send)
RW(containerItem.count, send);
RW(containerItem.charge, send);
RW(containerItem.goldValue, send);
RW(containerItem.owner, send);
RW(containerItem.actionCount, send);
if (!send)

Loading…
Cancel
Save