diff --git a/apps/openmw-mp/Networking.cpp b/apps/openmw-mp/Networking.cpp index 651ef393c..af69ecfda 100644 --- a/apps/openmw-mp/Networking.cpp +++ b/apps/openmw-mp/Networking.cpp @@ -27,6 +27,8 @@ using namespace std; Networking *Networking::sThis = 0; +static int currentMpNum = 0; + Networking::Networking(RakNet::RakPeerInterface *peer) { sThis = this; @@ -288,6 +290,22 @@ BaseEvent *Networking::getLastEvent() return &baseEvent; } +int Networking::getCurrentMpNum() +{ + return currentMpNum; +} + +void Networking::setCurrentMpNum(int value) +{ + currentMpNum = value; +} + +int Networking::getNextMpNum() +{ + currentMpNum++; + return currentMpNum; +} + const Networking &Networking::get() { return *sThis; diff --git a/apps/openmw-mp/Networking.hpp b/apps/openmw-mp/Networking.hpp index 286f1a602..bc556c946 100644 --- a/apps/openmw-mp/Networking.hpp +++ b/apps/openmw-mp/Networking.hpp @@ -38,6 +38,10 @@ namespace mwmp WorldPacketController *getWorldController() const; BaseEvent *getLastEvent(); + int getCurrentMpNum(); + void setCurrentMpNum(int value); + int getNextMpNum(); + MasterClient *getMasterClient(); void InitQuery(std::string queryAddr, unsigned short queryPort, std::string serverAddr, unsigned short serverPort); void setServerPassword(std::string passw) noexcept; diff --git a/apps/openmw-mp/processors/world/ProcessorObjectPlace.hpp b/apps/openmw-mp/processors/world/ProcessorObjectPlace.hpp index d9b473eab..51271e9fd 100644 --- a/apps/openmw-mp/processors/world/ProcessorObjectPlace.hpp +++ b/apps/openmw-mp/processors/world/ProcessorObjectPlace.hpp @@ -6,6 +6,7 @@ #define OPENMW_PROCESSOROBJECTPLACE_HPP #include "apps/openmw-mp/WorldProcessor.hpp" +#include namespace mwmp { @@ -19,6 +20,11 @@ namespace mwmp void Do(WorldPacket &packet, Player &player, BaseEvent &event) override { + for (unsigned int i = 0; i < event.objectChanges.count; i++) + { + event.objectChanges.objects.at(i).mpNum = mwmp::Networking::getPtr()->getNextMpNum(); + } + packet.Send(true); Script::Call(player.getId(), event.cell.getDescription().c_str()); diff --git a/apps/openmw/mwmp/WorldEvent.cpp b/apps/openmw/mwmp/WorldEvent.cpp index 4451afe8f..a65cd3e8e 100644 --- a/apps/openmw/mwmp/WorldEvent.cpp +++ b/apps/openmw/mwmp/WorldEvent.cpp @@ -162,8 +162,8 @@ void WorldEvent::placeObjects(MWWorld::CellStore* cellStore) { worldObject = objectChanges.objects.at(i); - LOG_APPEND(Log::LOG_VERBOSE, "- cellRef: %s, %i\n- charge: %i\n- count: %i", worldObject.refId.c_str(), - worldObject.refNumIndex, worldObject.charge, worldObject.count); + LOG_APPEND(Log::LOG_VERBOSE, "- cellRef: %s, %i, %i\n- charge: %i\n- count: %i", worldObject.refId.c_str(), + worldObject.refNumIndex, worldObject.mpNum, worldObject.charge, worldObject.count); MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), worldObject.refId, 1); MWWorld::Ptr newPtr = ref.getPtr(); @@ -174,6 +174,8 @@ void WorldEvent::placeObjects(MWWorld::CellStore* cellStore) if (worldObject.count > 1) newPtr.getRefData().setCount(worldObject.count); + newPtr.getCellRef().setMpNum(worldObject.mpNum); + newPtr.getCellRef().setGoldValue(worldObject.goldValue); newPtr = MWBase::Environment::get().getWorld()->placeObject(newPtr, cellStore, worldObject.pos); } diff --git a/components/openmw-mp/Base/BaseEvent.hpp b/components/openmw-mp/Base/BaseEvent.hpp index 54d6484fc..a5f4a4dcd 100644 --- a/components/openmw-mp/Base/BaseEvent.hpp +++ b/components/openmw-mp/Base/BaseEvent.hpp @@ -31,6 +31,7 @@ namespace mwmp { std::string refId; int refNumIndex; + int mpNum; int count; int charge; int goldValue; diff --git a/components/openmw-mp/Packets/World/PacketObjectPlace.cpp b/components/openmw-mp/Packets/World/PacketObjectPlace.cpp index fb12e6927..c839c38a3 100644 --- a/components/openmw-mp/Packets/World/PacketObjectPlace.cpp +++ b/components/openmw-mp/Packets/World/PacketObjectPlace.cpp @@ -35,6 +35,7 @@ void PacketObjectPlace::Packet(RakNet::BitStream *bs, bool send) RW(worldObject.refId, send); RW(worldObject.refNumIndex, send); + RW(worldObject.mpNum, send); RW(worldObject.count, send); RW(worldObject.charge, send); RW(worldObject.goldValue, send);