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 ()
 
const std::string & 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 HandleServerSetLogLevelCommand (ChatHandler *, bool isLogger, std::string const &name, int32 level)
 

Additional Inherited Members

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

Detailed Description

Constructor & Destructor Documentation

◆ server_commandscript()

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

Member Function Documentation

◆ GetCommands()

ChatCommandTable server_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

49 {
50 static ChatCommandTable serverIdleRestartCommandTable =
51 {
54 };
55
56 static ChatCommandTable serverIdleShutdownCommandTable =
57 {
60 };
61
62 static ChatCommandTable serverRestartCommandTable =
63 {
66 };
67
68 static ChatCommandTable serverShutdownCommandTable =
69 {
72 };
73
74 static ChatCommandTable serverSetCommandTable =
75 {
79 };
80
81 static ChatCommandTable serverCommandTable =
82 {
86 { "idlerestart", serverIdleRestartCommandTable },
87 { "idleshutdown", serverIdleShutdownCommandTable },
90 { "restart", serverRestartCommandTable },
91 { "shutdown", serverShutdownCommandTable },
92 { "set", serverSetCommandTable }
93 };
94
95 static ChatCommandTable commandTable =
96 {
97 { "server", serverCommandTable }
98 };
99
100 return commandTable;
101 }
static bool HandleServerCorpsesCommand(ChatHandler *)
Definition cs_server.cpp:104
static bool HandleServerSetLogLevelCommand(ChatHandler *, bool isLogger, std::string const &name, int32 level)
Definition cs_server.cpp:604
static bool HandleServerSetClosedCommand(ChatHandler *handler, Optional< std::string > args)
Definition cs_server.cpp:584
static bool HandleServerRestartCommand(ChatHandler *handler, std::string time, Optional< int32 > exitCode, Tail reason)
Definition cs_server.cpp:357
static bool HandleServerShutDownCommand(ChatHandler *handler, std::string time, Optional< int32 > exitCode, Tail reason)
Definition cs_server.cpp:304
static bool HandleServerInfoCommand(ChatHandler *handler)
Definition cs_server.cpp:258
static bool HandleServerSetMotdCommand(ChatHandler *handler, Optional< int32 > realmId, std::string locale, Tail motd)
Definition cs_server.cpp:525
static bool HandleServerMotdCommand(ChatHandler *handler)
Definition cs_server.cpp:289
static bool HandleServerIdleShutDownCommand(ChatHandler *handler, std::string time, Optional< int32 > exitCode, Tail reason)
Definition cs_server.cpp:463
static bool HandleServerExitCommand(ChatHandler *handler)
Definition cs_server.cpp:517
static bool HandleServerDebugCommand(ChatHandler *handler)
Definition cs_server.cpp:113
static bool HandleServerIdleRestartCommand(ChatHandler *handler, std::string time, Optional< int32 > exitCode, Tail reason)
Definition cs_server.cpp:410
static bool HandleServerShutDownCancelCommand(ChatHandler *)
Definition cs_server.cpp:297
std::vector< ChatCommandBuilder > ChatCommandTable
Definition ChatCommand.h:46
@ RBAC_PERM_COMMAND_SERVER_SHUTDOWN
Definition RBAC.h:562
@ RBAC_PERM_COMMAND_SERVER_SET_LOGLEVEL
Definition RBAC.h:560
@ RBAC_PERM_COMMAND_SERVER_RESTART_CANCEL
Definition RBAC.h:556
@ RBAC_PERM_COMMAND_SERVER_EXIT
Definition RBAC.h:548
@ RBAC_PERM_COMMAND_SERVER_RESTART
Definition RBAC.h:555
@ RBAC_PERM_COMMAND_SERVER_IDLESHUTDOWN_CANCEL
Definition RBAC.h:552
@ RBAC_PERM_COMMAND_SERVER_SHUTDOWN_CANCEL
Definition RBAC.h:563
@ RBAC_PERM_COMMAND_SERVER_IDLERESTART_CANCEL
Definition RBAC.h:550
@ RBAC_PERM_COMMAND_SERVER_MOTD
Definition RBAC.h:564
@ RBAC_PERM_COMMAND_SERVER_SET_CLOSED
Definition RBAC.h:558
@ RBAC_PERM_COMMAND_SERVER_SET_MOTD
Definition RBAC.h:561
@ RBAC_PERM_COMMAND_SERVER_INFO
Definition RBAC.h:553
@ RBAC_PERM_COMMAND_SERVER_IDLERESTART
Definition RBAC.h:549
@ RBAC_PERM_COMMAND_SERVER_IDLESHUTDOWN
Definition RBAC.h:551
@ RBAC_PERM_COMMAND_SERVER_DEBUG
Definition RBAC.h:641
@ RBAC_PERM_COMMAND_SERVER_CORPSES
Definition RBAC.h:547

References HandleServerCorpsesCommand(), HandleServerDebugCommand(), HandleServerExitCommand(), HandleServerIdleRestartCommand(), HandleServerIdleShutDownCommand(), HandleServerInfoCommand(), HandleServerMotdCommand(), HandleServerRestartCommand(), HandleServerSetClosedCommand(), HandleServerSetLogLevelCommand(), HandleServerSetMotdCommand(), 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_SHUTDOWN, and rbac::RBAC_PERM_COMMAND_SERVER_SHUTDOWN_CANCEL.

◆ HandleServerCorpsesCommand()

static bool server_commandscript::HandleServerCorpsesCommand ( ChatHandler )
inlinestatic
105 {
106 sMapMgr->DoForAllMaps([](Map* map)
107 {
108 map->RemoveOldCorpses();
109 });
110 return true;
111 }
#define sMapMgr
Definition MapMgr.h:220
Definition Map.h:166
void RemoveOldCorpses()
Definition Map.cpp:3046

References Map::RemoveOldCorpses(), and sMapMgr.

Referenced by GetCommands().

◆ HandleServerDebugCommand()

static bool server_commandscript::HandleServerDebugCommand ( ChatHandler handler)
inlinestatic
114 {
115 uint16 worldPort = uint16(sWorld->getIntConfig(CONFIG_PORT_WORLD));
116 std::string dbPortOutput;
117
118 {
119 uint16 dbPort = 0;
120 if (QueryResult res = LoginDatabase.Query("SELECT port FROM realmlist WHERE id = {}", realm.Id.Realm))
121 dbPort = (*res)[0].Get<uint16>();
122
123 if (dbPort)
124 dbPortOutput = Acore::StringFormat("Realmlist (Realm Id: {}) configured in port {}", realm.Id.Realm, dbPort);
125 else
126 dbPortOutput = Acore::StringFormat("Realm Id: {} not found in `realmlist` table. Please check your setup", realm.Id.Realm);
127 }
128
130
131 handler->PSendSysMessage("Using SSL version: {} (library: {})", OPENSSL_VERSION_TEXT, OpenSSL_version(OPENSSL_VERSION));
132 handler->PSendSysMessage("Using Boost version: {}.{}.{}", BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100);
133 handler->PSendSysMessage("Using CMake version: {}", GitRevision::GetCMakeVersion());
134
135 handler->PSendSysMessage("Using MySQL version: {}", MySQL::GetLibraryVersion());
136 handler->PSendSysMessage("Found MySQL Executable: {}", GitRevision::GetMySQLExecutable());
137
138 handler->PSendSysMessage("Compiled on: {}", GitRevision::GetHostOSVersion());
139
140 handler->PSendSysMessage("Worldserver listening connections on port {}", worldPort);
141 handler->PSendSysMessage("{}", dbPortOutput);
142
143 bool vmapIndoorCheck = sWorld->getBoolConfig(CONFIG_VMAP_INDOOR_CHECK);
146
147 bool mmapEnabled = sWorld->getBoolConfig(CONFIG_ENABLE_MMAPS);
148
149 std::string dataDir = sWorld->GetDataPath();
150 std::vector<std::string> subDirs;
151 subDirs.emplace_back("maps");
152 if (vmapIndoorCheck || vmapLOSCheck || vmapHeightCheck)
153 {
154 handler->PSendSysMessage("VMAPs status: Enabled. LineOfSight: {}, getHeight: {}, indoorCheck: {}", vmapLOSCheck, vmapHeightCheck, vmapIndoorCheck);
155 subDirs.emplace_back("vmaps");
156 }
157 else
158 handler->SendSysMessage("VMAPs status: Disabled");
159
160 if (mmapEnabled)
161 {
162 handler->SendSysMessage("MMAPs status: Enabled");
163 subDirs.emplace_back("mmaps");
164 }
165 else
166 handler->SendSysMessage("MMAPs status: Disabled");
167
168 for (std::string const& subDir : subDirs)
169 {
170 std::filesystem::path mapPath(dataDir);
171 mapPath /= subDir;
172
173 if (!std::filesystem::exists(mapPath))
174 {
175 handler->PSendSysMessage("{} directory doesn't exist!. Using path: {}", subDir, mapPath.generic_string());
176 continue;
177 }
178
179 auto end = std::filesystem::directory_iterator();
180 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)
181 {
182 if (std::filesystem::is_regular_file(mapFile))
183 val += std::filesystem::file_size(mapFile);
184 return val;
185 });
186
187 handler->PSendSysMessage("{} directory located in {}. Total size: {} bytes", subDir, mapPath.generic_string(), folderSize);
188 }
189
190 LocaleConstant defaultLocale = sWorld->GetDefaultDbcLocale();
191 uint32 availableLocalesMask = (1 << defaultLocale);
192
193 for (uint8 i = 0; i < TOTAL_LOCALES; ++i)
194 {
195 LocaleConstant locale = static_cast<LocaleConstant>(i);
196 if (locale == defaultLocale)
197 continue;
198
199 if (sWorld->GetAvailableDbcLocale(locale) != defaultLocale)
200 availableLocalesMask |= (1 << locale);
201 }
202
203 std::string availableLocales;
204 for (uint8 i = 0; i < TOTAL_LOCALES; ++i)
205 {
206 if (!(availableLocalesMask & (1 << i)))
207 continue;
208
209 availableLocales += localeNames[i];
210 if (i != TOTAL_LOCALES - 1)
211 availableLocales += " ";
212 }
213
214 handler->PSendSysMessage("Default DBC locale: {}.\nAll available DBC locales: {}", localeNames[defaultLocale], availableLocales);
215
216 handler->PSendSysMessage("Using World DB: {}", sWorld->GetDBVersion());
217
218 std::string lldb = "No updates found!";
219 if (QueryResult resL = LoginDatabase.Query("SELECT name FROM updates ORDER BY name DESC LIMIT 1"))
220 {
221 Field* fields = resL->Fetch();
222 lldb = fields[0].Get<std::string>();
223 }
224 std::string lcdb = "No updates found!";
225 if (QueryResult resC = CharacterDatabase.Query("SELECT name FROM updates ORDER BY name DESC LIMIT 1"))
226 {
227 Field* fields = resC->Fetch();
228 lcdb = fields[0].Get<std::string>();
229 }
230 std::string lwdb = "No updates found!";
231 if (QueryResult resW = WorldDatabase.Query("SELECT name FROM updates ORDER BY name DESC LIMIT 1"))
232 {
233 Field* fields = resW->Fetch();
234 lwdb = fields[0].Get<std::string>();
235 }
236
237 handler->PSendSysMessage("Latest LoginDatabase update: {}", lldb);
238 handler->PSendSysMessage("Latest CharacterDatabase update: {}", lcdb);
239 handler->PSendSysMessage("Latest WorldDatabase update: {}", lwdb);
240
241 handler->PSendSysMessage("LoginDatabase queue size: {}", LoginDatabase.QueueSize());
242 handler->PSendSysMessage("CharacterDatabase queue size: {}", CharacterDatabase.QueueSize());
243 handler->PSendSysMessage("WorldDatabase queue size: {}", WorldDatabase.QueueSize());
244
246 handler->PSendSysMessage("No modules are enabled");
247 else
248 handler->PSendSysMessage("List of enabled modules:");
249
250 for (auto const& modName : Acore::Module::GetEnableModulesList())
251 {
252 handler->PSendSysMessage("|- {}", modName);
253 }
254
255 return true;
256 }
char const * localeNames[TOTAL_LOCALES]
Definition Common.cpp:20
LocaleConstant
Definition Common.h:117
@ TOTAL_LOCALES
Definition Common.h:128
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
struct Module_79C0768D657977D697E10BAD956CCED1 Module
@ CONFIG_ENABLE_MMAPS
Definition WorldConfig.h:104
@ CONFIG_VMAP_INDOOR_CHECK
Definition WorldConfig.h:82
@ CONFIG_PORT_WORLD
Definition WorldConfig.h:173
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:98
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition Field.h:112
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:317
Realm realm
Definition World.cpp:111
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(), Acore::StringFormat(), sWorld, TOTAL_LOCALES, and WorldDatabase.

Referenced by GetCommands().

◆ HandleServerExitCommand()

static bool server_commandscript::HandleServerExitCommand ( ChatHandler handler)
inlinestatic
518 {
521 return true;
522 }
@ 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
411 {
412 std::wstring wReason = std::wstring();
413 std::string strReason = std::string();
414
415 if (time.empty())
416 {
417 return false;
418 }
419
420 if (Acore::StringTo<int32>(time).value_or(0) < 0)
421 {
423 return false;
424 }
425
426 if (!reason.empty())
427 {
428 if (!Utf8toWStr(reason, wReason))
429 {
430 return false;
431 }
432
433 if (!WStrToUtf8(wReason, strReason))
434 {
435 return false;
436 }
437 }
438
439 int32 delay = TimeStringToSecs(time);
440 if (delay <= 0)
441 {
442 delay = Acore::StringTo<int32>(time).value_or(0);
443 }
444
445 if (delay <= 0)
446 {
448 return false;
449 }
450
451 if (exitCode && *exitCode >= 0 && *exitCode <= 125)
452 {
453 sWorld->ShutdownServ(delay, SHUTDOWN_MASK_RESTART | SHUTDOWN_MASK_IDLE, *exitCode);
454 }
455 else
456 {
457 sWorld->ShutdownServ(delay, SHUTDOWN_MASK_RESTART | SHUTDOWN_MASK_IDLE, RESTART_EXIT_CODE, strReason);
458 }
459
460 return true;
461 }
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(const std::string &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
464 {
465 std::wstring wReason = std::wstring();
466 std::string strReason = std::string();
467
468 if (time.empty())
469 {
470 return false;
471 }
472
473 if (Acore::StringTo<int32>(time).value_or(0) < 0)
474 {
476 return false;
477 }
478
479 if (!reason.empty())
480 {
481 if (!Utf8toWStr(reason, wReason))
482 {
483 return false;
484 }
485
486 if (!WStrToUtf8(wReason, strReason))
487 {
488 return false;
489 }
490 }
491
492 int32 delay = TimeStringToSecs(time);
493 if (delay <= 0)
494 {
495 delay = Acore::StringTo<int32>(time).value_or(0);
496 }
497
498 if (delay <= 0)
499 {
501 return false;
502 }
503
504 if (exitCode && *exitCode >= 0 && *exitCode <= 125)
505 {
506 sWorld->ShutdownServ(delay, SHUTDOWN_MASK_IDLE, *exitCode);
507 }
508 else
509 {
510 sWorld->ShutdownServ(delay, SHUTDOWN_MASK_IDLE, SHUTDOWN_EXIT_CODE, strReason);
511 }
512
513 return true;
514 }

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

259 {
260 std::string realmName = sWorld->GetRealmName();
261 uint32 playerCount = sWorldSessionMgr->GetPlayerCount();
262 uint32 activeSessionCount = sWorldSessionMgr->GetActiveSessionCount();
263 uint32 queuedSessionCount = sWorldSessionMgr->GetQueuedSessionCount();
264 uint32 connPeak = sWorldSessionMgr->GetMaxActiveSessionCount();
265
267 if (!queuedSessionCount)
268 handler->PSendSysMessage("Connected players: {}. Characters in world: {}.", activeSessionCount, playerCount);
269 else
270 handler->PSendSysMessage("Connected players: {}. Characters in world: {}. Queue: {}.", activeSessionCount, playerCount, queuedSessionCount);
271
272 handler->PSendSysMessage("Connection peak: {}.", connPeak);
274 handler->PSendSysMessage("Update time diff: {}ms. Last {} diffs summary:", sWorldUpdateTime.GetLastUpdateTime(), sWorldUpdateTime.GetDatasetSize());
275 handler->PSendSysMessage("|- Mean: {}ms", sWorldUpdateTime.GetAverageUpdateTime());
276 handler->PSendSysMessage("|- Median: {}ms", sWorldUpdateTime.GetPercentile(50));
277 handler->PSendSysMessage("|- Percentiles (95, 99, max): {}ms, {}ms, {}ms",
281
283 if (sWorld->IsShuttingDown())
284 handler->PSendSysMessage(LANG_SHUTDOWN_TIMELEFT, secsToTimeString(sWorld->GetShutDownTimeLeft()).append("."));
285
286 return true;
287 }
@ 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:108
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_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
290 {
292 for (uint32 i = 0; i < TOTAL_LOCALES; ++i)
294 return true;
295 }
const std::string GetNameByLocaleConstant(LocaleConstant localeConstant)
Definition Common.cpp:51
@ 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
358 {
359 std::wstring wReason = std::wstring();
360 std::string strReason = std::string();
361
362 if (time.empty())
363 {
364 return false;
365 }
366
367 if (Acore::StringTo<int32>(time).value_or(0) < 0)
368 {
370 return false;
371 }
372
373 if (!reason.empty())
374 {
375 if (!Utf8toWStr(reason, wReason))
376 {
377 return false;
378 }
379
380 if (!WStrToUtf8(wReason, strReason))
381 {
382 return false;
383 }
384 }
385
386 int32 delay = TimeStringToSecs(time);
387 if (delay <= 0)
388 {
389 delay = Acore::StringTo<int32>(time).value_or(0);
390 }
391
392 if (delay <= 0)
393 {
395 return false;
396 }
397
398 if (exitCode && *exitCode >= 0 && *exitCode <= 125)
399 {
400 sWorld->ShutdownServ(delay, SHUTDOWN_MASK_RESTART, *exitCode);
401 }
402 else
403 {
404 sWorld->ShutdownServ(delay, SHUTDOWN_MASK_RESTART, RESTART_EXIT_CODE, strReason);
405 }
406
407 return true;
408 }

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
585 {
586 if (StringStartsWith("on", *args))
587 {
589 sWorld->SetClosed(true);
590 return true;
591 }
592 else if (StringStartsWith("off", *args))
593 {
595 sWorld->SetClosed(false);
596 return true;
597 }
598
600 return false;
601 }
@ LANG_USE_BOL
Definition Language.h:311
@ LANG_WORLD_CLOSED
Definition Language.h:1256
@ LANG_WORLD_OPENED
Definition Language.h:1257
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
605 {
606 sLog->SetLogLevel(name, level, isLogger);
607 return true;
608 }
#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
526 {
527 std::wstring wMotd = std::wstring();
528 std::string strMotd = std::string();
529
530 // Default realmId to the current realm if not provided
531 if (!realmId)
532 realmId = static_cast<int32>(realm.Id.Realm);
533
534 // Determine the locale; default to "enUS" if not provided
535 LocaleConstant localeConstant;
536 if (IsLocaleValid(locale))
537 localeConstant = GetLocaleByName(locale);
538 else
539 {
540 handler->SendErrorMessage("locale ({}) is not valid. Valid locales: enUS, koKR, frFR, deDE, zhCN, zhWE, esES, esMX, ruRU.", locale);
541 return false;
542 }
543
544 if (motd.empty())
545 return false;
546
547 // Convert the concatenated motdString to UTF-8 and ensure encoding consistency
548 if (!Utf8toWStr(motd, wMotd))
549 return false;
550
551 if (!WStrToUtf8(wMotd, strMotd))
552 return false;
553
554 // Start a transaction for the database operations
555 LoginDatabaseTransaction trans = LoginDatabase.BeginTransaction();
556
557 if (localeConstant == LOCALE_enUS)
558 {
559 // Insert or update in the main motd table for enUS
560 LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_REP_MOTD);
561 stmt->SetData(0, realmId.value()); // realmId for insertion
562 stmt->SetData(1, strMotd); // motd text for insertion
563 trans->Append(stmt);
564 }
565 else
566 {
567 // Insert or update in the motd_localized table for other locales
569 stmt->SetData(0, realmId.value()); // realmId for insertion
570 stmt->SetData(1, locale); // locale for insertion
571 stmt->SetData(2, strMotd); // motd text for insertion
572 trans->Append(stmt);
573 }
574
575 // Commit the transaction & update db
576 LoginDatabase.CommitTransaction(trans);
577
578 sMotdMgr->SetMotd(strMotd, localeConstant);
579 handler->PSendSysMessage(LANG_MOTD_NEW, realmId.value(), locale, strMotd);
580 return true;
581 }
LocaleConstant GetLocaleByName(const std::string &name)
Definition Common.cpp:42
bool IsLocaleValid(std::string const &locale)
Definition Common.cpp:33
@ LOCALE_enUS
Definition Common.h:118
SQLTransaction< LoginDatabaseConnection > LoginDatabaseTransaction
Definition DatabaseEnvFwd.h:70
@ LANG_MOTD_NEW
Definition Language.h:902
@ LOGIN_REP_MOTD
Definition LoginDatabase.h:112
@ LOGIN_REP_MOTD_LOCALE
Definition LoginDatabase.h:113
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().

◆ HandleServerShutDownCancelCommand()

static bool server_commandscript::HandleServerShutDownCancelCommand ( ChatHandler )
inlinestatic
298 {
299 sWorld->ShutdownCancel();
300
301 return true;
302 }

References sWorld.

Referenced by GetCommands().

◆ HandleServerShutDownCommand()

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

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: