forked from mirror/openmw-tes3mp
[General] Send charge and goldValue in ID_CONTAINER
This commit is contained in:
parent
e703dd42aa
commit
3614b21e10
4 changed files with 46 additions and 9 deletions
|
@ -110,9 +110,14 @@ namespace MWGui
|
|||
worldObject.refNumIndex = mPtr.getCellRef().getRefNum().mIndex;
|
||||
event->addObject(worldObject);
|
||||
|
||||
MWWorld::Ptr itemPtr = mModel->getItem(mSelectedItem).mBase;
|
||||
|
||||
mwmp::ContainerItem containerItem;
|
||||
containerItem.refId = mModel->getItem(mSelectedItem).mBase.getCellRef().getRefId();
|
||||
containerItem.count = count;
|
||||
containerItem.refId =itemPtr.getCellRef().getRefId();
|
||||
containerItem.count = itemPtr.getRefData().getCount();
|
||||
containerItem.charge = itemPtr.getCellRef().getCharge();
|
||||
containerItem.goldValue = itemPtr.getCellRef().getGoldValue();
|
||||
containerItem.actionCount = count;
|
||||
event->addContainerItem(containerItem);
|
||||
event->containerChanges.action = mwmp::ContainerChanges::REMOVE;
|
||||
|
||||
|
@ -166,6 +171,8 @@ namespace MWGui
|
|||
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();
|
||||
event->addContainerItem(containerItem);
|
||||
event->containerChanges.action = mwmp::ContainerChanges::ADD;
|
||||
|
||||
|
|
|
@ -75,15 +75,40 @@ void WorldEvent::editContainer(MWWorld::CellStore* cellStore)
|
|||
|
||||
for (unsigned int i = 0; i < containerChanges.count; i++)
|
||||
{
|
||||
ContainerItem item = containerChanges.items.at(i);
|
||||
ContainerItem containerItem = containerChanges.items.at(i);
|
||||
|
||||
if (action == ContainerChanges::ADD || action == ContainerChanges::SET)
|
||||
{
|
||||
containerStore.add(item.refId, item.count, mwmp::Players::getPlayer(guid)->getPtr());
|
||||
// Create a ManualRef to be able to set item charge
|
||||
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), containerItem.refId, 1);
|
||||
MWWorld::Ptr newPtr = ref.getPtr();
|
||||
|
||||
if (containerItem.count > 1)
|
||||
newPtr.getRefData().setCount(containerItem.count);
|
||||
|
||||
if (containerItem.charge > -1)
|
||||
newPtr.getCellRef().setCharge(containerItem.charge);
|
||||
|
||||
newPtr.getCellRef().setGoldValue(containerItem.goldValue);
|
||||
|
||||
containerStore.add(newPtr, containerItem.count, mwmp::Players::getPlayer(guid)->getPtr(), true);
|
||||
}
|
||||
else if (action == ContainerChanges::REMOVE)
|
||||
{
|
||||
containerStore.remove(item.refId, item.count, mwmp::Players::getPlayer(guid)->getPtr());
|
||||
// We have to find the right item ourselves because ContainerStore has no method
|
||||
// accounting for charge
|
||||
for (MWWorld::ContainerStoreIterator iter(containerStore.begin()); iter != containerStore.end(); ++iter)
|
||||
{
|
||||
if (Misc::StringUtils::ciEqual(iter->getCellRef().getRefId(), containerItem.refId))
|
||||
{
|
||||
if (iter->getCellRef().getCharge() == containerItem.charge &&
|
||||
iter->getCellRef().getGoldValue() == containerItem.goldValue &&
|
||||
iter->getRefData().getCount() == containerItem.count)
|
||||
{
|
||||
containerStore.remove(*iter, containerItem.actionCount, mwmp::Players::getPlayer(guid)->getPtr());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,7 +144,6 @@ void WorldEvent::placeObjects(MWWorld::CellStore* cellStore)
|
|||
worldObject.count);
|
||||
|
||||
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), worldObject.refId, 1);
|
||||
|
||||
MWWorld::Ptr newPtr = ref.getPtr();
|
||||
|
||||
if (worldObject.charge > -1)
|
||||
|
|
|
@ -11,8 +11,8 @@ namespace mwmp
|
|||
{
|
||||
std::string refId;
|
||||
int refNumIndex;
|
||||
int charge;
|
||||
int count;
|
||||
int charge;
|
||||
int goldValue;
|
||||
ESM::Position pos;
|
||||
|
||||
|
@ -36,11 +36,14 @@ namespace mwmp
|
|||
{
|
||||
std::string refId;
|
||||
int count;
|
||||
int health;
|
||||
int charge;
|
||||
int goldValue;
|
||||
|
||||
int actionCount;
|
||||
|
||||
inline bool operator==(const ContainerItem& rhs)
|
||||
{
|
||||
return refId == rhs.refId && count == rhs.count && health == rhs.health;
|
||||
return refId == rhs.refId && count == rhs.count && charge == rhs.charge && goldValue && rhs.goldValue;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -62,6 +62,9 @@ void PacketContainer::Packet(RakNet::BitStream *bs, BaseEvent *event, bool send)
|
|||
|
||||
RW(containerItem.refId, send);
|
||||
RW(containerItem.count, send);
|
||||
RW(containerItem.charge, send);
|
||||
RW(containerItem.goldValue, send);
|
||||
RW(containerItem.actionCount, send);
|
||||
|
||||
if (!send)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue