aboutsummaryrefslogtreecommitdiff
path: root/src/server/scripts/Commands
diff options
context:
space:
mode:
authorjackpoz <giacomopoz@gmail.com>2016-08-04 15:03:58 +0200
committerjackpoz <giacomopoz@gmail.com>2016-08-04 15:03:58 +0200
commitb37c7101de272d1b3d599f26d6b5077cfacfb121 (patch)
tree1ea2d17ff89eb9f25851195a954eb4ace36677cb /src/server/scripts/Commands
parent2125c126097812fd6682db8edfd543c0d5583abf (diff)
Scripts/Commands: Change "server shutdown" behavior
Change "server shutdown 0" behavior to delay the shutdown by the force threshold specified in configs if there are still players connected, set to 30 by default
Diffstat (limited to 'src/server/scripts/Commands')
-rw-r--r--src/server/scripts/Commands/cs_server.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/server/scripts/Commands/cs_server.cpp b/src/server/scripts/Commands/cs_server.cpp
index c3ed0d61a6c..47239dba720 100644
--- a/src/server/scripts/Commands/cs_server.cpp
+++ b/src/server/scripts/Commands/cs_server.cpp
@@ -195,14 +195,10 @@ public:
return true;
}
- static bool AlwaysForceShutdown(WorldSession* mySession)
+ static bool IsOnlyUser(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->GetRemoteAddress();
+ std::string myAddr = mySession ? mySession->GetRemoteAddress() : "";
SessionMap const& sessions = sWorld->GetAllSessions();
for (SessionMap::value_type const& session : sessions)
if (session.second && myAddr != session.second->GetRemoteAddress())
@@ -211,12 +207,12 @@ public:
}
static bool HandleServerShutDownCommand(ChatHandler* handler, char const* args)
{
- return ShutdownServer(args, AlwaysForceShutdown(handler->GetSession()) ? SHUTDOWN_MASK_FORCE : 0, SHUTDOWN_EXIT_CODE);
+ return ShutdownServer(args, IsOnlyUser(handler->GetSession()) ? SHUTDOWN_MASK_FORCE : 0, SHUTDOWN_EXIT_CODE);
}
static bool HandleServerRestartCommand(ChatHandler* handler, char const* args)
{
- return ShutdownServer(args, AlwaysForceShutdown(handler->GetSession()) ? (SHUTDOWN_MASK_FORCE | SHUTDOWN_MASK_RESTART) : SHUTDOWN_MASK_RESTART, RESTART_EXIT_CODE);
+ return ShutdownServer(args, IsOnlyUser(handler->GetSession()) ? (SHUTDOWN_MASK_FORCE | SHUTDOWN_MASK_RESTART) : SHUTDOWN_MASK_RESTART, RESTART_EXIT_CODE);
}
static bool HandleServerForceShutDownCommand(ChatHandler* /*handler*/, char const* args)
@@ -385,8 +381,9 @@ private:
if (!ParseExitCode(exitCodeStr, exitCode))
return false;
+ // Override parameter "delay" with the configuration value if there are still players connected and "force" parameter was not specified
if (delay < (int32)sWorld->getIntConfig(CONFIG_FORCE_SHUTDOWN_THRESHOLD) && !(shutdownMask & SHUTDOWN_MASK_FORCE))
- return false;
+ delay = (int32)sWorld->getIntConfig(CONFIG_FORCE_SHUTDOWN_THRESHOLD);
sWorld->ShutdownServ(delay, shutdownMask, static_cast<uint8>(exitCode), std::string(reason));