mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 09:44:45 +01:00
Scripts/Commands: Some adjustments to make shutdown commands more user-friendly.
- New error message if a shutdown is delayed due to force threshold.
- New status message indicating that a server shutdown was successfully cancelled.
(cherry picked from commit d760219062)
This commit is contained in:
@@ -191,9 +191,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;
|
||||
}
|
||||
@@ -210,32 +211,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
|
||||
@@ -330,7 +331,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;
|
||||
@@ -385,8 +386,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));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user