mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-04-01 20:36:42 +00:00
[Server] Add experimental option for not crashing from Lua script errors
Additionally, fix return type of GetPluginEnforcementState()
This commit is contained in:
parent
b39e3f518b
commit
b7090b2550
5 changed files with 58 additions and 6 deletions
|
@ -31,6 +31,7 @@ Networking *Networking::sThis = 0;
|
||||||
|
|
||||||
static int currentMpNum = 0;
|
static int currentMpNum = 0;
|
||||||
static bool pluginEnforcementState = true;
|
static bool pluginEnforcementState = true;
|
||||||
|
static bool scriptErrorIgnoringState = false;
|
||||||
|
|
||||||
Networking::Networking(RakNet::RakPeerInterface *peer) : mclient(nullptr)
|
Networking::Networking(RakNet::RakPeerInterface *peer) : mclient(nullptr)
|
||||||
{
|
{
|
||||||
|
@ -430,6 +431,16 @@ void Networking::setPluginEnforcementState(bool state)
|
||||||
pluginEnforcementState = state;
|
pluginEnforcementState = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Networking::getScriptErrorIgnoringState()
|
||||||
|
{
|
||||||
|
return scriptErrorIgnoringState;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Networking::setScriptErrorIgnoringState(bool state)
|
||||||
|
{
|
||||||
|
scriptErrorIgnoringState = state;
|
||||||
|
}
|
||||||
|
|
||||||
const Networking &Networking::get()
|
const Networking &Networking::get()
|
||||||
{
|
{
|
||||||
return *sThis;
|
return *sThis;
|
||||||
|
|
|
@ -56,6 +56,9 @@ namespace mwmp
|
||||||
bool getPluginEnforcementState();
|
bool getPluginEnforcementState();
|
||||||
void setPluginEnforcementState(bool state);
|
void setPluginEnforcementState(bool state);
|
||||||
|
|
||||||
|
bool getScriptErrorIgnoringState();
|
||||||
|
void setScriptErrorIgnoringState(bool state);
|
||||||
|
|
||||||
MasterClient *getMasterClient();
|
MasterClient *getMasterClient();
|
||||||
void InitQuery(std::string queryAddr, unsigned short queryPort);
|
void InitQuery(std::string queryAddr, unsigned short queryPort);
|
||||||
void setServerPassword(std::string passw) noexcept;
|
void setServerPassword(std::string passw) noexcept;
|
||||||
|
|
|
@ -75,11 +75,16 @@ bool ServerFunctions::HasPassword() noexcept
|
||||||
return mwmp::Networking::get().isPassworded();
|
return mwmp::Networking::get().isPassworded();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ServerFunctions::GetPluginEnforcementState() noexcept
|
bool ServerFunctions::GetPluginEnforcementState() noexcept
|
||||||
{
|
{
|
||||||
return mwmp::Networking::getPtr()->getPluginEnforcementState();
|
return mwmp::Networking::getPtr()->getPluginEnforcementState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ServerFunctions::GetScriptErrorIgnoringState() noexcept
|
||||||
|
{
|
||||||
|
return mwmp::Networking::getPtr()->getScriptErrorIgnoringState();
|
||||||
|
}
|
||||||
|
|
||||||
void ServerFunctions::SetGameMode(const char *gameMode) noexcept
|
void ServerFunctions::SetGameMode(const char *gameMode) noexcept
|
||||||
{
|
{
|
||||||
if (mwmp::Networking::getPtr()->getMasterClient())
|
if (mwmp::Networking::getPtr()->getMasterClient())
|
||||||
|
@ -102,6 +107,11 @@ void ServerFunctions::SetPluginEnforcementState(bool state) noexcept
|
||||||
mwmp::Networking::getPtr()->setPluginEnforcementState(state);
|
mwmp::Networking::getPtr()->setPluginEnforcementState(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ServerFunctions::SetScriptErrorIgnoringState(bool state) noexcept
|
||||||
|
{
|
||||||
|
mwmp::Networking::getPtr()->setScriptErrorIgnoringState(state);
|
||||||
|
}
|
||||||
|
|
||||||
void ServerFunctions::SetRuleString(const char *key, const char *value) noexcept
|
void ServerFunctions::SetRuleString(const char *key, const char *value) noexcept
|
||||||
{
|
{
|
||||||
auto mc = mwmp::Networking::getPtr()->getMasterClient();
|
auto mc = mwmp::Networking::getPtr()->getMasterClient();
|
||||||
|
|
|
@ -18,11 +18,13 @@
|
||||||
{"GetPort", ServerFunctions::GetPort},\
|
{"GetPort", ServerFunctions::GetPort},\
|
||||||
{"HasPassword", ServerFunctions::HasPassword},\
|
{"HasPassword", ServerFunctions::HasPassword},\
|
||||||
{"GetPluginEnforcementState", ServerFunctions::GetPluginEnforcementState},\
|
{"GetPluginEnforcementState", ServerFunctions::GetPluginEnforcementState},\
|
||||||
|
{"GetScriptErrorIgnoringState", ServerFunctions::GetScriptErrorIgnoringState},\
|
||||||
\
|
\
|
||||||
{"SetGameMode", ServerFunctions::SetGameMode},\
|
{"SetGameMode", ServerFunctions::SetGameMode},\
|
||||||
{"SetHostname", ServerFunctions::SetHostname},\
|
{"SetHostname", ServerFunctions::SetHostname},\
|
||||||
{"SetServerPassword", ServerFunctions::SetServerPassword},\
|
{"SetServerPassword", ServerFunctions::SetServerPassword},\
|
||||||
{"SetPluginEnforcementState", ServerFunctions::SetPluginEnforcementState},\
|
{"SetPluginEnforcementState", ServerFunctions::SetPluginEnforcementState},\
|
||||||
|
{"SetScriptErrorIgnoringState", ServerFunctions::SetScriptErrorIgnoringState},\
|
||||||
{"SetRuleString", ServerFunctions::SetRuleString},\
|
{"SetRuleString", ServerFunctions::SetRuleString},\
|
||||||
{"SetRuleValue", ServerFunctions::SetRuleValue},\
|
{"SetRuleValue", ServerFunctions::SetRuleValue},\
|
||||||
{"AddPluginHash", ServerFunctions::AddPluginHash}
|
{"AddPluginHash", ServerFunctions::AddPluginHash}
|
||||||
|
@ -121,7 +123,16 @@ public:
|
||||||
*
|
*
|
||||||
* \return The enforcement state.
|
* \return The enforcement state.
|
||||||
*/
|
*/
|
||||||
static int GetPluginEnforcementState() noexcept;
|
static bool GetPluginEnforcementState() noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Get the script error ignoring state of the server.
|
||||||
|
*
|
||||||
|
* If true, script errors will not crash the server.
|
||||||
|
*
|
||||||
|
* \return The script error ignoring state.
|
||||||
|
*/
|
||||||
|
static bool GetScriptErrorIgnoringState() noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set the game mode of the server, as displayed in the server browser.
|
* \brief Set the game mode of the server, as displayed in the server browser.
|
||||||
|
@ -157,6 +168,18 @@ public:
|
||||||
*/
|
*/
|
||||||
static void SetPluginEnforcementState(bool state) noexcept;
|
static void SetPluginEnforcementState(bool state) noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Set whether script errors should be ignored or not.
|
||||||
|
*
|
||||||
|
* If true, script errors will not crash the server, but could have any number
|
||||||
|
* of unforeseen consequences, which is why this is a highly experimental
|
||||||
|
* setting.
|
||||||
|
*
|
||||||
|
* \param state The new script error ignoring state.
|
||||||
|
* \return void
|
||||||
|
*/
|
||||||
|
static void SetScriptErrorIgnoringState(bool state) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set a rule string for the server details displayed in the server browser.
|
* \brief Set a rule string for the server details displayed in the server browser.
|
||||||
*
|
*
|
||||||
|
|
|
@ -4,15 +4,18 @@
|
||||||
|
|
||||||
#ifndef PLUGINSYSTEM3_SCRIPT_HPP
|
#ifndef PLUGINSYSTEM3_SCRIPT_HPP
|
||||||
#define PLUGINSYSTEM3_SCRIPT_HPP
|
#define PLUGINSYSTEM3_SCRIPT_HPP
|
||||||
|
|
||||||
|
#include <boost/any.hpp>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "Types.hpp"
|
#include "Types.hpp"
|
||||||
#include "SystemInterface.hpp"
|
#include "SystemInterface.hpp"
|
||||||
#include "ScriptFunction.hpp"
|
#include "ScriptFunction.hpp"
|
||||||
#include "ScriptFunctions.hpp"
|
#include "ScriptFunctions.hpp"
|
||||||
#include "Language.hpp"
|
#include "Language.hpp"
|
||||||
|
|
||||||
#include <boost/any.hpp>
|
#include "Networking.hpp"
|
||||||
#include <unordered_map>
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
class Script : private ScriptFunctions
|
class Script : private ScriptFunctions
|
||||||
{
|
{
|
||||||
|
@ -98,7 +101,9 @@ public:
|
||||||
catch (std::exception &e)
|
catch (std::exception &e)
|
||||||
{
|
{
|
||||||
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, e.what());
|
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, e.what());
|
||||||
throw;
|
|
||||||
|
if (!mwmp::Networking::getPtr()->getScriptErrorIgnoringState())
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue