Skip to content

An OpenMW mod that lets you play the whole Elder Scrolls III: Morrowind as a top-down isometric game — with full online co-op or MMO modes.

C++

Placed objects keyed by mpNum alone, so a dropped item can be picked up again

Claude0c577756e5de
diff --git a/apps/openmw-mp/processors/object/ProcessorObjectPlace.hpp b/apps/openmw-mp/processors/object/ProcessorObjectPlace.hpp
index 0442e2e..b94e5cf 100644
--- a/apps/openmw-mp/processors/object/ProcessorObjectPlace.hpp
+++ b/apps/openmw-mp/processors/object/ProcessorObjectPlace.hpp
@@ -20,6 +20,9 @@ namespace mwmp
for (unsigned int i = 0; i < objectList.baseObjectCount; i++)
{
+ // A placed object is the server's own, known by its mpNum alone; a dropped item can still carry
+ // the refNum of the game-file reference it was picked up from, which clients drop once it has an mpNum
+ objectList.baseObjects.at(i).refNum = 0;
objectList.baseObjects.at(i).mpNum = mwmp::Networking::getPtr()->incrementMpNum();
}
diff --git a/apps/openmw/mwmp/ObjectList.cpp b/apps/openmw/mwmp/ObjectList.cpp
index e06046a..92a4342 100644
--- a/apps/openmw/mwmp/ObjectList.cpp
+++ b/apps/openmw/mwmp/ObjectList.cpp
@@ -1202,6 +1202,9 @@ void ObjectList::addObjectPlace(const MWWorld::Ptr& ptr, bool droppedByPlayer)
cell = ptr.getCell()->getCell()->getEsm3();
mwmp::BaseObject baseObject = getBaseObjectFromPtr(ptr);
+ // The server gives a placed object an mpNum of its own; don't keep the refNum of the game-file reference a
+ // dropped item was picked up from
+ baseObject.refNum = 0;
baseObject.charge = ptr.getCellRef().getCharge();
baseObject.enchantmentCharge = ptr.getCellRef().getEnchantmentCharge();
baseObject.soul = idString(ptr.getCellRef().getSoul());