From ebf7740969283534a0e2e7daf034c50d67b1b56b Mon Sep 17 00:00:00 2001 From: David Cernat Date: Tue, 20 Jun 2017 05:28:45 +0300 Subject: [PATCH] [General] Repurpose GameConsole packet as GameSettings & add difficulty to it --- apps/openmw-mp/Script/Functions/GUI.cpp | 4 +-- apps/openmw/CMakeLists.txt | 2 +- apps/openmw/mwmechanics/difficultyscaling.cpp | 15 ++++++++-- apps/openmw/mwmp/LocalPlayer.cpp | 3 ++ .../mwmp/processors/ProcessorInitializer.cpp | 4 +-- .../player/ProcessorGameConsole.hpp | 30 ------------------- .../player/ProcessorGameSettings.hpp | 23 ++++++++++++++ components/CMakeLists.txt | 14 ++++----- components/openmw-mp/Base/BasePlayer.hpp | 2 ++ .../Controllers/PlayerPacketController.cpp | 4 +-- components/openmw-mp/NetworkMessages.hpp | 2 +- .../Packets/Player/PacketConsole.hpp | 29 ------------------ .../Packets/Player/PacketGameSettings.cpp | 18 +++++++++++ .../Packets/Player/PacketGameSettings.hpp | 18 +++++++++++ 14 files changed, 92 insertions(+), 76 deletions(-) delete mode 100644 apps/openmw/mwmp/processors/player/ProcessorGameConsole.hpp create mode 100644 apps/openmw/mwmp/processors/player/ProcessorGameSettings.hpp delete mode 100644 components/openmw-mp/Packets/Player/PacketConsole.hpp create mode 100644 components/openmw-mp/Packets/Player/PacketGameSettings.cpp create mode 100644 components/openmw-mp/Packets/Player/PacketGameSettings.hpp diff --git a/apps/openmw-mp/Script/Functions/GUI.cpp b/apps/openmw-mp/Script/Functions/GUI.cpp index 6780bfb00..b8614d57c 100644 --- a/apps/openmw-mp/Script/Functions/GUI.cpp +++ b/apps/openmw-mp/Script/Functions/GUI.cpp @@ -93,6 +93,6 @@ void GUIFunctions::SetConsoleAllow(unsigned short pid, bool state) player->consoleAllowed = state; - mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GAME_CONSOLE)->setPlayer(player); - mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GAME_CONSOLE)->Send(false); + mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GAME_SETTINGS)->setPlayer(player); + mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GAME_SETTINGS)->Send(false); } diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 613dc1d0f..97503b77b 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -112,7 +112,7 @@ add_openmw_dir (mwmp/processors/actor ProcessorActorAI ProcessorActorAnimFlags P ) add_openmw_dir (mwmp/processors/player ProcessorChatMessage ProcessorGUIMessageBox ProcessorHandshake ProcessorUserDisconnected - ProcessorUserMyID ProcessorGameConsole ProcessorGameTime ProcessorGameWeather ProcessorPlayerBaseInfo + ProcessorUserMyID ProcessorGameSettings ProcessorGameTime ProcessorGameWeather ProcessorPlayerBaseInfo ProcessorPlayerAnimFlags ProcessorPlayerAnimPlay ProcessorPlayerAttack ProcessorPlayerAttribute ProcessorPlayerBook ProcessorPlayerBounty ProcessorPlayerCellChange ProcessorPlayerCellState ProcessorPlayerCharClass ProcessorPlayerCharGen ProcessorPlayerDeath ProcessorPlayerDisposition ProcessorPlayerEquipment ProcessorPlayerFaction ProcessorPlayerInventory diff --git a/apps/openmw/mwmechanics/difficultyscaling.cpp b/apps/openmw/mwmechanics/difficultyscaling.cpp index 83dd41e52..d5007d68c 100644 --- a/apps/openmw/mwmechanics/difficultyscaling.cpp +++ b/apps/openmw/mwmechanics/difficultyscaling.cpp @@ -2,6 +2,17 @@ #include +/* + Start of tes3mp addition + + Include additional headers for multiplayer purposes +*/ +#include "../mwmp/Main.hpp" +#include "../mwmp/LocalPlayer.hpp" +/* + End of tes3mp addition +*/ + #include "../mwbase/world.hpp" #include "../mwbase/environment.hpp" #include "../mwworld/esmstore.hpp" @@ -18,9 +29,9 @@ float scaleDamage(float damage, const MWWorld::Ptr& attacker, const MWWorld::Ptr /* Start of tes3mp change (major) - Don't set difficulty based on client settings + Use difficulty setting received from server instead of basing it on client settings */ - difficultySetting = 0; + difficultySetting = mwmp::Main::get().getLocalPlayer()->difficulty; /* End of tes3mp change (major) */ diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index e44f46037..8fcf41628 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -46,7 +46,10 @@ LocalPlayer::LocalPlayer() { charGenStage.current = 0; charGenStage.end = 1; + consoleAllowed = true; + difficulty = 0; + ignorePosPacket = false; attack.shouldSend = false; diff --git a/apps/openmw/mwmp/processors/ProcessorInitializer.cpp b/apps/openmw/mwmp/processors/ProcessorInitializer.cpp index 1fcba13ad..63d64df7d 100644 --- a/apps/openmw/mwmp/processors/ProcessorInitializer.cpp +++ b/apps/openmw/mwmp/processors/ProcessorInitializer.cpp @@ -10,7 +10,7 @@ #include "player/ProcessorGUIMessageBox.hpp" #include "player/ProcessorHandshake.hpp" #include "player/ProcessorUserDisconnected.hpp" -#include "player/ProcessorGameConsole.hpp" +#include "player/ProcessorGameSettings.hpp" #include "player/ProcessorGameTime.hpp" #include "player/ProcessorGameWeather.hpp" #include "player/ProcessorPlayerBaseInfo.hpp" @@ -84,7 +84,7 @@ void ProcessorInitializer() PlayerProcessor::AddProcessor(new ProcessorGUIMessageBox()); PlayerProcessor::AddProcessor(new ProcessorHandshake()); PlayerProcessor::AddProcessor(new ProcessorUserDisconnected()); - PlayerProcessor::AddProcessor(new ProcessorGameConsole()); + PlayerProcessor::AddProcessor(new ProcessorGameSettings()); PlayerProcessor::AddProcessor(new ProcessorGameTime()); PlayerProcessor::AddProcessor(new ProcessorGameWeather()); PlayerProcessor::AddProcessor(new ProcessorPlayerBaseInfo()); diff --git a/apps/openmw/mwmp/processors/player/ProcessorGameConsole.hpp b/apps/openmw/mwmp/processors/player/ProcessorGameConsole.hpp deleted file mode 100644 index 381f7a162..000000000 --- a/apps/openmw/mwmp/processors/player/ProcessorGameConsole.hpp +++ /dev/null @@ -1,30 +0,0 @@ -// -// Created by koncord on 16.04.17. -// - -#ifndef OPENMW_PROCESSORGAMECONSOLE_HPP -#define OPENMW_PROCESSORGAMECONSOLE_HPP - - -#include "../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/ProcessorGameSettings.hpp b/apps/openmw/mwmp/processors/player/ProcessorGameSettings.hpp new file mode 100644 index 000000000..738de5b26 --- /dev/null +++ b/apps/openmw/mwmp/processors/player/ProcessorGameSettings.hpp @@ -0,0 +1,23 @@ +#ifndef OPENMW_PROCESSORGAMESETTINGS_HPP +#define OPENMW_PROCESSORGAMESETTINGS_HPP + +#include "../PlayerProcessor.hpp" + +namespace mwmp +{ + class ProcessorGameSettings : public PlayerProcessor + { + public: + ProcessorGameSettings() + { + BPP_INIT(ID_GAME_SETTINGS) + } + + virtual void Do(PlayerPacket &packet, BasePlayer *player) + { + + } + }; +} + +#endif //OPENMW_PROCESSORGAMESETTINGS_HPP diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 8faa880c4..dd2347306 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -176,13 +176,13 @@ add_component_dir (openmw-mp/Packets/Actor add_component_dir (openmw-mp/Packets/Player PlayerPacket - PacketHandshake PacketChatMessage PacketGUIBoxes PacketGameTime PacketGameWeather PacketPlayerBaseInfo PacketPlayerCharGen - PacketPlayerActiveSkills PacketPlayerAnimFlags PacketPlayerAnimPlay PacketPlayerAttack PacketPlayerAttribute - PacketPlayerBook PacketPlayerBounty PacketPlayerCellChange PacketPlayerCellState PacketPlayerClass - PacketPlayerDeath PacketPlayerEquipment PacketPlayerFaction PacketPlayerInventory PacketPlayerJournal - PacketPlayerKillCount PacketPlayerLevel PacketPlayerMap PacketPlayerPosition PacketPlayerRegionAuthority - PacketPlayerRest PacketPlayerResurrect PacketPlayerSkill PacketPlayerSpeech PacketPlayerSpellbook - PacketPlayerStatsDynamic PacketPlayerTopic + PacketHandshake PacketChatMessage PacketGUIBoxes PacketGameSettings PacketGameTime PacketGameWeather + PacketPlayerBaseInfo PacketPlayerCharGen PacketPlayerActiveSkills PacketPlayerAnimFlags PacketPlayerAnimPlay + PacketPlayerAttack PacketPlayerAttribute PacketPlayerBook PacketPlayerBounty PacketPlayerCellChange + PacketPlayerCellState PacketPlayerClass PacketPlayerDeath PacketPlayerEquipment PacketPlayerFaction + PacketPlayerInventory PacketPlayerJournal PacketPlayerKillCount PacketPlayerLevel PacketPlayerMap + PacketPlayerPosition PacketPlayerRegionAuthority PacketPlayerRest PacketPlayerResurrect PacketPlayerSkill + PacketPlayerSpeech PacketPlayerSpellbook PacketPlayerStatsDynamic PacketPlayerTopic ) add_component_dir (openmw-mp/Packets/World diff --git a/components/openmw-mp/Base/BasePlayer.hpp b/components/openmw-mp/Base/BasePlayer.hpp index 42db1e83b..a46e47b96 100644 --- a/components/openmw-mp/Base/BasePlayer.hpp +++ b/components/openmw-mp/Base/BasePlayer.hpp @@ -189,6 +189,8 @@ namespace mwmp CurrentContainer currentContainer; bool consoleAllowed; + int difficulty; + bool ignorePosPacket; unsigned int movementFlags; diff --git a/components/openmw-mp/Controllers/PlayerPacketController.cpp b/components/openmw-mp/Controllers/PlayerPacketController.cpp index 2417a4864..c18604d9b 100644 --- a/components/openmw-mp/Controllers/PlayerPacketController.cpp +++ b/components/openmw-mp/Controllers/PlayerPacketController.cpp @@ -8,7 +8,7 @@ #include "../Packets/Player/PacketHandshake.hpp" #include "../Packets/Player/PacketGUIBoxes.hpp" #include "../Packets/Player/PacketLoaded.hpp" -#include "../Packets/Player/PacketConsole.hpp" +#include "../Packets/Player/PacketGameSettings.hpp" #include "../Packets/Player/PacketGameTime.hpp" #include "../Packets/Player/PacketGameWeather.hpp" #include "../Packets/Player/PacketPlayerActiveSkills.hpp" @@ -57,7 +57,7 @@ mwmp::PlayerPacketController::PlayerPacketController(RakNet::RakPeerInterface *p AddPacket(&packets, peer); AddPacket(&packets, peer); AddPacket(&packets, peer); - AddPacket(&packets, peer); + AddPacket(&packets, peer); AddPacket(&packets, peer); AddPacket(&packets, peer); AddPacket(&packets, peer); diff --git a/components/openmw-mp/NetworkMessages.hpp b/components/openmw-mp/NetworkMessages.hpp index 9bcd284fe..4fba4784a 100644 --- a/components/openmw-mp/NetworkMessages.hpp +++ b/components/openmw-mp/NetworkMessages.hpp @@ -86,7 +86,7 @@ enum GameMessages ID_SCRIPT_MEMBER_SHORT, ID_SCRIPT_GLOBAL_SHORT, - ID_GAME_CONSOLE, + ID_GAME_SETTINGS, ID_GAME_PREINIT }; diff --git a/components/openmw-mp/Packets/Player/PacketConsole.hpp b/components/openmw-mp/Packets/Player/PacketConsole.hpp deleted file mode 100644 index 3a0dd002d..000000000 --- a/components/openmw-mp/Packets/Player/PacketConsole.hpp +++ /dev/null @@ -1,29 +0,0 @@ -// -// Created by koncord on 04.11.16. -// - -#ifndef OPENMW_PACKETCONSOLE_HPP -#define OPENMW_PACKETCONSOLE_HPP - -#include -#include - -namespace mwmp -{ - class PacketConsole: public PlayerPacket - { - public: - PacketConsole(RakNet::RakPeerInterface *peer) : PlayerPacket(peer) - { - packetID = ID_GAME_CONSOLE; - orderChannel = CHANNEL_SYSTEM; - } - void Packet(RakNet::BitStream *bs, bool send) - { - PlayerPacket::Packet(bs, send); - RW(player->consoleAllowed, send); - } - }; -} - -#endif //OPENMW_PACKETCONSOLE_HPP diff --git a/components/openmw-mp/Packets/Player/PacketGameSettings.cpp b/components/openmw-mp/Packets/Player/PacketGameSettings.cpp new file mode 100644 index 000000000..4e90d6c34 --- /dev/null +++ b/components/openmw-mp/Packets/Player/PacketGameSettings.cpp @@ -0,0 +1,18 @@ +#include "PacketGameSettings.hpp" +#include + +using namespace mwmp; + +PacketGameSettings::PacketGameSettings(RakNet::RakPeerInterface *peer) : PlayerPacket(peer) +{ + packetID = ID_GAME_SETTINGS; + orderChannel = CHANNEL_SYSTEM; +} + +void PacketGameSettings::Packet(RakNet::BitStream *bs, bool send) +{ + PlayerPacket::Packet(bs, send); + + RW(player->consoleAllowed, send); + RW(player->difficulty, send); +} diff --git a/components/openmw-mp/Packets/Player/PacketGameSettings.hpp b/components/openmw-mp/Packets/Player/PacketGameSettings.hpp new file mode 100644 index 000000000..1ee0db4be --- /dev/null +++ b/components/openmw-mp/Packets/Player/PacketGameSettings.hpp @@ -0,0 +1,18 @@ +#ifndef OPENMW_PACKETGAMESETTINGS_HPP +#define OPENMW_PACKETGAMESETTINGS_HPP + +#include +#include + +namespace mwmp +{ + class PacketGameSettings: public PlayerPacket + { + public: + PacketGameSettings(RakNet::RakPeerInterface *peer); + + virtual void Packet(RakNet::BitStream *bs, bool send); + }; +} + +#endif //OPENMW_PACKETGAMESETTINGS_HPP