diff --git a/apps/openmw-mp/ProcessorInitializer.cpp b/apps/openmw-mp/ProcessorInitializer.cpp index 4e3c7c43c..ebf9fd18a 100644 --- a/apps/openmw-mp/ProcessorInitializer.cpp +++ b/apps/openmw-mp/ProcessorInitializer.cpp @@ -25,14 +25,17 @@ #include "processors/player/ProcessorGUIMessageBox.hpp" #include "processors/player/ProcessorPlayerCharClass.hpp" #include "WorldProcessor.hpp" +#include "processors/world/ProcessorActorList.hpp" +#include "processors/world/ProcessorActorAuthority.hpp" +#include "processors/world/ProcessorActorFrame.hpp" #include "processors/world/ProcessorContainer.hpp" #include "processors/world/ProcessorDoorState.hpp" #include "processors/world/ProcessorMusicPlay.hpp" #include "processors/world/ProcessorObjectAnimPlay.hpp" #include "processors/world/ProcessorObjectDelete.hpp" +#include "processors/world/ProcessorObjectPlace.hpp" #include "processors/world/ProcessorObjectLock.hpp" #include "processors/world/ProcessorObjectMove.hpp" -#include "processors/world/ProcessorObjectPlace.hpp" #include "processors/world/ProcessorObjectRotate.hpp" #include "processors/world/ProcessorObjectScale.hpp" #include "processors/world/ProcessorObjectUnlock.hpp" @@ -67,6 +70,9 @@ void ProcessorInitializer() PlayerProcessor::AddProcessor(new ProcessorGUIMessageBox()); PlayerProcessor::AddProcessor(new ProcessorPlayerCharClass()); + WorldProcessor::AddProcessor(new ProcessorActorList()); + WorldProcessor::AddProcessor(new ProcessorActorAuthority()); + WorldProcessor::AddProcessor(new ProcessorActorFrame()); WorldProcessor::AddProcessor(new ProcessorContainer()); WorldProcessor::AddProcessor(new ProcessorDoorState()); WorldProcessor::AddProcessor(new ProcessorMusicPlay()); diff --git a/apps/openmw-mp/Script/ScriptFunctions.hpp b/apps/openmw-mp/Script/ScriptFunctions.hpp index fcc5b2e86..24e17471d 100644 --- a/apps/openmw-mp/Script/ScriptFunctions.hpp +++ b/apps/openmw-mp/Script/ScriptFunctions.hpp @@ -121,6 +121,8 @@ public: {"OnPlayerInventoryChange", Function()}, {"OnPlayerSpellbookChange", Function()}, {"OnPlayerJournalChange", Function()}, + {"OnActorList", Function()}, + {"OnActorFrame", Function()}, {"OnObjectPlace", Function()}, {"OnObjectDelete", Function()}, {"OnObjectScale", Function()}, diff --git a/apps/openmw-mp/processors/world/ProcessorActorAuthority.hpp b/apps/openmw-mp/processors/world/ProcessorActorAuthority.hpp new file mode 100644 index 000000000..366faef9a --- /dev/null +++ b/apps/openmw-mp/processors/world/ProcessorActorAuthority.hpp @@ -0,0 +1,23 @@ +#ifndef OPENMW_PROCESSORACTORAUTHORITY_HPP +#define OPENMW_PROCESSORACTORAUTHORITY_HPP + +#include "apps/openmw-mp/WorldProcessor.hpp" + +namespace mwmp +{ + class ProcessorActorAuthority : public WorldProcessor + { + public: + ProcessorActorAuthority() + { + BPP_INIT(ID_ACTOR_AUTHORITY) + } + + void Do(WorldPacket &packet, Player &player, BaseEvent &event) override + { + packet.Send(true); + } + }; +} + +#endif //OPENMW_PROCESSORACTORAUTHORITY_HPP diff --git a/apps/openmw-mp/processors/world/ProcessorActorFrame.hpp b/apps/openmw-mp/processors/world/ProcessorActorFrame.hpp new file mode 100644 index 000000000..40acd03f0 --- /dev/null +++ b/apps/openmw-mp/processors/world/ProcessorActorFrame.hpp @@ -0,0 +1,25 @@ +#ifndef OPENMW_PROCESSORACTORFRAME_HPP +#define OPENMW_PROCESSORACTORFRAME_HPP + +#include "apps/openmw-mp/WorldProcessor.hpp" + +namespace mwmp +{ + class ProcessorActorFrame : public WorldProcessor + { + public: + ProcessorActorFrame() + { + BPP_INIT(ID_ACTOR_FRAME) + } + + void Do(WorldPacket &packet, Player &player, BaseEvent &event) override + { + packet.Send(true); + + Script::Call(player.getId(), event.cell.getDescription().c_str()); + } + }; +} + +#endif //OPENMW_PROCESSORACTORFRAME_HPP diff --git a/apps/openmw-mp/processors/world/ProcessorActorList.hpp b/apps/openmw-mp/processors/world/ProcessorActorList.hpp new file mode 100644 index 000000000..c2c6cb87c --- /dev/null +++ b/apps/openmw-mp/processors/world/ProcessorActorList.hpp @@ -0,0 +1,25 @@ +#ifndef OPENMW_PROCESSORACTORLIST_HPP +#define OPENMW_PROCESSORACTORLIST_HPP + +#include "apps/openmw-mp/WorldProcessor.hpp" + +namespace mwmp +{ + class ProcessorActorList : public WorldProcessor + { + public: + ProcessorActorList() + { + BPP_INIT(ID_ACTOR_LIST) + } + + void Do(WorldPacket &packet, Player &player, BaseEvent &event) override + { + packet.Send(true); + + Script::Call(player.getId(), event.cell.getDescription().c_str()); + } + }; +} + +#endif //OPENMW_PROCESSORACTORLIST_HPP diff --git a/apps/openmw/mwmp/Networking.cpp b/apps/openmw/mwmp/Networking.cpp index e8744dcff..a3019c8c8 100644 --- a/apps/openmw/mwmp/Networking.cpp +++ b/apps/openmw/mwmp/Networking.cpp @@ -840,6 +840,21 @@ void Networking::processWorldPacket(RakNet::Packet *packet) switch (packet->data[0]) { + case ID_ACTOR_LIST: + { + LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Received ID_ACTOR_LIST about %s", worldEvent.cell.getDescription().c_str()); + break; + } + case ID_ACTOR_AUTHORITY: + { + LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Received ID_ACTOR_AUTHORITY about %s", worldEvent.cell.getDescription().c_str()); + break; + } + case ID_ACTOR_FRAME: + { + LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Received ID_ACTOR_FRAME about %s", worldEvent.cell.getDescription().c_str()); + break; + } case ID_CONTAINER: { MWWorld::CellStore *ptrCellStore = Main::get().getWorldController()->getCell(worldEvent.cell); diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 9b952f109..9105875ad 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -165,6 +165,8 @@ add_component_dir (openmw-mp Packets/Player/PacketGUIBoxes Packets/Player/PacketTime + Packets/World/PacketActorList Packets/World/PacketActorAuthority Packets/World/PacketActorFrame + Packets/World/PacketObjectDelete Packets/World/PacketObjectPlace Packets/World/PacketObjectScale Packets/World/PacketObjectLock Packets/World/PacketObjectUnlock Packets/World/PacketObjectMove Packets/World/PacketObjectRotate Packets/World/PacketObjectAnimPlay diff --git a/components/openmw-mp/Controllers/WorldPacketController.cpp b/components/openmw-mp/Controllers/WorldPacketController.cpp index dece05a83..9ee8846c9 100644 --- a/components/openmw-mp/Controllers/WorldPacketController.cpp +++ b/components/openmw-mp/Controllers/WorldPacketController.cpp @@ -2,6 +2,10 @@ #include #include +#include "../Packets/World/PacketActorList.hpp" +#include "../Packets/World/PacketActorAuthority.hpp" +#include "../Packets/World/PacketActorFrame.hpp" + #include "../Packets/World/PacketObjectDelete.hpp" #include "../Packets/World/PacketObjectPlace.hpp" #include "../Packets/World/PacketObjectScale.hpp" @@ -33,6 +37,10 @@ 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); AddPacket(&packets, peer); AddPacket(&packets, peer); diff --git a/components/openmw-mp/NetworkMessages.hpp b/components/openmw-mp/NetworkMessages.hpp index 8182a7ada..cfd7e7afa 100644 --- a/components/openmw-mp/NetworkMessages.hpp +++ b/components/openmw-mp/NetworkMessages.hpp @@ -39,6 +39,10 @@ enum GameMessages ID_PLAYER_CELL_CHANGE, ID_PLAYER_CELL_STATE, + ID_ACTOR_LIST, + ID_ACTOR_AUTHORITY, + ID_ACTOR_FRAME, + ID_OBJECT_PLACE, ID_OBJECT_DELETE, ID_OBJECT_SCALE, diff --git a/components/openmw-mp/Packets/World/PacketActorAuthority.cpp b/components/openmw-mp/Packets/World/PacketActorAuthority.cpp new file mode 100644 index 000000000..65b33c96a --- /dev/null +++ b/components/openmw-mp/Packets/World/PacketActorAuthority.cpp @@ -0,0 +1,45 @@ +#include +#include "PacketActorAuthority.hpp" + +using namespace mwmp; + +PacketActorAuthority::PacketActorAuthority(RakNet::RakPeerInterface *peer) : WorldPacket(peer) +{ + packetID = ID_ACTOR_AUTHORITY; +} + +void PacketActorAuthority::Packet(RakNet::BitStream *bs, bool send) +{ + WorldPacket::Packet(bs, send); + + if (!send) + event->objectChanges.objects.clear(); + else + event->objectChanges.count = (unsigned int)(event->objectChanges.objects.size()); + + RW(event->objectChanges.count, send); + + RW(event->cell.mData.mFlags, send); + RW(event->cell.mData.mX, send); + RW(event->cell.mData.mY, send); + RW(event->cell.mName, send); + + WorldObject worldObject; + + for (unsigned int i = 0; i < event->objectChanges.count; i++) + { + if (send) + { + worldObject = event->objectChanges.objects.at(i); + } + + RW(worldObject.refId, send); + RW(worldObject.refNumIndex, send); + RW(worldObject.mpNum, send); + + if (!send) + { + event->objectChanges.objects.push_back(worldObject); + } + } +} diff --git a/components/openmw-mp/Packets/World/PacketActorAuthority.hpp b/components/openmw-mp/Packets/World/PacketActorAuthority.hpp new file mode 100644 index 000000000..f442d5ae2 --- /dev/null +++ b/components/openmw-mp/Packets/World/PacketActorAuthority.hpp @@ -0,0 +1,17 @@ +#ifndef OPENMW_PACKETACTORAUTHORITY_HPP +#define OPENMW_PACKETACTORAUTHORITY_HPP + +#include + +namespace mwmp +{ + class PacketActorAuthority : public WorldPacket + { + public: + PacketActorAuthority(RakNet::RakPeerInterface *peer); + + virtual void Packet(RakNet::BitStream *bs, bool send); + }; +} + +#endif //OPENMW_PACKETACTORAUTHORITY_HPP diff --git a/components/openmw-mp/Packets/World/PacketActorFrame.cpp b/components/openmw-mp/Packets/World/PacketActorFrame.cpp new file mode 100644 index 000000000..eb1271908 --- /dev/null +++ b/components/openmw-mp/Packets/World/PacketActorFrame.cpp @@ -0,0 +1,46 @@ +#include +#include "PacketActorFrame.hpp" + +using namespace mwmp; + +PacketActorFrame::PacketActorFrame(RakNet::RakPeerInterface *peer) : WorldPacket(peer) +{ + packetID = ID_ACTOR_FRAME; +} + +void PacketActorFrame::Packet(RakNet::BitStream *bs, bool send) +{ + WorldPacket::Packet(bs, send); + + if (!send) + event->objectChanges.objects.clear(); + else + event->objectChanges.count = (unsigned int)(event->objectChanges.objects.size()); + + RW(event->objectChanges.count, send); + + RW(event->cell.mData.mFlags, send); + RW(event->cell.mData.mX, send); + RW(event->cell.mData.mY, send); + RW(event->cell.mName, send); + + WorldObject worldObject; + + for (unsigned int i = 0; i < event->objectChanges.count; i++) + { + if (send) + { + worldObject = event->objectChanges.objects.at(i); + } + + RW(worldObject.refId, send); + RW(worldObject.refNumIndex, send); + RW(worldObject.mpNum, send); + RW(worldObject.pos, send); + + if (!send) + { + event->objectChanges.objects.push_back(worldObject); + } + } +} diff --git a/components/openmw-mp/Packets/World/PacketActorFrame.hpp b/components/openmw-mp/Packets/World/PacketActorFrame.hpp new file mode 100644 index 000000000..1961cccb9 --- /dev/null +++ b/components/openmw-mp/Packets/World/PacketActorFrame.hpp @@ -0,0 +1,17 @@ +#ifndef OPENMW_PACKETACTORFRAME_HPP +#define OPENMW_PACKETACTORFRAME_HPP + +#include + +namespace mwmp +{ + class PacketActorFrame : public WorldPacket + { + public: + PacketActorFrame(RakNet::RakPeerInterface *peer); + + virtual void Packet(RakNet::BitStream *bs, bool send); + }; +} + +#endif //OPENMW_PACKETACTORFRAME_HPP diff --git a/components/openmw-mp/Packets/World/PacketActorList.cpp b/components/openmw-mp/Packets/World/PacketActorList.cpp new file mode 100644 index 000000000..634d22822 --- /dev/null +++ b/components/openmw-mp/Packets/World/PacketActorList.cpp @@ -0,0 +1,45 @@ +#include +#include "PacketActorList.hpp" + +using namespace mwmp; + +PacketActorList::PacketActorList(RakNet::RakPeerInterface *peer) : WorldPacket(peer) +{ + packetID = ID_ACTOR_LIST; +} + +void PacketActorList::Packet(RakNet::BitStream *bs, bool send) +{ + WorldPacket::Packet(bs, send); + + if (!send) + event->objectChanges.objects.clear(); + else + event->objectChanges.count = (unsigned int)(event->objectChanges.objects.size()); + + RW(event->objectChanges.count, send); + + RW(event->cell.mData.mFlags, send); + RW(event->cell.mData.mX, send); + RW(event->cell.mData.mY, send); + RW(event->cell.mName, send); + + WorldObject worldObject; + + for (unsigned int i = 0; i < event->objectChanges.count; i++) + { + if (send) + { + worldObject = event->objectChanges.objects.at(i); + } + + RW(worldObject.refId, send); + RW(worldObject.refNumIndex, send); + RW(worldObject.mpNum, send); + + if (!send) + { + event->objectChanges.objects.push_back(worldObject); + } + } +} diff --git a/components/openmw-mp/Packets/World/PacketActorList.hpp b/components/openmw-mp/Packets/World/PacketActorList.hpp new file mode 100644 index 000000000..1435ef8dd --- /dev/null +++ b/components/openmw-mp/Packets/World/PacketActorList.hpp @@ -0,0 +1,17 @@ +#ifndef OPENMW_PACKETACTORLIST_HPP +#define OPENMW_PACKETACTORLIST_HPP + +#include + +namespace mwmp +{ + class PacketActorList : public WorldPacket + { + public: + PacketActorList(RakNet::RakPeerInterface *peer); + + virtual void Packet(RakNet::BitStream *bs, bool send); + }; +} + +#endif //OPENMW_PACKETACTORLIST_HPP