From fd3a7d2ad0020b6c4ea2b829e8e53ca14a0fb631 Mon Sep 17 00:00:00 2001 From: Koncord Date: Tue, 18 Apr 2017 11:37:32 +0800 Subject: [PATCH] [Client] Add world processors --- .../processors/world/BaseObjectProcessor.hpp | 32 ++++++++++++++++ .../processors/world/ProcessorContainer.hpp | 37 +++++++++++++++++++ .../processors/world/ProcessorDoorState.hpp | 30 +++++++++++++++ .../processors/world/ProcessorMusicPlay.hpp | 29 +++++++++++++++ .../world/ProcessorObjectAnimPlay.hpp | 30 +++++++++++++++ .../world/ProcessorObjectDelete.hpp | 30 +++++++++++++++ .../processors/world/ProcessorObjectLock.hpp | 30 +++++++++++++++ .../processors/world/ProcessorObjectMove.hpp | 30 +++++++++++++++ .../processors/world/ProcessorObjectPlace.hpp | 31 ++++++++++++++++ .../world/ProcessorObjectRotate.hpp | 30 +++++++++++++++ .../processors/world/ProcessorObjectScale.hpp | 30 +++++++++++++++ .../world/ProcessorObjectUnlock.hpp | 30 +++++++++++++++ .../world/ProcessorScriptGlobalShort.hpp | 29 +++++++++++++++ .../world/ProcessorScriptLocalFloat.hpp | 30 +++++++++++++++ .../world/ProcessorScriptLocalShort.hpp | 30 +++++++++++++++ .../world/ProcessorScriptMemberShort.hpp | 29 +++++++++++++++ .../processors/world/ProcessorVideoPlay.hpp | 29 +++++++++++++++ 17 files changed, 516 insertions(+) create mode 100644 apps/openmw/mwmp/processors/world/BaseObjectProcessor.hpp create mode 100644 apps/openmw/mwmp/processors/world/ProcessorContainer.hpp create mode 100644 apps/openmw/mwmp/processors/world/ProcessorDoorState.hpp create mode 100644 apps/openmw/mwmp/processors/world/ProcessorMusicPlay.hpp create mode 100644 apps/openmw/mwmp/processors/world/ProcessorObjectAnimPlay.hpp create mode 100644 apps/openmw/mwmp/processors/world/ProcessorObjectDelete.hpp create mode 100644 apps/openmw/mwmp/processors/world/ProcessorObjectLock.hpp create mode 100644 apps/openmw/mwmp/processors/world/ProcessorObjectMove.hpp create mode 100644 apps/openmw/mwmp/processors/world/ProcessorObjectPlace.hpp create mode 100644 apps/openmw/mwmp/processors/world/ProcessorObjectRotate.hpp create mode 100644 apps/openmw/mwmp/processors/world/ProcessorObjectScale.hpp create mode 100644 apps/openmw/mwmp/processors/world/ProcessorObjectUnlock.hpp create mode 100644 apps/openmw/mwmp/processors/world/ProcessorScriptGlobalShort.hpp create mode 100644 apps/openmw/mwmp/processors/world/ProcessorScriptLocalFloat.hpp create mode 100644 apps/openmw/mwmp/processors/world/ProcessorScriptLocalShort.hpp create mode 100644 apps/openmw/mwmp/processors/world/ProcessorScriptMemberShort.hpp create mode 100644 apps/openmw/mwmp/processors/world/ProcessorVideoPlay.hpp diff --git a/apps/openmw/mwmp/processors/world/BaseObjectProcessor.hpp b/apps/openmw/mwmp/processors/world/BaseObjectProcessor.hpp new file mode 100644 index 000000000..0e7e5356a --- /dev/null +++ b/apps/openmw/mwmp/processors/world/BaseObjectProcessor.hpp @@ -0,0 +1,32 @@ +// +// Created by koncord on 18.04.17. +// + +#ifndef OPENMW_BASEOBJECTPROCESSOR_HPP +#define OPENMW_BASEOBJECTPROCESSOR_HPP + +#include "apps/openmw/mwmp/WorldProcessor.hpp" +#include "apps/openmw/mwmp/Main.hpp" +#include "apps/openmw/mwmp/WorldController.hpp" +#include "apps/openmw/mwworld/cellstore.hpp" + +namespace mwmp +{ + class BaseObjectProcessor : public WorldProcessor + { + public: + virtual void Do(WorldPacket &packet, WorldEvent &event) + { + MWWorld::CellStore *ptrCellStore = Main::get().getWorldController()->getCell(event.cell); + + if (!ptrCellStore) return; + + LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Received %s about %s", strPacketID.c_str(), event.cell.getDescription().c_str()); + } + protected: + MWWorld::CellStore *ptrCellStore; + + }; +} + +#endif //OPENMW_BASEOBJECTPROCESSOR_HPP diff --git a/apps/openmw/mwmp/processors/world/ProcessorContainer.hpp b/apps/openmw/mwmp/processors/world/ProcessorContainer.hpp new file mode 100644 index 000000000..e0ee32b16 --- /dev/null +++ b/apps/openmw/mwmp/processors/world/ProcessorContainer.hpp @@ -0,0 +1,37 @@ +// +// Created by koncord on 18.04.17. +// + +#ifndef OPENMW_PROCESSORCONTAINER_HPP +#define OPENMW_PROCESSORCONTAINER_HPP + +#include "BaseObjectProcessor.hpp" + +namespace mwmp +{ + class ProcessorContainer : public BaseObjectProcessor + { + public: + ProcessorContainer() + { + BPP_INIT(ID_CONTAINER) + } + + virtual void Do(WorldPacket &packet, WorldEvent &event) + { + BaseObjectProcessor::Do(packet, event); + + LOG_APPEND(Log::LOG_VERBOSE, "- action: %i", event.action); + + // If we've received a request for information, comply with it + if (event.action == mwmp::BaseEvent::REQUEST) + event.sendContainers(ptrCellStore); + // Otherwise, edit containers based on the information received + else + event.editContainers(ptrCellStore); + } + + }; +} + +#endif //OPENMW_PROCESSORCONTAINER_HPP diff --git a/apps/openmw/mwmp/processors/world/ProcessorDoorState.hpp b/apps/openmw/mwmp/processors/world/ProcessorDoorState.hpp new file mode 100644 index 000000000..17434327d --- /dev/null +++ b/apps/openmw/mwmp/processors/world/ProcessorDoorState.hpp @@ -0,0 +1,30 @@ +// +// Created by koncord on 18.04.17. +// + +#ifndef OPENMW_PROCESSDOORSTATE_HPP +#define OPENMW_PROCESSDOORSTATE_HPP + + +#include "BaseObjectProcessor.hpp" + +namespace mwmp +{ + class ProcessorDoorState : public BaseObjectProcessor + { + public: + ProcessorDoorState() + { + BPP_INIT(ID_DOOR_STATE) + } + + virtual void Do(WorldPacket &packet, WorldEvent &event) + { + BaseObjectProcessor::Do(packet, event); + + event.activateDoors(ptrCellStore); + } + }; +} + +#endif //OPENMW_PROCESSDOORSTATE_HPP diff --git a/apps/openmw/mwmp/processors/world/ProcessorMusicPlay.hpp b/apps/openmw/mwmp/processors/world/ProcessorMusicPlay.hpp new file mode 100644 index 000000000..efbe2d0f2 --- /dev/null +++ b/apps/openmw/mwmp/processors/world/ProcessorMusicPlay.hpp @@ -0,0 +1,29 @@ +// +// Created by koncord on 18.04.17. +// + +#ifndef OPENMW_PROCESSORMUSICPLAY_HPP +#define OPENMW_PROCESSORMUSICPLAY_HPP + + +#include "apps/openmw/mwmp/WorldProcessor.hpp" + +namespace mwmp +{ + class ProcessorMusicPlay : public WorldProcessor + { + public: + ProcessorMusicPlay() + { + BPP_INIT(ID_MUSIC_PLAY) + } + + virtual void Do(WorldPacket &packet, WorldEvent &event) + { + LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Received %s", strPacketID.c_str()); + event.playMusic(); + } + }; +} + +#endif //OPENMW_PROCESSORSCRIPTGLOBALSHORT_HPP diff --git a/apps/openmw/mwmp/processors/world/ProcessorObjectAnimPlay.hpp b/apps/openmw/mwmp/processors/world/ProcessorObjectAnimPlay.hpp new file mode 100644 index 000000000..73dfa8794 --- /dev/null +++ b/apps/openmw/mwmp/processors/world/ProcessorObjectAnimPlay.hpp @@ -0,0 +1,30 @@ +// +// Created by koncord on 18.04.17. +// + +#ifndef OPENMW_PROCESSOROBJECTANIMPLAY_HPP +#define OPENMW_PROCESSOROBJECTANIMPLAY_HPP + + +#include "BaseObjectProcessor.hpp" + +namespace mwmp +{ + class ProcessorObjectAnimPlay : public BaseObjectProcessor + { + public: + ProcessorObjectAnimPlay() + { + BPP_INIT(ID_OBJECT_ANIM_PLAY) + } + + virtual void Do(WorldPacket &packet, WorldEvent &event) + { + BaseObjectProcessor::Do(packet, event); + + event.animateObjects(ptrCellStore); + } + }; +} + +#endif //OPENMW_PROCESSOROBJECTANIMPLAY_HPP diff --git a/apps/openmw/mwmp/processors/world/ProcessorObjectDelete.hpp b/apps/openmw/mwmp/processors/world/ProcessorObjectDelete.hpp new file mode 100644 index 000000000..b5079c6cb --- /dev/null +++ b/apps/openmw/mwmp/processors/world/ProcessorObjectDelete.hpp @@ -0,0 +1,30 @@ +// +// Created by koncord on 18.04.17. +// + +#ifndef OPENMW_PROCESSOROBJECTDELETE_HPP +#define OPENMW_PROCESSOROBJECTDELETE_HPP + + +#include "BaseObjectProcessor.hpp" + +namespace mwmp +{ + class ProcessorObjectDelete : public BaseObjectProcessor + { + public: + ProcessorObjectDelete() + { + BPP_INIT(ID_OBJECT_DELETE) + } + + virtual void Do(WorldPacket &packet, WorldEvent &event) + { + BaseObjectProcessor::Do(packet, event); + + event.deleteObjects(ptrCellStore); + } + }; +} + +#endif //OPENMW_PROCESSOROBJECTDELETE_HPP diff --git a/apps/openmw/mwmp/processors/world/ProcessorObjectLock.hpp b/apps/openmw/mwmp/processors/world/ProcessorObjectLock.hpp new file mode 100644 index 000000000..fc9be71a8 --- /dev/null +++ b/apps/openmw/mwmp/processors/world/ProcessorObjectLock.hpp @@ -0,0 +1,30 @@ +// +// Created by koncord on 18.04.17. +// + +#ifndef OPENMW_PROCESSOROBJECTLOCK_HPP +#define OPENMW_PROCESSOROBJECTLOCK_HPP + + +#include "BaseObjectProcessor.hpp" + +namespace mwmp +{ + class ProcessorObjectLock : public BaseObjectProcessor + { + public: + ProcessorObjectLock() + { + BPP_INIT(ID_OBJECT_LOCK) + } + + virtual void Do(WorldPacket &packet, WorldEvent &event) + { + BaseObjectProcessor::Do(packet, event); + + event.lockObjects(ptrCellStore); + } + }; +} + +#endif //OPENMW_PROCESSOROBJECTLOCK_HPP diff --git a/apps/openmw/mwmp/processors/world/ProcessorObjectMove.hpp b/apps/openmw/mwmp/processors/world/ProcessorObjectMove.hpp new file mode 100644 index 000000000..0bef6ca4e --- /dev/null +++ b/apps/openmw/mwmp/processors/world/ProcessorObjectMove.hpp @@ -0,0 +1,30 @@ +// +// Created by koncord on 18.04.17. +// + +#ifndef OPENMW_PROCESSOROBJECTMOVE_HPP +#define OPENMW_PROCESSOROBJECTMOVE_HPP + + +#include "BaseObjectProcessor.hpp" + +namespace mwmp +{ + class ProcessorObjectMove : public BaseObjectProcessor + { + public: + ProcessorObjectMove() + { + BPP_INIT(ID_OBJECT_MOVE) + } + + virtual void Do(WorldPacket &packet, WorldEvent &event) + { + BaseObjectProcessor::Do(packet, event); + + event.moveObjects(ptrCellStore); + } + }; +} + +#endif //OPENMW_PROCESSOROBJECTMOVE_HPP diff --git a/apps/openmw/mwmp/processors/world/ProcessorObjectPlace.hpp b/apps/openmw/mwmp/processors/world/ProcessorObjectPlace.hpp new file mode 100644 index 000000000..2fe203c76 --- /dev/null +++ b/apps/openmw/mwmp/processors/world/ProcessorObjectPlace.hpp @@ -0,0 +1,31 @@ +// +// Created by koncord on 18.04.17. +// + +#ifndef OPENMW_PROCESSOROBJECTPLACE_HPP +#define OPENMW_PROCESSOROBJECTPLACE_HPP + + +#include "BaseObjectProcessor.hpp" + +namespace mwmp +{ + class ProcessorObjectPlace : public BaseObjectProcessor + { + public: + ProcessorObjectPlace() + { + BPP_INIT(ID_OBJECT_PLACE) + } + + virtual void Do(WorldPacket &packet, WorldEvent &event) + { + BaseObjectProcessor::Do(packet, event); + + event.placeObjects(ptrCellStore); + } + + }; +} + +#endif //OPENMW_PROCESSOROBJECTPLACE_HPP diff --git a/apps/openmw/mwmp/processors/world/ProcessorObjectRotate.hpp b/apps/openmw/mwmp/processors/world/ProcessorObjectRotate.hpp new file mode 100644 index 000000000..1af285a53 --- /dev/null +++ b/apps/openmw/mwmp/processors/world/ProcessorObjectRotate.hpp @@ -0,0 +1,30 @@ +// +// Created by koncord on 18.04.17. +// + +#ifndef OPENMW_PROCESSOROBJECTROTATE_HPP +#define OPENMW_PROCESSOROBJECTROTATE_HPP + + +#include "BaseObjectProcessor.hpp" + +namespace mwmp +{ + class ProcessorObjectRotate : public BaseObjectProcessor + { + public: + ProcessorObjectRotate() + { + BPP_INIT(ID_OBJECT_ROTATE) + } + + virtual void Do(WorldPacket &packet, WorldEvent &event) + { + BaseObjectProcessor::Do(packet, event); + + event.rotateObjects(ptrCellStore); + } + }; +} + +#endif //OPENMW_PROCESSOROBJECTROTATE_HPP diff --git a/apps/openmw/mwmp/processors/world/ProcessorObjectScale.hpp b/apps/openmw/mwmp/processors/world/ProcessorObjectScale.hpp new file mode 100644 index 000000000..4ce599b89 --- /dev/null +++ b/apps/openmw/mwmp/processors/world/ProcessorObjectScale.hpp @@ -0,0 +1,30 @@ +// +// Created by koncord on 18.04.17. +// + +#ifndef OPENMW_PROCESSOROBJECTSCALE_HPP +#define OPENMW_PROCESSOROBJECTSCALE_HPP + + +#include "BaseObjectProcessor.hpp" + +namespace mwmp +{ + class ProcessorObjectScale : public BaseObjectProcessor + { + public: + ProcessorObjectScale() + { + BPP_INIT(ID_OBJECT_SCALE) + } + + virtual void Do(WorldPacket &packet, WorldEvent &event) + { + BaseObjectProcessor::Do(packet, event); + + event.scaleObjects(ptrCellStore); + } + }; +} + +#endif //OPENMW_PROCESSOROBJECTSCALE_HPP diff --git a/apps/openmw/mwmp/processors/world/ProcessorObjectUnlock.hpp b/apps/openmw/mwmp/processors/world/ProcessorObjectUnlock.hpp new file mode 100644 index 000000000..bf4bc086d --- /dev/null +++ b/apps/openmw/mwmp/processors/world/ProcessorObjectUnlock.hpp @@ -0,0 +1,30 @@ +// +// Created by koncord on 18.04.17. +// + +#ifndef OPENMW_PROCESSOROBJECTUNLOCK_HPP +#define OPENMW_PROCESSOROBJECTUNLOCK_HPP + + +#include "BaseObjectProcessor.hpp" + +namespace mwmp +{ + class ProcessorObjectUnlock : public BaseObjectProcessor + { + public: + ProcessorObjectUnlock() + { + BPP_INIT(ID_OBJECT_UNLOCK) + } + + virtual void Do(WorldPacket &packet, WorldEvent &event) + { + BaseObjectProcessor::Do(packet, event); + + event.unlockObjects(ptrCellStore); + } + }; +} + +#endif //OPENMW_PROCESSOROBJECTUNLOCK_HPP diff --git a/apps/openmw/mwmp/processors/world/ProcessorScriptGlobalShort.hpp b/apps/openmw/mwmp/processors/world/ProcessorScriptGlobalShort.hpp new file mode 100644 index 000000000..cd275ec39 --- /dev/null +++ b/apps/openmw/mwmp/processors/world/ProcessorScriptGlobalShort.hpp @@ -0,0 +1,29 @@ +// +// Created by koncord on 18.04.17. +// + +#ifndef OPENMW_PROCESSORSCRIPTGLOBALSHORT_HPP +#define OPENMW_PROCESSORSCRIPTGLOBALSHORT_HPP + + +#include "apps/openmw/mwmp/WorldProcessor.hpp" + +namespace mwmp +{ + class ProcessorScriptGlobalShort : public WorldProcessor + { + public: + ProcessorScriptGlobalShort() + { + BPP_INIT(ID_SCRIPT_GLOBAL_SHORT) + } + + virtual void Do(WorldPacket &packet, WorldEvent &event) + { + LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Received %s", strPacketID.c_str()); + event.setGlobalShorts(); + } + }; +} + +#endif //OPENMW_PROCESSORSCRIPTGLOBALSHORT_HPP diff --git a/apps/openmw/mwmp/processors/world/ProcessorScriptLocalFloat.hpp b/apps/openmw/mwmp/processors/world/ProcessorScriptLocalFloat.hpp new file mode 100644 index 000000000..1ec78d2d1 --- /dev/null +++ b/apps/openmw/mwmp/processors/world/ProcessorScriptLocalFloat.hpp @@ -0,0 +1,30 @@ +// +// Created by koncord on 18.04.17. +// + +#ifndef OPENMW_PROCESSORSCRIPTLOCALFLOAT_HPP +#define OPENMW_PROCESSORSCRIPTLOCALFLOAT_HPP + + +#include "BaseObjectProcessor.hpp" + +namespace mwmp +{ + class ProcessorScriptLocalFloat : public BaseObjectProcessor + { + public: + ProcessorScriptLocalFloat() + { + BPP_INIT(ID_SCRIPT_LOCAL_FLOAT) + } + + virtual void Do(WorldPacket &packet, WorldEvent &event) + { + BaseObjectProcessor::Do(packet, event); + + event.setLocalFloats(ptrCellStore); + } + }; +} + +#endif //OPENMW_PROCESSORSCRIPTLOCALFLOAT_HPP diff --git a/apps/openmw/mwmp/processors/world/ProcessorScriptLocalShort.hpp b/apps/openmw/mwmp/processors/world/ProcessorScriptLocalShort.hpp new file mode 100644 index 000000000..dabce4067 --- /dev/null +++ b/apps/openmw/mwmp/processors/world/ProcessorScriptLocalShort.hpp @@ -0,0 +1,30 @@ +// +// Created by koncord on 18.04.17. +// + +#ifndef OPENMW_PROCESSORSCRIPTLOCALSHORT_HPP +#define OPENMW_PROCESSORSCRIPTLOCALSHORT_HPP + + +#include "BaseObjectProcessor.hpp" + +namespace mwmp +{ + class ProcessorScriptLocalShort : public BaseObjectProcessor + { + public: + ProcessorScriptLocalShort() + { + BPP_INIT(ID_SCRIPT_LOCAL_SHORT) + } + + virtual void Do(WorldPacket &packet, WorldEvent &event) + { + BaseObjectProcessor::Do(packet, event); + + event.setLocalShorts(ptrCellStore); + } + }; +} + +#endif //OPENMW_PROCESSORSCRIPTLOCALSHORT_HPP diff --git a/apps/openmw/mwmp/processors/world/ProcessorScriptMemberShort.hpp b/apps/openmw/mwmp/processors/world/ProcessorScriptMemberShort.hpp new file mode 100644 index 000000000..ca0295636 --- /dev/null +++ b/apps/openmw/mwmp/processors/world/ProcessorScriptMemberShort.hpp @@ -0,0 +1,29 @@ +// +// Created by koncord on 18.04.17. +// + +#ifndef OPENMW_PROCESSORSCRIPTMEMBERSHORT_HPP +#define OPENMW_PROCESSORSCRIPTMEMBERSHORT_HPP + + +#include "apps/openmw/mwmp/WorldProcessor.hpp" + +namespace mwmp +{ + class ProcessorScriptMemberShort : public WorldProcessor + { + public: + ProcessorScriptMemberShort() + { + BPP_INIT(ID_SCRIPT_MEMBER_SHORT) + } + + virtual void Do(WorldPacket &packet, WorldEvent &event) + { + LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Received %s", strPacketID.c_str()); + event.setMemberShorts(); + } + }; +} + +#endif //OPENMW_PROCESSORSCRIPTMEMBERSHORT_HPP diff --git a/apps/openmw/mwmp/processors/world/ProcessorVideoPlay.hpp b/apps/openmw/mwmp/processors/world/ProcessorVideoPlay.hpp new file mode 100644 index 000000000..b56b3b6d7 --- /dev/null +++ b/apps/openmw/mwmp/processors/world/ProcessorVideoPlay.hpp @@ -0,0 +1,29 @@ +// +// Created by koncord on 18.04.17. +// + +#ifndef OPENMW_PROCESSORVIDEOPLAY_HPP +#define OPENMW_PROCESSORVIDEOPLAY_HPP + + +#include "apps/openmw/mwmp/WorldProcessor.hpp" + +namespace mwmp +{ + class ProcessorVideoPlay : public WorldProcessor + { + public: + ProcessorVideoPlay() + { + BPP_INIT(ID_VIDEO_PLAY) + } + + virtual void Do(WorldPacket &packet, WorldEvent &event) + { + LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Received %s", strPacketID.c_str()); + event.playVideo(); + } + }; +} + +#endif //OPENMW_PROCESSORVIDEOPLAY_HPP