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
51: CommandScript("server_commandscript") { }
Definition CommandScript.h:25

Member Function Documentation

◆ GetCommands()

ChatCommandTable server_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

54 {
55 static ChatCommandTable serverIdleRestartCommandTable =
56 {
57 { "cancel", HandleServerShutDownCancelCommand, SEC_ADMINISTRATOR, Console::Yes },
58 { "", HandleServerIdleRestartCommand, SEC_CONSOLE, Console::Yes }
59 };
60
61 static ChatCommandTable serverIdleShutdownCommandTable =
62 {
63 { "cancel", HandleServerShutDownCancelCommand, SEC_ADMINISTRATOR, Console::Yes },
64 { "", HandleServerIdleShutDownCommand, SEC_CONSOLE, Console::Yes }
65 };
66
67 static ChatCommandTable serverRestartCommandTable =
68 {
69 { "cancel", HandleServerShutDownCancelCommand, SEC_ADMINISTRATOR, Console::Yes },
71 };
72
73 static ChatCommandTable serverShutdownCommandTable =
74 {
75 { "cancel", HandleServerShutDownCancelCommand, SEC_ADMINISTRATOR, Console::Yes },
77 };
78
79 static ChatCommandTable serverSetCommandTable =
80 {
81 { "loglevel", HandleServerSetLogLevelCommand, SEC_CONSOLE, Console::Yes },
82 { "motd", HandleServerSetMotdCommand, SEC_ADMINISTRATOR, Console::Yes },
83 { "closed", HandleServerSetClosedCommand, SEC_CONSOLE, Console::Yes },
84 };
85
86 static ChatCommandTable serverCommandTable =
87 {
88 { "corpses", HandleServerCorpsesCommand, SEC_GAMEMASTER, Console::Yes },
89 { "debug", HandleServerDebugCommand, SEC_ADMINISTRATOR, Console::Yes },
90 { "exit", HandleServerExitCommand, SEC_CONSOLE, Console::Yes },
91 { "idlerestart", serverIdleRestartCommandTable },
92 { "idleshutdown", serverIdleShutdownCommandTable },
93 { "info", HandleServerInfoCommand, SEC_PLAYER, Console::Yes },
94 { "motd", HandleServerMotdCommand, SEC_PLAYER, Console::Yes },
95 { "restart", serverRestartCommandTable },
96 { "shutdown", serverShutdownCommandTable },
97 { "set", serverSetCommandTable }
98 };
99
100 static ChatCommandTable commandTable =
101 {
102 { "server", serverCommandTable }
103 };
104
105 return commandTable;
106 }
@ SEC_PLAYER
Definition Common.h:57
@ SEC_ADMINISTRATOR
Definition Common.h:60
@ SEC_GAMEMASTER
Definition Common.h:59
@ SEC_CONSOLE
Definition Common.h:61
static bool HandleServerCorpsesCommand(ChatHandler *)
Definition cs_server.cpp:109
static bool HandleServerSetLogLevelCommand(ChatHandler *, bool isLogger, std::string const &name, int32 level)
Definition cs_server.cpp:606
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:260
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 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:115
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

References HandleServerCorpsesCommand(), HandleServerDebugCommand(), HandleServerExitCommand(), HandleServerIdleRestartCommand(), HandleServerIdleShutDownCommand(), HandleServerInfoCommand(), HandleServerMotdCommand(), HandleServerRestartCommand(), HandleServerSetClosedCommand(), HandleServerSetLogLevelCommand(), HandleServerSetMotdCommand(), HandleServerShutDownCancelCommand(), HandleServerShutDownCommand(), SEC_ADMINISTRATOR, SEC_CONSOLE, SEC_GAMEMASTER, and SEC_PLAYER.

◆ HandleServerCorpsesCommand()

static bool server_commandscript::HandleServerCorpsesCommand ( ChatHandler )
inlinestatic
110 {
111 sWorld->RemoveOldCorpses();
112 return true;
113 }
#define sWorld
Definition World.h:363

References sWorld.

Referenced by GetCommands().

◆ HandleServerDebugCommand()

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

261 {
262 std::string realmName = sWorld->GetRealmName();
263 uint32 playerCount = sWorldSessionMgr->GetPlayerCount();
264 uint32 activeSessionCount = sWorldSessionMgr->GetActiveSessionCount();
265 uint32 queuedSessionCount = sWorldSessionMgr->GetQueuedSessionCount();
266 uint32 connPeak = sWorldSessionMgr->GetMaxActiveSessionCount();
267
269 if (!queuedSessionCount)
270 handler->PSendSysMessage("Connected players: {}. Characters in world: {}.", activeSessionCount, playerCount);
271 else
272 handler->PSendSysMessage("Connected players: {}. Characters in world: {}. Queue: {}.", activeSessionCount, playerCount, queuedSessionCount);
273
274 handler->PSendSysMessage("Connection peak: {}.", connPeak);
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_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:110
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
292 {
294 for (uint32 i = 0; i < TOTAL_LOCALES; ++i)
296 return true;
297 }
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
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:304
@ LANG_WORLD_CLOSED
Definition Language.h:1174
@ LANG_WORLD_OPENED
Definition Language.h:1175
bool StringStartsWith(std::string_view haystack, std::string_view needle)
Definition Util.h:401

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
607 {
608 sLog->SetLogLevel(name, level, isLogger);
609 return true;
610 }
#define sLog
Definition Log.h:126

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(const std::string &name)
Definition Common.cpp:42
bool IsLocaleValid(std::string const &locale)
Definition Common.cpp:33
@ LOCALE_enUS
Definition Common.h:66
SQLTransaction< LoginDatabaseConnection > LoginDatabaseTransaction
Definition DatabaseEnvFwd.h:70
@ LANG_MOTD_NEW
Definition Language.h:891
@ LOGIN_REP_MOTD
Definition LoginDatabase.h:103
@ LOGIN_REP_MOTD_LOCALE
Definition LoginDatabase.h:104
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
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: