forked from mirror/openmw-tes3mp
[Server] Add script functions to set & get plugin enforcement state
This commit is contained in:
parent
65d978a3cb
commit
1cf2f35a28
4 changed files with 49 additions and 1 deletions
|
@ -33,6 +33,7 @@ using namespace std;
|
|||
Networking *Networking::sThis = 0;
|
||||
|
||||
static int currentMpNum = 0;
|
||||
static bool pluginEnforcementState = true;
|
||||
|
||||
Networking::Networking(RakNet::RakPeerInterface *peer) : mclient(nullptr)
|
||||
{
|
||||
|
@ -232,14 +233,16 @@ void Networking::update(RakNet::Packet *packet)
|
|||
packetPreInit.SetSendStream(&bs);
|
||||
|
||||
// If the loop above was broken, then the client's plugins do not match the server's
|
||||
if (plugin != plugins.end())
|
||||
if (pluginEnforcementState && plugin != plugins.end())
|
||||
{
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "%s was not allowed to connect due to incompatible plugins", packet->systemAddress.ToString());
|
||||
packetPreInit.setChecksums(&samples);
|
||||
packetPreInit.Send(packet->systemAddress);
|
||||
peer->CloseConnection(packet->systemAddress, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "%s was allowed to connect", packet->systemAddress.ToString());
|
||||
PacketPreInit::PluginContainer tmp;
|
||||
packetPreInit.setChecksums(&tmp);
|
||||
packetPreInit.Send(packet->systemAddress);
|
||||
|
@ -373,6 +376,16 @@ int Networking::incrementMpNum()
|
|||
return currentMpNum;
|
||||
}
|
||||
|
||||
bool Networking::getPluginEnforcementState()
|
||||
{
|
||||
return pluginEnforcementState;
|
||||
}
|
||||
|
||||
void Networking::setPluginEnforcementState(bool state)
|
||||
{
|
||||
pluginEnforcementState = state;
|
||||
}
|
||||
|
||||
const Networking &Networking::get()
|
||||
{
|
||||
return *sThis;
|
||||
|
|
|
@ -52,6 +52,9 @@ namespace mwmp
|
|||
void setCurrentMpNum(int value);
|
||||
int incrementMpNum();
|
||||
|
||||
bool getPluginEnforcementState();
|
||||
void setPluginEnforcementState(bool state);
|
||||
|
||||
MasterClient *getMasterClient();
|
||||
void InitQuery(std::string queryAddr, unsigned short queryPort);
|
||||
void setServerPassword(std::string passw) noexcept;
|
||||
|
|
|
@ -43,6 +43,16 @@ void MiscellaneousFunctions::SetCurrentMpNum(int mpNum) noexcept
|
|||
mwmp::Networking::getPtr()->setCurrentMpNum(mpNum);
|
||||
}
|
||||
|
||||
int MiscellaneousFunctions::GetPluginEnforcementState() noexcept
|
||||
{
|
||||
return mwmp::Networking::getPtr()->getPluginEnforcementState();
|
||||
}
|
||||
|
||||
void MiscellaneousFunctions::SetPluginEnforcementState(bool state) noexcept
|
||||
{
|
||||
mwmp::Networking::getPtr()->setPluginEnforcementState(state);
|
||||
}
|
||||
|
||||
void MiscellaneousFunctions::LogMessage(unsigned short level, const char *message) noexcept
|
||||
{
|
||||
LOG_MESSAGE_SIMPLE(level, "[Script]: %s", message);
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
{"GetCurrentMpNum", MiscellaneousFunctions::GetCurrentMpNum},\
|
||||
{"SetCurrentMpNum", MiscellaneousFunctions::SetCurrentMpNum},\
|
||||
\
|
||||
{"GetPluginEnforcementState", MiscellaneousFunctions::GetPluginEnforcementState},\
|
||||
{"SetPluginEnforcementState", MiscellaneousFunctions::SetPluginEnforcementState},\
|
||||
\
|
||||
{"LogMessage", MiscellaneousFunctions::LogMessage},\
|
||||
{"LogAppend", MiscellaneousFunctions::LogAppend}
|
||||
|
||||
|
@ -64,6 +67,25 @@ public:
|
|||
*/
|
||||
static void SetCurrentMpNum(int mpNum) noexcept;
|
||||
|
||||
/**
|
||||
* \brief Get the plugin enforcement state of the server.
|
||||
*
|
||||
* If true, clients are required to use the same plugins as set for the server.
|
||||
*
|
||||
* \return The enforcement state.
|
||||
*/
|
||||
static int GetPluginEnforcementState() noexcept;
|
||||
|
||||
/**
|
||||
* \brief Set the plugin enforcement state of the server.
|
||||
*
|
||||
* If true, clients are required to use the same plugins as set for the server.
|
||||
*
|
||||
* \param state The new enforcement state.
|
||||
* \return void
|
||||
*/
|
||||
static void SetPluginEnforcementState(bool state) noexcept;
|
||||
|
||||
/**
|
||||
* \brief Write a log message with its own timestamp.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue