aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjackpoz <giacomopoz@gmail.com>2016-08-03 16:26:30 +0200
committerjoschiwald <joschiwald.trinity@gmail.com>2017-02-11 21:43:03 +0100
commit6367be09fa04d681342982164089982c70d0325d (patch)
tree708eadcac34fe8a902be0b12a55ca8b90514d659 /src
parenta0d886020d66c626182724d4340566c0639cb33c (diff)
Scripts/Commands: Change "server shutdown" behavior
Change "server shutdown" behavior to always include [force] optional parameter when issued from local or remote console. (cherry picked from commit 884736b3b279737c44b0954ca3fe0f193085fbb3)
Diffstat (limited to 'src')
-rw-r--r--src/server/scripts/Commands/cs_server.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/server/scripts/Commands/cs_server.cpp b/src/server/scripts/Commands/cs_server.cpp
index 79c3945505d..fb6df1f8863 100644
--- a/src/server/scripts/Commands/cs_server.cpp
+++ b/src/server/scripts/Commands/cs_server.cpp
@@ -198,10 +198,14 @@ public:
return true;
}
- static inline bool IsOnlyUser(WorldSession* mySession)
+ static bool AlwaysForceShutdown(WorldSession* mySession)
{
+ // if mySession is null then the shutdown command was issued from console (local or remote), always shutdown in this case
+ if (!mySession)
+ return true;
+
// check if there is any session connected from a different address
- std::string myAddr = mySession ? mySession->GetRemoteAddress() : "";
+ std::string myAddr = mySession->GetRemoteAddress();
SessionMap const& sessions = sWorld->GetAllSessions();
for (SessionMap::value_type const& session : sessions)
if (session.second && myAddr != session.second->GetRemoteAddress())
@@ -210,12 +214,12 @@ public:
}
static bool HandleServerShutDownCommand(ChatHandler* handler, char const* args)
{
- return ShutdownServer(args, IsOnlyUser(handler->GetSession()) ? SHUTDOWN_MASK_FORCE : 0, SHUTDOWN_EXIT_CODE);
+ return ShutdownServer(args, AlwaysForceShutdown(handler->GetSession()) ? SHUTDOWN_MASK_FORCE : 0, SHUTDOWN_EXIT_CODE);
}
static bool HandleServerRestartCommand(ChatHandler* handler, char const* args)
{
- return ShutdownServer(args, IsOnlyUser(handler->GetSession()) ? (SHUTDOWN_MASK_FORCE | SHUTDOWN_MASK_RESTART) : SHUTDOWN_MASK_RESTART, RESTART_EXIT_CODE);
+ return ShutdownServer(args, AlwaysForceShutdown(handler->GetSession()) ? (SHUTDOWN_MASK_FORCE | SHUTDOWN_MASK_RESTART) : SHUTDOWN_MASK_RESTART, RESTART_EXIT_CODE);
}
static bool HandleServerForceShutDownCommand(ChatHandler* /*handler*/, char const* args)