Add new API function: SetConsoleAllow

example:
tes3mp.SetConsoleAllow(pid, 0) -- disallow console to the player

The console is allowed by default
coverity_scan^2
Koncord 8 years ago
parent 3759127627
commit 37e9cafbf7

@ -67,4 +67,14 @@ void GUIFunctions::SetMapVisibility(unsigned short targetPID, unsigned short aff
void GUIFunctions::SetMapVisibilityAll(unsigned short targetPID, unsigned short state) noexcept
{
LOG_MESSAGE(Log::LOG_WARN, "%s", "stub");
}
}
void GUIFunctions::SetConsoleAllow(unsigned short pid, char state)
{
Player *player;
GET_PLAYER(pid, player,);
player->consoleAllowed = state;
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_CONSOLE)->Send(player, false);
}

@ -11,7 +11,8 @@
{"InputDialog", GUIFunctions::InputDialog},\
{"ListBox", GUIFunctions::ListBox},\
{"SetMapVisibility", GUIFunctions::SetMapVisibility},\
{"SetMapVisibilityAll", GUIFunctions::SetMapVisibilityAll}\
{"SetMapVisibilityAll", GUIFunctions::SetMapVisibilityAll},\
{"SetConsoleAllow", GUIFunctions::SetConsoleAllow}\
class GUIFunctions
{
@ -27,6 +28,8 @@ public:
//state 0 - disallow, 1 - allow
static void SetMapVisibility(unsigned short targetPID, unsigned short affectedPID, unsigned short state) noexcept;
static void SetMapVisibilityAll(unsigned short targetPID, unsigned short state) noexcept;
static void SetConsoleAllow(unsigned short pid, char state);
};
#endif //OPENMW_GUI_HPP

@ -200,6 +200,8 @@ void mwmp::GUIController::update(float dt)
Main::get().getNetworking()->GetPlayerPacket(ID_GUI_MESSAGEBOX)->Send(Main::get().getLocalPlayer());
}
blockConsole();
}
void mwmp::GUIController::WM_UpdateVisible(MWGui::GuiMode mode)
@ -369,3 +371,13 @@ void mwmp::GUIController::updateGlobalMapMarkerTooltips(MWGui::MapWindow *mapWin
setGlobalMapMarkerTooltip(mapWindow, markerWidget, 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();
}

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

@ -34,6 +34,7 @@ LocalPlayer::LocalPlayer()
{
CharGenStage()->current = 0;
CharGenStage()->end = 1;
consoleAllowed = true;
}
LocalPlayer::~LocalPlayer()

@ -675,6 +675,11 @@ void Networking::ProcessPlayerPacket(RakNet::Packet *packet)
}
break;
}
case ID_GAME_CONSOLE:
{
myPacket->Packet(&bsIn, getLocalPlayer(), false);
break;
}
default:
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Unhandled PlayerPacket with identifier %i has arrived",
packet->data[0]);

@ -168,6 +168,7 @@ namespace mwmp
int day;
double hour;
Inventory inventory;
bool consoleAllowed;
protected:
ESM::Position pos;

@ -24,6 +24,7 @@
#include "../Packets/Player/PacketTime.hpp"
#include "../Packets/Player/PacketLoaded.hpp"
#include "../Packets/Player/PacketInventory.hpp"
#include "../Packets/Player/PacketConsole.hpp"
#include "PlayerPacketController.hpp"
@ -63,6 +64,8 @@ mwmp::PlayerPacketController::PlayerPacketController(RakNet::RakPeerInterface *p
AddPacket<PacketTime>(&packets, peer);
AddPacket<PacketLoaded>(&packets, peer);
AddPacket<PacketInventory>(&packets, peer);
AddPacket<PacketConsole>(&packets, peer);
}

@ -50,7 +50,9 @@ enum GameMessages
ID_SCRIPT_LOCAL_SHORT,
ID_SCRIPT_LOCAL_FLOAT,
ID_SCRIPT_MEMBER_SHORT,
ID_SCRIPT_GLOBAL_SHORT
ID_SCRIPT_GLOBAL_SHORT,
ID_GAME_CONSOLE
};

@ -0,0 +1,29 @@
//
// 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;
}
void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send)
{
PlayerPacket::Packet(bs, player, send);
RW(player->consoleAllowed, send);
}
};
}
#endif //OPENMW_PACKETCONSOLE_HPP
Loading…
Cancel
Save