[General] Repurpose GameConsole packet as GameSettings & add difficulty to it

This commit is contained in:
David Cernat 2017-06-20 05:28:45 +03:00
parent df67ae4689
commit ebf7740969
14 changed files with 92 additions and 76 deletions

View file

@ -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);
}

View file

@ -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

View file

@ -2,6 +2,17 @@
#include <components/settings/settings.hpp>
/*
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)
*/

View file

@ -46,7 +46,10 @@ LocalPlayer::LocalPlayer()
{
charGenStage.current = 0;
charGenStage.end = 1;
consoleAllowed = true;
difficulty = 0;
ignorePosPacket = false;
attack.shouldSend = false;

View file

@ -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());

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -189,6 +189,8 @@ namespace mwmp
CurrentContainer currentContainer;
bool consoleAllowed;
int difficulty;
bool ignorePosPacket;
unsigned int movementFlags;

View file

@ -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<PacketHandshake>(&packets, peer);
AddPacket<PacketGUIBoxes>(&packets, peer);
AddPacket<PacketLoaded>(&packets, peer);
AddPacket<PacketConsole>(&packets, peer);
AddPacket<PacketGameSettings>(&packets, peer);
AddPacket<PacketGameTime>(&packets, peer);
AddPacket<PacketGameWeather>(&packets, peer);
AddPacket<PacketPlayerActiveSkills>(&packets, peer);

View file

@ -86,7 +86,7 @@ enum GameMessages
ID_SCRIPT_MEMBER_SHORT,
ID_SCRIPT_GLOBAL_SHORT,
ID_GAME_CONSOLE,
ID_GAME_SETTINGS,
ID_GAME_PREINIT
};

View file

@ -1,29 +0,0 @@
//
// Created by koncord on 04.11.16.
//
#ifndef OPENMW_PACKETCONSOLE_HPP
#define OPENMW_PACKETCONSOLE_HPP
#include <components/openmw-mp/Packets/Player/PlayerPacket.hpp>
#include <components/openmw-mp/NetworkMessages.hpp>
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

View file

@ -0,0 +1,18 @@
#include "PacketGameSettings.hpp"
#include <components/openmw-mp/NetworkMessages.hpp>
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);
}

View file

@ -0,0 +1,18 @@
#ifndef OPENMW_PACKETGAMESETTINGS_HPP
#define OPENMW_PACKETGAMESETTINGS_HPP
#include <components/openmw-mp/Packets/Player/PlayerPacket.hpp>
#include <components/openmw-mp/NetworkMessages.hpp>
namespace mwmp
{
class PacketGameSettings: public PlayerPacket
{
public:
PacketGameSettings(RakNet::RakPeerInterface *peer);
virtual void Packet(RakNet::BitStream *bs, bool send);
};
}
#endif //OPENMW_PACKETGAMESETTINGS_HPP