[Client] Use less exploitable way of disabling console

Previously, large framerate drops allowed players to open and use the console for short periods of time.
0.6.1
David Cernat 7 years ago
parent 056d54e9f7
commit 8f543fb34e

@ -13,7 +13,16 @@
#include <components/sdlutil/sdlinputwrapper.hpp>
#include <components/sdlutil/sdlvideowrapper.hpp>
/*
Start of tes3mp addition
Include additional headers for multiplayer purposes
*/
#include "../mwmp/Main.hpp"
#include "../mwmp/LocalPlayer.hpp"
/*
End of tes3mp addition
*/
#include <components/esm/esmwriter.hpp>
#include <components/esm/esmreader.hpp>
@ -1026,6 +1035,17 @@ namespace MWInput
void InputManager::toggleConsole()
{
/*
Start of tes3mp addition
If a player's console is disabled by the server, go no further
*/
if (!mwmp::Main::get().getLocalPlayer()->consoleAllowed)
return;
/*
End of tes3mp addition
*/
if (MyGUI::InputManager::getInstance ().isModalAny())
return;

@ -214,8 +214,6 @@ void mwmp::GUIController::update(float dt)
Main::get().getNetworking()->getPlayerPacket(ID_GUI_MESSAGEBOX)->setPlayer(Main::get().getLocalPlayer());
Main::get().getNetworking()->getPlayerPacket(ID_GUI_MESSAGEBOX)->Send();
}
blockConsole();
}
void mwmp::GUIController::WM_UpdateVisible(MWGui::GuiMode mode)
@ -383,13 +381,3 @@ void mwmp::GUIController::updateGlobalMapMarkerTooltips(MWGui::MapWindow *mapWin
setGlobalMapMarkerTooltip(mapWindow, widget.second, x, y);
}
}
void mwmp::GUIController::blockConsole()
{
if (Main::get().getLocalPlayer()->consoleAllowed)
return;
if (MWBase::Environment::get().getWindowManager()->isGuiMode())
if (MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_Console)
MWBase::Environment::get().getWindowManager()->popGuiMode();
}

@ -74,7 +74,6 @@ namespace mwmp
GUIDialogList *mListBox;
void onInputBoxDone(MWGui::WindowBase* parWindow);
//MyGUI::Widget *oldFocusWidget, *currentFocusWidget;
void blockConsole();
};
}

@ -47,7 +47,7 @@ LocalPlayer::LocalPlayer()
charGenStage.current = 0;
charGenStage.end = 1;
consoleAllowed = true;
consoleAllowed = false;
difficulty = 0;
ignorePosPacket = false;

@ -1,6 +1,9 @@
#ifndef OPENMW_PROCESSORGAMESETTINGS_HPP
#define OPENMW_PROCESSORGAMESETTINGS_HPP
#include "apps/openmw/mwbase/environment.hpp"
#include "apps/openmw/mwgui/windowmanagerimp.hpp"
#include "../PlayerProcessor.hpp"
namespace mwmp
@ -15,7 +18,16 @@ namespace mwmp
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
if (isLocal())
{
if (MWBase::Environment::get().getWindowManager()->isGuiMode())
{
if (MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_Console && !player->consoleAllowed)
{
MWBase::Environment::get().getWindowManager()->popGuiMode();
}
}
}
}
};
}

Loading…
Cancel
Save