AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
server_commandscript Class Reference
Inheritance diagram for server_commandscript:
CommandScript ScriptObject

Public Member Functions

 server_commandscript ()
 
ChatCommandTable GetCommands () const override
 
- Public Member Functions inherited from ScriptObject
virtual bool IsDatabaseBound () const
 
virtual bool isAfterLoadScript () const
 
virtual void checkValidity ()
 
std::string const & GetName () const
 
uint16 GetTotalAvailableHooks ()
 

Static Public Member Functions

static bool HandleServerCorpsesCommand (ChatHandler *)
 
static bool HandleServerDebugCommand (ChatHandler *handler)
 
static bool HandleServerInfoCommand (ChatHandler *handler)
 
static bool HandleServerMotdCommand (ChatHandler *handler)
 
static bool HandleServerShutDownCancelCommand (ChatHandler *)
 
static bool HandleServerShutDownCommand (ChatHandler *handler, std::string time, Optional< int32 > exitCode, Tail reason)
 
static bool HandleServerRestartCommand (ChatHandler *handler, std::string time, Optional< int32 > exitCode, Tail reason)
 
static bool HandleServerIdleRestartCommand (ChatHandler *handler, std::string time, Optional< int32 > exitCode, Tail reason)
 
static bool HandleServerIdleShutDownCommand (ChatHandler *handler, std::string time, Optional< int32 > exitCode, Tail reason)
 
static bool HandleServerExitCommand (ChatHandler *handler)
 
static bool HandleServerSetMotdCommand (ChatHandler *handler, Optional< int32 > realmId, std::string locale, Tail motd)
 
static bool HandleServerSetClosedCommand (ChatHandler *handler, Optional< std::string > args)
 
static bool HandleServerSetSecurityCommand (ChatHandler *handler, uint8 level)
 
static bool HandleServerSetLogLevelCommand (ChatHandler *, bool isLogger, std::string const &name, int32 level)
 

Additional Inherited Members

- Protected Member Functions inherited from CommandScript
 CommandScript (char const *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (char const *name, uint16 totalAvailableHooks=0)
 
virtual ~ScriptObject ()=default
 

Detailed Description

Constructor & Destructor Documentation

◆ server_commandscript()

server_commandscript::server_commandscript ( )
inline
48: CommandScript("server_commandscript") { }
Definition CommandScript.h:25

Member Function Documentation

◆ GetCommands()

ChatCommandTable server_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

51 {
52 static ChatCommandTable serverIdleRestartCommandTable =
53 {
56 };
57
58 static ChatCommandTable serverIdleShutdownCommandTable =
59 {
62 };
63
64 static ChatCommandTable serverRestartCommandTable =
65 {
68 };
69
70 static ChatCommandTable serverShutdownCommandTable =
71 {
74 };
75
76 static ChatCommandTable serverSetCommandTable =
77 {
82 };
83
84 static ChatCommandTable serverCommandTable =
85 {
89 { "idlerestart", serverIdleRestartCommandTable },
90 { "idleshutdown", serverIdleShutdownCommandTable },
93 { "restart", serverRestartCommandTable },
94 { "shutdown", serverShutdownCommandTable },
95 { "set", serverSetCommandTable }
96 };
97
98 static ChatCommandTable commandTable =
99 {
100 { "server", serverCommandTable }
101 };
102
103 return commandTable;
104 }
static bool HandleServerCorpsesCommand(ChatHandler *)
Definition cs_server.cpp:107
static bool HandleServerSetLogLevelCommand(ChatHandler *, bool isLogger, std::string const &name, int32 level)
Definition cs_server.cpp:634
static bool HandleServerSetClosedCommand(ChatHandler *handler, Optional< std::string > args)
Definition cs_server.cpp:593
static bool HandleServerRestartCommand(ChatHandler *handler, std::string time, Optional< int32 > exitCode, Tail reason)
Definition cs_server.cpp:366
static bool HandleServerShutDownCommand(ChatHandler *handler, std::string time, Optional< int32 > exitCode, Tail reason)
Definition cs_server.cpp:313
static bool HandleServerInfoCommand(ChatHandler *handler)
Definition cs_server.cpp:266
static bool HandleServerSetMotdCommand(ChatHandler *handler, Optional< int32 > realmId, std::string locale, Tail motd)
Definition cs_server.cpp:534
static bool HandleServerMotdCommand(ChatHandler *handler)
Definition cs_server.cpp:298
static bool HandleServerSetSecurityCommand(ChatHandler *handler, uint8 level)
Definition cs_server.cpp:613
static bool HandleServerIdleShutDownCommand(ChatHandler *handler, std::string time, Optional< int32 > exitCode, Tail reason)
Definition cs_server.cpp:472
static bool HandleServerExitCommand(ChatHandler *handler)
Definition cs_server.cpp:526
static bool HandleServerDebugCommand(ChatHandler *handler)
Definition cs_server.cpp:116
static bool HandleServerIdleRestartCommand(ChatHandler *handler, std::string time, Optional< int32 > exitCode, Tail reason)
Definition cs_server.cpp:419
static bool HandleServerShutDownCancelCommand(ChatHandler *)
Definition cs_server.cpp:306
std::vector< ChatCommandBuilder > ChatCommandTable
Definition ChatCommand.h:46
@ RBAC_PERM_COMMAND_SERVER_SHUTDOWN
Definition RBAC.h:561
@ RBAC_PERM_COMMAND_SERVER_SET_LOGLEVEL
Definition RBAC.h:559
@ RBAC_PERM_COMMAND_SERVER_RESTART_CANCEL
Definition RBAC.h:555
@ RBAC_PERM_COMMAND_SERVER_EXIT
Definition RBAC.h:547
@ RBAC_PERM_COMMAND_SERVER_RESTART
Definition RBAC.h:554
@ RBAC_PERM_COMMAND_SERVER_IDLESHUTDOWN_CANCEL
Definition RBAC.h:551
@ RBAC_PERM_COMMAND_SERVER_SET_SECURITY
Definition RBAC.h:703
@ RBAC_PERM_COMMAND_SERVER_SHUTDOWN_CANCEL
Definition RBAC.h:562
@ RBAC_PERM_COMMAND_SERVER_IDLERESTART_CANCEL
Definition RBAC.h:549
@ RBAC_PERM_COMMAND_SERVER_MOTD
Definition RBAC.h:563
@ RBAC_PERM_COMMAND_SERVER_SET_CLOSED
Definition RBAC.h:557
@ RBAC_PERM_COMMAND_SERVER_SET_MOTD
Definition RBAC.h:560
@ RBAC_PERM_COMMAND_SERVER_INFO
Definition RBAC.h:552
@ RBAC_PERM_COMMAND_SERVER_IDLERESTART
Definition RBAC.h:548
@ RBAC_PERM_COMMAND_SERVER_IDLESHUTDOWN
Definition RBAC.h:550
@ RBAC_PERM_COMMAND_SERVER_DEBUG
Definition RBAC.h:640
@ RBAC_PERM_COMMAND_SERVER_CORPSES
Definition RBAC.h:546

References HandleServerCorpsesCommand(), HandleServerDebugCommand(), HandleServerExitCommand(), HandleServerIdleRestartCommand(), HandleServerIdleShutDownCommand(), HandleServerInfoCommand(), HandleServerMotdCommand(), HandleServerRestartCommand(), HandleServerSetClosedCommand(), HandleServerSetLogLevelCommand(), HandleServerSetMotdCommand(), HandleServerSetSecurityCommand(), HandleServerShutDownCancelCommand(), HandleServerShutDownCommand(), rbac::RBAC_PERM_COMMAND_SERVER_CORPSES, rbac::RBAC_PERM_COMMAND_SERVER_DEBUG, rbac::RBAC_PERM_COMMAND_SERVER_EXIT, rbac::RBAC_PERM_COMMAND_SERVER_IDLERESTART, rbac::RBAC_PERM_COMMAND_SERVER_IDLERESTART_CANCEL, rbac::RBAC_PERM_COMMAND_SERVER_IDLESHUTDOWN, rbac::RBAC_PERM_COMMAND_SERVER_IDLESHUTDOWN_CANCEL, rbac::RBAC_PERM_COMMAND_SERVER_INFO, rbac::RBAC_PERM_COMMAND_SERVER_MOTD, rbac::RBAC_PERM_COMMAND_SERVER_RESTART, rbac::RBAC_PERM_COMMAND_SERVER_RESTART_CANCEL, rbac::RBAC_PERM_COMMAND_SERVER_SET_CLOSED, rbac::RBAC_PERM_COMMAND_SERVER_SET_LOGLEVEL, rbac::RBAC_PERM_COMMAND_SERVER_SET_MOTD, rbac::RBAC_PERM_COMMAND_SERVER_SET_SECURITY, rbac::RBAC_PERM_COMMAND_SERVER_SHUTDOWN, and rbac::RBAC_PERM_COMMAND_SERVER_SHUTDOWN_CANCEL.

◆ HandleServerCorpsesCommand()

static bool server_commandscript::HandleServerCorpsesCommand ( ChatHandler *  )
inlinestatic
108 {
109 sMapMgr->DoForAllMaps([](Map* map)
110 {
111 map->RemoveOldCorpses();
112 });
113 return true;
114 }
#define sMapMgr
Definition MapMgr.h:220
Definition Map.h:168
void RemoveOldCorpses()
Definition Map.cpp:3158

References Map::RemoveOldCorpses(), and sMapMgr.

Referenced by GetCommands().

◆ HandleServerDebugCommand()

static bool server_commandscript::HandleServerDebugCommand ( ChatHandler *  handler)
inlinestatic
117 {
118 uint16 worldPort = uint16(sWorld->getIntConfig(CONFIG_PORT_WORLD));
119 std::string dbPortOutput;
120
121 {
122 uint16 dbPort = 0;
123 if (QueryResult res = LoginDatabase.Query("SELECT port FROM realmlist WHERE id = {}", realm.Id.Realm))
124 dbPort = (*res)[0].Get<uint16>();
125
126 if (dbPort)
127 dbPortOutput = Acore::StringFormat("Realmlist (Realm Id: {}) configured in port {}", realm.Id.Realm, dbPort);
128 else
129 dbPortOutput = Acore::StringFormat("Realm Id: {} not found in `realmlist` table. Please check your setup", realm.Id.Realm);
130 }
131
133
134 handler->PSendSysMessage("Using SSL version: {} (library: {})", OPENSSL_VERSION_TEXT, OpenSSL_version(OPENSSL_VERSION));
135 handler->PSendSysMessage("Using Boost version: {}.{}.{}", BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100);
136 handler->PSendSysMessage("Using CMake version: {}", GitRevision::GetCMakeVersion());
137
138 handler->PSendSysMessage("Using MySQL version: {}", MySQL::GetLibraryVersion());
139 handler->PSendSysMessage("Found MySQL Executable: {}", GitRevision::GetMySQLExecutable());
140
141 handler->PSendSysMessage("Compiled on: {}", GitRevision::GetHostOSVersion());
142
143 handler->PSendSysMessage("Worldserver listening connections on port {}", worldPort);
144 handler->PSendSysMessage("{}", dbPortOutput);
145
146 bool vmapIndoorCheck = sWorld->getBoolConfig(CONFIG_VMAP_INDOOR_CHECK);
149
150 bool mmapEnabled = sWorld->getBoolConfig(CONFIG_ENABLE_MMAPS);
151
152 std::string dataDir = sWorld->GetDataPath();
153 std::vector<std::string> subDirs;
154 subDirs.emplace_back("maps");
155 if (vmapIndoorCheck || vmapLOSCheck || vmapHeightCheck)
156 {
157 handler->PSendSysMessage("VMAPs status: Enabled. LineOfSight: {}, getHeight: {}, indoorCheck: {}", vmapLOSCheck, vmapHeightCheck, vmapIndoorCheck);
158 subDirs.emplace_back("vmaps");
159 }
160 else
161 handler->SendSysMessage("VMAPs status: Disabled");
162
163 if (mmapEnabled)
164 {
165 handler->SendSysMessage("MMAPs status: Enabled");
166 subDirs.emplace_back("mmaps");
167 }
168 else
169 handler->SendSysMessage("MMAPs status: Disabled");
170
171 for (std::string const& subDir : subDirs)
172 {
173 std::filesystem::path mapPath(dataDir);
174 mapPath /= subDir;
175
176 if (!std::filesystem::exists(mapPath))
177 {
178 handler->PSendSysMessage("{} directory doesn't exist!. Using path: {}", subDir, mapPath.generic_string());
179 continue;
180 }
181
182 auto end = std::filesystem::directory_iterator();
183 std::size_t folderSize = std::accumulate(std::filesystem::directory_iterator(mapPath), end, std::size_t(0), [](std::size_t val, std::filesystem::path const& mapFile)
184 {
185 if (std::filesystem::is_regular_file(mapFile))
186 val += std::filesystem::file_size(mapFile);
187 return val;
188 });
189
190 handler->PSendSysMessage("{} directory located in {}. Total size: {} bytes", subDir, mapPath.generic_string(), folderSize);
191 }
192
193 LocaleConstant defaultLocale = sWorld->GetDefaultDbcLocale();
194 uint32 availableLocalesMask = (1 << defaultLocale);
195
196 for (uint8 i = 0; i < TOTAL_LOCALES; ++i)
197 {
198 LocaleConstant locale = static_cast<LocaleConstant>(i);
199 if (locale == defaultLocale)
200 continue;
201
202 if (sWorld->GetAvailableDbcLocale(locale) != defaultLocale)
203 availableLocalesMask |= (1 << locale);
204 }
205
206 std::string availableLocales;
207 for (uint8 i = 0; i < TOTAL_LOCALES; ++i)
208 {
209 if (!(availableLocalesMask & (1 << i)))
210 continue;
211
212 availableLocales += localeNames[i];
213 if (i != TOTAL_LOCALES - 1)
214 availableLocales += " ";
215 }
216
217 handler->PSendSysMessage("Default DBC locale: {}.\nAll available DBC locales: {}", localeNames[defaultLocale], availableLocales);
218
219 handler->PSendSysMessage("Using World DB: {}", sWorld->GetDBVersion());
220
221 std::map<std::string, std::string> moduleDBRevisions;
222 sScriptMgr->OnDatabaseGetDBRevision(moduleDBRevisions);
223 for (auto const& [moduleName, revision] : moduleDBRevisions)
224 handler->PSendSysMessage("Using {} DB Revision: {}", moduleName, revision);
225
226 std::string lldb = "No updates found!";
227 if (QueryResult resL = LoginDatabase.Query("SELECT name FROM updates ORDER BY name DESC LIMIT 1"))
228 {
229 Field* fields = resL->Fetch();
230 lldb = fields[0].Get<std::string>();
231 }
232 std::string lcdb = "No updates found!";
233 if (QueryResult resC = CharacterDatabase.Query("SELECT name FROM updates ORDER BY name DESC LIMIT 1"))
234 {
235 Field* fields = resC->Fetch();
236 lcdb = fields[0].Get<std::string>();
237 }
238 std::string lwdb = "No updates found!";
239 if (QueryResult resW = WorldDatabase.Query("SELECT name FROM updates ORDER BY name DESC LIMIT 1"))
240 {
241 Field* fields = resW->Fetch();
242 lwdb = fields[0].Get<std::string>();
243 }
244
245 handler->PSendSysMessage("Latest LoginDatabase update: {}", lldb);
246 handler->PSendSysMessage("Latest CharacterDatabase update: {}", lcdb);
247 handler->PSendSysMessage("Latest WorldDatabase update: {}", lwdb);
248
249 handler->PSendSysMessage("LoginDatabase queue size: {}", LoginDatabase.QueueSize());
250 handler->PSendSysMessage("CharacterDatabase queue size: {}", CharacterDatabase.QueueSize());
251 handler->PSendSysMessage("WorldDatabase queue size: {}", WorldDatabase.QueueSize());
252
254 handler->PSendSysMessage("No modules are enabled");
255 else
256 handler->PSendSysMessage("List of enabled modules:");
257
258 for (auto const& modName : Acore::Module::GetEnableModulesList())
259 {
260 handler->PSendSysMessage("|- {}", modName);
261 }
262
263 return true;
264 }
char const * localeNames[TOTAL_LOCALES]
Definition Common.cpp:20
LocaleConstant
Definition Common.h:125
@ TOTAL_LOCALES
Definition Common.h:136
std::shared_ptr< ResultSet > QueryResult
Definition DatabaseEnvFwd.h:27
DatabaseWorkerPool< LoginDatabaseConnection > LoginDatabase
Accessor to the realm/login database.
Definition DatabaseEnv.cpp:22
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition DatabaseEnv.cpp:21
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition DatabaseEnv.cpp:20
std::uint8_t uint8
Definition Define.h:109
std::uint32_t uint32
Definition Define.h:107
std::uint16_t uint16
Definition Define.h:108
#define sScriptMgr
Definition ScriptMgr.h:766
struct Module_79C0768D657977D697E10BAD956CCED1 Module
@ CONFIG_ENABLE_MMAPS
Definition WorldConfig.h:103
@ CONFIG_VMAP_INDOOR_CHECK
Definition WorldConfig.h:81
@ CONFIG_PORT_WORLD
Definition WorldConfig.h:174
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:219
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:168
Class used to access individual fields of database query result.
Definition Field.h:99
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition Field.h:113
bool isHeightCalcEnabled() const
Definition IVMapMgr.h:112
bool isLineOfSightCalcEnabled() const
Definition IVMapMgr.h:111
static VMapMgr2 * createOrGetVMapMgr()
Definition VMapFactory.cpp:27
#define sWorld
Definition World.h:318
Realm realm
Definition World.cpp:115
AC_COMMON_API std::vector< std::string_view > GetEnableModulesList()
Definition ModuleMgr.cpp:31
Definition AsioHacksFwd.h:47
std::string StringFormat(FormatStringView fmt, Args &&... args)
Default AC string format function.
Definition StringFormat.h:44
AC_COMMON_API char const * GetMySQLExecutable()
Definition GitRevision.cpp:61
AC_COMMON_API char const * GetCMakeVersion()
Definition GitRevision.cpp:41
AC_COMMON_API char const * GetHostOSVersion()
Definition GitRevision.cpp:46
AC_DATABASE_API uint32 GetLibraryVersion()
Definition MySQLThreading.cpp:31
uint32 Realm
Definition Realm.h:43
RealmHandle Id
Definition Realm.h:69

References CharacterDatabase, CONFIG_ENABLE_MMAPS, CONFIG_PORT_WORLD, CONFIG_VMAP_INDOOR_CHECK, VMAP::VMapFactory::createOrGetVMapMgr(), Field::Get(), GitRevision::GetCMakeVersion(), Acore::Module::GetEnableModulesList(), GitRevision::GetHostOSVersion(), MySQL::GetLibraryVersion(), GitRevision::GetMySQLExecutable(), HandleServerInfoCommand(), Realm::Id, VMAP::IVMapMgr::isHeightCalcEnabled(), VMAP::IVMapMgr::isLineOfSightCalcEnabled(), localeNames, LoginDatabase, ChatHandler::PSendSysMessage(), realm, RealmHandle::Realm, ChatHandler::SendSysMessage(), sScriptMgr, Acore::StringFormat(), sWorld, TOTAL_LOCALES, and WorldDatabase.

Referenced by GetCommands().

◆ HandleServerExitCommand()

static bool server_commandscript::HandleServerExitCommand ( ChatHandler *  handler)
inlinestatic
527 {
530 return true;
531 }
@ LANG_COMMAND_EXIT
Definition Language.h:867
static void StopNow(uint8 exitcode)
Definition World.h:188
@ SHUTDOWN_EXIT_CODE
Definition World.h:53

References LANG_COMMAND_EXIT, ChatHandler::SendSysMessage(), SHUTDOWN_EXIT_CODE, and World::StopNow().

Referenced by GetCommands().

◆ HandleServerIdleRestartCommand()

static bool server_commandscript::HandleServerIdleRestartCommand ( ChatHandler *  handler,
std::string  time,
Optional< int32 >  exitCode,
Tail  reason 
)
inlinestatic
420 {
421 std::wstring wReason = std::wstring();
422 std::string strReason = std::string();
423
424 if (time.empty())
425 {
426 return false;
427 }
428
429 if (Acore::StringTo<int32>(time).value_or(0) < 0)
430 {
432 return false;
433 }
434
435 if (!reason.empty())
436 {
437 if (!Utf8toWStr(reason, wReason))
438 {
439 return false;
440 }
441
442 if (!WStrToUtf8(wReason, strReason))
443 {
444 return false;
445 }
446 }
447
448 int32 delay = TimeStringToSecs(time);
449 if (delay <= 0)
450 {
451 delay = Acore::StringTo<int32>(time).value_or(0);
452 }
453
454 if (delay <= 0)
455 {
457 return false;
458 }
459
460 if (exitCode && *exitCode >= 0 && *exitCode <= 125)
461 {
462 sWorld->ShutdownServ(delay, SHUTDOWN_MASK_RESTART | SHUTDOWN_MASK_IDLE, *exitCode);
463 }
464 else
465 {
466 sWorld->ShutdownServ(delay, SHUTDOWN_MASK_RESTART | SHUTDOWN_MASK_IDLE, RESTART_EXIT_CODE, strReason);
467 }
468
469 return true;
470 }
std::int32_t int32
Definition Define.h:103
@ LANG_BAD_VALUE
Definition Language.h:151
bool Utf8toWStr(char const *utf8str, std::size_t csize, wchar_t *wstr, std::size_t &wsize)
Definition Util.cpp:281
bool WStrToUtf8(wchar_t const *wstr, std::size_t size, std::string &utf8str)
Definition Util.cpp:333
uint32 TimeStringToSecs(std::string const &timestring)
Definition Util.cpp:163
void SendErrorMessage(uint32 entry)
Definition Chat.cpp:224
@ RESTART_EXIT_CODE
Definition World.h:55
@ SHUTDOWN_MASK_RESTART
Definition World.h:47
@ SHUTDOWN_MASK_IDLE
Definition World.h:48

References LANG_BAD_VALUE, RESTART_EXIT_CODE, ChatHandler::SendErrorMessage(), SHUTDOWN_MASK_IDLE, SHUTDOWN_MASK_RESTART, sWorld, TimeStringToSecs(), Utf8toWStr(), and WStrToUtf8().

Referenced by GetCommands().

◆ HandleServerIdleShutDownCommand()

static bool server_commandscript::HandleServerIdleShutDownCommand ( ChatHandler *  handler,
std::string  time,
Optional< int32 >  exitCode,
Tail  reason 
)
inlinestatic
473 {
474 std::wstring wReason = std::wstring();
475 std::string strReason = std::string();
476
477 if (time.empty())
478 {
479 return false;
480 }
481
482 if (Acore::StringTo<int32>(time).value_or(0) < 0)
483 {
485 return false;
486 }
487
488 if (!reason.empty())
489 {
490 if (!Utf8toWStr(reason, wReason))
491 {
492 return false;
493 }
494
495 if (!WStrToUtf8(wReason, strReason))
496 {
497 return false;
498 }
499 }
500
501 int32 delay = TimeStringToSecs(time);
502 if (delay <= 0)
503 {
504 delay = Acore::StringTo<int32>(time).value_or(0);
505 }
506
507 if (delay <= 0)
508 {
510 return false;
511 }
512
513 if (exitCode && *exitCode >= 0 && *exitCode <= 125)
514 {
515 sWorld->ShutdownServ(delay, SHUTDOWN_MASK_IDLE, *exitCode);
516 }
517 else
518 {
519 sWorld->ShutdownServ(delay, SHUTDOWN_MASK_IDLE, SHUTDOWN_EXIT_CODE, strReason);
520 }
521
522 return true;
523 }

References LANG_BAD_VALUE, ChatHandler::SendErrorMessage(), SHUTDOWN_EXIT_CODE, SHUTDOWN_MASK_IDLE, sWorld, TimeStringToSecs(), Utf8toWStr(), and WStrToUtf8().

Referenced by GetCommands().

◆ HandleServerInfoCommand()

static bool server_commandscript::HandleServerInfoCommand ( ChatHandler *  handler)
inlinestatic

Can't use sWorld->ShutdownMsg here in case of console command

267 {
268 std::string realmName = sWorld->GetRealmName();
269 uint32 playerCount = sWorldSessionMgr->GetPlayerCount();
270 uint32 activeSessionCount = sWorldSessionMgr->GetActiveSessionCount();
271 uint32 queuedSessionCount = sWorldSessionMgr->GetQueuedSessionCount();
272 uint32 connPeak = sWorldSessionMgr->GetMaxActiveSessionCount();
273
275 if (!queuedSessionCount)
276 handler->PSendSysMessage("Connected players: {}. Characters in world: {}.", activeSessionCount, playerCount);
277 else
278 handler->PSendSysMessage("Connected players: {}. Characters in world: {}. Queue: {}.", activeSessionCount, playerCount, queuedSessionCount);
279
280 handler->PSendSysMessage("Connection peak: {}.", connPeak);
281 handler->PSendSysMessage(LANG_COMMAND_SERVER_INFO_SECURITY, uint32(sWorld->GetPlayerSecurityLimit()));
283 handler->PSendSysMessage("Update time diff: {}ms. Last {} diffs summary:", sWorldUpdateTime.GetLastUpdateTime(), sWorldUpdateTime.GetDatasetSize());
284 handler->PSendSysMessage("|- Mean: {}ms", sWorldUpdateTime.GetAverageUpdateTime());
285 handler->PSendSysMessage("|- Median: {}ms", sWorldUpdateTime.GetPercentile(50));
286 handler->PSendSysMessage("|- Percentiles (95, 99, max): {}ms, {}ms, {}ms",
290
292 if (sWorld->IsShuttingDown())
293 handler->PSendSysMessage(LANG_SHUTDOWN_TIMELEFT, secsToTimeString(sWorld->GetShutDownTimeLeft()).append("."));
294
295 return true;
296 }
@ LANG_COMMAND_SERVER_INFO_SECURITY
Definition Language.h:1405
@ LANG_UPTIME
Definition Language.h:45
@ LANG_SHUTDOWN_TIMELEFT
Definition Language.h:52
WorldUpdateTime sWorldUpdateTime
Definition UpdateTime.cpp:27
std::string secsToTimeString(uint64 timeInSecs, bool shortText)
Definition Util.cpp:73
#define sWorldSessionMgr
Definition WorldSessionMgr.h:118
uint32 GetAverageUpdateTime() const
Definition UpdateTime.cpp:41
uint32 GetDatasetSize() const
Definition UpdateTime.cpp:77
uint32 GetLastUpdateTime() const
Definition UpdateTime.cpp:72
uint32 GetPercentile(uint8 p)
Definition UpdateTime.cpp:82
Seconds GetUptime()
Uptime.
Definition GameTime.cpp:58
AC_COMMON_API char const * GetFullVersion()
Definition GitRevision.cpp:82

References UpdateTime::GetAverageUpdateTime(), UpdateTime::GetDatasetSize(), GitRevision::GetFullVersion(), UpdateTime::GetLastUpdateTime(), UpdateTime::GetPercentile(), GameTime::GetUptime(), LANG_COMMAND_SERVER_INFO_SECURITY, LANG_SHUTDOWN_TIMELEFT, LANG_UPTIME, ChatHandler::PSendSysMessage(), secsToTimeString(), sWorld, sWorldSessionMgr, and sWorldUpdateTime.

Referenced by GetCommands(), and HandleServerDebugCommand().

◆ HandleServerMotdCommand()

static bool server_commandscript::HandleServerMotdCommand ( ChatHandler *  handler)
inlinestatic
299 {
301 for (uint32 i = 0; i < TOTAL_LOCALES; ++i)
303 return true;
304 }
const std::string GetNameByLocaleConstant(LocaleConstant localeConstant)
Definition Common.cpp:87
@ LANG_MOTD_CURRENT
Definition Language.h:88
@ LANG_GENERIC_TWO_CURLIES_WITH_COLON
Definition Language.h:114
#define sMotdMgr
Definition MotdMgr.h:52

References GetNameByLocaleConstant(), LANG_GENERIC_TWO_CURLIES_WITH_COLON, LANG_MOTD_CURRENT, ChatHandler::PSendSysMessage(), sMotdMgr, and TOTAL_LOCALES.

Referenced by GetCommands().

◆ HandleServerRestartCommand()

static bool server_commandscript::HandleServerRestartCommand ( ChatHandler *  handler,
std::string  time,
Optional< int32 >  exitCode,
Tail  reason 
)
inlinestatic
367 {
368 std::wstring wReason = std::wstring();
369 std::string strReason = std::string();
370
371 if (time.empty())
372 {
373 return false;
374 }
375
376 if (Acore::StringTo<int32>(time).value_or(0) < 0)
377 {
379 return false;
380 }
381
382 if (!reason.empty())
383 {
384 if (!Utf8toWStr(reason, wReason))
385 {
386 return false;
387 }
388
389 if (!WStrToUtf8(wReason, strReason))
390 {
391 return false;
392 }
393 }
394
395 int32 delay = TimeStringToSecs(time);
396 if (delay <= 0)
397 {
398 delay = Acore::StringTo<int32>(time).value_or(0);
399 }
400
401 if (delay <= 0)
402 {
404 return false;
405 }
406
407 if (exitCode && *exitCode >= 0 && *exitCode <= 125)
408 {
409 sWorld->ShutdownServ(delay, SHUTDOWN_MASK_RESTART, *exitCode);
410 }
411 else
412 {
413 sWorld->ShutdownServ(delay, SHUTDOWN_MASK_RESTART, RESTART_EXIT_CODE, strReason);
414 }
415
416 return true;
417 }

References LANG_BAD_VALUE, RESTART_EXIT_CODE, ChatHandler::SendErrorMessage(), SHUTDOWN_MASK_RESTART, sWorld, TimeStringToSecs(), Utf8toWStr(), and WStrToUtf8().

Referenced by GetCommands().

◆ HandleServerSetClosedCommand()

static bool server_commandscript::HandleServerSetClosedCommand ( ChatHandler *  handler,
Optional< std::string >  args 
)
inlinestatic
594 {
595 if (StringStartsWith("on", *args))
596 {
598 sWorld->SetClosed(true);
599 return true;
600 }
601 else if (StringStartsWith("off", *args))
602 {
604 sWorld->SetClosed(false);
605 return true;
606 }
607
609 return false;
610 }
@ LANG_USE_BOL
Definition Language.h:311
@ LANG_WORLD_CLOSED
Definition Language.h:1261
@ LANG_WORLD_OPENED
Definition Language.h:1262
bool StringStartsWith(std::string_view haystack, std::string_view needle)
Definition Util.h:392

References LANG_USE_BOL, LANG_WORLD_CLOSED, LANG_WORLD_OPENED, ChatHandler::SendErrorMessage(), ChatHandler::SendSysMessage(), StringStartsWith(), and sWorld.

Referenced by GetCommands().

◆ HandleServerSetLogLevelCommand()

static bool server_commandscript::HandleServerSetLogLevelCommand ( ChatHandler *  ,
bool  isLogger,
std::string const &  name,
int32  level 
)
inlinestatic
635 {
636 sLog->SetLogLevel(name, level, isLogger);
637 return true;
638 }
#define sLog
Definition Log.h:127

References sLog.

Referenced by GetCommands().

◆ HandleServerSetMotdCommand()

static bool server_commandscript::HandleServerSetMotdCommand ( ChatHandler *  handler,
Optional< int32 >  realmId,
std::string  locale,
Tail  motd 
)
inlinestatic
535 {
536 std::wstring wMotd = std::wstring();
537 std::string strMotd = std::string();
538
539 // Default realmId to the current realm if not provided
540 if (!realmId)
541 realmId = static_cast<int32>(realm.Id.Realm);
542
543 // Determine the locale; default to "enUS" if not provided
544 LocaleConstant localeConstant;
545 if (IsLocaleValid(locale))
546 localeConstant = GetLocaleByName(locale);
547 else
548 {
549 handler->SendErrorMessage("locale ({}) is not valid. Valid locales: enUS, koKR, frFR, deDE, zhCN, zhWE, esES, esMX, ruRU.", locale);
550 return false;
551 }
552
553 if (motd.empty())
554 return false;
555
556 // Convert the concatenated motdString to UTF-8 and ensure encoding consistency
557 if (!Utf8toWStr(motd, wMotd))
558 return false;
559
560 if (!WStrToUtf8(wMotd, strMotd))
561 return false;
562
563 // Start a transaction for the database operations
564 LoginDatabaseTransaction trans = LoginDatabase.BeginTransaction();
565
566 if (localeConstant == LOCALE_enUS)
567 {
568 // Insert or update in the main motd table for enUS
569 LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_REP_MOTD);
570 stmt->SetData(0, realmId.value()); // realmId for insertion
571 stmt->SetData(1, strMotd); // motd text for insertion
572 trans->Append(stmt);
573 }
574 else
575 {
576 // Insert or update in the motd_localized table for other locales
578 stmt->SetData(0, realmId.value()); // realmId for insertion
579 stmt->SetData(1, locale); // locale for insertion
580 stmt->SetData(2, strMotd); // motd text for insertion
581 trans->Append(stmt);
582 }
583
584 // Commit the transaction & update db
585 LoginDatabase.CommitTransaction(trans);
586
587 sMotdMgr->SetMotd(strMotd, localeConstant);
588 handler->PSendSysMessage(LANG_MOTD_NEW, realmId.value(), locale, strMotd);
589 return true;
590 }
LocaleConstant GetLocaleByName(std::string const &name)
Definition Common.cpp:78
bool IsLocaleValid(std::string const &locale)
Definition Common.cpp:69
@ LOCALE_enUS
Definition Common.h:126
SQLTransaction< LoginDatabaseConnection > LoginDatabaseTransaction
Definition DatabaseEnvFwd.h:70
@ LANG_MOTD_NEW
Definition Language.h:902
@ LOGIN_REP_MOTD
Definition LoginDatabase.h:115
@ LOGIN_REP_MOTD_LOCALE
Definition LoginDatabase.h:116
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition PreparedStatement.h:77
Definition PreparedStatement.h:157

References GetLocaleByName(), Realm::Id, IsLocaleValid(), LANG_MOTD_NEW, LOCALE_enUS, LOGIN_REP_MOTD, LOGIN_REP_MOTD_LOCALE, LoginDatabase, ChatHandler::PSendSysMessage(), realm, RealmHandle::Realm, ChatHandler::SendErrorMessage(), PreparedStatementBase::SetData(), sMotdMgr, Utf8toWStr(), and WStrToUtf8().

Referenced by GetCommands().

◆ HandleServerSetSecurityCommand()

static bool server_commandscript::HandleServerSetSecurityCommand ( ChatHandler *  handler,
uint8  level 
)
inlinestatic
614 {
615 if (level > SEC_ADMINISTRATOR)
616 {
618 return false;
619 }
620
622 stmt->SetData(0, level);
623 stmt->SetData(1, realm.Id.Realm);
624 LoginDatabase.Execute(stmt);
625
626 // Apply live; raising the limit kicks any now-disallowed sessions.
627 sWorld->SetPlayerSecurityLimit(AccountTypes(level));
628
630 return true;
631 }
AccountTypes
Definition Common.h:56
@ SEC_PLAYER
Definition Common.h:57
@ SEC_ADMINISTRATOR
Definition Common.h:60
@ LANG_COMMAND_SERVER_SET_SECURITY_ERROR
Definition Language.h:1404
@ LANG_COMMAND_SERVER_SET_SECURITY
Definition Language.h:1403
@ LOGIN_UPD_REALMLIST_SECURITY_LEVEL
Definition LoginDatabase.h:102

References Realm::Id, LANG_COMMAND_SERVER_SET_SECURITY, LANG_COMMAND_SERVER_SET_SECURITY_ERROR, LOGIN_UPD_REALMLIST_SECURITY_LEVEL, LoginDatabase, ChatHandler::PSendSysMessage(), realm, RealmHandle::Realm, SEC_ADMINISTRATOR, SEC_PLAYER, ChatHandler::SendErrorMessage(), PreparedStatementBase::SetData(), and sWorld.

Referenced by GetCommands().

◆ HandleServerShutDownCancelCommand()

static bool server_commandscript::HandleServerShutDownCancelCommand ( ChatHandler *  )
inlinestatic
307 {
308 sWorld->ShutdownCancel();
309
310 return true;
311 }

References sWorld.

Referenced by GetCommands().

◆ HandleServerShutDownCommand()

static bool server_commandscript::HandleServerShutDownCommand ( ChatHandler *  handler,
std::string  time,
Optional< int32 >  exitCode,
Tail  reason 
)
inlinestatic
314 {
315 std::wstring wReason = std::wstring();
316 std::string strReason = std::string();
317
318 if (time.empty())
319 {
320 return false;
321 }
322
323 if (Acore::StringTo<int32>(time).value_or(0) < 0)
324 {
326 return false;
327 }
328
329 if (!reason.empty())
330 {
331 if (!Utf8toWStr(reason, wReason))
332 {
333 return false;
334 }
335
336 if (!WStrToUtf8(wReason, strReason))
337 {
338 return false;
339 }
340 }
341
342 int32 delay = TimeStringToSecs(time);
343 if (delay <= 0)
344 {
345 delay = Acore::StringTo<int32>(time).value_or(0);
346 }
347
348 if (delay <= 0)
349 {
351 return false;
352 }
353
354 if (exitCode && *exitCode >= 0 && *exitCode <= 125)
355 {
356 sWorld->ShutdownServ(delay, 0, *exitCode);
357 }
358 else
359 {
360 sWorld->ShutdownServ(delay, 0, SHUTDOWN_EXIT_CODE, strReason);
361 }
362
363 return true;
364 }

References LANG_BAD_VALUE, ChatHandler::SendErrorMessage(), SHUTDOWN_EXIT_CODE, sWorld, TimeStringToSecs(), Utf8toWStr(), and WStrToUtf8().

Referenced by GetCommands().


The documentation for this class was generated from the following file: