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
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 {
80 };
81
82 static ChatCommandTable serverCommandTable =
83 {
87 { "idlerestart", serverIdleRestartCommandTable },
88 { "idleshutdown", serverIdleShutdownCommandTable },
91 { "restart", serverRestartCommandTable },
92 { "shutdown", serverShutdownCommandTable },
93 { "set", serverSetCommandTable }
94 };
95
96 static ChatCommandTable commandTable =
97 {
98 { "server", serverCommandTable }
99 };
100
101 return commandTable;
102 }
static bool HandleServerCorpsesCommand(ChatHandler *)
Definition cs_server.cpp:105
static bool HandleServerSetLogLevelCommand(ChatHandler *, bool isLogger, std::string const &name, int32 level)
Definition cs_server.cpp:627
static bool HandleServerSetClosedCommand(ChatHandler *handler, Optional< std::string > args)
Definition cs_server.cpp:586
static bool HandleServerRestartCommand(ChatHandler *handler, std::string time, Optional< int32 > exitCode, Tail reason)
Definition cs_server.cpp:359
static bool HandleServerShutDownCommand(ChatHandler *handler, std::string time, Optional< int32 > exitCode, Tail reason)
Definition cs_server.cpp:306
static bool HandleServerInfoCommand(ChatHandler *handler)
Definition cs_server.cpp:259
static bool HandleServerSetMotdCommand(ChatHandler *handler, Optional< int32 > realmId, std::string locale, Tail motd)
Definition cs_server.cpp:527
static bool HandleServerMotdCommand(ChatHandler *handler)
Definition cs_server.cpp:291
static bool HandleServerSetSecurityCommand(ChatHandler *handler, uint8 level)
Definition cs_server.cpp:606
static bool HandleServerIdleShutDownCommand(ChatHandler *handler, std::string time, Optional< int32 > exitCode, Tail reason)
Definition cs_server.cpp:465
static bool HandleServerExitCommand(ChatHandler *handler)
Definition cs_server.cpp:519
static bool HandleServerDebugCommand(ChatHandler *handler)
Definition cs_server.cpp:114
static bool HandleServerIdleRestartCommand(ChatHandler *handler, std::string time, Optional< int32 > exitCode, Tail reason)
Definition cs_server.cpp:412
static bool HandleServerShutDownCancelCommand(ChatHandler *)
Definition cs_server.cpp:299
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
106 {
107 sMapMgr->DoForAllMaps([](Map* map)
108 {
109 map->RemoveOldCorpses();
110 });
111 return true;
112 }
#define sMapMgr
Definition MapMgr.h:220
Definition Map.h:168
void RemoveOldCorpses()
Definition Map.cpp:3130

References Map::RemoveOldCorpses(), and sMapMgr.

Referenced by GetCommands().

◆ HandleServerDebugCommand()

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

Referenced by GetCommands().

◆ HandleServerExitCommand()

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

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

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

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
587 {
588 if (StringStartsWith("on", *args))
589 {
591 sWorld->SetClosed(true);
592 return true;
593 }
594 else if (StringStartsWith("off", *args))
595 {
597 sWorld->SetClosed(false);
598 return true;
599 }
600
602 return false;
603 }
@ 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
628 {
629 sLog->SetLogLevel(name, level, isLogger);
630 return true;
631 }
#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
528 {
529 std::wstring wMotd = std::wstring();
530 std::string strMotd = std::string();
531
532 // Default realmId to the current realm if not provided
533 if (!realmId)
534 realmId = static_cast<int32>(realm.Id.Realm);
535
536 // Determine the locale; default to "enUS" if not provided
537 LocaleConstant localeConstant;
538 if (IsLocaleValid(locale))
539 localeConstant = GetLocaleByName(locale);
540 else
541 {
542 handler->SendErrorMessage("locale ({}) is not valid. Valid locales: enUS, koKR, frFR, deDE, zhCN, zhWE, esES, esMX, ruRU.", locale);
543 return false;
544 }
545
546 if (motd.empty())
547 return false;
548
549 // Convert the concatenated motdString to UTF-8 and ensure encoding consistency
550 if (!Utf8toWStr(motd, wMotd))
551 return false;
552
553 if (!WStrToUtf8(wMotd, strMotd))
554 return false;
555
556 // Start a transaction for the database operations
557 LoginDatabaseTransaction trans = LoginDatabase.BeginTransaction();
558
559 if (localeConstant == LOCALE_enUS)
560 {
561 // Insert or update in the main motd table for enUS
562 LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_REP_MOTD);
563 stmt->SetData(0, realmId.value()); // realmId for insertion
564 stmt->SetData(1, strMotd); // motd text for insertion
565 trans->Append(stmt);
566 }
567 else
568 {
569 // Insert or update in the motd_localized table for other locales
571 stmt->SetData(0, realmId.value()); // realmId for insertion
572 stmt->SetData(1, locale); // locale for insertion
573 stmt->SetData(2, strMotd); // motd text for insertion
574 trans->Append(stmt);
575 }
576
577 // Commit the transaction & update db
578 LoginDatabase.CommitTransaction(trans);
579
580 sMotdMgr->SetMotd(strMotd, localeConstant);
581 handler->PSendSysMessage(LANG_MOTD_NEW, realmId.value(), locale, strMotd);
582 return true;
583 }
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:114
@ LOGIN_REP_MOTD_LOCALE
Definition LoginDatabase.h:115
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
607 {
608 if (level > SEC_ADMINISTRATOR)
609 {
611 return false;
612 }
613
615 stmt->SetData(0, level);
616 stmt->SetData(1, realm.Id.Realm);
617 LoginDatabase.Execute(stmt);
618
619 // Apply live; raising the limit kicks any now-disallowed sessions.
620 sWorld->SetPlayerSecurityLimit(AccountTypes(level));
621
623 return true;
624 }
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:101

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
300 {
301 sWorld->ShutdownCancel();
302
303 return true;
304 }

References sWorld.

Referenced by GetCommands().

◆ HandleServerShutDownCommand()

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

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: