From b6111d16cc9e50f0bf6fb9e993abe2d53e943062 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Mon, 24 Oct 2016 17:52:19 +0300 Subject: [PATCH] Add and implement ID_WORLD_VIDEO_PLAY --- apps/openmw-mp/Networking.cpp | 16 ++++++++++++++++ apps/openmw/mwmp/Networking.cpp | 15 +++++++++++++++ components/CMakeLists.txt | 2 +- components/openmw-mp/Base/WorldEvent.hpp | 3 +++ .../Controllers/WorldPacketController.cpp | 2 ++ components/openmw-mp/NetworkMessages.hpp | 4 +++- .../openmw-mp/Packets/World/PacketVideoPlay.cpp | 17 +++++++++++++++++ .../openmw-mp/Packets/World/PacketVideoPlay.hpp | 17 +++++++++++++++++ 8 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 components/openmw-mp/Packets/World/PacketVideoPlay.cpp create mode 100644 components/openmw-mp/Packets/World/PacketVideoPlay.hpp diff --git a/apps/openmw-mp/Networking.cpp b/apps/openmw-mp/Networking.cpp index 1dbf11417..9d9be874b 100644 --- a/apps/openmw-mp/Networking.cpp +++ b/apps/openmw-mp/Networking.cpp @@ -444,6 +444,22 @@ void Networking::ProcessWorldPacket(RakNet::Packet *packet) break; } + case ID_WORLD_VIDEO_PLAY: + { + LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_WORLD_VIDEO_PLAY from %s", + player->Npc()->mName.c_str()); + + myPacket->Read(event); + + LOG_APPEND(Log::LOG_WARN, "- video: %s\n- allowSkipping: %s", + event->video.c_str(), + event->allowSkipping ? "true" : "false"); + + 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 4a3f93d65..031e5eae7 100644 --- a/apps/openmw/mwmp/Networking.cpp +++ b/apps/openmw/mwmp/Networking.cpp @@ -6,13 +6,17 @@ #include #include #include + #include #include +#include + #include #include #include #include #include + #include #include "Networking.hpp" #include "../mwstate/statemanagerimp.hpp" @@ -763,6 +767,17 @@ void Networking::ProcessWorldPacket(RakNet::Packet *packet) break; } + case ID_WORLD_VIDEO_PLAY: + { + LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "%s", "Received ID_WORLD_VIDEO_PLAY"); + LOG_APPEND(Log::LOG_WARN, "- video: %s\n- allowSkipping: %s", + event->video.c_str(), + event->allowSkipping ? "true" : "false"); + + MWBase::Environment::get().getWindowManager()->playVideo(event->video, event->allowSkipping); + + 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 f2e8e559a..8cd070f45 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -158,7 +158,7 @@ add_component_dir (openmw-mp Packets/Player/PacketTime Packets/Player/PacketInventory Packets/World/PacketObjectDelete Packets/World/PacketObjectPlace Packets/World/PacketObjectLock - Packets/World/PacketObjectUnlock) + Packets/World/PacketObjectUnlock Packets/World/PacketVideoPlay) add_component_dir (fallback fallback validate diff --git a/components/openmw-mp/Base/WorldEvent.hpp b/components/openmw-mp/Base/WorldEvent.hpp index c8bdb8504..118ab5365 100644 --- a/components/openmw-mp/Base/WorldEvent.hpp +++ b/components/openmw-mp/Base/WorldEvent.hpp @@ -26,6 +26,9 @@ namespace mwmp ESM::Cell cell; ESM::CellRef cellRef; int lockLevel; + + std::string video; + bool allowSkipping; }; } diff --git a/components/openmw-mp/Controllers/WorldPacketController.cpp b/components/openmw-mp/Controllers/WorldPacketController.cpp index 3b35cfe7e..915df1d06 100644 --- a/components/openmw-mp/Controllers/WorldPacketController.cpp +++ b/components/openmw-mp/Controllers/WorldPacketController.cpp @@ -6,6 +6,7 @@ #include "../Packets/World/PacketObjectPlace.hpp" #include "../Packets/World/PacketObjectLock.hpp" #include "../Packets/World/PacketObjectUnlock.hpp" +#include "../Packets/World/PacketVideoPlay.hpp" #include "WorldPacketController.hpp" @@ -23,6 +24,7 @@ mwmp::WorldPacketController::WorldPacketController(RakNet::RakPeerInterface *pee 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 7ad46d8a8..bb459db6d 100644 --- a/components/openmw-mp/NetworkMessages.hpp +++ b/components/openmw-mp/NetworkMessages.hpp @@ -36,7 +36,9 @@ enum GameMessages ID_WORLD_OBJECT_PLACE, ID_WORLD_OBJECT_DELETE, ID_WORLD_OBJECT_LOCK, - ID_WORLD_OBJECT_UNLOCK + ID_WORLD_OBJECT_UNLOCK, + + ID_WORLD_VIDEO_PLAY }; diff --git a/components/openmw-mp/Packets/World/PacketVideoPlay.cpp b/components/openmw-mp/Packets/World/PacketVideoPlay.cpp new file mode 100644 index 000000000..9131224ce --- /dev/null +++ b/components/openmw-mp/Packets/World/PacketVideoPlay.cpp @@ -0,0 +1,17 @@ +#include +#include "PacketVideoPlay.hpp" + +using namespace mwmp; + +PacketVideoPlay::PacketVideoPlay(RakNet::RakPeerInterface *peer) : WorldPacket(peer) +{ + packetID = ID_WORLD_VIDEO_PLAY; +} + +void PacketVideoPlay::Packet(RakNet::BitStream *bs, WorldEvent *event, bool send) +{ + WorldPacket::Packet(bs, event, send); + + RW(event->video, send); + RW(event->allowSkipping, send); +} diff --git a/components/openmw-mp/Packets/World/PacketVideoPlay.hpp b/components/openmw-mp/Packets/World/PacketVideoPlay.hpp new file mode 100644 index 000000000..869864852 --- /dev/null +++ b/components/openmw-mp/Packets/World/PacketVideoPlay.hpp @@ -0,0 +1,17 @@ +#ifndef OPENMW_PACKETVIDEOPLAY_HPP +#define OPENMW_PACKETVIDEOPLAY_HPP + +#include + +namespace mwmp +{ + class PacketVideoPlay : public WorldPacket + { + public: + PacketVideoPlay(RakNet::RakPeerInterface *peer); + + virtual void Packet(RakNet::BitStream *bs, WorldEvent *event, bool send); + }; +} + +#endif //OPENMW_PACKETVIDEOPLAY_HPP