From f20f94a8867bd6931c5065539ceaaed7172a0a4a Mon Sep 17 00:00:00 2001 From: David Cernat Date: Mon, 25 Jun 2018 05:17:33 +0300 Subject: [PATCH 1/5] [Documentation] Update credits --- tes3mp-credits.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tes3mp-credits.md b/tes3mp-credits.md index 6811a9bc1..13c26712f 100644 --- a/tes3mp-credits.md +++ b/tes3mp-credits.md @@ -60,7 +60,10 @@ Special thanks (in alphabetical order) Lewis Sadlier Luc Keating Michael Zagar (Zoops) + Nac + NicholasAH (Jónas Hafthorsson) Olaxan + ppsychrite psi29a Rhiyo Scorcio From 914b79fcc9c903a20ea1c4f767022427e12883c9 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Tue, 26 Jun 2018 16:56:08 +0300 Subject: [PATCH 2/5] [General] Make it possible to check which placed objects have containers --- apps/openmw-mp/Script/Functions/Objects.cpp | 5 +++++ apps/openmw-mp/Script/Functions/Objects.hpp | 14 ++++++++++++++ apps/openmw/mwmp/ObjectList.cpp | 1 + components/openmw-mp/Base/BaseObject.hpp | 2 ++ .../openmw-mp/Packets/Object/PacketObjectPlace.cpp | 1 + 5 files changed, 23 insertions(+) diff --git a/apps/openmw-mp/Script/Functions/Objects.cpp b/apps/openmw-mp/Script/Functions/Objects.cpp index c8aa8a652..00f612bcb 100644 --- a/apps/openmw-mp/Script/Functions/Objects.cpp +++ b/apps/openmw-mp/Script/Functions/Objects.cpp @@ -178,6 +178,11 @@ int ObjectFunctions::GetContainerItemActionCount(unsigned int objectIndex, unsig .containerItems.at(itemIndex).actionCount; } +bool ObjectFunctions::DoesObjectHaveContainer(unsigned int i) noexcept +{ + return readObjectList->baseObjects.at(i).hasContainer; +} + void ObjectFunctions::SetObjectListCell(const char* cellDescription) noexcept { writeObjectList.cell = Utils::getCellFromDescription(cellDescription); diff --git a/apps/openmw-mp/Script/Functions/Objects.hpp b/apps/openmw-mp/Script/Functions/Objects.hpp index 47a3dffa5..ded7d5004 100644 --- a/apps/openmw-mp/Script/Functions/Objects.hpp +++ b/apps/openmw-mp/Script/Functions/Objects.hpp @@ -38,6 +38,8 @@ {"GetContainerItemEnchantmentCharge", ObjectFunctions::GetContainerItemEnchantmentCharge},\ {"GetContainerItemActionCount", ObjectFunctions::GetContainerItemActionCount},\ \ + {"DoesObjectHaveContainer", ObjectFunctions::DoesObjectHaveContainer},\ + \ {"SetObjectListCell", ObjectFunctions::SetObjectListCell},\ {"SetObjectListAction", ObjectFunctions::SetObjectListAction},\ {"SetObjectListConsoleCommand", ObjectFunctions::SetObjectListConsoleCommand},\ @@ -360,6 +362,18 @@ public: */ static int GetContainerItemActionCount(unsigned int objectIndex, unsigned int itemIndex) noexcept; + /** + * \brief Check whether the object at a certain index in the read object list's object + * changes has a container. + * + * Note: Only ObjectLists from ObjectPlace packets contain this information. Objects from + * received ObjectSpawn packets can always be assumed to have a container. + * + * \param i The index of the object. + * \return Whether the object has a container. + */ + static bool DoesObjectHaveContainer(unsigned int i) noexcept; + /** * \brief Set the cell of the temporary object list stored on the server. * diff --git a/apps/openmw/mwmp/ObjectList.cpp b/apps/openmw/mwmp/ObjectList.cpp index 72fc20572..aee3cf804 100644 --- a/apps/openmw/mwmp/ObjectList.cpp +++ b/apps/openmw/mwmp/ObjectList.cpp @@ -809,6 +809,7 @@ void ObjectList::addObjectPlace(const MWWorld::Ptr& ptr, bool droppedByPlayer) baseObject.charge = ptr.getCellRef().getCharge(); baseObject.enchantmentCharge = ptr.getCellRef().getEnchantmentCharge(); baseObject.droppedByPlayer = droppedByPlayer; + baseObject.hasContainer = ptr.getClass().hasContainerStore(ptr); // Make sure we send the RefData position instead of the CellRef one, because that's what // we actually see on this client diff --git a/components/openmw-mp/Base/BaseObject.hpp b/components/openmw-mp/Base/BaseObject.hpp index 02f40097b..349b1af3f 100644 --- a/components/openmw-mp/Base/BaseObject.hpp +++ b/components/openmw-mp/Base/BaseObject.hpp @@ -60,6 +60,8 @@ namespace mwmp Target master; bool hasMaster; + bool hasContainer; + std::vector containerItems; unsigned int containerItemCount; diff --git a/components/openmw-mp/Packets/Object/PacketObjectPlace.cpp b/components/openmw-mp/Packets/Object/PacketObjectPlace.cpp index 2c65bee41..a9d3820ac 100644 --- a/components/openmw-mp/Packets/Object/PacketObjectPlace.cpp +++ b/components/openmw-mp/Packets/Object/PacketObjectPlace.cpp @@ -18,4 +18,5 @@ void PacketObjectPlace::Object(BaseObject &baseObject, bool send) RW(baseObject.goldValue, send); RW(baseObject.position, send); RW(baseObject.droppedByPlayer, send); + RW(baseObject.hasContainer, send); } From fec500c4b04fa2d05e80ea3dfbc0971d0c12504d Mon Sep 17 00:00:00 2001 From: David Cernat Date: Tue, 26 Jun 2018 23:40:19 +0300 Subject: [PATCH 3/5] [Client] Reduce container debug spam by requiring VERBOSE logging for it --- apps/openmw/mwmp/ObjectList.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwmp/ObjectList.cpp b/apps/openmw/mwmp/ObjectList.cpp index aee3cf804..d323818d1 100644 --- a/apps/openmw/mwmp/ObjectList.cpp +++ b/apps/openmw/mwmp/ObjectList.cpp @@ -80,14 +80,14 @@ void ObjectList::addContainerItem(mwmp::BaseObject& baseObject, const MWWorld::P containerItem.enchantmentCharge = itemPtr.getCellRef().getEnchantmentCharge(); containerItem.actionCount = actionCount; - LOG_APPEND(Log::LOG_INFO, "--- Adding container item %s", containerItem.refId.c_str()); + LOG_APPEND(Log::LOG_VERBOSE, "--- Adding container item %s", containerItem.refId.c_str()); baseObject.containerItems.push_back(containerItem); } void ObjectList::addEntireContainer(const MWWorld::Ptr& ptr) { - LOG_APPEND(Log::LOG_INFO, "-- Adding entire container %s %i-%i", ptr.getCellRef().getRefId().c_str(), + LOG_APPEND(Log::LOG_VERBOSE, "-- Adding entire container %s %i-%i", ptr.getCellRef().getRefId().c_str(), ptr.getCellRef().getRefNum().mIndex, ptr.getCellRef().getMpNum()); MWWorld::ContainerStore& containerStore = ptr.getClass().getContainerStore(ptr); From 7060ff59c5852ded1ac82292ebc497bb3f906e20 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Wed, 27 Jun 2018 01:23:48 +0300 Subject: [PATCH 4/5] [Client] Enforce the default global map cell size in multiplayer --- apps/openmw/mwrender/globalmap.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwrender/globalmap.cpp b/apps/openmw/mwrender/globalmap.cpp index 7f088b94e..0f6b0d47a 100644 --- a/apps/openmw/mwrender/globalmap.cpp +++ b/apps/openmw/mwrender/globalmap.cpp @@ -253,7 +253,19 @@ namespace MWRender , mMinY(0), mMaxY(0) { - mCellSize = Settings::Manager::getInt("global map cell size", "Map"); + /* + Start of tes3mp change (major) + + We need map tiles to have consistent sizes, because the server's map + is gradually filled in through tiles sent by players via WorldMap packets + + As a result, the default value is enforced for the time being + */ + //mCellSize = Settings::Manager::getInt("global map cell size", "Map"); + mCellSize = 18; + /* + End of tes3mp change (major) + */ } GlobalMap::~GlobalMap() From 15bfa3007019ffe3cb61d39c0ea6ff3e359d745a Mon Sep 17 00:00:00 2001 From: David Cernat Date: Wed, 27 Jun 2018 02:00:16 +0300 Subject: [PATCH 5/5] [Server] Make it possible to resend received worldstates --- apps/openmw-mp/Script/Functions/Worldstate.cpp | 5 +++++ apps/openmw-mp/Script/Functions/Worldstate.hpp | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/apps/openmw-mp/Script/Functions/Worldstate.cpp b/apps/openmw-mp/Script/Functions/Worldstate.cpp index 825dff1f2..db90cea55 100644 --- a/apps/openmw-mp/Script/Functions/Worldstate.cpp +++ b/apps/openmw-mp/Script/Functions/Worldstate.cpp @@ -18,6 +18,11 @@ void WorldstateFunctions::ReadLastWorldstate() noexcept readWorldstate = mwmp::Networking::getPtr()->getLastWorldstate(); } +void WorldstateFunctions::CopyLastWorldstateToStore() noexcept +{ + writeWorldstate = *readWorldstate; +} + void WorldstateFunctions::ClearMapChanges() noexcept { writeWorldstate.mapChanges.mapTiles.clear(); diff --git a/apps/openmw-mp/Script/Functions/Worldstate.hpp b/apps/openmw-mp/Script/Functions/Worldstate.hpp index 7f19de142..e14bf5776 100644 --- a/apps/openmw-mp/Script/Functions/Worldstate.hpp +++ b/apps/openmw-mp/Script/Functions/Worldstate.hpp @@ -6,6 +6,8 @@ #define WORLDSTATEAPI \ {"ReadLastWorldstate", WorldstateFunctions::ReadLastWorldstate},\ \ + {"CopyLastWorldstateToStore", WorldstateFunctions::CopyLastWorldstateToStore},\ + \ {"ClearMapChanges", WorldstateFunctions::ClearMapChanges},\ \ {"GetMapChangesSize", WorldstateFunctions::GetMapChangesSize},\ @@ -43,6 +45,15 @@ public: */ static void ReadLastWorldstate() noexcept; + /** + * \brief Take the contents of the read-only worldstate last received by the + * server from a player and move its contents to the stored worldstate + * that can be sent by the server. + * + * \return void + */ + static void CopyLastWorldstateToStore() noexcept; + /** * \brief Clear the map changes for the write-only worldstate. *