From 5894ffae7d0c1abf0bbdb418c17dc9d62c88f1c2 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Wed, 17 Jan 2018 11:01:31 +0200 Subject: [PATCH] [Client] Ignore dynamic object placements or spawns in packets --- apps/openmw/mwgui/alchemywindow.cpp | 2 +- apps/openmw/mwmp/WorldEvent.cpp | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/alchemywindow.cpp b/apps/openmw/mwgui/alchemywindow.cpp index 500115f83..5557e7b0d 100644 --- a/apps/openmw/mwgui/alchemywindow.cpp +++ b/apps/openmw/mwgui/alchemywindow.cpp @@ -97,7 +97,7 @@ namespace MWGui Include a messagebox notifying players that player-made potions are not synced yet */ - MWBase::Environment::get().getWindowManager()->messageBox("Player-made potions are not synchronized in multiplayer yet and they will not show up for other players."); + MWBase::Environment::get().getWindowManager()->messageBox("Player-made potions are not synchronized in multiplayer yet and they will not show up for the server or other players."); /* End of tes3mp addition */ diff --git a/apps/openmw/mwmp/WorldEvent.cpp b/apps/openmw/mwmp/WorldEvent.cpp index 07e3f4534..3ba14ef2b 100644 --- a/apps/openmw/mwmp/WorldEvent.cpp +++ b/apps/openmw/mwmp/WorldEvent.cpp @@ -83,6 +83,9 @@ void WorldEvent::editContainers(MWWorld::CellStore* cellStore) MWWorld::Ptr ownerPtr = MWBase::Environment::get().getWorld()->getPlayerPtr(); for (const auto &containerItem : worldObject.containerItems) { + if (containerItem.refId.find("$dynamic") != string::npos) + continue; + if (action == BaseEvent::ADD || action == BaseEvent::SET) { // Create a ManualRef to be able to set item charge @@ -160,6 +163,10 @@ void WorldEvent::placeObjects(MWWorld::CellStore* cellStore) LOG_APPEND(Log::LOG_VERBOSE, "- cellRef: %s, %i, %i, count: %i, charge: %i, enchantmentCharge: %i", worldObject.refId.c_str(), worldObject.refNumIndex, worldObject.mpNum, worldObject.count, worldObject.charge, worldObject.enchantmentCharge); + // Ignore generic dynamic refIds because they could be anything on other clients + if (worldObject.refId.find("$dynamic") != string::npos) + continue; + MWWorld::Ptr ptrFound = cellStore->searchExact(0, worldObject.mpNum); // Only create this object if it doesn't already exist @@ -195,6 +202,10 @@ void WorldEvent::spawnObjects(MWWorld::CellStore* cellStore) LOG_APPEND(Log::LOG_VERBOSE, "- cellRef: %s, %i, %i", worldObject.refId.c_str(), worldObject.refNumIndex, worldObject.mpNum); + // Ignore generic dynamic refIds because they could be anything on other clients + if (worldObject.refId.find("$dynamic") != string::npos) + continue; + MWWorld::Ptr ptrFound = cellStore->searchExact(0, worldObject.mpNum); // Only create this object if it doesn't already exist @@ -599,6 +610,12 @@ void WorldEvent::playVideo() void WorldEvent::addObjectPlace(const MWWorld::Ptr& ptr) { + if (ptr.getCellRef().getRefId().find("$dynamic") != string::npos) + { + MWBase::Environment::get().getWindowManager()->messageBox("You're trying to place a custom item, but those are not synchronized in multiplayer yet."); + return; + } + cell = *ptr.getCell()->getCell(); mwmp::WorldObject worldObject; @@ -624,6 +641,12 @@ void WorldEvent::addObjectPlace(const MWWorld::Ptr& ptr) void WorldEvent::addObjectSpawn(const MWWorld::Ptr& ptr) { + if (ptr.getCellRef().getRefId().find("$dynamic") != string::npos) + { + MWBase::Environment::get().getWindowManager()->messageBox("You're trying to spawn a custom object, but those are not synchronized in multiplayer yet."); + return; + } + cell = *ptr.getCell()->getCell(); mwmp::WorldObject worldObject; @@ -821,6 +844,9 @@ void WorldEvent::addScriptGlobalShort(std::string varName, int shortVal) void WorldEvent::sendObjectPlace() { + if (worldObjects.size() == 0) + return; + LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_OBJECT_PLACE about %s", cell.getDescription().c_str()); for (const auto &worldObject : worldObjects) @@ -832,6 +858,9 @@ void WorldEvent::sendObjectPlace() void WorldEvent::sendObjectSpawn() { + if (worldObjects.size() == 0) + return; + LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_OBJECT_SPAWN about %s", cell.getDescription().c_str()); for (const auto &worldObject : worldObjects)