From a6111b65995d2835441bdde2b0f718bb28f5431b Mon Sep 17 00:00:00 2001 From: Koncord Date: Sun, 16 Apr 2017 14:58:40 +0800 Subject: [PATCH 1/9] [Client] Add PlayerProcessor & WorldProcessor --- apps/openmw/mwmp/LocalPlayer.hpp | 1 + apps/openmw/mwmp/Main.hpp | 5 ++ apps/openmw/mwmp/PlayerProcessor.cpp | 73 ++++++++++++++++++++++++++++ apps/openmw/mwmp/PlayerProcessor.hpp | 58 ++++++++++++++++++++++ apps/openmw/mwmp/WorldProcesssor.cpp | 60 +++++++++++++++++++++++ apps/openmw/mwmp/WorldProcesssor.hpp | 50 +++++++++++++++++++ 6 files changed, 247 insertions(+) create mode 100644 apps/openmw/mwmp/PlayerProcessor.cpp create mode 100644 apps/openmw/mwmp/PlayerProcessor.hpp create mode 100644 apps/openmw/mwmp/WorldProcesssor.cpp create mode 100644 apps/openmw/mwmp/WorldProcesssor.hpp diff --git a/apps/openmw/mwmp/LocalPlayer.hpp b/apps/openmw/mwmp/LocalPlayer.hpp index 0d12df168..53b0a1e86 100644 --- a/apps/openmw/mwmp/LocalPlayer.hpp +++ b/apps/openmw/mwmp/LocalPlayer.hpp @@ -6,6 +6,7 @@ #define OPENMW_LOCALPLAYER_HPP #include +#include "../mwworld/ptr.hpp" #include namespace mwmp diff --git a/apps/openmw/mwmp/Main.hpp b/apps/openmw/mwmp/Main.hpp index 6592ebc28..808d5707a 100644 --- a/apps/openmw/mwmp/Main.hpp +++ b/apps/openmw/mwmp/Main.hpp @@ -1,3 +1,6 @@ +#ifndef OPENMW_MWMP_MAIN +#define OPENMW_MWMP_MAIN + #include "../mwworld/ptr.hpp" #include #include @@ -54,3 +57,5 @@ namespace mwmp unsigned short port; }; } + +#endif //OPENMW_MWMP_MAIN \ No newline at end of file diff --git a/apps/openmw/mwmp/PlayerProcessor.cpp b/apps/openmw/mwmp/PlayerProcessor.cpp new file mode 100644 index 000000000..a8b790ce4 --- /dev/null +++ b/apps/openmw/mwmp/PlayerProcessor.cpp @@ -0,0 +1,73 @@ +// +// Created by koncord on 04.04.17. +// + +#include +#include "Networking.hpp" +#include "PlayerProcessor.hpp" +#include "DedicatedPlayer.hpp" +#include "LocalPlayer.hpp" +#include "Main.hpp" + +using namespace mwmp; + +PlayerProcessor::processors_t PlayerProcessor::processors; +RakNet::RakNetGUID PlayerProcessor::myGuid; +RakNet::RakNetGUID PlayerProcessor::guid; +RakNet::SystemAddress PlayerProcessor::serverAddr; +bool PlayerProcessor::request; + +void PlayerProcessor::AddProcessor(PlayerProcessor *processor) +{ + BOOST_FOREACH(processors_t::value_type &p, processors) + { + if(processor->packetID == p.first) + throw std::logic_error("processor " + p.second->strPacketID + " already registered. Check " + + processor->className + " and " + p.second->className); + } + processors.insert(processors_t::value_type(processor->GetPacketID(), boost::shared_ptr(processor))); +} + +bool PlayerProcessor::Process(RakNet::Packet &packet) +{ + RakNet::BitStream bsIn(&packet.data[1], packet.length, false); + bsIn.Read(guid); + + PlayerPacket *myPacket = Main::get().getNetworking()->getPlayerPacket(packet.data[0]); + myPacket->SetReadStream(&bsIn); + + /*if(myPacket == 0) + { + // error: packet not found + }*/ + + BOOST_FOREACH(processors_t::value_type &processor, processors) + { + if(processor.first == packet.data[0]) + { + myGuid = Main::get().getLocalPlayer()->guid; + request = packet.length == myPacket->headerSize(); + + BasePlayer *player = 0; + if (guid != myGuid) + player = Players::getPlayer(guid); + else + player = Main::get().getLocalPlayer(); + + if(!request && !processor.second->avoidReading && player != 0) + { + myPacket->setPlayer(player); + myPacket->Read(); + } + + processor.second->Do(*myPacket, player); + return true; + } + } + return false; +} + +LocalPlayer *PlayerProcessor::getLocalPlayer() +{ + return Main::get().getLocalPlayer(); +} \ No newline at end of file diff --git a/apps/openmw/mwmp/PlayerProcessor.hpp b/apps/openmw/mwmp/PlayerProcessor.hpp new file mode 100644 index 000000000..c7d257789 --- /dev/null +++ b/apps/openmw/mwmp/PlayerProcessor.hpp @@ -0,0 +1,58 @@ +// +// Created by koncord on 03.04.17. +// + +#ifndef OPENMW_PLAYERPROCESSOR_HPP +#define OPENMW_PLAYERPROCESSOR_HPP + +#include +#include + +#include +#include +#include +#include +#include "LocalPlayer.hpp" +#include "DedicatedPlayer.hpp" + +namespace mwmp +{ + class PlayerProcessor : public BasePacketProcessor + { + public: + virtual void Do(PlayerPacket &packet, BasePlayer *player) = 0; + + static bool Process(RakNet::Packet &packet); + static void AddProcessor(PlayerProcessor *processor); + static void SetServerAddr(RakNet::SystemAddress addr) + { + serverAddr = addr; + } + + typedef boost::unordered_map > processors_t; + //typedef std::unordered_map > processors_t; + private: + static processors_t processors; + static bool request; + protected: + inline bool isRequest() + { + return request; + } + + inline bool isLocal() + { + return guid == myGuid; + } + + LocalPlayer *getLocalPlayer(); + protected: + static RakNet::RakNetGUID myGuid; + static RakNet::RakNetGUID guid; + static RakNet::SystemAddress serverAddr; + }; +} + + + +#endif //OPENMW_PLAYERPROCESSOR_HPP diff --git a/apps/openmw/mwmp/WorldProcesssor.cpp b/apps/openmw/mwmp/WorldProcesssor.cpp new file mode 100644 index 000000000..fd0aeef2b --- /dev/null +++ b/apps/openmw/mwmp/WorldProcesssor.cpp @@ -0,0 +1,60 @@ +// +// Created by koncord on 16.04.17. +// + +#include +#include "WorldProcesssor.hpp" +#include "Main.hpp" +#include "Networking.hpp" + +using namespace mwmp; + +WorldProcesssor::processors_t WorldProcesssor::processors; +RakNet::RakNetGUID WorldProcesssor::guid; +RakNet::SystemAddress WorldProcesssor::serverAddr; +bool WorldProcesssor::request; + +bool WorldProcesssor::Process(RakNet::Packet &packet, BaseEvent &event) +{ + RakNet::BitStream bsIn(&packet.data[1], packet.length, false); + bsIn.Read(guid); + + WorldPacket *myPacket = Main::get().getNetworking()->getWorldPacket(packet.data[0]); + + myPacket->setEvent(&event); + myPacket->SetReadStream(&bsIn); + + BOOST_FOREACH(processors_t::value_type &processor, processors) + { + if(processor.first == packet.data[0]) + { + request = packet.length == myPacket->headerSize(); + + if(!request && !processor.second->avoidReading) + { + myPacket->Read(); + } + + processor.second->Do(*myPacket, event); + + return true; + } + } + return false; +} + +void WorldProcesssor::AddProcessor(mwmp::WorldProcesssor *processor) +{ + BOOST_FOREACH(processors_t::value_type &p, processors) + { + if(processor->packetID == p.first) + throw std::logic_error("processor " + p.second->strPacketID + " already registered. Check " + + processor->className + " and " + p.second->className); + } + processors.insert(processors_t::value_type(processor->GetPacketID(), boost::shared_ptr(processor))); +} + +LocalPlayer *WorldProcesssor::getLocalPlayer() +{ + return Main::get().getLocalPlayer(); +} diff --git a/apps/openmw/mwmp/WorldProcesssor.hpp b/apps/openmw/mwmp/WorldProcesssor.hpp new file mode 100644 index 000000000..1e0ff0de3 --- /dev/null +++ b/apps/openmw/mwmp/WorldProcesssor.hpp @@ -0,0 +1,50 @@ +// +// Created by koncord on 16.04.17. +// + +#ifndef OPENMW_WORLDPROCESSSOR_HPP +#define OPENMW_WORLDPROCESSSOR_HPP + +#include +#include + +#include +#include +#include +#include +#include "LocalPlayer.hpp" +#include "DedicatedPlayer.hpp" + +namespace mwmp +{ + class WorldProcesssor : public BasePacketProcessor + { + public: + virtual void Do(WorldPacket &packet, BaseEvent &event) = 0; + + static bool Process(RakNet::Packet &packet, BaseEvent &event); + static void AddProcessor(WorldProcesssor *processor); + static void SetServerAddr(RakNet::SystemAddress addr) + { + serverAddr = addr; + } + + typedef boost::unordered_map > processors_t; + + protected: + inline bool isRequest() + { + return request; + } + LocalPlayer *getLocalPlayer(); + protected: + static RakNet::RakNetGUID guid; + static RakNet::SystemAddress serverAddr; + private: + static processors_t processors; + static bool request; + }; +} + + +#endif //OPENMW_WORLDPROCESSSOR_HPP From f09dc2b65b8b6d9db959a782a7ba5768ec4ec767 Mon Sep 17 00:00:00 2001 From: Koncord Date: Sun, 16 Apr 2017 15:00:25 +0800 Subject: [PATCH 2/9] [Client] Add player processors --- .../player/ProcessorChatMessage.hpp | 30 +++++++ .../player/ProcessorGUIMessageBox.hpp | 44 ++++++++++ .../player/ProcessorGameConsole.hpp | 30 +++++++ .../processors/player/ProcessorGameTime.hpp | 39 ++++++++ .../processors/player/ProcessorHandshake.hpp | 28 ++++++ .../player/ProcessorPlayerAttack.hpp | 88 +++++++++++++++++++ .../player/ProcessorPlayerAttribute.hpp | 49 +++++++++++ .../player/ProcessorPlayerBaseInfo.hpp | 58 ++++++++++++ .../player/ProcessorPlayerCellChange.hpp | 37 ++++++++ .../player/ProcessorPlayerCellState.hpp | 31 +++++++ .../player/ProcessorPlayerCharClass.hpp | 35 ++++++++ .../player/ProcessorPlayerCharGen.hpp | 29 ++++++ .../player/ProcessorPlayerDeath.hpp | 53 +++++++++++ .../player/ProcessorPlayerDrawState.hpp | 35 ++++++++ .../player/ProcessorPlayerDynamicStats.hpp | 47 ++++++++++ .../player/ProcessorPlayerEquipment.hpp | 36 ++++++++ .../player/ProcessorPlayerInventory.hpp | 43 +++++++++ .../player/ProcessorPlayerJournal.hpp | 36 ++++++++ .../player/ProcessorPlayerLevel.hpp | 42 +++++++++ .../processors/player/ProcessorPlayerPos.hpp | 41 +++++++++ .../player/ProcessorPlayerResurrect.hpp | 67 ++++++++++++++ .../player/ProcessorPlayerSkill.hpp | 47 ++++++++++ .../player/ProcessorPlayerSpellbook.hpp | 44 ++++++++++ .../player/ProcessorUserDisconnected.hpp | 33 +++++++ .../processors/player/ProcessorUserMyID.hpp | 31 +++++++ 25 files changed, 1053 insertions(+) create mode 100644 apps/openmw/mwmp/processors/player/ProcessorChatMessage.hpp create mode 100644 apps/openmw/mwmp/processors/player/ProcessorGUIMessageBox.hpp create mode 100644 apps/openmw/mwmp/processors/player/ProcessorGameConsole.hpp create mode 100644 apps/openmw/mwmp/processors/player/ProcessorGameTime.hpp create mode 100644 apps/openmw/mwmp/processors/player/ProcessorHandshake.hpp create mode 100644 apps/openmw/mwmp/processors/player/ProcessorPlayerAttack.hpp create mode 100644 apps/openmw/mwmp/processors/player/ProcessorPlayerAttribute.hpp create mode 100644 apps/openmw/mwmp/processors/player/ProcessorPlayerBaseInfo.hpp create mode 100644 apps/openmw/mwmp/processors/player/ProcessorPlayerCellChange.hpp create mode 100644 apps/openmw/mwmp/processors/player/ProcessorPlayerCellState.hpp create mode 100644 apps/openmw/mwmp/processors/player/ProcessorPlayerCharClass.hpp create mode 100644 apps/openmw/mwmp/processors/player/ProcessorPlayerCharGen.hpp create mode 100644 apps/openmw/mwmp/processors/player/ProcessorPlayerDeath.hpp create mode 100644 apps/openmw/mwmp/processors/player/ProcessorPlayerDrawState.hpp create mode 100644 apps/openmw/mwmp/processors/player/ProcessorPlayerDynamicStats.hpp create mode 100644 apps/openmw/mwmp/processors/player/ProcessorPlayerEquipment.hpp create mode 100644 apps/openmw/mwmp/processors/player/ProcessorPlayerInventory.hpp create mode 100644 apps/openmw/mwmp/processors/player/ProcessorPlayerJournal.hpp create mode 100644 apps/openmw/mwmp/processors/player/ProcessorPlayerLevel.hpp create mode 100644 apps/openmw/mwmp/processors/player/ProcessorPlayerPos.hpp create mode 100644 apps/openmw/mwmp/processors/player/ProcessorPlayerResurrect.hpp create mode 100644 apps/openmw/mwmp/processors/player/ProcessorPlayerSkill.hpp create mode 100644 apps/openmw/mwmp/processors/player/ProcessorPlayerSpellbook.hpp create mode 100644 apps/openmw/mwmp/processors/player/ProcessorUserDisconnected.hpp create mode 100644 apps/openmw/mwmp/processors/player/ProcessorUserMyID.hpp diff --git a/apps/openmw/mwmp/processors/player/ProcessorChatMessage.hpp b/apps/openmw/mwmp/processors/player/ProcessorChatMessage.hpp new file mode 100644 index 000000000..399d5d057 --- /dev/null +++ b/apps/openmw/mwmp/processors/player/ProcessorChatMessage.hpp @@ -0,0 +1,30 @@ +// +// Created by koncord on 16.04.17. +// + +#ifndef OPENMW_PROCESSORCHATMESSAGE_HPP +#define OPENMW_PROCESSORCHATMESSAGE_HPP + + +#include "apps/openmw/mwmp/PlayerProcessor.hpp" +#include "apps/openmw/mwmp/Main.hpp" +#include "apps/openmw/mwmp/GUIController.hpp" + +namespace mwmp +{ + class ProcessorChatMessage : public PlayerProcessor + { + public: + ProcessorChatMessage() + { + BPP_INIT(ID_CHAT_MESSAGE) + } + + virtual void Do(PlayerPacket &packet, BasePlayer *player) + { + Main::get().getGUIController()->printChatMessage(player->chatMessage); + } + }; +} + +#endif //OPENMW_PROCESSORCHATMESSAGE_HPP diff --git a/apps/openmw/mwmp/processors/player/ProcessorGUIMessageBox.hpp b/apps/openmw/mwmp/processors/player/ProcessorGUIMessageBox.hpp new file mode 100644 index 000000000..790be60e1 --- /dev/null +++ b/apps/openmw/mwmp/processors/player/ProcessorGUIMessageBox.hpp @@ -0,0 +1,44 @@ +// +// Created by koncord on 16.04.17. +// + +#ifndef OPENMW_PROCESSORGUIMESSAGEBOX_HPP +#define OPENMW_PROCESSORGUIMESSAGEBOX_HPP + + +#include "apps/openmw/mwmp/PlayerProcessor.hpp" + +namespace mwmp +{ + class ProcessorGUIMessageBox : public PlayerProcessor + { + public: + ProcessorGUIMessageBox() + { + BPP_INIT(ID_GUI_MESSAGEBOX) + } + + virtual void Do(PlayerPacket &packet, BasePlayer *player) + { + if (isLocal()) + { + LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "ID_GUI_MESSAGEBOX, Type %d, MSG %s", player->guiMessageBox.type, + player->guiMessageBox.label.c_str()); + + int messageBoxType = player->guiMessageBox.type; + + if (messageBoxType == BasePlayer::GUIMessageBox::MessageBox) + Main::get().getGUIController()->showMessageBox(player->guiMessageBox); + else if (messageBoxType == BasePlayer::GUIMessageBox::CustomMessageBox) + Main::get().getGUIController()->showCustomMessageBox(player->guiMessageBox); + else if (messageBoxType == BasePlayer::GUIMessageBox::InputDialog) + Main::get().getGUIController()->showInputBox(player->guiMessageBox); + else if (messageBoxType == BasePlayer::GUIMessageBox::ListBox) + Main::get().getGUIController()->showDialogList(player->guiMessageBox); + } + } + }; +} + + +#endif //OPENMW_PROCESSORGUIMESSAGEBOX_HPP diff --git a/apps/openmw/mwmp/processors/player/ProcessorGameConsole.hpp b/apps/openmw/mwmp/processors/player/ProcessorGameConsole.hpp new file mode 100644 index 000000000..92b648e73 --- /dev/null +++ b/apps/openmw/mwmp/processors/player/ProcessorGameConsole.hpp @@ -0,0 +1,30 @@ +// +// Created by koncord on 16.04.17. +// + +#ifndef OPENMW_PROCESSORGAMECONSOLE_HPP +#define OPENMW_PROCESSORGAMECONSOLE_HPP + + +#include "apps/openmw/mwmp/PlayerProcessor.hpp" + +namespace mwmp +{ + class ProcessorGameConsole : public PlayerProcessor + { + public: + ProcessorGameConsole() + { + BPP_INIT(ID_GAME_CONSOLE) + } + + virtual void Do(PlayerPacket &packet, BasePlayer *player) + { + + } + }; +} + + + +#endif //OPENMW_PROCESSORGAMECONSOLE_HPP diff --git a/apps/openmw/mwmp/processors/player/ProcessorGameTime.hpp b/apps/openmw/mwmp/processors/player/ProcessorGameTime.hpp new file mode 100644 index 000000000..cc7a1adbc --- /dev/null +++ b/apps/openmw/mwmp/processors/player/ProcessorGameTime.hpp @@ -0,0 +1,39 @@ +// +// Created by koncord on 16.04.17. +// + +#ifndef OPENMW_PROCESSORGAMETIME_HPP +#define OPENMW_PROCESSORGAMETIME_HPP + + +#include "apps/openmw/mwmp/PlayerProcessor.hpp" + +namespace mwmp +{ + class ProcessorGameTime : public PlayerProcessor + { + public: + ProcessorGameTime() + { + BPP_INIT(ID_PLAYER_CHARCLASS) + } + + virtual void Do(PlayerPacket &packet, BasePlayer *player) + { + if (isLocal()) + { + MWBase::World *world = MWBase::Environment::get().getWorld(); + if (player->hour != -1) + world->setHour(player->hour); + else if (player->day != -1) + world->setDay(player->day); + else if (player->month != -1) + world->setMonth(player->month); + } + } + }; +} + + + +#endif //OPENMW_PROCESSORGAMETIME_HPP diff --git a/apps/openmw/mwmp/processors/player/ProcessorHandshake.hpp b/apps/openmw/mwmp/processors/player/ProcessorHandshake.hpp new file mode 100644 index 000000000..8390fedcd --- /dev/null +++ b/apps/openmw/mwmp/processors/player/ProcessorHandshake.hpp @@ -0,0 +1,28 @@ +// +// Created by koncord on 04.04.17. +// + +#ifndef OPENMW_PROCESSORHANDSHAKE_HPP +#define OPENMW_PROCESSORHANDSHAKE_HPP + +#include "apps/openmw/mwmp/PlayerProcessor.hpp" + +namespace mwmp +{ + class ProcessorHandshake : public PlayerProcessor + { + public: + ProcessorHandshake() + { + BPP_INIT(ID_HANDSHAKE) + } + + virtual void Do(PlayerPacket &packet, BasePlayer *player) + { + packet.setPlayer(getLocalPlayer()); // player is 0 because myGuid will be setted after ProcessUserMyID + packet.Send(serverAddr); + } + }; +} + +#endif //OPENMW_PROCESSORHANDSHAKE_HPP diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerAttack.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerAttack.hpp new file mode 100644 index 000000000..437b98b3e --- /dev/null +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerAttack.hpp @@ -0,0 +1,88 @@ +// +// Created by koncord on 16.04.17. +// + +#ifndef OPENMW_PROCESSORPLAYERATTACK_HPP +#define OPENMW_PROCESSORPLAYERATTACK_HPP + + +#include "apps/openmw/mwmp/PlayerProcessor.hpp" +#include "apps/openmw/mwbase/world.hpp" +#include "apps/openmw/mwworld/containerstore.hpp" +#include "apps/openmw/mwworld/inventorystore.hpp" +#include "apps/openmw/mwmechanics/combat.hpp" + +#include "apps/openmw/mwbase/environment.hpp" + +namespace mwmp +{ + class ProcessorPlayerAttack : public PlayerProcessor + { + public: + ProcessorPlayerAttack() + { + BPP_INIT(ID_PLAYER_ATTACK) + } + + virtual void Do(PlayerPacket &packet, BasePlayer *player) + { + DedicatedPlayer &dedicatedPlayer = static_cast(*player); + //cout << "Player: " << dedicatedPlayer.Npc()->mName << " pressed: " << (dedicatedPlayer.getAttack()->pressed == 1) << endl; + if (dedicatedPlayer.attack.pressed == 0) + { + LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Attack success: %s", dedicatedPlayer.attack.success ? "true" : "false"); + + if (dedicatedPlayer.attack.success == 1) + LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Damage: %f",dedicatedPlayer.attack.damage); + } + + MWMechanics::CreatureStats &stats = dedicatedPlayer.getPtr().getClass().getNpcStats(dedicatedPlayer.getPtr()); + stats.getSpells().setSelectedSpell(dedicatedPlayer.attack.refid); + + MWWorld::Ptr victim; + if (dedicatedPlayer.attack.target == getLocalPlayer()->guid) + victim = MWBase::Environment::get().getWorld()->getPlayerPtr(); + else if (Players::getPlayer(dedicatedPlayer.attack.target) != 0) + victim = Players::getPlayer(dedicatedPlayer.attack.target)->getPtr(); + + MWWorld::Ptr attacker; + attacker = dedicatedPlayer.getPtr(); + + // Get the weapon used (if hand-to-hand, weapon = inv.end()) + if (dedicatedPlayer.drawState == 1) + { + MWWorld::InventoryStore &inv = attacker.getClass().getInventoryStore(attacker); + MWWorld::ContainerStoreIterator weaponslot = inv.getSlot( + MWWorld::InventoryStore::Slot_CarriedRight); + MWWorld::Ptr weapon = ((weaponslot != inv.end()) ? *weaponslot : MWWorld::Ptr()); + if (!weapon.isEmpty() && weapon.getTypeName() != typeid(ESM::Weapon).name()) + weapon = MWWorld::Ptr(); + + if (victim.mRef != 0) + { + bool healthdmg; + if (!weapon.isEmpty()) + healthdmg = true; + else + { + MWMechanics::CreatureStats &otherstats = victim.getClass().getCreatureStats(victim); + healthdmg = otherstats.isParalyzed() || otherstats.getKnockedDown(); + } + + if (!weapon.isEmpty()) + MWMechanics::blockMeleeAttack(attacker, victim, weapon, dedicatedPlayer.attack.damage, 1); + dedicatedPlayer.getPtr().getClass().onHit(victim, dedicatedPlayer.attack.damage, healthdmg, weapon, attacker, osg::Vec3f(), + dedicatedPlayer.attack.success); + } + } + else + { + LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "SpellId: %s", dedicatedPlayer.attack.refid.c_str()); + LOG_APPEND(Log::LOG_VERBOSE, " - success: %d", dedicatedPlayer.attack.success); + } + } + }; +} + + +#endif //OPENMW_PROCESSORPLAYERATTACK_HPP diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerAttribute.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerAttribute.hpp new file mode 100644 index 000000000..0a649b5be --- /dev/null +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerAttribute.hpp @@ -0,0 +1,49 @@ +// +// Created by koncord on 16.04.17. +// + +#ifndef OPENMW_PROCESSORPLAYERATTRIBUTE_HPP +#define OPENMW_PROCESSORPLAYERATTRIBUTE_HPP + + +#include "apps/openmw/mwmp/PlayerProcessor.hpp" +#include "apps/openmw/mwmechanics/npcstats.hpp" +#include "apps/openmw/mwclass/npc.hpp" + +namespace mwmp +{ + class ProcessorPlayerAttribute : public PlayerProcessor + { + public: + ProcessorPlayerAttribute() + { + BPP_INIT(ID_PLAYER_ATTRIBUTE) + } + + virtual void Do(PlayerPacket &packet, BasePlayer *player) + { + if (isLocal()) + { + if(isRequest()) + static_cast(player)->updateAttributes(true); + else + static_cast(player)->setAttributes(); + } + else + { + MWWorld::Ptr ptrPlayer = static_cast(player)->getPtr(); + MWMechanics::CreatureStats *ptrCreatureStats = &ptrPlayer.getClass().getCreatureStats(ptrPlayer); + MWMechanics::AttributeValue attributeValue; + + for (int i = 0; i < 8; ++i) + { + attributeValue.readState(player->creatureStats.mAttributes[i]); + ptrCreatureStats->setAttribute(i, attributeValue); + } + } + } + }; +} + + +#endif //OPENMW_PROCESSORPLAYERATTRIBUTE_HPP diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerBaseInfo.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerBaseInfo.hpp new file mode 100644 index 000000000..4504c80ee --- /dev/null +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerBaseInfo.hpp @@ -0,0 +1,58 @@ +// +// Created by koncord on 04.04.17. +// + +#ifndef OPENMW_PROCESSORPLAYERBASEINFO_HPP +#define OPENMW_PROCESSORPLAYERBASEINFO_HPP + +#include "apps/openmw/mwmp/PlayerProcessor.hpp" + +namespace mwmp +{ + class ProcessorPlayerBaseInfo : public PlayerProcessor + { + public: + ProcessorPlayerBaseInfo() + { + BPP_INIT(ID_PLAYER_BASEINFO) + } + + virtual void Do(PlayerPacket &packet, BasePlayer *player) + { + LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_PLAYER_BASEINFO from server"); + + if(isLocal()) + { + LOG_APPEND(Log::LOG_INFO, "- Packet was about my id"); + + if(isRequest()) + { + LOG_APPEND(Log::LOG_INFO, "- Requesting info"); + packet.Send(serverAddr); + } + else + { + LOG_APPEND(Log::LOG_INFO, "- Updating LocalPlayer"); + static_cast(player)->updateChar(); + } + } + else + { + LOG_APPEND(Log::LOG_INFO, "- Packet was about %s", player == 0 ? "new player" : player->npc.mName.c_str()); + + if (player == 0) + { + LOG_APPEND(Log::LOG_INFO, "- Exchanging data with new player"); + player = Players::newPlayer(guid); + + packet.setPlayer(player); + packet.Read(); + } + + Players::createPlayer(guid); + } + } + }; +} + +#endif //OPENMW_PROCESSORPLAYERBASEINFO_HPP diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerCellChange.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerCellChange.hpp new file mode 100644 index 000000000..405046135 --- /dev/null +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerCellChange.hpp @@ -0,0 +1,37 @@ +// +// Created by koncord on 16.04.17. +// + +#ifndef OPENMW_PROCESSORPLAYERCELLCHANGE_HPP +#define OPENMW_PROCESSORPLAYERCELLCHANGE_HPP + + +#include "apps/openmw/mwmp/PlayerProcessor.hpp" + +namespace mwmp +{ + class ProcessorPlayerCellChange : public PlayerProcessor + { + public: + ProcessorPlayerCellChange() + { + BPP_INIT(ID_PLAYER_CELL_CHANGE) + } + + virtual void Do(PlayerPacket &packet, BasePlayer *player) + { + if (isLocal()) + { + if (isRequest()) + static_cast(player)->updateCell(true); + else + static_cast(player)->setCell(); + } + else + static_cast(player)->updateCell(); + } + }; +} + + +#endif //OPENMW_PROCESSORPLAYERCELLCHANGE_HPP diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerCellState.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerCellState.hpp new file mode 100644 index 000000000..b7c124fed --- /dev/null +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerCellState.hpp @@ -0,0 +1,31 @@ +// +// Created by koncord on 16.04.17. +// + +#ifndef OPENMW_PROCESSORPLAYERCELLSTATE_HPP +#define OPENMW_PROCESSORPLAYERCELLSTATE_HPP + + +#include "apps/openmw/mwmp/PlayerProcessor.hpp" + +namespace mwmp +{ + class ProcessorPlayerCellState : public PlayerProcessor + { + public: + ProcessorPlayerCellState() + { + BPP_INIT(ID_PLAYER_CELL_STATE) + avoidReading = true; + } + + virtual void Do(PlayerPacket &packet, BasePlayer *player) + { + if (isLocal() && isRequest()) + static_cast(player)->sendCellStates(); + } + }; +} + + +#endif //OPENMW_PROCESSORPLAYERCELLSTATE_HPP diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerCharClass.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerCharClass.hpp new file mode 100644 index 000000000..4019e79c9 --- /dev/null +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerCharClass.hpp @@ -0,0 +1,35 @@ +// +// Created by koncord on 16.04.17. +// + +#ifndef OPENMW_PROCESSORPLAYERCHARCLASS_HPP +#define OPENMW_PROCESSORPLAYERCHARCLASS_HPP + + +#include "apps/openmw/mwmp/PlayerProcessor.hpp" + +namespace mwmp +{ + class ProcessorPlayerCharClass : public PlayerProcessor + { + public: + ProcessorPlayerCharClass() + { + BPP_INIT(ID_PLAYER_CHARCLASS) + } + + virtual void Do(PlayerPacket &packet, BasePlayer *player) + { + if (isLocal()) + { + if(isRequest()) + static_cast(player)->sendClass(); + else + static_cast(player)->setClass(); + } + } + }; +} + + +#endif //OPENMW_PROCESSORPLAYERCHARCLASS_HPP diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerCharGen.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerCharGen.hpp new file mode 100644 index 000000000..ff1b8a65a --- /dev/null +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerCharGen.hpp @@ -0,0 +1,29 @@ +// +// Created by koncord on 16.04.17. +// + +#ifndef OPENMW_PROCESSORPLAYERCHARGEN_HPP +#define OPENMW_PROCESSORPLAYERCHARGEN_HPP + + +#include "apps/openmw/mwmp/PlayerProcessor.hpp" + +namespace mwmp +{ + class ProcessorPlayerCharGen : public PlayerProcessor + { + public: + ProcessorPlayerCharGen() + { + BPP_INIT(ID_PLAYER_CHARGEN) + } + + virtual void Do(PlayerPacket &packet, BasePlayer *player) + { + + } + }; +} + + +#endif //OPENMW_PROCESSORPLAYERCHARGEN_HPP diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerDeath.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerDeath.hpp new file mode 100644 index 000000000..7386ec0f7 --- /dev/null +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerDeath.hpp @@ -0,0 +1,53 @@ +// +// Created by koncord on 16.04.17. +// + +#ifndef OPENMW_PROCESSORPLAYERDEATH_HPP +#define OPENMW_PROCESSORPLAYERDEATH_HPP + + +#include "apps/openmw/mwmp/PlayerProcessor.hpp" + +namespace mwmp +{ + class ProcessorPlayerDeath : public PlayerProcessor + { + public: + ProcessorPlayerDeath() + { + BPP_INIT(ID_PLAYER_DEATH) + avoidReading = true; + } + + virtual void Do(PlayerPacket &packet, BasePlayer *player) + { + LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_PLAYER_DEATH from server"); + if (isLocal()) + { + LOG_APPEND(Log::LOG_INFO, "- Packet was about me"); + + MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayerPtr(); + MWMechanics::DynamicStat health = playerPtr.getClass().getCreatureStats(playerPtr).getHealth(); + health.setCurrent(0); + playerPtr.getClass().getCreatureStats(playerPtr).setHealth(health); + packet.setPlayer(player); + packet.Send(serverAddr); + } + else + { + LOG_APPEND(Log::LOG_INFO, "- Packet was about %s", player->npc.mName.c_str()); + + MWMechanics::DynamicStat health; + player->creatureStats.mDead = true; + health.readState(player->creatureStats.mDynamic[0]); + health.setCurrent(0); + health.writeState(player->creatureStats.mDynamic[0]); + + MWWorld::Ptr ptr = static_cast(player)->getPtr(); + ptr.getClass().getCreatureStats(ptr).setHealth(health); + } + } + }; +} + +#endif //OPENMW_PROCESSORPLAYERDEATH_HPP diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerDrawState.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerDrawState.hpp new file mode 100644 index 000000000..aeba23b50 --- /dev/null +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerDrawState.hpp @@ -0,0 +1,35 @@ +// +// Created by koncord on 16.04.17. +// + +#ifndef OPENMW_PROCESSORPLAYERDRAWSTATE_HPP +#define OPENMW_PROCESSORPLAYERDRAWSTATE_HPP + + +#include "apps/openmw/mwmp/PlayerProcessor.hpp" + +namespace mwmp +{ + class ProcessorPlayerDrawState : public PlayerProcessor + { + public: + ProcessorPlayerDrawState() + { + BPP_INIT(ID_PLAYER_DRAWSTATE) + } + + virtual void Do(PlayerPacket &packet, BasePlayer *player) + { + if (isLocal()) + { + if(isRequest()) + static_cast(player)->updateDrawStateAndFlags(true); + } + else + static_cast(player)->updateDrawState(); + } + }; +} + + +#endif //OPENMW_PROCESSORPLAYERDRAWSTATE_HPP diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerDynamicStats.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerDynamicStats.hpp new file mode 100644 index 000000000..7dd33eadb --- /dev/null +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerDynamicStats.hpp @@ -0,0 +1,47 @@ +// +// Created by koncord on 16.04.17. +// + +#ifndef OPENMW_PROCESSORPLAYERDYNAMICSTATS_HPP +#define OPENMW_PROCESSORPLAYERDYNAMICSTATS_HPP + + +#include "apps/openmw/mwmp/PlayerProcessor.hpp" + +namespace mwmp +{ + class ProcessorPlayerDynamicStats : public PlayerProcessor + { + public: + ProcessorPlayerDynamicStats() + { + BPP_INIT(ID_PLAYER_DYNAMICSTATS) + } + + virtual void Do(PlayerPacket &packet, BasePlayer *player) + { + if (isLocal()) + { + if (isRequest()) + static_cast(player)->updateDynamicStats(true); + else + static_cast(player)->setDynamicStats(); + } + else + { + MWWorld::Ptr ptrPlayer = static_cast(player)->getPtr(); + MWMechanics::CreatureStats *ptrCreatureStats = &ptrPlayer.getClass().getCreatureStats(ptrPlayer); + MWMechanics::DynamicStat value; + + for (int i = 0; i < 3; ++i) + { + value.readState(player->creatureStats.mDynamic[i]); + ptrCreatureStats->setDynamic(i, value); + } + } + } + }; +} + + +#endif //OPENMW_PROCESSORPLAYERDYNAMICSTATS_HPP diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerEquipment.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerEquipment.hpp new file mode 100644 index 000000000..c6cbf1ee8 --- /dev/null +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerEquipment.hpp @@ -0,0 +1,36 @@ +// +// Created by koncord on 16.04.17. +// + +#ifndef OPENMW_PROCESSORPLAYEREQUIPMENT_HPP +#define OPENMW_PROCESSORPLAYEREQUIPMENT_HPP + + +#include "apps/openmw/mwmp/PlayerProcessor.hpp" + +namespace mwmp +{ + class ProcessorPlayerEquipment : public PlayerProcessor + { + public: + ProcessorPlayerEquipment() + { + BPP_INIT(ID_PLAYER_EQUIPMENT) + } + + virtual void Do(PlayerPacket &packet, BasePlayer *player) + { + if (isLocal()) + { + if (isRequest()) + static_cast(player)->updateEquipment(true); + else + static_cast(player)->setEquipment(); + } + else + static_cast(player)->updateEquipment(); + } + }; +} + +#endif //OPENMW_PROCESSORPLAYEREQUIPMENT_HPP diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerInventory.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerInventory.hpp new file mode 100644 index 000000000..150d7100d --- /dev/null +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerInventory.hpp @@ -0,0 +1,43 @@ +// +// Created by koncord on 16.04.17. +// + +#ifndef OPENMW_PROCESSORPLAYERUPDATEINVENTORY_HPP +#define OPENMW_PROCESSORPLAYERUPDATEINVENTORY_HPP + + +#include "apps/openmw/mwmp/PlayerProcessor.hpp" + +namespace mwmp +{ + class ProcessorPlayerInventory : public PlayerProcessor + { + public: + ProcessorPlayerInventory() + { + BPP_INIT(ID_PLAYER_INVENTORY) + } + + virtual void Do(PlayerPacket &packet, BasePlayer *player) + { + if (!isLocal()) return; + + if (isRequest()) + static_cast(player)->updateInventory(true); + else + { + LocalPlayer &localPlayer = static_cast(*player); + int inventoryAction = localPlayer.inventoryChanges.action; + + if (inventoryAction == InventoryChanges::ADD) + localPlayer.addItems(); + else if (inventoryAction == InventoryChanges::REMOVE) + localPlayer.removeItems(); + else // InventoryChanges::SET + localPlayer.setInventory(); + } + } + }; +} + +#endif //OPENMW_PROCESSORPLAYERUPDATEINVENTORY_HPP diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerJournal.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerJournal.hpp new file mode 100644 index 000000000..c1b8b5f2e --- /dev/null +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerJournal.hpp @@ -0,0 +1,36 @@ +// +// Created by koncord on 16.04.17. +// + +#ifndef OPENMW_PROCESSORPLAYERJOURNAL_HPP +#define OPENMW_PROCESSORPLAYERJOURNAL_HPP + + +#include "apps/openmw/mwmp/PlayerProcessor.hpp" + +namespace mwmp +{ + class ProcessorPlayerJournal : public PlayerProcessor + { + public: + ProcessorPlayerJournal() + { + BPP_INIT(ID_PLAYER_JOURNAL) + } + + virtual void Do(PlayerPacket &packet, BasePlayer *player) + { + if (!isLocal()) return; + + if (isRequest()) + { + // Entire journal cannot currently be requested from players + } + else + static_cast(player)->addJournalItems(); + } + }; +} + + +#endif //OPENMW_PROCESSORPLAYERJOURNAL_HPP diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerLevel.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerLevel.hpp new file mode 100644 index 000000000..d86acdd7d --- /dev/null +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerLevel.hpp @@ -0,0 +1,42 @@ +// +// Created by koncord on 16.04.17. +// + +#ifndef OPENMW_PROCESSORPLAYERLEVEL_HPP +#define OPENMW_PROCESSORPLAYERLEVEL_HPP + + +#include "apps/openmw/mwmp/PlayerProcessor.hpp" + +namespace mwmp +{ + class ProcessorPlayerLevel : public PlayerProcessor + { + public: + ProcessorPlayerLevel() + { + BPP_INIT(ID_PLAYER_LEVEL) + } + + virtual void Do(PlayerPacket &packet, BasePlayer *player) + { + if (isLocal()) + { + if(isRequest()) + static_cast(player)->updateLevel(true); + else + static_cast(player)->setLevel(); + } + else + { + MWWorld::Ptr ptrPlayer = static_cast(player)->getPtr(); + MWMechanics::CreatureStats *ptrCreatureStats = &ptrPlayer.getClass().getCreatureStats(ptrPlayer); + + ptrCreatureStats->setLevel(player->creatureStats.mLevel); + } + } + }; +} + + +#endif //OPENMW_PROCESSORPLAYERLEVEL_HPP diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerPos.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerPos.hpp new file mode 100644 index 000000000..2fbaeb503 --- /dev/null +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerPos.hpp @@ -0,0 +1,41 @@ +// +// Created by koncord on 16.04.17. +// + +#ifndef OPENMW_PROCESSORPLAYERPOS_HPP +#define OPENMW_PROCESSORPLAYERPOS_HPP + + +#include "apps/openmw/mwmp/PlayerProcessor.hpp" + +namespace mwmp +{ + class ProcessorPlayerPos : public PlayerProcessor + { + public: + ProcessorPlayerPos() + { + BPP_INIT(ID_PLAYER_POS) + } + + virtual void Do(PlayerPacket &packet, BasePlayer *player) + { + if (isLocal()) + { + if (!isRequest()) + { + LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "ID_PLAYER_POS changed by server"); + + static_cast(player)->setPosition(); + } + else + static_cast(player)->updatePosition(true); + } + else // dedicated player + static_cast(player)->updateMarker(); + } + }; +} + + +#endif //OPENMW_PROCESSORPLAYERPOS_HPP diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerResurrect.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerResurrect.hpp new file mode 100644 index 000000000..4122bed58 --- /dev/null +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerResurrect.hpp @@ -0,0 +1,67 @@ +// +// Created by koncord on 16.04.17. +// + +#ifndef OPENMW_PROCESSORPLAYERRESURRECT_HPP +#define OPENMW_PROCESSORPLAYERRESURRECT_HPP + + +#include "apps/openmw/mwmp/PlayerProcessor.hpp" +#include "apps/openmw/mwmp/Main.hpp" +#include "apps/openmw/mwmp/Networking.hpp" + +namespace mwmp +{ + class ProcessorPlayerResurrect : public PlayerProcessor + { + public: + ProcessorPlayerResurrect() + { + BPP_INIT(ID_PLAYER_RESURRECT) + avoidReading = true; + } + + virtual void Do(PlayerPacket &packet, BasePlayer *player) + { + LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_PLAYER_RESURRECT from server"); + + if (isLocal()) + { + LOG_APPEND(Log::LOG_INFO, "- Packet was about me"); + + MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayerPtr(); + playerPtr.getClass().getCreatureStats(playerPtr).resurrect(); + + // If this player had a weapon or spell readied when dying, they will + // still have it readied but be unable to use it unless we clear it here + playerPtr.getClass().getNpcStats(playerPtr).setDrawState(MWMechanics::DrawState_Nothing); + + packet.setPlayer(player); + packet.Send(serverAddr); + + static_cast(player)->updateDynamicStats(true); + Main::get().getNetworking()->getPlayerPacket(ID_PLAYER_DYNAMICSTATS)->setPlayer(player); + Main::get().getNetworking()->getPlayerPacket(ID_PLAYER_DYNAMICSTATS)->Send(serverAddr); + } + else + { + LOG_APPEND(Log::LOG_INFO, "- Packet was about %s", player->npc.mName.c_str()); + + player->creatureStats.mDead = false; + if (player->creatureStats.mDynamic[0].mMod < 1) + player->creatureStats.mDynamic[0].mMod = 1; + player->creatureStats.mDynamic[0].mCurrent = player->creatureStats.mDynamic[0].mMod; + + MWWorld::Ptr ptr = static_cast(player)->getPtr(); + + ptr.getClass().getCreatureStats(ptr).resurrect(); + + MWMechanics::DynamicStat health; + health.readState(player->creatureStats.mDynamic[0]); + ptr.getClass().getCreatureStats(ptr).setHealth(health); + } + } + }; +} + +#endif //OPENMW_PROCESSORPLAYERRESURRECT_HPP diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerSkill.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerSkill.hpp new file mode 100644 index 000000000..ccfe2d2b4 --- /dev/null +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerSkill.hpp @@ -0,0 +1,47 @@ +// +// Created by koncord on 16.04.17. +// + +#ifndef OPENMW_PROCESSORPLAYERSKILL_HPP +#define OPENMW_PROCESSORPLAYERSKILL_HPP + + +#include "apps/openmw/mwmp/PlayerProcessor.hpp" + +namespace mwmp +{ + class ProcessorPlayerSkill : public PlayerProcessor + { + public: + ProcessorPlayerSkill() + { + BPP_INIT(ID_PLAYER_SKILL) + } + + virtual void Do(PlayerPacket &packet, BasePlayer *player) + { + if (isLocal()) + { + if(isRequest()) + static_cast(player)->updateSkills(true); + else + static_cast(player)->setSkills(); + } + else + { + MWWorld::Ptr ptrPlayer = static_cast(player)->getPtr(); + MWMechanics::NpcStats *ptrNpcStats = &ptrPlayer.getClass().getNpcStats(ptrPlayer); + MWMechanics::SkillValue skillValue; + + for (int i = 0; i < 27; ++i) + { + skillValue.readState(player->npcStats.mSkills[i]); + ptrNpcStats->setSkill(i, skillValue); + } + } + } + }; +} + + +#endif //OPENMW_PROCESSORPLAYERSKILL_HPP diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerSpellbook.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerSpellbook.hpp new file mode 100644 index 000000000..d446b6099 --- /dev/null +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerSpellbook.hpp @@ -0,0 +1,44 @@ +// +// Created by koncord on 16.04.17. +// + +#ifndef OPENMW_PROCESSORPLAYERSPELLBOOK_HPP +#define OPENMW_PROCESSORPLAYERSPELLBOOK_HPP + + +#include "apps/openmw/mwmp/PlayerProcessor.hpp" + +namespace mwmp +{ + class ProcessorPlayerSpellbook : public PlayerProcessor + { + public: + ProcessorPlayerSpellbook() + { + BPP_INIT(ID_PLAYER_SPELLBOOK) + } + + virtual void Do(PlayerPacket &packet, BasePlayer *player) + { + if (!isLocal()) return; + + if (isRequest()) + static_cast(player)->sendSpellbook(); + else + { + LocalPlayer &localPlayer = static_cast(*player); + + int spellbookAction = localPlayer.spellbookChanges.action; + + if (spellbookAction == SpellbookChanges::ADD) + localPlayer.addSpells(); + else if (spellbookAction == SpellbookChanges::REMOVE) + localPlayer.removeSpells(); + else // SpellbookChanges::SET + localPlayer.setSpellbook(); + } + } + }; +} + +#endif //OPENMW_PROCESSORPLAYERSPELLBOOK_HPP diff --git a/apps/openmw/mwmp/processors/player/ProcessorUserDisconnected.hpp b/apps/openmw/mwmp/processors/player/ProcessorUserDisconnected.hpp new file mode 100644 index 000000000..bccb1eb20 --- /dev/null +++ b/apps/openmw/mwmp/processors/player/ProcessorUserDisconnected.hpp @@ -0,0 +1,33 @@ +// +// Created by koncord on 16.04.17. +// + +#ifndef OPENMW_PROCESSORUSERDISCONNECTED_HPP +#define OPENMW_PROCESSORUSERDISCONNECTED_HPP + + +#include "apps/openmw/mwmp/PlayerProcessor.hpp" +#include "apps/openmw/mwstate/statemanagerimp.hpp" + +namespace mwmp +{ + class ProcessorUserDisconnected : public PlayerProcessor + { + public: + ProcessorUserDisconnected() + { + BPP_INIT(ID_USER_DISCONNECTED) + avoidReading = true; + } + + virtual void Do(PlayerPacket &packet, BasePlayer *player) + { + if (isLocal()) + MWBase::Environment::get().getStateManager()->requestQuit(); + else + Players::disconnectPlayer(guid); + } + }; +} + +#endif //OPENMW_PROCESSORUSERDISCONNECTED_HPP diff --git a/apps/openmw/mwmp/processors/player/ProcessorUserMyID.hpp b/apps/openmw/mwmp/processors/player/ProcessorUserMyID.hpp new file mode 100644 index 000000000..bdd0a8b94 --- /dev/null +++ b/apps/openmw/mwmp/processors/player/ProcessorUserMyID.hpp @@ -0,0 +1,31 @@ +// +// Created by koncord on 16.04.17. +// + +#ifndef OPENMW_PROCESSORUSERMYID_HPP +#define OPENMW_PROCESSORUSERMYID_HPP + + +#include "apps/openmw/mwmp/PlayerProcessor.hpp" + +namespace mwmp +{ + class ProcessorUserMyID : public PlayerProcessor + { + public: + ProcessorUserMyID() + { + BPP_INIT(ID_USER_MYID) + avoidReading = true; + } + + virtual void Do(PlayerPacket &packet, BasePlayer *player) + { + LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_USER_MYID from server"); + myGuid = guid; + getLocalPlayer()->guid = guid; + } + }; +} + +#endif //OPENMW_PROCESSORUSERMYID_HPP From e98fa6ad0739ed3b603725491b8fd1ddb19d532b Mon Sep 17 00:00:00 2001 From: Koncord Date: Sun, 16 Apr 2017 15:01:16 +0800 Subject: [PATCH 3/9] [Client] Add ProcessorInitializer --- apps/openmw/CMakeLists.txt | 3 +- apps/openmw/mwmp/ProcessorInitializer.cpp | 95 +++++++++++++++++++++++ apps/openmw/mwmp/ProcessorInitializer.hpp | 11 +++ 3 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 apps/openmw/mwmp/ProcessorInitializer.cpp create mode 100644 apps/openmw/mwmp/ProcessorInitializer.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 958c23d89..520b9ec9e 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -96,7 +96,8 @@ add_openmw_dir (mwbase inputmanager windowmanager statemanager ) -add_openmw_dir (mwmp Main Networking LocalPlayer DedicatedPlayer LocalActor DedicatedActor ActorList WorldEvent Cell CellController MechanicsHelper GUIChat GUILogin GUIController PlayerMarkerCollection GUIDialogList) +add_openmw_dir (mwmp Main Networking LocalPlayer DedicatedPlayer LocalActor DedicatedActor ActorList WorldEvent Cell CellController MechanicsHelper GUIChat GUILogin + GUIController PlayerMarkerCollection GUIDialogList WorldController PlayerProcessor WorldProcesssor ProcessorInitializer) # Main executable diff --git a/apps/openmw/mwmp/ProcessorInitializer.cpp b/apps/openmw/mwmp/ProcessorInitializer.cpp new file mode 100644 index 000000000..5a10951b9 --- /dev/null +++ b/apps/openmw/mwmp/ProcessorInitializer.cpp @@ -0,0 +1,95 @@ +// +// Created by koncord on 31.03.17. +// + +#include "ProcessorInitializer.hpp" + +#include "PlayerProcessor.hpp" +#include "processors/player/ProcessorPlayerPos.hpp" +#include "processors/player/ProcessorPlayerCellChange.hpp" +#include "processors/player/ProcessorPlayerCellState.hpp" +#include "processors/player/ProcessorPlayerAttribute.hpp" +#include "processors/player/ProcessorPlayerSkill.hpp" +#include "processors/player/ProcessorPlayerLevel.hpp" +#include "processors/player/ProcessorPlayerEquipment.hpp" +#include "processors/player/ProcessorPlayerInventory.hpp" +#include "processors/player/ProcessorPlayerSpellbook.hpp" +#include "processors/player/ProcessorPlayerJournal.hpp" +#include "processors/player/ProcessorPlayerAttack.hpp" +#include "processors/player/ProcessorPlayerDynamicStats.hpp" +#include "processors/player/ProcessorPlayerDeath.hpp" +#include "processors/player/ProcessorPlayerResurrect.hpp" +#include "processors/player/ProcessorPlayerDrawState.hpp" +#include "processors/player/ProcessorChatMessage.hpp" +#include "processors/player/ProcessorPlayerCharGen.hpp" +#include "processors/player/ProcessorGUIMessageBox.hpp" +#include "processors/player/ProcessorPlayerCharClass.hpp" +#include "processors/player/ProcessorHandshake.hpp" +#include "processors/player/ProcessorPlayerBaseInfo.hpp" +#include "processors/player/ProcessorUserDisconnected.hpp" +#include "processors/player/ProcessorUserMyID.hpp" + +/*#include "WorldProcessor.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/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" +#include "processors/world/ProcessorScriptGlobalShort.hpp" +#include "processors/world/ProcessorScriptLocalFloat.hpp" +#include "processors/world/ProcessorScriptLocalShort.hpp" +#include "processors/world/ProcessorScriptMemberShort.hpp" +#include "processors/world/ProcessorVideoPlay.hpp"*/ + + +using namespace mwmp; + +void ProcessorInitializer() +{ + PlayerProcessor::AddProcessor(new ProcessorPlayerPos()); + PlayerProcessor::AddProcessor(new ProcessorPlayerCellChange()); + PlayerProcessor::AddProcessor(new ProcessorPlayerCellState()); + PlayerProcessor::AddProcessor(new ProcessorPlayerAttribute()); + PlayerProcessor::AddProcessor(new ProcessorPlayerSkill()); + PlayerProcessor::AddProcessor(new ProcessorPlayerLevel()); + PlayerProcessor::AddProcessor(new ProcessorPlayerEquipment()); + PlayerProcessor::AddProcessor(new ProcessorPlayerInventory()); + PlayerProcessor::AddProcessor(new ProcessorPlayerSpellbook()); + PlayerProcessor::AddProcessor(new ProcessorPlayerJournal()); + PlayerProcessor::AddProcessor(new ProcessorPlayerAttack()); + PlayerProcessor::AddProcessor(new ProcessorPlayerDynamicStats()); + PlayerProcessor::AddProcessor(new ProcessorPlayerDeath()); + PlayerProcessor::AddProcessor(new ProcessorPlayerResurrect()); + PlayerProcessor::AddProcessor(new ProcessorPlayerDrawState()); + PlayerProcessor::AddProcessor(new ProcessorChatMessage()); + PlayerProcessor::AddProcessor(new ProcessorPlayerCharGen()); + PlayerProcessor::AddProcessor(new ProcessorGUIMessageBox()); + PlayerProcessor::AddProcessor(new ProcessorPlayerCharClass()); + PlayerProcessor::AddProcessor(new ProcessorHandshake()); + PlayerProcessor::AddProcessor(new ProcessorPlayerBaseInfo()); + PlayerProcessor::AddProcessor(new ProcessorUserDisconnected()); + PlayerProcessor::AddProcessor(new ProcessorUserMyID()); + + /*WorldProcessor::AddProcessor(new ProcessorContainer()); + WorldProcessor::AddProcessor(new ProcessorDoorState()); + WorldProcessor::AddProcessor(new ProcessorMusicPlay()); + WorldProcessor::AddProcessor(new ProcessorObjectAnimPlay()); + WorldProcessor::AddProcessor(new ProcessorObjectDelete()); + WorldProcessor::AddProcessor(new ProcessorObjectLock()); + WorldProcessor::AddProcessor(new ProcessorObjectMove()); + WorldProcessor::AddProcessor(new ProcessorObjectPlace()); + WorldProcessor::AddProcessor(new ProcessorObjectRotate()); + WorldProcessor::AddProcessor(new ProcessorObjectScale()); + WorldProcessor::AddProcessor(new ProcessorObjectUnlock()); + WorldProcessor::AddProcessor(new ProcessorScriptGlobalShort()); + WorldProcessor::AddProcessor(new ProcessorScriptLocalFloat()); + WorldProcessor::AddProcessor(new ProcessorScriptLocalShort()); + WorldProcessor::AddProcessor(new ProcessorScriptMemberShort()); + WorldProcessor::AddProcessor(new ProcessorVideoPlay());*/ +} \ No newline at end of file diff --git a/apps/openmw/mwmp/ProcessorInitializer.hpp b/apps/openmw/mwmp/ProcessorInitializer.hpp new file mode 100644 index 000000000..f4a5aa515 --- /dev/null +++ b/apps/openmw/mwmp/ProcessorInitializer.hpp @@ -0,0 +1,11 @@ +// +// Created by koncord on 31.03.17. +// + +#ifndef OPENMW_INIT_PROCESSORS_HPP +#define OPENMW_INIT_PROCESSORS_HPP + +void ProcessorInitializer(); + + +#endif //OPENMW_INIT_PROCESSORS_HPP From 740bfea0b2a52662f30fda65eed4f1fbced0773a Mon Sep 17 00:00:00 2001 From: Koncord Date: Sun, 16 Apr 2017 15:02:37 +0800 Subject: [PATCH 4/9] [Client] Use processors for player packets --- apps/openmw/mwmp/Networking.cpp | 535 +------------------------------- 1 file changed, 4 insertions(+), 531 deletions(-) diff --git a/apps/openmw/mwmp/Networking.cpp b/apps/openmw/mwmp/Networking.cpp index 4af89067c..f9027fef0 100644 --- a/apps/openmw/mwmp/Networking.cpp +++ b/apps/openmw/mwmp/Networking.cpp @@ -55,6 +55,7 @@ Networking::Networking(): peer(RakNet::RakPeerInterface::GetInstance()), playerP worldPacketController.SetStream(0, &bsOut); connected = 0; + ProcessorInitializer(); } Networking::~Networking() @@ -151,6 +152,7 @@ void Networking::connect(const std::string &ip, unsigned short port, std::vector case ID_CONNECTION_REQUEST_ACCEPTED: { serverAddr = packet->systemAddress; + PlayerProcessor::SetServerAddr(packet->systemAddress); connected = true; queue = false; @@ -245,537 +247,8 @@ void Networking::preInit(std::vector &content, Files::Collections & void Networking::processPlayerPacket(RakNet::Packet *packet) { - RakNet::RakNetGUID guid; - RakNet::BitStream bsIn(&packet->data[1], packet->length, false); - bsIn.Read(guid); - - DedicatedPlayer *pl = 0; - static RakNet::RakNetGUID myGuid = getLocalPlayer()->guid; - if (guid != myGuid) - pl = PlayerList::getPlayer(guid); - - PlayerPacket *myPacket = playerPacketController.GetPacket(packet->data[0]); - - switch (packet->data[0]) - { - case ID_HANDSHAKE: - { - myPacket->setPlayer(getLocalPlayer()); - myPacket->Send(serverAddr); - break; - } - case ID_PLAYER_BASEINFO: - { - LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_PLAYER_BASEINFO from server"); - - if (guid == myGuid) - { - LOG_APPEND(Log::LOG_INFO, "- Packet was about my id"); - - if (packet->length == myPacket->headerSize()) - { - LOG_APPEND(Log::LOG_INFO, "- Requesting info"); - - myPacket->setPlayer(getLocalPlayer()); - myPacket->Send(serverAddr); - } - else - { - myPacket->setPlayer(getLocalPlayer()); - myPacket->Packet(&bsIn, false); - LOG_APPEND(Log::LOG_INFO, "- Updating LocalPlayer"); - getLocalPlayer()->updateChar(); - } - } - else - { - LOG_APPEND(Log::LOG_INFO, "- Packet was about %s", pl == 0 ? "new player" : pl->npc.mName.c_str()); - - if (pl == 0) - { - LOG_APPEND(Log::LOG_INFO, "- Exchanging data with new player"); - pl = PlayerList::newPlayer(guid); - } - - myPacket->setPlayer(pl); - myPacket->Packet(&bsIn, false); - PlayerList::createPlayer(guid); - } - break; - } - case ID_PLAYER_POS: - { - if (guid == myGuid) - { - if (packet->length != myPacket->headerSize()) - { - LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "ID_PLAYER_POS changed by server"); - - myPacket->setPlayer(getLocalPlayer()); - myPacket->Packet(&bsIn, false); - getLocalPlayer()->setPosition(); - } - else - getLocalPlayer()->updatePosition(true); - } - else if (pl != 0) - { - myPacket->setPlayer(pl); - myPacket->Packet(&bsIn, false); - pl->updateMarker(); - } - break; - } - case ID_USER_MYID: - { - LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_USER_MYID from server"); - myGuid = guid; - getLocalPlayer()->guid = guid; - break; - } - case ID_USER_DISCONNECTED: - { - if (guid == myGuid) - MWBase::Environment::get().getStateManager()->requestQuit(); - else if (pl != 0) - PlayerList::disconnectPlayer(guid); - - } - case ID_PLAYER_EQUIPMENT: - { - if (guid == myGuid) - { - if (packet->length == myPacket->headerSize()) - { - getLocalPlayer()->updateEquipment(true); - } - else - { - myPacket->setPlayer(getLocalPlayer()); - myPacket->Packet(&bsIn, false); - getLocalPlayer()->setEquipment(); - } - } - else if (pl != 0) - { - myPacket->setPlayer(pl); - myPacket->Packet(&bsIn, false); - pl->updateEquipment(); - } - break; - } - case ID_PLAYER_INVENTORY: - { - if (guid == myGuid) - { - if (packet->length == myPacket->headerSize()) - { - getLocalPlayer()->updateInventory(true); - } - else - { - myPacket->setPlayer(getLocalPlayer()); - myPacket->Packet(&bsIn, false); - int inventoryAction = getLocalPlayer()->inventoryChanges.action; - - if (inventoryAction == InventoryChanges::ADD) - { - getLocalPlayer()->addItems(); - } - else if (inventoryAction == InventoryChanges::REMOVE) - { - getLocalPlayer()->removeItems(); - } - else // InventoryChanges::SET - { - getLocalPlayer()->setInventory(); - } - } - } - break; - } - case ID_PLAYER_SPELLBOOK: - { - if (guid == myGuid) - { - if (packet->length == myPacket->headerSize()) - { - getLocalPlayer()->sendSpellbook(); - } - else - { - myPacket->setPlayer(getLocalPlayer()); - myPacket->Packet(&bsIn, false); - int spellbookAction = getLocalPlayer()->spellbookChanges.action; - - if (spellbookAction == SpellbookChanges::ADD) - { - getLocalPlayer()->addSpells(); - } - else if (spellbookAction == SpellbookChanges::REMOVE) - { - getLocalPlayer()->removeSpells(); - } - else // SpellbookChanges::SET - { - getLocalPlayer()->setSpellbook(); - } - } - } - break; - } - case ID_PLAYER_JOURNAL: - { - if (guid == myGuid) - { - if (packet->length == myPacket->headerSize()) - { - // Entire journal cannot currently be requested from players - } - else - { - myPacket->setPlayer(getLocalPlayer()); - myPacket->Packet(&bsIn, false); - getLocalPlayer()->addJournalItems(); - } - } - break; - } - case ID_PLAYER_ATTACK: - { - if (pl != 0) - { - myPacket->setPlayer(pl); - myPacket->Packet(&bsIn, false); - - Main::get().getMechanicsHelper()->processAttack(pl->getPtr(), pl->attack); - } - break; - } - case ID_PLAYER_STATS_DYNAMIC: - { - if (guid == myGuid) - { - if (packet->length == myPacket->headerSize()) - { - getLocalPlayer()->updateStatsDynamic(true); - } - else - { - myPacket->setPlayer(getLocalPlayer()); - myPacket->Packet(&bsIn, false); - getLocalPlayer()->setDynamicStats(); - } - } - else if (pl != 0) - { - myPacket->setPlayer(pl); - myPacket->Packet(&bsIn, false); - - MWWorld::Ptr ptrPlayer = pl->getPtr(); - MWMechanics::CreatureStats *ptrCreatureStats = &ptrPlayer.getClass().getCreatureStats(ptrPlayer); - MWMechanics::DynamicStat value; - - for (int i = 0; i < 3; ++i) - { - value.readState(pl->creatureStats.mDynamic[i]); - ptrCreatureStats->setDynamic(i, value); - } - } - break; - } - case ID_PLAYER_DEATH: - { - LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_PLAYER_DEATH from server"); - - if (guid == myGuid) - { - LOG_APPEND(Log::LOG_INFO, "- Packet was about me"); - - MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); - MWMechanics::DynamicStat health = player.getClass().getCreatureStats(player).getHealth(); - health.setCurrent(0); - player.getClass().getCreatureStats(player).setHealth(health); - myPacket->setPlayer(getLocalPlayer()); - myPacket->Send(serverAddr); - } - else if (pl != 0) - { - LOG_APPEND(Log::LOG_INFO, "- Packet was about %s", pl->npc.mName.c_str()); - - MWMechanics::DynamicStat health; - pl->creatureStats.mDead = true; - health.readState(pl->creatureStats.mDynamic[0]); - health.setCurrent(0); - health.writeState(pl->creatureStats.mDynamic[0]); - pl->getPtr().getClass().getCreatureStats(pl->getPtr()).setHealth(health); - } - break; - } - case ID_PLAYER_RESURRECT: - { - LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_PLAYER_RESURRECT from server"); - - if (guid == myGuid) - { - LOG_APPEND(Log::LOG_INFO, "- Packet was about me"); - - MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); - player.getClass().getCreatureStats(player).resurrect(); - - // If this player had a weapon or spell readied when dying, they will - // still have it readied but be unable to use it unless we clear it here - player.getClass().getNpcStats(player).setDrawState(MWMechanics::DrawState_Nothing); - - myPacket->setPlayer(getLocalPlayer()); - myPacket->Send(serverAddr); - - getLocalPlayer()->updateStatsDynamic(true); - playerPacketController.GetPacket(ID_PLAYER_STATS_DYNAMIC)->setPlayer(getLocalPlayer()); - playerPacketController.GetPacket(ID_PLAYER_STATS_DYNAMIC)->Send(serverAddr); - } - else if (pl != 0) - { - LOG_APPEND(Log::LOG_INFO, "- Packet was about %s", pl->npc.mName.c_str()); - - pl->creatureStats.mDead = false; - if (pl->creatureStats.mDynamic[0].mMod < 1) - pl->creatureStats.mDynamic[0].mMod = 1; - pl->creatureStats.mDynamic[0].mCurrent = pl->creatureStats.mDynamic[0].mMod; - - pl->getPtr().getClass().getCreatureStats(pl->getPtr()).resurrect(); - - MWMechanics::DynamicStat health; - health.readState(pl->creatureStats.mDynamic[0]); - pl->getPtr().getClass().getCreatureStats(pl->getPtr()).setHealth(health); - } - break; - } - case ID_PLAYER_CELL_CHANGE: - { - if (guid == myGuid) - { - if (packet->length == myPacket->headerSize()) - getLocalPlayer()->updateCell(true); - else - { - myPacket->setPlayer(getLocalPlayer()); - myPacket->Packet(&bsIn, false); - getLocalPlayer()->setCell(); - } - } - else if (pl != 0) - { - myPacket->setPlayer(pl); - myPacket->Packet(&bsIn, false); - pl->updateCell(); - } - break; - } - case ID_PLAYER_CELL_STATE: - { - if (guid == myGuid) - { - if (packet->length == myPacket->headerSize()) - getLocalPlayer()->sendCellStates(); - } - - break; - } - case ID_PLAYER_ANIM_FLAGS: - { - if (guid == myGuid) - getLocalPlayer()->updateAnimFlags(true); - else if (pl != 0) - { - myPacket->setPlayer(pl); - myPacket->Packet(&bsIn, false); - pl->updateAnimFlags(); - } - break; - } - case ID_CHAT_MESSAGE: - { - std::string message; - if (guid == myGuid) - { - myPacket->setPlayer(getLocalPlayer()); - myPacket->Packet(&bsIn, false); - message = getLocalPlayer()->chatMessage; - } - else if (pl != 0) - { - myPacket->setPlayer(pl); - myPacket->Packet(&bsIn, false); - message = pl->chatMessage; - } - Main::get().getGUIController()->printChatMessage(message); - - break; - } - case ID_PLAYER_CHARGEN: - { - if (guid == myGuid) - { - myPacket->setPlayer(getLocalPlayer()); - myPacket->Packet(&bsIn, false); - } - break; - } - case ID_PLAYER_ATTRIBUTE: - { - if (guid == myGuid) - { - if (packet->length == myPacket->headerSize()) - { - getLocalPlayer()->updateAttributes(true); - } - else - { - myPacket->setPlayer(getLocalPlayer()); - myPacket->Packet(&bsIn, false); - getLocalPlayer()->setAttributes(); - } - } - else if (pl != 0) - { - myPacket->setPlayer(pl); - myPacket->Packet(&bsIn, false); - - MWWorld::Ptr ptrPlayer = pl->getPtr(); - MWMechanics::CreatureStats *ptrCreatureStats = &ptrPlayer.getClass().getCreatureStats(ptrPlayer); - MWMechanics::AttributeValue attributeValue; - - for (int i = 0; i < 8; ++i) - { - attributeValue.readState(pl->creatureStats.mAttributes[i]); - ptrCreatureStats->setAttribute(i, attributeValue); - } - } - break; - } - case ID_PLAYER_SKILL: - { - if (guid == myGuid) - { - if (packet->length == myPacket->headerSize()) - { - getLocalPlayer()->updateSkills(true); - } - else - { - myPacket->setPlayer(getLocalPlayer()); - myPacket->Packet(&bsIn, false); - getLocalPlayer()->setSkills(); - } - } - else if (pl != 0) - { - myPacket->setPlayer(pl); - myPacket->Packet(&bsIn, false); - - MWWorld::Ptr ptrPlayer = pl->getPtr(); - MWMechanics::NpcStats *ptrNpcStats = &ptrPlayer.getClass().getNpcStats(ptrPlayer); - MWMechanics::SkillValue skillValue; - - for (int i = 0; i < 27; ++i) - { - skillValue.readState(pl->npcStats.mSkills[i]); - ptrNpcStats->setSkill(i, skillValue); - } - } - break; - } - case ID_PLAYER_LEVEL: - { - if (guid == myGuid) - { - if (packet->length == myPacket->headerSize()) - { - getLocalPlayer()->updateLevel(true); - } - else - { - myPacket->setPlayer(getLocalPlayer()); - myPacket->Packet(&bsIn, false); - getLocalPlayer()->setLevel(); - } - } - else if (pl != 0) - { - myPacket->setPlayer(pl); - myPacket->Packet(&bsIn, false); - - MWWorld::Ptr ptrPlayer = pl->getPtr(); - MWMechanics::CreatureStats *ptrCreatureStats = &ptrPlayer.getClass().getCreatureStats(ptrPlayer); - - ptrCreatureStats->setLevel(pl->creatureStats.mLevel); - } - break; - } - case ID_GUI_MESSAGEBOX: - { - if (guid == myGuid) - { - myPacket->setPlayer(getLocalPlayer()); - myPacket->Packet(&bsIn, false); - - LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "ID_GUI_MESSAGEBOX, Type %d, MSG %s", getLocalPlayer()->guiMessageBox.type, - getLocalPlayer()->guiMessageBox.label.c_str()); - - int messageBoxType = getLocalPlayer()->guiMessageBox.type; - - if (messageBoxType == BasePlayer::GUIMessageBox::MessageBox) - Main::get().getGUIController()->showMessageBox(getLocalPlayer()->guiMessageBox); - else if (messageBoxType == BasePlayer::GUIMessageBox::CustomMessageBox) - Main::get().getGUIController()->showCustomMessageBox(getLocalPlayer()->guiMessageBox); - else if (messageBoxType == BasePlayer::GUIMessageBox::InputDialog) - Main::get().getGUIController()->showInputBox(getLocalPlayer()->guiMessageBox); - else if (messageBoxType == BasePlayer::GUIMessageBox::ListBox) - Main::get().getGUIController()->showDialogList(getLocalPlayer()->guiMessageBox); - } - break; - } - case ID_PLAYER_CHARCLASS: - { - if (guid == myGuid) - { - if (packet->length == myPacket->headerSize()) - getLocalPlayer()->sendClass(); - else - { - myPacket->setPlayer(getLocalPlayer()); - myPacket->Packet(&bsIn, false); - getLocalPlayer()->setClass(); - } - } - break; - } - case ID_GAME_TIME: - { - if (guid == myGuid) - { - myPacket->setPlayer(getLocalPlayer()); - myPacket->Packet(&bsIn, false); - MWBase::World *world = MWBase::Environment::get().getWorld(); - if (getLocalPlayer()->hour != -1) - world->setHour(getLocalPlayer()->hour); - else if (getLocalPlayer()->day != -1) - world->setDay(getLocalPlayer()->day); - else if (getLocalPlayer()->month != -1) - world->setMonth(getLocalPlayer()->month); - } - break; - } - case ID_GAME_CONSOLE: - { - myPacket->setPlayer(getLocalPlayer()); - myPacket->Packet(&bsIn, false); - break; - } - default: - LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Unhandled PlayerPacket with identifier %i has arrived", packet->data[0]); - } + if(!PlayerProcessor::Process(*packet)) + LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Unhandled PlayerPacket with identifier %i has arrived", packet->data[0]); } void Networking::processActorPacket(RakNet::Packet *packet) From f0805ca6f7a2128d70e0990484ed1ff483b2c78d Mon Sep 17 00:00:00 2001 From: Koncord Date: Tue, 18 Apr 2017 11:35:50 +0800 Subject: [PATCH 5/9] [Client] Fix typo --- apps/openmw/CMakeLists.txt | 2 +- ...{WorldProcesssor.cpp => WorldProcessor.cpp} | 18 +++++++++--------- ...{WorldProcesssor.hpp => WorldProcessor.hpp} | 11 ++++++----- 3 files changed, 16 insertions(+), 15 deletions(-) rename apps/openmw/mwmp/{WorldProcesssor.cpp => WorldProcessor.cpp} (73%) rename apps/openmw/mwmp/{WorldProcesssor.hpp => WorldProcessor.hpp} (76%) diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 520b9ec9e..de33bb2bb 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -97,7 +97,7 @@ add_openmw_dir (mwbase ) add_openmw_dir (mwmp Main Networking LocalPlayer DedicatedPlayer LocalActor DedicatedActor ActorList WorldEvent Cell CellController MechanicsHelper GUIChat GUILogin - GUIController PlayerMarkerCollection GUIDialogList WorldController PlayerProcessor WorldProcesssor ProcessorInitializer) + GUIController PlayerMarkerCollection GUIDialogList WorldController PlayerProcessor WorldProcessor ProcessorInitializer) # Main executable diff --git a/apps/openmw/mwmp/WorldProcesssor.cpp b/apps/openmw/mwmp/WorldProcessor.cpp similarity index 73% rename from apps/openmw/mwmp/WorldProcesssor.cpp rename to apps/openmw/mwmp/WorldProcessor.cpp index fd0aeef2b..a70a89e1e 100644 --- a/apps/openmw/mwmp/WorldProcesssor.cpp +++ b/apps/openmw/mwmp/WorldProcessor.cpp @@ -3,18 +3,18 @@ // #include -#include "WorldProcesssor.hpp" +#include "WorldProcessor.hpp" #include "Main.hpp" #include "Networking.hpp" using namespace mwmp; -WorldProcesssor::processors_t WorldProcesssor::processors; -RakNet::RakNetGUID WorldProcesssor::guid; -RakNet::SystemAddress WorldProcesssor::serverAddr; -bool WorldProcesssor::request; +WorldProcessor::processors_t WorldProcessor::processors; +RakNet::RakNetGUID WorldProcessor::guid; +RakNet::SystemAddress WorldProcessor::serverAddr; +bool WorldProcessor::request; -bool WorldProcesssor::Process(RakNet::Packet &packet, BaseEvent &event) +bool WorldProcessor::Process(RakNet::Packet &packet, WorldEvent &event) { RakNet::BitStream bsIn(&packet.data[1], packet.length, false); bsIn.Read(guid); @@ -43,7 +43,7 @@ bool WorldProcesssor::Process(RakNet::Packet &packet, BaseEvent &event) return false; } -void WorldProcesssor::AddProcessor(mwmp::WorldProcesssor *processor) +void WorldProcessor::AddProcessor(mwmp::WorldProcessor *processor) { BOOST_FOREACH(processors_t::value_type &p, processors) { @@ -51,10 +51,10 @@ void WorldProcesssor::AddProcessor(mwmp::WorldProcesssor *processor) throw std::logic_error("processor " + p.second->strPacketID + " already registered. Check " + processor->className + " and " + p.second->className); } - processors.insert(processors_t::value_type(processor->GetPacketID(), boost::shared_ptr(processor))); + processors.insert(processors_t::value_type(processor->GetPacketID(), boost::shared_ptr(processor))); } -LocalPlayer *WorldProcesssor::getLocalPlayer() +LocalPlayer *WorldProcessor::getLocalPlayer() { return Main::get().getLocalPlayer(); } diff --git a/apps/openmw/mwmp/WorldProcesssor.hpp b/apps/openmw/mwmp/WorldProcessor.hpp similarity index 76% rename from apps/openmw/mwmp/WorldProcesssor.hpp rename to apps/openmw/mwmp/WorldProcessor.hpp index 1e0ff0de3..8a2f0ae55 100644 --- a/apps/openmw/mwmp/WorldProcesssor.hpp +++ b/apps/openmw/mwmp/WorldProcessor.hpp @@ -12,24 +12,25 @@ #include #include #include +#include "WorldEvent.hpp" #include "LocalPlayer.hpp" #include "DedicatedPlayer.hpp" namespace mwmp { - class WorldProcesssor : public BasePacketProcessor + class WorldProcessor : public BasePacketProcessor { public: - virtual void Do(WorldPacket &packet, BaseEvent &event) = 0; + virtual void Do(WorldPacket &packet, WorldEvent &event) = 0; - static bool Process(RakNet::Packet &packet, BaseEvent &event); - static void AddProcessor(WorldProcesssor *processor); + static bool Process(RakNet::Packet &packet, WorldEvent &event); + static void AddProcessor(WorldProcessor *processor); static void SetServerAddr(RakNet::SystemAddress addr) { serverAddr = addr; } - typedef boost::unordered_map > processors_t; + typedef boost::unordered_map > processors_t; protected: inline bool isRequest() From fd3a7d2ad0020b6c4ea2b829e8e53ca14a0fb631 Mon Sep 17 00:00:00 2001 From: Koncord Date: Tue, 18 Apr 2017 11:37:32 +0800 Subject: [PATCH 6/9] [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 From 7dcaef5a5a49865e0140285a19c7da9f73cdd7be Mon Sep 17 00:00:00 2001 From: Koncord Date: Tue, 18 Apr 2017 11:38:09 +0800 Subject: [PATCH 7/9] [Client] Init world processors --- apps/openmw/mwmp/ProcessorInitializer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwmp/ProcessorInitializer.cpp b/apps/openmw/mwmp/ProcessorInitializer.cpp index 5a10951b9..f569fc77a 100644 --- a/apps/openmw/mwmp/ProcessorInitializer.cpp +++ b/apps/openmw/mwmp/ProcessorInitializer.cpp @@ -29,7 +29,7 @@ #include "processors/player/ProcessorUserDisconnected.hpp" #include "processors/player/ProcessorUserMyID.hpp" -/*#include "WorldProcessor.hpp" +#include "WorldProcessor.hpp" #include "processors/world/ProcessorContainer.hpp" #include "processors/world/ProcessorDoorState.hpp" #include "processors/world/ProcessorMusicPlay.hpp" @@ -45,7 +45,7 @@ #include "processors/world/ProcessorScriptLocalFloat.hpp" #include "processors/world/ProcessorScriptLocalShort.hpp" #include "processors/world/ProcessorScriptMemberShort.hpp" -#include "processors/world/ProcessorVideoPlay.hpp"*/ +#include "processors/world/ProcessorVideoPlay.hpp" using namespace mwmp; @@ -76,7 +76,7 @@ void ProcessorInitializer() PlayerProcessor::AddProcessor(new ProcessorUserDisconnected()); PlayerProcessor::AddProcessor(new ProcessorUserMyID()); - /*WorldProcessor::AddProcessor(new ProcessorContainer()); + WorldProcessor::AddProcessor(new ProcessorContainer()); WorldProcessor::AddProcessor(new ProcessorDoorState()); WorldProcessor::AddProcessor(new ProcessorMusicPlay()); WorldProcessor::AddProcessor(new ProcessorObjectAnimPlay()); @@ -91,5 +91,5 @@ void ProcessorInitializer() WorldProcessor::AddProcessor(new ProcessorScriptLocalFloat()); WorldProcessor::AddProcessor(new ProcessorScriptLocalShort()); WorldProcessor::AddProcessor(new ProcessorScriptMemberShort()); - WorldProcessor::AddProcessor(new ProcessorVideoPlay());*/ + WorldProcessor::AddProcessor(new ProcessorVideoPlay()); } \ No newline at end of file From 578d305d86bff8a215e6089b1b26672656bdf1eb Mon Sep 17 00:00:00 2001 From: Koncord Date: Tue, 18 Apr 2017 11:38:35 +0800 Subject: [PATCH 8/9] [Client] Enable world processors --- apps/openmw/mwmp/Networking.cpp | 196 ++------------------------------ 1 file changed, 10 insertions(+), 186 deletions(-) diff --git a/apps/openmw/mwmp/Networking.cpp b/apps/openmw/mwmp/Networking.cpp index f9027fef0..502af5ebb 100644 --- a/apps/openmw/mwmp/Networking.cpp +++ b/apps/openmw/mwmp/Networking.cpp @@ -37,6 +37,13 @@ #include "MechanicsHelper.hpp" #include "LocalPlayer.hpp" #include "DedicatedPlayer.hpp" +#include "LocalPlayer.hpp" +#include "GUIController.hpp" +#include "WorldController.hpp" +#include "Main.hpp" +#include "PlayerProcessor.hpp" +#include "ProcessorInitializer.hpp" +#include "WorldProcessor.hpp" using namespace std; using namespace mwmp; @@ -153,6 +160,7 @@ void Networking::connect(const std::string &ip, unsigned short port, std::vector { serverAddr = packet->systemAddress; PlayerProcessor::SetServerAddr(packet->systemAddress); + WorldProcessor::SetServerAddr(packet->systemAddress); connected = true; queue = false; @@ -342,192 +350,8 @@ void Networking::processActorPacket(RakNet::Packet *packet) void Networking::processWorldPacket(RakNet::Packet *packet) { - RakNet::RakNetGUID guid; - RakNet::BitStream bsIn(&packet->data[1], packet->length, false); - bsIn.Read(guid); - - DedicatedPlayer *pl = 0; - static RakNet::RakNetGUID myGuid = getLocalPlayer()->guid; - if (guid != myGuid) - pl = PlayerList::getPlayer(guid); - - WorldPacket *myPacket = worldPacketController.GetPacket(packet->data[0]); - - myPacket->setEvent(&worldEvent); - myPacket->Packet(&bsIn, false); - - switch (packet->data[0]) - { - case ID_CONTAINER: - { - MWWorld::CellStore *ptrCellStore = Main::get().getCellController()->getCellStore(worldEvent.cell); - - if (!ptrCellStore) return; - - LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Received ID_CONTAINER about %s", worldEvent.cell.getDescription().c_str()); - LOG_APPEND(Log::LOG_VERBOSE, "- action: %i", worldEvent.action); - - // If we've received a request for information, comply with it - if (worldEvent.action == mwmp::BaseEvent::REQUEST) - worldEvent.sendContainers(ptrCellStore); - // Otherwise, edit containers based on the information received - else - worldEvent.editContainers(ptrCellStore); - - break; - } - case ID_OBJECT_PLACE: - { - MWWorld::CellStore *ptrCellStore = Main::get().getCellController()->getCellStore(worldEvent.cell); - - if (!ptrCellStore) return; - - LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_PLACE about %s", worldEvent.cell.getDescription().c_str()); - worldEvent.placeObjects(ptrCellStore); - - break; - } - case ID_OBJECT_DELETE: - { - MWWorld::CellStore *ptrCellStore = Main::get().getCellController()->getCellStore(worldEvent.cell); - - if (!ptrCellStore) return; - - LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_DELETE about %s", worldEvent.cell.getDescription().c_str()); - worldEvent.deleteObjects(ptrCellStore); - - break; - } - case ID_OBJECT_LOCK: - { - MWWorld::CellStore *ptrCellStore = Main::get().getCellController()->getCellStore(worldEvent.cell); - - if (!ptrCellStore) return; - - LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_LOCK about %s", worldEvent.cell.getDescription().c_str()); - worldEvent.lockObjects(ptrCellStore); - - break; - } - case ID_OBJECT_UNLOCK: - { - MWWorld::CellStore *ptrCellStore = Main::get().getCellController()->getCellStore(worldEvent.cell); - - if (!ptrCellStore) return; - - LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_UNLOCK about %s", worldEvent.cell.getDescription().c_str()); - worldEvent.unlockObjects(ptrCellStore); - - break; - } - case ID_OBJECT_SCALE: - { - MWWorld::CellStore *ptrCellStore = Main::get().getCellController()->getCellStore(worldEvent.cell); - - if (!ptrCellStore) return; - - LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_SCALE about %s", worldEvent.cell.getDescription().c_str()); - worldEvent.scaleObjects(ptrCellStore); - - break; - } - case ID_OBJECT_MOVE: - { - MWWorld::CellStore *ptrCellStore = Main::get().getCellController()->getCellStore(worldEvent.cell); - - if (!ptrCellStore) return; - - LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_MOVE about %s", worldEvent.cell.getDescription().c_str()); - worldEvent.moveObjects(ptrCellStore); - - break; - } - case ID_OBJECT_ROTATE: - { - MWWorld::CellStore *ptrCellStore = Main::get().getCellController()->getCellStore(worldEvent.cell); - - if (!ptrCellStore) return; - - LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_ROTATE about %s", worldEvent.cell.getDescription().c_str()); - worldEvent.rotateObjects(ptrCellStore); - - break; - } - case ID_OBJECT_ANIM_PLAY: - { - MWWorld::CellStore *ptrCellStore = Main::get().getCellController()->getCellStore(worldEvent.cell); - - if (!ptrCellStore) return; - - LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_ANIM_PLAY about %s", worldEvent.cell.getDescription().c_str()); - worldEvent.animateObjects(ptrCellStore); - - break; - } - case ID_DOOR_STATE: - { - MWWorld::CellStore *ptrCellStore = Main::get().getCellController()->getCellStore(worldEvent.cell); - - if (!ptrCellStore) return; - - LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_DOOR_STATE about %s", worldEvent.cell.getDescription().c_str()); - worldEvent.activateDoors(ptrCellStore); - - break; - } - case ID_SCRIPT_LOCAL_SHORT: - { - MWWorld::CellStore *ptrCellStore = Main::get().getCellController()->getCellStore(worldEvent.cell); - - if (!ptrCellStore) return; - - LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_SCRIPT_LOCAL_SHORT about %s", worldEvent.cell.getDescription().c_str()); - worldEvent.setLocalShorts(ptrCellStore); - - break; - } - case ID_SCRIPT_LOCAL_FLOAT: - { - MWWorld::CellStore *ptrCellStore = Main::get().getCellController()->getCellStore(worldEvent.cell); - - if (!ptrCellStore) return; - - LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_SCRIPT_LOCAL_FLOAT about %s", worldEvent.cell.getDescription().c_str()); - worldEvent.setLocalFloats(ptrCellStore); - - break; - } - case ID_SCRIPT_MEMBER_SHORT: - { - LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_SCRIPT_MEMBER_SHORT"); - worldEvent.setMemberShorts(); - - break; - } - case ID_SCRIPT_GLOBAL_SHORT: - { - LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_SCRIPT_GLOBAL_SHORT"); - worldEvent.setGlobalShorts(); - - break; - } - case ID_MUSIC_PLAY: - { - LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_MUSIC_PLAY"); - worldEvent.playMusic(); - - break; - } - case ID_VIDEO_PLAY: - { - LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_VIDEO_PLAY"); - worldEvent.playVideo(); - - break; - } - default: - LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Unhandled WorldPacket with identifier %i has arrived", packet->data[0]); - } + if (!WorldProcessor::Process(*packet, worldEvent)) + LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Unhandled WorldPacket with identifier %i has arrived", packet->data[0]); } void Networking::receiveMessage(RakNet::Packet *packet) From 25fef1a7b88e6d1ae81cc56961b3acb47cf9a802 Mon Sep 17 00:00:00 2001 From: Koncord Date: Tue, 18 Apr 2017 12:17:58 +0800 Subject: [PATCH 9/9] [Client] FIx conflicts --- apps/openmw/mwmp/Networking.cpp | 1 - apps/openmw/mwmp/PlayerProcessor.cpp | 2 +- .../player/ProcessorPlayerAttack.hpp | 58 +------------------ .../player/ProcessorPlayerBaseInfo.hpp | 4 +- .../player/ProcessorPlayerDrawState.hpp | 6 +- .../player/ProcessorPlayerDynamicStats.hpp | 4 +- .../player/ProcessorPlayerResurrect.hpp | 6 +- .../player/ProcessorUserDisconnected.hpp | 2 +- .../processors/world/BaseObjectProcessor.hpp | 4 +- 9 files changed, 17 insertions(+), 70 deletions(-) diff --git a/apps/openmw/mwmp/Networking.cpp b/apps/openmw/mwmp/Networking.cpp index 502af5ebb..20354af2c 100644 --- a/apps/openmw/mwmp/Networking.cpp +++ b/apps/openmw/mwmp/Networking.cpp @@ -39,7 +39,6 @@ #include "DedicatedPlayer.hpp" #include "LocalPlayer.hpp" #include "GUIController.hpp" -#include "WorldController.hpp" #include "Main.hpp" #include "PlayerProcessor.hpp" #include "ProcessorInitializer.hpp" diff --git a/apps/openmw/mwmp/PlayerProcessor.cpp b/apps/openmw/mwmp/PlayerProcessor.cpp index a8b790ce4..209b473cc 100644 --- a/apps/openmw/mwmp/PlayerProcessor.cpp +++ b/apps/openmw/mwmp/PlayerProcessor.cpp @@ -50,7 +50,7 @@ bool PlayerProcessor::Process(RakNet::Packet &packet) BasePlayer *player = 0; if (guid != myGuid) - player = Players::getPlayer(guid); + player = PlayerList::getPlayer(guid); else player = Main::get().getLocalPlayer(); diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerAttack.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerAttack.hpp index 437b98b3e..5503aac96 100644 --- a/apps/openmw/mwmp/processors/player/ProcessorPlayerAttack.hpp +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerAttack.hpp @@ -5,8 +5,9 @@ #ifndef OPENMW_PROCESSORPLAYERATTACK_HPP #define OPENMW_PROCESSORPLAYERATTACK_HPP - +#include "apps/openmw/mwmp/Main.hpp" #include "apps/openmw/mwmp/PlayerProcessor.hpp" +#include "apps/openmw/mwmp/MechanicsHelper.hpp" #include "apps/openmw/mwbase/world.hpp" #include "apps/openmw/mwworld/containerstore.hpp" #include "apps/openmw/mwworld/inventorystore.hpp" @@ -26,60 +27,7 @@ namespace mwmp virtual void Do(PlayerPacket &packet, BasePlayer *player) { - DedicatedPlayer &dedicatedPlayer = static_cast(*player); - //cout << "Player: " << dedicatedPlayer.Npc()->mName << " pressed: " << (dedicatedPlayer.getAttack()->pressed == 1) << endl; - if (dedicatedPlayer.attack.pressed == 0) - { - LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Attack success: %s", dedicatedPlayer.attack.success ? "true" : "false"); - - if (dedicatedPlayer.attack.success == 1) - LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Damage: %f",dedicatedPlayer.attack.damage); - } - - MWMechanics::CreatureStats &stats = dedicatedPlayer.getPtr().getClass().getNpcStats(dedicatedPlayer.getPtr()); - stats.getSpells().setSelectedSpell(dedicatedPlayer.attack.refid); - - MWWorld::Ptr victim; - if (dedicatedPlayer.attack.target == getLocalPlayer()->guid) - victim = MWBase::Environment::get().getWorld()->getPlayerPtr(); - else if (Players::getPlayer(dedicatedPlayer.attack.target) != 0) - victim = Players::getPlayer(dedicatedPlayer.attack.target)->getPtr(); - - MWWorld::Ptr attacker; - attacker = dedicatedPlayer.getPtr(); - - // Get the weapon used (if hand-to-hand, weapon = inv.end()) - if (dedicatedPlayer.drawState == 1) - { - MWWorld::InventoryStore &inv = attacker.getClass().getInventoryStore(attacker); - MWWorld::ContainerStoreIterator weaponslot = inv.getSlot( - MWWorld::InventoryStore::Slot_CarriedRight); - MWWorld::Ptr weapon = ((weaponslot != inv.end()) ? *weaponslot : MWWorld::Ptr()); - if (!weapon.isEmpty() && weapon.getTypeName() != typeid(ESM::Weapon).name()) - weapon = MWWorld::Ptr(); - - if (victim.mRef != 0) - { - bool healthdmg; - if (!weapon.isEmpty()) - healthdmg = true; - else - { - MWMechanics::CreatureStats &otherstats = victim.getClass().getCreatureStats(victim); - healthdmg = otherstats.isParalyzed() || otherstats.getKnockedDown(); - } - - if (!weapon.isEmpty()) - MWMechanics::blockMeleeAttack(attacker, victim, weapon, dedicatedPlayer.attack.damage, 1); - dedicatedPlayer.getPtr().getClass().onHit(victim, dedicatedPlayer.attack.damage, healthdmg, weapon, attacker, osg::Vec3f(), - dedicatedPlayer.attack.success); - } - } - else - { - LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "SpellId: %s", dedicatedPlayer.attack.refid.c_str()); - LOG_APPEND(Log::LOG_VERBOSE, " - success: %d", dedicatedPlayer.attack.success); - } + Main::get().getMechanicsHelper()->processAttack(static_cast(player)->getPtr(), player->attack); } }; } diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerBaseInfo.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerBaseInfo.hpp index 4504c80ee..110d96029 100644 --- a/apps/openmw/mwmp/processors/player/ProcessorPlayerBaseInfo.hpp +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerBaseInfo.hpp @@ -43,13 +43,13 @@ namespace mwmp if (player == 0) { LOG_APPEND(Log::LOG_INFO, "- Exchanging data with new player"); - player = Players::newPlayer(guid); + player = PlayerList::newPlayer(guid); packet.setPlayer(player); packet.Read(); } - Players::createPlayer(guid); + PlayerList::createPlayer(guid); } } }; diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerDrawState.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerDrawState.hpp index aeba23b50..6aff8f968 100644 --- a/apps/openmw/mwmp/processors/player/ProcessorPlayerDrawState.hpp +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerDrawState.hpp @@ -15,7 +15,7 @@ namespace mwmp public: ProcessorPlayerDrawState() { - BPP_INIT(ID_PLAYER_DRAWSTATE) + BPP_INIT(ID_PLAYER_ANIM_FLAGS) } virtual void Do(PlayerPacket &packet, BasePlayer *player) @@ -23,10 +23,10 @@ namespace mwmp if (isLocal()) { if(isRequest()) - static_cast(player)->updateDrawStateAndFlags(true); + static_cast(player)->updateAnimFlags(true); } else - static_cast(player)->updateDrawState(); + static_cast(player)->updateAnimFlags(); } }; } diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerDynamicStats.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerDynamicStats.hpp index 7dd33eadb..bf4a79704 100644 --- a/apps/openmw/mwmp/processors/player/ProcessorPlayerDynamicStats.hpp +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerDynamicStats.hpp @@ -15,7 +15,7 @@ namespace mwmp public: ProcessorPlayerDynamicStats() { - BPP_INIT(ID_PLAYER_DYNAMICSTATS) + BPP_INIT(ID_PLAYER_STATS_DYNAMIC) } virtual void Do(PlayerPacket &packet, BasePlayer *player) @@ -23,7 +23,7 @@ namespace mwmp if (isLocal()) { if (isRequest()) - static_cast(player)->updateDynamicStats(true); + static_cast(player)->updateStatsDynamic(true); else static_cast(player)->setDynamicStats(); } diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerResurrect.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerResurrect.hpp index 4122bed58..05d0c0c58 100644 --- a/apps/openmw/mwmp/processors/player/ProcessorPlayerResurrect.hpp +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerResurrect.hpp @@ -39,9 +39,9 @@ namespace mwmp packet.setPlayer(player); packet.Send(serverAddr); - static_cast(player)->updateDynamicStats(true); - Main::get().getNetworking()->getPlayerPacket(ID_PLAYER_DYNAMICSTATS)->setPlayer(player); - Main::get().getNetworking()->getPlayerPacket(ID_PLAYER_DYNAMICSTATS)->Send(serverAddr); + static_cast(player)->updateStatsDynamic(true); + Main::get().getNetworking()->getPlayerPacket(ID_PLAYER_STATS_DYNAMIC)->setPlayer(player); + Main::get().getNetworking()->getPlayerPacket(ID_PLAYER_STATS_DYNAMIC)->Send(serverAddr); } else { diff --git a/apps/openmw/mwmp/processors/player/ProcessorUserDisconnected.hpp b/apps/openmw/mwmp/processors/player/ProcessorUserDisconnected.hpp index bccb1eb20..eb3b38e7d 100644 --- a/apps/openmw/mwmp/processors/player/ProcessorUserDisconnected.hpp +++ b/apps/openmw/mwmp/processors/player/ProcessorUserDisconnected.hpp @@ -25,7 +25,7 @@ namespace mwmp if (isLocal()) MWBase::Environment::get().getStateManager()->requestQuit(); else - Players::disconnectPlayer(guid); + PlayerList::disconnectPlayer(guid); } }; } diff --git a/apps/openmw/mwmp/processors/world/BaseObjectProcessor.hpp b/apps/openmw/mwmp/processors/world/BaseObjectProcessor.hpp index 0e7e5356a..d3092f5bd 100644 --- a/apps/openmw/mwmp/processors/world/BaseObjectProcessor.hpp +++ b/apps/openmw/mwmp/processors/world/BaseObjectProcessor.hpp @@ -7,7 +7,7 @@ #include "apps/openmw/mwmp/WorldProcessor.hpp" #include "apps/openmw/mwmp/Main.hpp" -#include "apps/openmw/mwmp/WorldController.hpp" +#include "apps/openmw/mwmp/CellController.hpp" #include "apps/openmw/mwworld/cellstore.hpp" namespace mwmp @@ -17,7 +17,7 @@ namespace mwmp public: virtual void Do(WorldPacket &packet, WorldEvent &event) { - MWWorld::CellStore *ptrCellStore = Main::get().getWorldController()->getCell(event.cell); + MWWorld::CellStore *ptrCellStore = Main::get().getCellController()->getCellStore(event.cell); if (!ptrCellStore) return;