diff --git a/apps/openmw/mwgui/container.cpp b/apps/openmw/mwgui/container.cpp index f949f6cb2..fdd0bae52 100644 --- a/apps/openmw/mwgui/container.cpp +++ b/apps/openmw/mwgui/container.cpp @@ -299,6 +299,26 @@ namespace MWGui } MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Container); + + // Added by tes3mp + mwmp::LocalEvent *event = mwmp::Main::get().getNetworking()->createLocalEvent(); + event->cell = *mPtr.getCell()->getCell(); + + mwmp::WorldObject worldObject; + worldObject.refId = mPtr.getCellRef().getRefId(); + worldObject.refNumIndex = mPtr.getCellRef().getRefNum().mIndex; + event->addObject(worldObject); + event->containerChanges.action = mwmp::ContainerChanges::SET; + + mwmp::Main::get().getNetworking()->getWorldPacket(ID_CONTAINER)->Send(event); + + LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_CONTAINER about\n- Ptr cellRef: %s, %i\n- cell: %s\n- item: %s, %i", + worldObject.refId.c_str(), + worldObject.refNumIndex, + event->cell.getDescription().c_str()); + + delete event; + event = NULL; } } diff --git a/apps/openmw/mwmp/LocalEvent.cpp b/apps/openmw/mwmp/LocalEvent.cpp index 7aa31eda6..f06afb047 100644 --- a/apps/openmw/mwmp/LocalEvent.cpp +++ b/apps/openmw/mwmp/LocalEvent.cpp @@ -67,16 +67,21 @@ void LocalEvent::editContainer(MWWorld::CellStore* cellStore) ptrFound.getCellRef().getRefNum()); MWWorld::ContainerStore& containerStore = ptrFound.getClass().getContainerStore(ptrFound); + int action = containerChanges.action; + + // If we are setting the entire contents, clear the current ones + if (action == ContainerChanges::SET) + containerStore.clear(); for (unsigned int i = 0; i < containerChanges.count; i++) { ContainerItem item = containerChanges.items.at(i); - if (containerChanges.action == ContainerChanges::ADD) + if (action == ContainerChanges::ADD || action == ContainerChanges::SET) { containerStore.add(item.refId, item.count, mwmp::Players::getPlayer(guid)->getPtr()); } - else if (containerChanges.action == ContainerChanges::REMOVE) + else if (action == ContainerChanges::REMOVE) { containerStore.remove(item.refId, item.count, mwmp::Players::getPlayer(guid)->getPtr()); }