aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Miscellaneous/Language.h2
-rw-r--r--src/server/game/World/World.cpp8
-rw-r--r--src/server/game/World/World.h2
-rw-r--r--src/server/scripts/Commands/cs_server.cpp32
4 files changed, 26 insertions, 18 deletions
diff --git a/src/server/game/Miscellaneous/Language.h b/src/server/game/Miscellaneous/Language.h
index 143f535ddf5..ef5779bb64c 100644
--- a/src/server/game/Miscellaneous/Language.h
+++ b/src/server/game/Miscellaneous/Language.h
@@ -1217,5 +1217,7 @@ enum TrinityStrings
LANG_INSTANCE_BIND_MISMATCH = 11014,
LANG_CREATURE_NOT_AI_ENABLED = 11015,
LANG_SELECT_PLAYER_OR_PET = 11016,
+ LANG_SHUTDOWN_DELAYED = 11017,
+ LANG_SHUTDOWN_CANCELLED = 11018
};
#endif
diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
index 19abfbe3152..8bda53f7a8f 100644
--- a/src/server/game/World/World.cpp
+++ b/src/server/game/World/World.cpp
@@ -2749,22 +2749,24 @@ void World::ShutdownMsg(bool show, Player* player, const std::string& reason)
}
/// Cancel a planned server shutdown
-void World::ShutdownCancel()
+uint32 World::ShutdownCancel()
{
// nothing cancel or too later
if (!m_ShutdownTimer || m_stopEvent)
- return;
+ return 0;
ServerMessageType msgid = (m_ShutdownMask & SHUTDOWN_MASK_RESTART) ? SERVER_MSG_RESTART_CANCELLED : SERVER_MSG_SHUTDOWN_CANCELLED;
+ uint32 oldTimer = m_ShutdownTimer;
m_ShutdownMask = 0;
m_ShutdownTimer = 0;
m_ExitCode = SHUTDOWN_EXIT_CODE; // to default value
SendServerMessage(msgid);
- TC_LOG_DEBUG("misc", "Server %s cancelled.", (m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shuttingdown"));
+ TC_LOG_DEBUG("misc", "Server %s cancelled.", (m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shutdown"));
sScriptMgr->OnShutdownCancel();
+ return oldTimer;
}
/// Send a server message to the user(s)
diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h
index 5850063bdc8..07094bc570b 100644
--- a/src/server/game/World/World.h
+++ b/src/server/game/World/World.h
@@ -664,7 +664,7 @@ class TC_GAME_API World
bool IsShuttingDown() const { return m_ShutdownTimer > 0; }
uint32 GetShutDownTimeLeft() const { return m_ShutdownTimer; }
void ShutdownServ(uint32 time, uint32 options, uint8 exitcode, const std::string& reason = std::string());
- void ShutdownCancel();
+ uint32 ShutdownCancel();
void ShutdownMsg(bool show = false, Player* player = NULL, const std::string& reason = std::string());
static uint8 GetExitCode() { return m_ExitCode; }
static void StopNow(uint8 exitcode) { m_stopEvent = true; m_ExitCode = exitcode; }
diff --git a/src/server/scripts/Commands/cs_server.cpp b/src/server/scripts/Commands/cs_server.cpp
index 47239dba720..b4697e3f64c 100644
--- a/src/server/scripts/Commands/cs_server.cpp
+++ b/src/server/scripts/Commands/cs_server.cpp
@@ -188,9 +188,10 @@ public:
return true;
}
- static bool HandleServerShutDownCancelCommand(ChatHandler* /*handler*/, char const* /*args*/)
+ static bool HandleServerShutDownCancelCommand(ChatHandler* handler, char const* /*args*/)
{
- sWorld->ShutdownCancel();
+ if (uint32 timer = sWorld->ShutdownCancel())
+ handler->PSendSysMessage(LANG_SHUTDOWN_CANCELLED, timer);
return true;
}
@@ -207,32 +208,32 @@ public:
}
static bool HandleServerShutDownCommand(ChatHandler* handler, char const* args)
{
- return ShutdownServer(args, IsOnlyUser(handler->GetSession()) ? SHUTDOWN_MASK_FORCE : 0, SHUTDOWN_EXIT_CODE);
+ return ShutdownServer(handler, args, 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(handler, args, SHUTDOWN_MASK_RESTART, RESTART_EXIT_CODE);
}
- static bool HandleServerForceShutDownCommand(ChatHandler* /*handler*/, char const* args)
+ static bool HandleServerForceShutDownCommand(ChatHandler* handler, char const* args)
{
- return ShutdownServer(args, SHUTDOWN_MASK_FORCE, SHUTDOWN_EXIT_CODE);
+ return ShutdownServer(handler, args, SHUTDOWN_MASK_FORCE, SHUTDOWN_EXIT_CODE);
}
- static bool HandleServerForceRestartCommand(ChatHandler* /*handler*/, char const* args)
+ static bool HandleServerForceRestartCommand(ChatHandler* handler, char const* args)
{
- return ShutdownServer(args, SHUTDOWN_MASK_FORCE | SHUTDOWN_MASK_RESTART, RESTART_EXIT_CODE);
+ return ShutdownServer(handler, args, SHUTDOWN_MASK_FORCE | SHUTDOWN_MASK_RESTART, RESTART_EXIT_CODE);
}
- static bool HandleServerIdleShutDownCommand(ChatHandler* /*handler*/, char const* args)
+ static bool HandleServerIdleShutDownCommand(ChatHandler* handler, char const* args)
{
- return ShutdownServer(args, SHUTDOWN_MASK_IDLE, SHUTDOWN_EXIT_CODE);
+ return ShutdownServer(handler, args, SHUTDOWN_MASK_IDLE, SHUTDOWN_EXIT_CODE);
}
- static bool HandleServerIdleRestartCommand(ChatHandler* /*handler*/, char const* args)
+ static bool HandleServerIdleRestartCommand(ChatHandler* handler, char const* args)
{
- return ShutdownServer(args, SHUTDOWN_MASK_RESTART | SHUTDOWN_MASK_IDLE, RESTART_EXIT_CODE);
+ return ShutdownServer(handler, args, SHUTDOWN_MASK_RESTART | SHUTDOWN_MASK_IDLE, RESTART_EXIT_CODE);
}
// Exit the realm
@@ -327,7 +328,7 @@ private:
return true;
}
- static bool ShutdownServer(char const* args, uint32 shutdownMask, int32 defaultExitCode)
+ static bool ShutdownServer(ChatHandler* handler, char const* args, uint32 shutdownMask, int32 defaultExitCode)
{
if (!*args)
return false;
@@ -382,8 +383,11 @@ private:
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))
+ if (delay < (int32)sWorld->getIntConfig(CONFIG_FORCE_SHUTDOWN_THRESHOLD) && !(shutdownMask & SHUTDOWN_MASK_FORCE) && !IsOnlyUser(handler->GetSession()))
+ {
delay = (int32)sWorld->getIntConfig(CONFIG_FORCE_SHUTDOWN_THRESHOLD);
+ handler->PSendSysMessage(LANG_SHUTDOWN_DELAYED, delay);
+ }
sWorld->ShutdownServ(delay, shutdownMask, static_cast<uint8>(exitCode), std::string(reason));