From d47b06fe7a7df845c7f58a7df7f9bf87449e774a Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sun, 29 Apr 2018 19:50:39 +0300 Subject: [PATCH] [Server] Prevent SetGameMode() and SetHostname() from crashing server Previously, turning off communication with the MasterServer from the server config and then attempting to use SetGameMode() or SetHostname() led to a server crash. --- apps/openmw-mp/Script/ScriptFunctions.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/openmw-mp/Script/ScriptFunctions.cpp b/apps/openmw-mp/Script/ScriptFunctions.cpp index edc4cd91b..56ec7b6ef 100644 --- a/apps/openmw-mp/Script/ScriptFunctions.cpp +++ b/apps/openmw-mp/Script/ScriptFunctions.cpp @@ -146,12 +146,14 @@ const char *ScriptFunctions::GetIP(unsigned short pid) noexcept void ScriptFunctions::SetGameMode(const char *gameMode) noexcept { - mwmp::Networking::getPtr()->getMasterClient()->SetModname(gameMode); + if (mwmp::Networking::getPtr()->getMasterClient()) + mwmp::Networking::getPtr()->getMasterClient()->SetModname(gameMode); } void ScriptFunctions::SetHostname(const char *name) noexcept { - mwmp::Networking::getPtr()->getMasterClient()->SetHostname(name); + if (mwmp::Networking::getPtr()->getMasterClient()) + mwmp::Networking::getPtr()->getMasterClient()->SetHostname(name); } void ScriptFunctions::SetServerPassword(const char *password) noexcept