forked from mirror/openmw-tes3mp
[General] Send item owner in ID_CONTAINER
This commit is contained in:
parent
ad3eac624f
commit
d8a9a5f6c9
4 changed files with 20 additions and 9 deletions
|
@ -117,6 +117,7 @@ namespace MWGui
|
||||||
containerItem.count = itemPtr.getRefData().getCount();
|
containerItem.count = itemPtr.getRefData().getCount();
|
||||||
containerItem.charge = itemPtr.getCellRef().getCharge();
|
containerItem.charge = itemPtr.getCellRef().getCharge();
|
||||||
containerItem.goldValue = itemPtr.getCellRef().getGoldValue();
|
containerItem.goldValue = itemPtr.getCellRef().getGoldValue();
|
||||||
|
containerItem.owner = itemPtr.getCellRef().getOwner();
|
||||||
containerItem.actionCount = count;
|
containerItem.actionCount = count;
|
||||||
event->addContainerItem(containerItem);
|
event->addContainerItem(containerItem);
|
||||||
event->containerChanges.action = mwmp::ContainerChanges::REMOVE;
|
event->containerChanges.action = mwmp::ContainerChanges::REMOVE;
|
||||||
|
@ -168,11 +169,14 @@ namespace MWGui
|
||||||
worldObject.refNumIndex = mPtr.getCellRef().getRefNum().mIndex;
|
worldObject.refNumIndex = mPtr.getCellRef().getRefNum().mIndex;
|
||||||
event->addObject(worldObject);
|
event->addObject(worldObject);
|
||||||
|
|
||||||
|
MWWorld::Ptr itemPtr = mDragAndDrop->mItem.mBase;
|
||||||
|
|
||||||
mwmp::ContainerItem containerItem;
|
mwmp::ContainerItem containerItem;
|
||||||
containerItem.refId = mDragAndDrop->mItem.mBase.getCellRef().getRefId();
|
containerItem.refId = itemPtr.getCellRef().getRefId();
|
||||||
containerItem.count = mDragAndDrop->mItem.mBase.getRefData().getCount();
|
containerItem.count = itemPtr.getRefData().getCount();
|
||||||
containerItem.charge = mDragAndDrop->mItem.mBase.getCellRef().getCharge();
|
containerItem.charge = itemPtr.getCellRef().getCharge();
|
||||||
containerItem.goldValue = mDragAndDrop->mItem.mBase.getCellRef().getGoldValue();
|
containerItem.goldValue = itemPtr.getCellRef().getGoldValue();
|
||||||
|
containerItem.owner = itemPtr.getCellRef().getOwner();
|
||||||
event->addContainerItem(containerItem);
|
event->addContainerItem(containerItem);
|
||||||
event->containerChanges.action = mwmp::ContainerChanges::ADD;
|
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++)
|
for (unsigned int i = 0; i < containerChanges.count; i++)
|
||||||
{
|
{
|
||||||
ContainerItem containerItem = containerChanges.items.at(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)
|
if (action == ContainerChanges::ADD || action == ContainerChanges::SET)
|
||||||
{
|
{
|
||||||
|
@ -91,7 +95,7 @@ void WorldEvent::editContainer(MWWorld::CellStore* cellStore)
|
||||||
|
|
||||||
newPtr.getCellRef().setGoldValue(containerItem.goldValue);
|
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)
|
else if (action == ContainerChanges::REMOVE)
|
||||||
{
|
{
|
||||||
|
@ -103,9 +107,10 @@ void WorldEvent::editContainer(MWWorld::CellStore* cellStore)
|
||||||
{
|
{
|
||||||
if (iter->getCellRef().getCharge() == containerItem.charge &&
|
if (iter->getCellRef().getCharge() == containerItem.charge &&
|
||||||
iter->getCellRef().getGoldValue() == containerItem.goldValue &&
|
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);
|
worldObject.shortVal);
|
||||||
|
|
||||||
// Mimic the way a Ptr is fetched in InterpreterContext for similar situations
|
// 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",
|
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Found %s, %i",
|
||||||
ptrFound.getCellRef().getRefId().c_str(),
|
ptrFound.getCellRef().getRefId().c_str(),
|
||||||
|
|
|
@ -39,6 +39,7 @@ namespace mwmp
|
||||||
int charge;
|
int charge;
|
||||||
int goldValue;
|
int goldValue;
|
||||||
|
|
||||||
|
std::string owner;
|
||||||
int actionCount;
|
int actionCount;
|
||||||
|
|
||||||
inline bool operator==(const ContainerItem& rhs)
|
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.count, send);
|
||||||
RW(containerItem.charge, send);
|
RW(containerItem.charge, send);
|
||||||
RW(containerItem.goldValue, send);
|
RW(containerItem.goldValue, send);
|
||||||
|
RW(containerItem.owner, send);
|
||||||
RW(containerItem.actionCount, send);
|
RW(containerItem.actionCount, send);
|
||||||
|
|
||||||
if (!send)
|
if (!send)
|
||||||
|
|
Loading…
Reference in a new issue