From 46397a7dac9f3d2de47f659ad34ad7c91a16489c Mon Sep 17 00:00:00 2001 From: David Cernat Date: Thu, 27 Oct 2016 16:09:02 +0300 Subject: [PATCH] Add and implement ID_OBJECT_ANIM_PLAY --- apps/openmw-mp/Networking.cpp | 17 +++++++++++ apps/openmw/mwmp/Networking.cpp | 29 +++++++++++++++++-- components/CMakeLists.txt | 2 +- components/openmw-mp/Base/WorldEvent.hpp | 3 ++ .../Controllers/WorldPacketController.cpp | 2 ++ components/openmw-mp/NetworkMessages.hpp | 1 + .../Packets/World/PacketObjectAnimPlay.cpp | 25 ++++++++++++++++ .../Packets/World/PacketObjectAnimPlay.hpp | 17 +++++++++++ 8 files changed, 93 insertions(+), 3 deletions(-) create mode 100644 components/openmw-mp/Packets/World/PacketObjectAnimPlay.cpp create mode 100644 components/openmw-mp/Packets/World/PacketObjectAnimPlay.hpp diff --git a/apps/openmw-mp/Networking.cpp b/apps/openmw-mp/Networking.cpp index 155f1c55a..8f7299f58 100644 --- a/apps/openmw-mp/Networking.cpp +++ b/apps/openmw-mp/Networking.cpp @@ -495,6 +495,23 @@ void Networking::ProcessWorldPacket(RakNet::Packet *packet) break; } + case ID_OBJECT_ANIM_PLAY: + { + LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_ANIM_PLAY 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 962a4558b..36e9ca5cb 100644 --- a/apps/openmw/mwmp/Networking.cpp +++ b/apps/openmw/mwmp/Networking.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -811,7 +812,8 @@ void Networking::ProcessWorldPacket(RakNet::Packet *packet) ptrFound.getCellRef().getRefId().c_str(), ptrFound.getCellRef().getRefNum()); - MWBase::Environment::get().getWorld()->moveObject(ptrFound, event->pos.pos[0], event->pos.pos[1], event->pos.pos[2]); + MWBase::Environment::get().getWorld()->moveObject(ptrFound, + event->pos.pos[0], event->pos.pos[1], event->pos.pos[2]); } break; @@ -832,7 +834,30 @@ void Networking::ProcessWorldPacket(RakNet::Packet *packet) 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]); + MWBase::Environment::get().getWorld()->rotateObject(ptrFound, + event->pos.rot[0], event->pos.rot[1], event->pos.rot[2]); + } + + break; + } + case ID_OBJECT_ANIM_PLAY: + { + LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "%s", "Received ID_OBJECT_ANIM_PLAY"); + 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().getMechanicsManager()->playAnimationGroup(ptrFound, + event->animGroup, event->animMode, std::numeric_limits::max(), true); } break; diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 5295a6941..b67b5de03 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -159,7 +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/PacketObjectRotate Packets/World/PacketObjectAnimPlay Packets/World/PacketContainerAdd Packets/World/PacketContainerRemove Packets/World/PacketDoorActivate Packets/World/PacketVideoPlay diff --git a/components/openmw-mp/Base/WorldEvent.hpp b/components/openmw-mp/Base/WorldEvent.hpp index 4ba85cc62..480051b21 100644 --- a/components/openmw-mp/Base/WorldEvent.hpp +++ b/components/openmw-mp/Base/WorldEvent.hpp @@ -35,6 +35,9 @@ namespace mwmp std::string video; bool allowSkipping; + std::string animGroup; + int animMode; + int index; int shortVal; float floatVal; diff --git a/components/openmw-mp/Controllers/WorldPacketController.cpp b/components/openmw-mp/Controllers/WorldPacketController.cpp index 6f20953f2..661456d6d 100644 --- a/components/openmw-mp/Controllers/WorldPacketController.cpp +++ b/components/openmw-mp/Controllers/WorldPacketController.cpp @@ -9,6 +9,7 @@ #include "../Packets/World/PacketObjectScale.hpp" #include "../Packets/World/PacketObjectMove.hpp" #include "../Packets/World/PacketObjectRotate.hpp" +#include "../Packets/World/PacketObjectAnimPlay.hpp" #include "../Packets/World/PacketContainerAdd.hpp" #include "../Packets/World/PacketContainerRemove.hpp" @@ -39,6 +40,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 eb9e2c0d6..827564b33 100644 --- a/components/openmw-mp/NetworkMessages.hpp +++ b/components/openmw-mp/NetworkMessages.hpp @@ -40,6 +40,7 @@ enum GameMessages ID_OBJECT_SCALE, ID_OBJECT_MOVE, ID_OBJECT_ROTATE, + ID_OBJECT_ANIM_PLAY, ID_CONTAINER_ADD, ID_CONTAINER_REMOVE, diff --git a/components/openmw-mp/Packets/World/PacketObjectAnimPlay.cpp b/components/openmw-mp/Packets/World/PacketObjectAnimPlay.cpp new file mode 100644 index 000000000..d5599a35c --- /dev/null +++ b/components/openmw-mp/Packets/World/PacketObjectAnimPlay.cpp @@ -0,0 +1,25 @@ +#include +#include "PacketObjectAnimPlay.hpp" + +using namespace mwmp; + +PacketObjectAnimPlay::PacketObjectAnimPlay(RakNet::RakPeerInterface *peer) : WorldPacket(peer) +{ + packetID = ID_OBJECT_ANIM_PLAY; +} + +void PacketObjectAnimPlay::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->animGroup, send); + RW(event->animMode, send); +} diff --git a/components/openmw-mp/Packets/World/PacketObjectAnimPlay.hpp b/components/openmw-mp/Packets/World/PacketObjectAnimPlay.hpp new file mode 100644 index 000000000..02082c644 --- /dev/null +++ b/components/openmw-mp/Packets/World/PacketObjectAnimPlay.hpp @@ -0,0 +1,17 @@ +#ifndef OPENMW_PACKETOBJECTANIMPLAY_HPP +#define OPENMW_PACKETOBJECTANIMPLAY_HPP + +#include + +namespace mwmp +{ + class PacketObjectAnimPlay : public WorldPacket + { + public: + PacketObjectAnimPlay(RakNet::RakPeerInterface *peer); + + virtual void Packet(RakNet::BitStream *bs, WorldEvent *event, bool send); + }; +} + +#endif //OPENMW_PACKETOBJECTANIMPLAY_HPP