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

Member Function Documentation

◆ GetCommands()

ChatCommandTable server_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

48 {
49 static ChatCommandTable serverIdleRestartCommandTable =
50 {
51 { "cancel", HandleServerShutDownCancelCommand, SEC_ADMINISTRATOR, Console::Yes },
52 { "", HandleServerIdleRestartCommand, SEC_CONSOLE, Console::Yes }
53 };
54
55 static ChatCommandTable serverIdleShutdownCommandTable =
56 {
57 { "cancel", HandleServerShutDownCancelCommand, SEC_ADMINISTRATOR, Console::Yes },
58 { "", HandleServerIdleShutDownCommand, SEC_CONSOLE, Console::Yes }
59 };
60
61 static ChatCommandTable serverRestartCommandTable =
62 {
63 { "cancel", HandleServerShutDownCancelCommand, SEC_ADMINISTRATOR, Console::Yes },
65 };
66
67 static ChatCommandTable serverShutdownCommandTable =
68 {
69 { "cancel", HandleServerShutDownCancelCommand, SEC_ADMINISTRATOR, Console::Yes },
71 };
72
73 static ChatCommandTable serverSetCommandTable =
74 {
75 { "loglevel", HandleServerSetLogLevelCommand, SEC_CONSOLE, Console::Yes },
76 { "motd", HandleServerSetMotdCommand, SEC_ADMINISTRATOR, Console::Yes },
77 { "closed", HandleServerSetClosedCommand, SEC_CONSOLE, Console::Yes },
78 };
79
80 static ChatCommandTable serverCommandTable =
81 {
82 { "corpses", HandleServerCorpsesCommand, SEC_GAMEMASTER, Console::Yes },
83 { "debug", HandleServerDebugCommand, SEC_ADMINISTRATOR, Console::Yes },
84 { "exit", HandleServerExitCommand, SEC_CONSOLE, Console::Yes },
85 { "idlerestart", serverIdleRestartCommandTable },
86 { "idleshutdown", serverIdleShutdownCommandTable },
87 { "info", HandleServerInfoCommand, SEC_PLAYER, Console::Yes },
88 { "motd", HandleServerMotdCommand, SEC_PLAYER, Console::Yes },
89 { "restart", serverRestartCommandTable },
90 { "shutdown", serverShutdownCommandTable },
91 { "set", serverSetCommandTable }
92 };
93
94 static ChatCommandTable commandTable =
95 {
96 { "server", serverCommandTable }
97 };
98
99 return commandTable;
100 }
@ 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:103
static bool HandleServerSetLogLevelCommand(ChatHandler *, bool isLogger, std::string const &name, int32 level)
Definition cs_server.cpp:603
static bool HandleServerSetClosedCommand(ChatHandler *handler, Optional< std::string > args)
Definition cs_server.cpp:583
static bool HandleServerRestartCommand(ChatHandler *handler, std::string time, Optional< int32 > exitCode, Tail reason)
Definition cs_server.cpp:356
static bool HandleServerShutDownCommand(ChatHandler *handler, std::string time, Optional< int32 > exitCode, Tail reason)
Definition cs_server.cpp:303
static bool HandleServerInfoCommand(ChatHandler *handler)
Definition cs_server.cpp:257
static bool HandleServerSetMotdCommand(ChatHandler *handler, Optional< int32 > realmId, std::string locale, Tail motd)
Definition cs_server.cpp:524
static bool HandleServerMotdCommand(ChatHandler *handler)
Definition cs_server.cpp:288
static bool HandleServerIdleShutDownCommand(ChatHandler *handler, std::string time, Optional< int32 > exitCode, Tail reason)
Definition cs_server.cpp:462
static bool HandleServerExitCommand(ChatHandler *handler)
Definition cs_server.cpp:516
static bool HandleServerDebugCommand(ChatHandler *handler)
Definition cs_server.cpp:112
static bool HandleServerIdleRestartCommand(ChatHandler *handler, std::string time, Optional< int32 > exitCode, Tail reason)
Definition cs_server.cpp:409
static bool HandleServerShutDownCancelCommand(ChatHandler *)
Definition cs_server.cpp:296
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
104 {
105 sMapMgr->DoForAllMaps([](Map* map)
106 {
107 map->RemoveOldCorpses();
108 });
109 return true;
110 }
#define sMapMgr
Definition MapMgr.h:220
Definition Map.h:160
void RemoveOldCorpses()
Definition Map.cpp:2733

References Map::RemoveOldCorpses(), and sMapMgr.

Referenced by GetCommands().

◆ HandleServerDebugCommand()

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

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

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

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

References sWorld.

Referenced by GetCommands().

◆ HandleServerShutDownCommand()

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

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: