From 08ea5163c4705afbfb7f404b4a319cdc02759958 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Mon, 24 Oct 2016 11:26:31 +0300 Subject: [PATCH] Add and implement ID_WORLD_OBJECT_UNLOCK --- apps/openmw-mp/Networking.cpp | 17 ++++++++++++++ apps/openmw/mwmp/Networking.cpp | 21 ++++++++++++++++++ components/CMakeLists.txt | 2 +- .../Controllers/WorldPacketController.cpp | 6 +++-- components/openmw-mp/NetworkMessages.hpp | 3 ++- .../Packets/World/PacketObjectUnlock.cpp | 22 +++++++++++++++++++ .../Packets/World/PacketObjectUnlock.hpp | 17 ++++++++++++++ 7 files changed, 84 insertions(+), 4 deletions(-) create mode 100644 components/openmw-mp/Packets/World/PacketObjectUnlock.cpp create mode 100644 components/openmw-mp/Packets/World/PacketObjectUnlock.hpp diff --git a/apps/openmw-mp/Networking.cpp b/apps/openmw-mp/Networking.cpp index 637ed49ce..4c9d37eb4 100644 --- a/apps/openmw-mp/Networking.cpp +++ b/apps/openmw-mp/Networking.cpp @@ -410,6 +410,23 @@ void Networking::ProcessWorldPacket(RakNet::Packet *packet) break; } + case ID_WORLD_OBJECT_UNLOCK: + { + LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_WORLD_OBJECT_UNLOCK from %s", + player->Npc()->mName.c_str()); + + myPacket->Read(event); + + LOG_APPEND(Log::LOG_WARN, "- cellRef: %s, %i\n- cell: %s", + event->cellRef.mRefID.c_str(), + event->cellRef.mRefNum.mIndex, + event->cell.getDescription().c_str()); + + myPacket->Send(event, true); + + break; + } + default: LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Unhandled WorldPacket with identifier %i has arrived", packet->data[0]); diff --git a/apps/openmw/mwmp/Networking.cpp b/apps/openmw/mwmp/Networking.cpp index a48380b5c..1d2300b31 100644 --- a/apps/openmw/mwmp/Networking.cpp +++ b/apps/openmw/mwmp/Networking.cpp @@ -725,6 +725,27 @@ void Networking::ProcessWorldPacket(RakNet::Packet *packet) break; } + case ID_WORLD_OBJECT_UNLOCK: + { + LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "%s", "Received ID_WORLD_OBJECT_UNLOCK"); + LOG_APPEND(Log::LOG_WARN, "- cellRef: %s, %i\n- cell: %s", + event->cellRef.mRefID.c_str(), + event->cellRef.mRefNum.mIndex, + event->cell.getDescription().c_str()); + + MWWorld::Ptr ptrFound = ptrCellStore->searchByRefNum(event->cellRef.mRefNum); + + if (ptrFound) + { + LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Found %s, %i", + ptrFound.getCellRef().getRefId().c_str(), + ptrFound.getCellRef().getRefNum()); + + ptrFound.getClass().unlock(ptrFound); + } + + break; + } default: LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Unhandled WorldPacket with identifier %i has arrived", packet->data[0]); diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index fa0a49395..8f66f782d 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -157,7 +157,7 @@ add_component_dir (openmw-mp Packets/Player/PacketHandshake Packets/Player/PacketGUIBoxes Packets/Player/PacketClass Packets/Player/PacketTime Packets/Player/PacketInventory - Packets/World/PacketObjectDelete Packets/World/PacketObjectPlace) + Packets/World/PacketObjectDelete Packets/World/PacketObjectPlace Packets/World/PacketObjectUnlock) add_component_dir (fallback fallback validate diff --git a/components/openmw-mp/Controllers/WorldPacketController.cpp b/components/openmw-mp/Controllers/WorldPacketController.cpp index 119c0b581..effccde9f 100644 --- a/components/openmw-mp/Controllers/WorldPacketController.cpp +++ b/components/openmw-mp/Controllers/WorldPacketController.cpp @@ -2,8 +2,9 @@ #include #include -#include "../Packets/World/PacketObjectPlace.hpp" #include "../Packets/World/PacketObjectDelete.hpp" +#include "../Packets/World/PacketObjectPlace.hpp" +#include "../Packets/World/PacketObjectUnlock.hpp" #include "WorldPacketController.hpp" @@ -17,8 +18,9 @@ inline void AddPacket(mwmp::WorldPacketController::packets_t *packets, RakNet::R mwmp::WorldPacketController::WorldPacketController(RakNet::RakPeerInterface *peer) { - AddPacket(&packets, peer); AddPacket(&packets, peer); + AddPacket(&packets, peer); + AddPacket(&packets, peer); } diff --git a/components/openmw-mp/NetworkMessages.hpp b/components/openmw-mp/NetworkMessages.hpp index a53ed59c1..17a5e5d80 100644 --- a/components/openmw-mp/NetworkMessages.hpp +++ b/components/openmw-mp/NetworkMessages.hpp @@ -34,7 +34,8 @@ enum GameMessages ID_GAME_INVENTORY, ID_WORLD_OBJECT_PLACE, - ID_WORLD_OBJECT_DELETE + ID_WORLD_OBJECT_DELETE, + ID_WORLD_OBJECT_UNLOCK }; diff --git a/components/openmw-mp/Packets/World/PacketObjectUnlock.cpp b/components/openmw-mp/Packets/World/PacketObjectUnlock.cpp new file mode 100644 index 000000000..88e07eafa --- /dev/null +++ b/components/openmw-mp/Packets/World/PacketObjectUnlock.cpp @@ -0,0 +1,22 @@ +#include +#include "PacketObjectUnlock.hpp" + +using namespace mwmp; + +PacketObjectUnlock::PacketObjectUnlock(RakNet::RakPeerInterface *peer) : WorldPacket(peer) +{ + packetID = ID_WORLD_OBJECT_UNLOCK; +} + +void PacketObjectUnlock::Packet(RakNet::BitStream *bs, WorldEvent *event, bool send) +{ + WorldPacket::Packet(bs, event, send); + + RW(event->cellRef.mRefID, send); + RW(event->cellRef.mRefNum.mIndex, send); + + RW(event->cell.mData.mFlags, send); + RW(event->cell.mData.mX, send); + RW(event->cell.mData.mY, send); + RW(event->cell.mName, send); +} diff --git a/components/openmw-mp/Packets/World/PacketObjectUnlock.hpp b/components/openmw-mp/Packets/World/PacketObjectUnlock.hpp new file mode 100644 index 000000000..dec44f18f --- /dev/null +++ b/components/openmw-mp/Packets/World/PacketObjectUnlock.hpp @@ -0,0 +1,17 @@ +#ifndef OPENMW_PACKETOBJECTUNLOCK_HPP +#define OPENMW_PACKETOBJECTUNLOCK_HPP + +#include + +namespace mwmp +{ + class PacketObjectUnlock : public WorldPacket + { + public: + PacketObjectUnlock(RakNet::RakPeerInterface *peer); + + virtual void Packet(RakNet::BitStream *bs, WorldEvent *event, bool send); + }; +} + +#endif //OPENMW_PACKETOBJECTUNLOCK_HPP