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

Member Function Documentation

◆ GetCommands()

ChatCommandTable server_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

47 {
48 static ChatCommandTable serverIdleRestartCommandTable =
49 {
50 { "cancel", HandleServerShutDownCancelCommand, SEC_ADMINISTRATOR, Console::Yes },
51 { "", HandleServerIdleRestartCommand, SEC_CONSOLE, Console::Yes }
52 };
53
54 static ChatCommandTable serverIdleShutdownCommandTable =
55 {
56 { "cancel", HandleServerShutDownCancelCommand, SEC_ADMINISTRATOR, Console::Yes },
57 { "", HandleServerIdleShutDownCommand, SEC_CONSOLE, Console::Yes }
58 };
59
60 static ChatCommandTable serverRestartCommandTable =
61 {
62 { "cancel", HandleServerShutDownCancelCommand, SEC_ADMINISTRATOR, Console::Yes },
64 };
65
66 static ChatCommandTable serverShutdownCommandTable =
67 {
68 { "cancel", HandleServerShutDownCancelCommand, SEC_ADMINISTRATOR, Console::Yes },
70 };
71
72 static ChatCommandTable serverSetCommandTable =
73 {
74 { "loglevel", HandleServerSetLogLevelCommand, SEC_CONSOLE, Console::Yes },
75 { "motd", HandleServerSetMotdCommand, SEC_ADMINISTRATOR, Console::Yes },
76 { "closed", HandleServerSetClosedCommand, SEC_CONSOLE, Console::Yes },
77 };
78
79 static ChatCommandTable serverCommandTable =
80 {
81 { "corpses", HandleServerCorpsesCommand, SEC_GAMEMASTER, Console::Yes },
82 { "debug", HandleServerDebugCommand, SEC_ADMINISTRATOR, Console::Yes },
83 { "exit", HandleServerExitCommand, SEC_CONSOLE, Console::Yes },
84 { "idlerestart", serverIdleRestartCommandTable },
85 { "idleshutdown", serverIdleShutdownCommandTable },
86 { "info", HandleServerInfoCommand, SEC_PLAYER, Console::Yes },
87 { "motd", HandleServerMotdCommand, SEC_PLAYER, Console::Yes },
88 { "restart", serverRestartCommandTable },
89 { "shutdown", serverShutdownCommandTable },
90 { "set", serverSetCommandTable }
91 };
92
93 static ChatCommandTable commandTable =
94 {
95 { "server", serverCommandTable }
96 };
97
98 return commandTable;
99 }
@ 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:102
static bool HandleServerSetLogLevelCommand(ChatHandler *, bool isLogger, std::string const &name, int32 level)
Definition cs_server.cpp:599
static bool HandleServerSetClosedCommand(ChatHandler *handler, Optional< std::string > args)
Definition cs_server.cpp:579
static bool HandleServerRestartCommand(ChatHandler *handler, std::string time, Optional< int32 > exitCode, Tail reason)
Definition cs_server.cpp:352
static bool HandleServerShutDownCommand(ChatHandler *handler, std::string time, Optional< int32 > exitCode, Tail reason)
Definition cs_server.cpp:299
static bool HandleServerInfoCommand(ChatHandler *handler)
Definition cs_server.cpp:253
static bool HandleServerSetMotdCommand(ChatHandler *handler, Optional< int32 > realmId, std::string locale, Tail motd)
Definition cs_server.cpp:520
static bool HandleServerMotdCommand(ChatHandler *handler)
Definition cs_server.cpp:284
static bool HandleServerIdleShutDownCommand(ChatHandler *handler, std::string time, Optional< int32 > exitCode, Tail reason)
Definition cs_server.cpp:458
static bool HandleServerExitCommand(ChatHandler *handler)
Definition cs_server.cpp:512
static bool HandleServerDebugCommand(ChatHandler *handler)
Definition cs_server.cpp:108
static bool HandleServerIdleRestartCommand(ChatHandler *handler, std::string time, Optional< int32 > exitCode, Tail reason)
Definition cs_server.cpp:405
static bool HandleServerShutDownCancelCommand(ChatHandler *)
Definition cs_server.cpp:292
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
103 {
104 sWorld->RemoveOldCorpses();
105 return true;
106 }
#define sWorld
Definition World.h:357

References sWorld.

Referenced by GetCommands().

◆ HandleServerDebugCommand()

static bool server_commandscript::HandleServerDebugCommand ( ChatHandler handler)
inlinestatic
109 {
110 uint16 worldPort = uint16(sWorld->getIntConfig(CONFIG_PORT_WORLD));
111 std::string dbPortOutput;
112
113 {
114 uint16 dbPort = 0;
115 if (QueryResult res = LoginDatabase.Query("SELECT port FROM realmlist WHERE id = {}", realm.Id.Realm))
116 dbPort = (*res)[0].Get<uint16>();
117
118 if (dbPort)
119 dbPortOutput = Acore::StringFormat("Realmlist (Realm Id: {}) configured in port {}", realm.Id.Realm, dbPort);
120 else
121 dbPortOutput = Acore::StringFormat("Realm Id: {} not found in `realmlist` table. Please check your setup", realm.Id.Realm);
122 }
123
125
126 handler->PSendSysMessage("Using SSL version: {} (library: {})", OPENSSL_VERSION_TEXT, OpenSSL_version(OPENSSL_VERSION));
127 handler->PSendSysMessage("Using Boost version: {}.{}.{}", BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100);
128 handler->PSendSysMessage("Using CMake version: {}", GitRevision::GetCMakeVersion());
129
130 handler->PSendSysMessage("Using MySQL version: {}", MySQL::GetLibraryVersion());
131 handler->PSendSysMessage("Found MySQL Executable: {}", GitRevision::GetMySQLExecutable());
132
133 handler->PSendSysMessage("Compiled on: {}", GitRevision::GetHostOSVersion());
134
135 handler->PSendSysMessage("Worldserver listening connections on port {}", worldPort);
136 handler->PSendSysMessage("{}", dbPortOutput);
137
138 bool vmapIndoorCheck = sWorld->getBoolConfig(CONFIG_VMAP_INDOOR_CHECK);
141
142 bool mmapEnabled = sWorld->getBoolConfig(CONFIG_ENABLE_MMAPS);
143
144 std::string dataDir = sWorld->GetDataPath();
145 std::vector<std::string> subDirs;
146 subDirs.emplace_back("maps");
147 if (vmapIndoorCheck || vmapLOSCheck || vmapHeightCheck)
148 {
149 handler->PSendSysMessage("VMAPs status: Enabled. LineOfSight: {}, getHeight: {}, indoorCheck: {}", vmapLOSCheck, vmapHeightCheck, vmapIndoorCheck);
150 subDirs.emplace_back("vmaps");
151 }
152 else
153 handler->SendSysMessage("VMAPs status: Disabled");
154
155 if (mmapEnabled)
156 {
157 handler->SendSysMessage("MMAPs status: Enabled");
158 subDirs.emplace_back("mmaps");
159 }
160 else
161 handler->SendSysMessage("MMAPs status: Disabled");
162
163 for (std::string const& subDir : subDirs)
164 {
165 std::filesystem::path mapPath(dataDir);
166 mapPath /= subDir;
167
168 if (!std::filesystem::exists(mapPath))
169 {
170 handler->PSendSysMessage("{} directory doesn't exist!. Using path: {}", subDir, mapPath.generic_string());
171 continue;
172 }
173
174 auto end = std::filesystem::directory_iterator();
175 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)
176 {
177 if (std::filesystem::is_regular_file(mapFile))
178 val += std::filesystem::file_size(mapFile);
179 return val;
180 });
181
182 handler->PSendSysMessage("{} directory located in {}. Total size: {} bytes", subDir, mapPath.generic_string(), folderSize);
183 }
184
185 LocaleConstant defaultLocale = sWorld->GetDefaultDbcLocale();
186 uint32 availableLocalesMask = (1 << defaultLocale);
187
188 for (uint8 i = 0; i < TOTAL_LOCALES; ++i)
189 {
190 LocaleConstant locale = static_cast<LocaleConstant>(i);
191 if (locale == defaultLocale)
192 continue;
193
194 if (sWorld->GetAvailableDbcLocale(locale) != defaultLocale)
195 availableLocalesMask |= (1 << locale);
196 }
197
198 std::string availableLocales;
199 for (uint8 i = 0; i < TOTAL_LOCALES; ++i)
200 {
201 if (!(availableLocalesMask & (1 << i)))
202 continue;
203
204 availableLocales += localeNames[i];
205 if (i != TOTAL_LOCALES - 1)
206 availableLocales += " ";
207 }
208
209 handler->PSendSysMessage("Default DBC locale: {}.\nAll available DBC locales: {}", localeNames[defaultLocale], availableLocales);
210
211 handler->PSendSysMessage("Using World DB: {}", sWorld->GetDBVersion());
212
213 std::string lldb = "No updates found!";
214 if (QueryResult resL = LoginDatabase.Query("SELECT name FROM updates ORDER BY name DESC LIMIT 1"))
215 {
216 Field* fields = resL->Fetch();
217 lldb = fields[0].Get<std::string>();
218 }
219 std::string lcdb = "No updates found!";
220 if (QueryResult resC = CharacterDatabase.Query("SELECT name FROM updates ORDER BY name DESC LIMIT 1"))
221 {
222 Field* fields = resC->Fetch();
223 lcdb = fields[0].Get<std::string>();
224 }
225 std::string lwdb = "No updates found!";
226 if (QueryResult resW = WorldDatabase.Query("SELECT name FROM updates ORDER BY name DESC LIMIT 1"))
227 {
228 Field* fields = resW->Fetch();
229 lwdb = fields[0].Get<std::string>();
230 }
231
232 handler->PSendSysMessage("Latest LoginDatabase update: {}", lldb);
233 handler->PSendSysMessage("Latest CharacterDatabase update: {}", lcdb);
234 handler->PSendSysMessage("Latest WorldDatabase update: {}", lwdb);
235
236 handler->PSendSysMessage("LoginDatabase queue size: {}", LoginDatabase.QueueSize());
237 handler->PSendSysMessage("CharacterDatabase queue size: {}", CharacterDatabase.QueueSize());
238 handler->PSendSysMessage("WorldDatabase queue size: {}", WorldDatabase.QueueSize());
239
241 handler->PSendSysMessage("No modules are enabled");
242 else
243 handler->PSendSysMessage("List of enabled modules:");
244
245 for (auto const& modName : Acore::Module::GetEnableModulesList())
246 {
247 handler->PSendSysMessage("|- {}", modName);
248 }
249
250 return true;
251 }
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:215
@ 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
513 {
516 return true;
517 }
@ 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
406 {
407 std::wstring wReason = std::wstring();
408 std::string strReason = std::string();
409
410 if (time.empty())
411 {
412 return false;
413 }
414
415 if (Acore::StringTo<int32>(time).value_or(0) < 0)
416 {
418 return false;
419 }
420
421 if (!reason.empty())
422 {
423 if (!Utf8toWStr(reason, wReason))
424 {
425 return false;
426 }
427
428 if (!WStrToUtf8(wReason, strReason))
429 {
430 return false;
431 }
432 }
433
434 int32 delay = TimeStringToSecs(time);
435 if (delay <= 0)
436 {
437 delay = Acore::StringTo<int32>(time).value_or(0);
438 }
439
440 if (delay <= 0)
441 {
443 return false;
444 }
445
446 if (exitCode && *exitCode >= 0 && *exitCode <= 125)
447 {
448 sWorld->ShutdownServ(delay, SHUTDOWN_MASK_RESTART | SHUTDOWN_MASK_IDLE, *exitCode);
449 }
450 else
451 {
452 sWorld->ShutdownServ(delay, SHUTDOWN_MASK_RESTART | SHUTDOWN_MASK_IDLE, RESTART_EXIT_CODE, strReason);
453 }
454
455 return true;
456 }
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
459 {
460 std::wstring wReason = std::wstring();
461 std::string strReason = std::string();
462
463 if (time.empty())
464 {
465 return false;
466 }
467
468 if (Acore::StringTo<int32>(time).value_or(0) < 0)
469 {
471 return false;
472 }
473
474 if (!reason.empty())
475 {
476 if (!Utf8toWStr(reason, wReason))
477 {
478 return false;
479 }
480
481 if (!WStrToUtf8(wReason, strReason))
482 {
483 return false;
484 }
485 }
486
487 int32 delay = TimeStringToSecs(time);
488 if (delay <= 0)
489 {
490 delay = Acore::StringTo<int32>(time).value_or(0);
491 }
492
493 if (delay <= 0)
494 {
496 return false;
497 }
498
499 if (exitCode && *exitCode >= 0 && *exitCode <= 125)
500 {
501 sWorld->ShutdownServ(delay, SHUTDOWN_MASK_IDLE, *exitCode);
502 }
503 else
504 {
505 sWorld->ShutdownServ(delay, SHUTDOWN_MASK_IDLE, SHUTDOWN_EXIT_CODE, strReason);
506 }
507
508 return true;
509 }

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

254 {
255 std::string realmName = sWorld->GetRealmName();
256 uint32 playerCount = sWorldSessionMgr->GetPlayerCount();
257 uint32 activeSessionCount = sWorldSessionMgr->GetActiveSessionCount();
258 uint32 queuedSessionCount = sWorldSessionMgr->GetQueuedSessionCount();
259 uint32 connPeak = sWorldSessionMgr->GetMaxActiveSessionCount();
260
262 if (!queuedSessionCount)
263 handler->PSendSysMessage("Connected players: {}. Characters in world: {}.", activeSessionCount, playerCount);
264 else
265 handler->PSendSysMessage("Connected players: {}. Characters in world: {}. Queue: {}.", activeSessionCount, playerCount, queuedSessionCount);
266
267 handler->PSendSysMessage("Connection peak: {}.", connPeak);
269 handler->PSendSysMessage("Update time diff: {}ms. Last {} diffs summary:", sWorldUpdateTime.GetLastUpdateTime(), sWorldUpdateTime.GetDatasetSize());
270 handler->PSendSysMessage("|- Mean: {}ms", sWorldUpdateTime.GetAverageUpdateTime());
271 handler->PSendSysMessage("|- Median: {}ms", sWorldUpdateTime.GetPercentile(50));
272 handler->PSendSysMessage("|- Percentiles (95, 99, max): {}ms, {}ms, {}ms",
276
278 if (sWorld->IsShuttingDown())
279 handler->PSendSysMessage(LANG_SHUTDOWN_TIMELEFT, secsToTimeString(sWorld->GetShutDownTimeLeft()).append("."));
280
281 return true;
282 }
@ 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
285 {
287 for (uint32 i = 0; i < TOTAL_LOCALES; ++i)
289 return true;
290 }
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
353 {
354 std::wstring wReason = std::wstring();
355 std::string strReason = std::string();
356
357 if (time.empty())
358 {
359 return false;
360 }
361
362 if (Acore::StringTo<int32>(time).value_or(0) < 0)
363 {
365 return false;
366 }
367
368 if (!reason.empty())
369 {
370 if (!Utf8toWStr(reason, wReason))
371 {
372 return false;
373 }
374
375 if (!WStrToUtf8(wReason, strReason))
376 {
377 return false;
378 }
379 }
380
381 int32 delay = TimeStringToSecs(time);
382 if (delay <= 0)
383 {
384 delay = Acore::StringTo<int32>(time).value_or(0);
385 }
386
387 if (delay <= 0)
388 {
390 return false;
391 }
392
393 if (exitCode && *exitCode >= 0 && *exitCode <= 125)
394 {
395 sWorld->ShutdownServ(delay, SHUTDOWN_MASK_RESTART, *exitCode);
396 }
397 else
398 {
399 sWorld->ShutdownServ(delay, SHUTDOWN_MASK_RESTART, RESTART_EXIT_CODE, strReason);
400 }
401
402 return true;
403 }

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
580 {
581 if (StringStartsWith("on", *args))
582 {
584 sWorld->SetClosed(true);
585 return true;
586 }
587 else if (StringStartsWith("off", *args))
588 {
590 sWorld->SetClosed(false);
591 return true;
592 }
593
595 return false;
596 }
@ 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
600 {
601 sLog->SetLogLevel(name, level, isLogger);
602 return true;
603 }
#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
521 {
522 std::wstring wMotd = std::wstring();
523 std::string strMotd = std::string();
524
525 // Default realmId to the current realm if not provided
526 if (!realmId)
527 realmId = static_cast<int32>(realm.Id.Realm);
528
529 // Determine the locale; default to "enUS" if not provided
530 LocaleConstant localeConstant;
531 if (IsLocaleValid(locale))
532 localeConstant = GetLocaleByName(locale);
533 else
534 {
535 handler->SendErrorMessage("locale ({}) is not valid. Valid locales: enUS, koKR, frFR, deDE, zhCN, zhWE, esES, esMX, ruRU.", locale);
536 return false;
537 }
538
539 if (motd.empty())
540 return false;
541
542 // Convert the concatenated motdString to UTF-8 and ensure encoding consistency
543 if (!Utf8toWStr(motd, wMotd))
544 return false;
545
546 if (!WStrToUtf8(wMotd, strMotd))
547 return false;
548
549 // Start a transaction for the database operations
550 LoginDatabaseTransaction trans = LoginDatabase.BeginTransaction();
551
552 if (localeConstant == LOCALE_enUS)
553 {
554 // Insert or update in the main motd table for enUS
555 LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_REP_MOTD);
556 stmt->SetData(0, realmId.value()); // realmId for insertion
557 stmt->SetData(1, strMotd); // motd text for insertion
558 trans->Append(stmt);
559 }
560 else
561 {
562 // Insert or update in the motd_localized table for other locales
564 stmt->SetData(0, realmId.value()); // realmId for insertion
565 stmt->SetData(1, locale); // locale for insertion
566 stmt->SetData(2, strMotd); // motd text for insertion
567 trans->Append(stmt);
568 }
569
570 // Commit the transaction & update db
571 LoginDatabase.CommitTransaction(trans);
572
573 sMotdMgr->SetMotd(strMotd, localeConstant);
574 handler->PSendSysMessage(LANG_MOTD_NEW, realmId.value(), locale, strMotd);
575 return true;
576 }
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
293 {
294 sWorld->ShutdownCancel();
295
296 return true;
297 }

References sWorld.

Referenced by GetCommands().

◆ HandleServerShutDownCommand()

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

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: