diff --git a/apps/openmw-mp/Networking.cpp b/apps/openmw-mp/Networking.cpp index b6485d803..f50de7524 100644 --- a/apps/openmw-mp/Networking.cpp +++ b/apps/openmw-mp/Networking.cpp @@ -478,6 +478,23 @@ void Networking::ProcessWorldPacket(RakNet::Packet *packet) break; } + case ID_OBJECT_ROTATE: + { + LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_ROTATE 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; + } + case ID_CONTAINER_ADD: { LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_CONTAINER_ADD from %s", diff --git a/apps/openmw/mwmp/Networking.cpp b/apps/openmw/mwmp/Networking.cpp index 0bda6e76e..5d9e294d6 100644 --- a/apps/openmw/mwmp/Networking.cpp +++ b/apps/openmw/mwmp/Networking.cpp @@ -814,6 +814,27 @@ void Networking::ProcessWorldPacket(RakNet::Packet *packet) break; } + case ID_OBJECT_ROTATE: + { + LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "%s", "Received ID_OBJECT_ROTATE"); + 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()); + + MWBase::Environment::get().getWorld()->rotateObject(ptrFound, event->pos.rot[0], event->pos.rot[1], event->pos.rot[2]); + } + + break; + } case ID_DOOR_ACTIVATE: { LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "%s", "Received ID_DOOR_ACTIVATE"); diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 89bc7a25a..91f4b42a0 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -159,6 +159,7 @@ add_component_dir (openmw-mp Packets/World/PacketObjectDelete Packets/World/PacketObjectPlace Packets/World/PacketObjectLock Packets/World/PacketObjectUnlock Packets/World/PacketObjectScale Packets/World/PacketObjectMove + Packets/World/PacketObjectRotate Packets/World/PacketContainerAdd Packets/World/PacketContainerRemove Packets/World/PacketDoorActivate Packets/World/PacketVideoPlay) diff --git a/components/openmw-mp/Controllers/WorldPacketController.cpp b/components/openmw-mp/Controllers/WorldPacketController.cpp index eee51a3b3..2f4f9735c 100644 --- a/components/openmw-mp/Controllers/WorldPacketController.cpp +++ b/components/openmw-mp/Controllers/WorldPacketController.cpp @@ -8,6 +8,7 @@ #include "../Packets/World/PacketObjectUnlock.hpp" #include "../Packets/World/PacketObjectScale.hpp" #include "../Packets/World/PacketObjectMove.hpp" +#include "../Packets/World/PacketObjectRotate.hpp" #include "../Packets/World/PacketContainerAdd.hpp" #include "../Packets/World/PacketContainerRemove.hpp" @@ -32,6 +33,7 @@ mwmp::WorldPacketController::WorldPacketController(RakNet::RakPeerInterface *pee AddPacket(&packets, peer); AddPacket(&packets, 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 7780090ed..d0935d566 100644 --- a/components/openmw-mp/NetworkMessages.hpp +++ b/components/openmw-mp/NetworkMessages.hpp @@ -39,6 +39,7 @@ enum GameMessages ID_OBJECT_UNLOCK, ID_OBJECT_SCALE, ID_OBJECT_MOVE, + ID_OBJECT_ROTATE, ID_CONTAINER_ADD, ID_CONTAINER_REMOVE, diff --git a/components/openmw-mp/Packets/World/PacketObjectRotate.cpp b/components/openmw-mp/Packets/World/PacketObjectRotate.cpp new file mode 100644 index 000000000..7e4cef098 --- /dev/null +++ b/components/openmw-mp/Packets/World/PacketObjectRotate.cpp @@ -0,0 +1,26 @@ +#include +#include "PacketObjectRotate.hpp" + +using namespace mwmp; + +PacketObjectRotate::PacketObjectRotate(RakNet::RakPeerInterface *peer) : WorldPacket(peer) +{ + packetID = ID_OBJECT_ROTATE; +} + +void PacketObjectRotate::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); + + RW(event->pos.rot[0], send); + RW(event->pos.rot[1], send); + RW(event->pos.rot[2], send); +} diff --git a/components/openmw-mp/Packets/World/PacketObjectRotate.hpp b/components/openmw-mp/Packets/World/PacketObjectRotate.hpp new file mode 100644 index 000000000..de772ef4c --- /dev/null +++ b/components/openmw-mp/Packets/World/PacketObjectRotate.hpp @@ -0,0 +1,17 @@ +#ifndef OPENMW_PACKETOBJECTROTATE_HPP +#define OPENMW_PACKETOBJECTROTATE_HPP + +#include + +namespace mwmp +{ + class PacketObjectRotate : public WorldPacket + { + public: + PacketObjectRotate(RakNet::RakPeerInterface *peer); + + virtual void Packet(RakNet::BitStream *bs, WorldEvent *event, bool send); + }; +} + +#endif //OPENMW_PACKETOBJECTROTATE_HPP