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
 
virtual std::vector< Acore::ChatCommands::ChatCommandBuilderGetCommands () const =0
 
- 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, 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
49: CommandScript("server_commandscript") { }
Definition: CommandScript.h:25

Member Function Documentation

◆ GetCommands()

ChatCommandTable server_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

52 {
53 static ChatCommandTable serverIdleRestartCommandTable =
54 {
55 { "cancel", HandleServerShutDownCancelCommand, SEC_ADMINISTRATOR, Console::Yes },
56 { "", HandleServerIdleRestartCommand, SEC_CONSOLE, Console::Yes }
57 };
58
59 static ChatCommandTable serverIdleShutdownCommandTable =
60 {
61 { "cancel", HandleServerShutDownCancelCommand, SEC_ADMINISTRATOR, Console::Yes },
62 { "", HandleServerIdleShutDownCommand, SEC_CONSOLE, Console::Yes }
63 };
64
65 static ChatCommandTable serverRestartCommandTable =
66 {
67 { "cancel", HandleServerShutDownCancelCommand, SEC_ADMINISTRATOR, Console::Yes },
69 };
70
71 static ChatCommandTable serverShutdownCommandTable =
72 {
73 { "cancel", HandleServerShutDownCancelCommand, SEC_ADMINISTRATOR, Console::Yes },
75 };
76
77 static ChatCommandTable serverSetCommandTable =
78 {
79 { "loglevel", HandleServerSetLogLevelCommand, SEC_CONSOLE, Console::Yes },
80 { "motd", HandleServerSetMotdCommand, SEC_ADMINISTRATOR, Console::Yes },
81 { "closed", HandleServerSetClosedCommand, SEC_CONSOLE, Console::Yes },
82 };
83
84 static ChatCommandTable serverCommandTable =
85 {
86 { "corpses", HandleServerCorpsesCommand, SEC_GAMEMASTER, Console::Yes },
87 { "debug", HandleServerDebugCommand, SEC_ADMINISTRATOR, Console::Yes },
88 { "exit", HandleServerExitCommand, SEC_CONSOLE, Console::Yes },
89 { "idlerestart", serverIdleRestartCommandTable },
90 { "idleshutdown", serverIdleShutdownCommandTable },
91 { "info", HandleServerInfoCommand, SEC_PLAYER, Console::Yes },
92 { "motd", HandleServerMotdCommand, SEC_PLAYER, Console::Yes },
93 { "restart", serverRestartCommandTable },
94 { "shutdown", serverShutdownCommandTable },
95 { "set", serverSetCommandTable }
96 };
97
98 static ChatCommandTable commandTable =
99 {
100 { "server", serverCommandTable }
101 };
102
103 return commandTable;
104 }
@ SEC_PLAYER
Definition: Common.h:57
@ SEC_ADMINISTRATOR
Definition: Common.h:60
@ SEC_GAMEMASTER
Definition: Common.h:59
@ SEC_CONSOLE
Definition: Common.h:61
std::vector< ChatCommandBuilder > ChatCommandTable
Definition: ChatCommand.h:49
static bool HandleServerCorpsesCommand(ChatHandler *)
Definition: cs_server.cpp:107
static bool HandleServerSetMotdCommand(ChatHandler *handler, Optional< int32 > realmId, Tail motd)
Definition: cs_server.cpp:523
static bool HandleServerSetLogLevelCommand(ChatHandler *, bool isLogger, std::string const &name, int32 level)
Definition: cs_server.cpp:573
static bool HandleServerSetClosedCommand(ChatHandler *handler, Optional< std::string > args)
Definition: cs_server.cpp:553
static bool HandleServerRestartCommand(ChatHandler *handler, std::string time, Optional< int32 > exitCode, Tail reason)
Definition: cs_server.cpp:355
static bool HandleServerShutDownCommand(ChatHandler *handler, std::string time, Optional< int32 > exitCode, Tail reason)
Definition: cs_server.cpp:302
static bool HandleServerInfoCommand(ChatHandler *handler)
Definition: cs_server.cpp:258
static bool HandleServerMotdCommand(ChatHandler *handler)
Definition: cs_server.cpp:289
static bool HandleServerIdleShutDownCommand(ChatHandler *handler, std::string time, Optional< int32 > exitCode, Tail reason)
Definition: cs_server.cpp:461
static bool HandleServerExitCommand(ChatHandler *handler)
Definition: cs_server.cpp:515
static bool HandleServerDebugCommand(ChatHandler *handler)
Definition: cs_server.cpp:113
static bool HandleServerIdleRestartCommand(ChatHandler *handler, std::string time, Optional< int32 > exitCode, Tail reason)
Definition: cs_server.cpp:408
static bool HandleServerShutDownCancelCommand(ChatHandler *)
Definition: cs_server.cpp:295

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
108 {
109 sWorld->RemoveOldCorpses();
110 return true;
111 }
#define sWorld
Definition: World.h:444

References sWorld.

Referenced by GetCommands().

◆ HandleServerDebugCommand()

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

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
409 {
410 std::wstring wReason = std::wstring();
411 std::string strReason = std::string();
412
413 if (time.empty())
414 {
415 return false;
416 }
417
418 if (Acore::StringTo<int32>(time).value_or(0) < 0)
419 {
421 return false;
422 }
423
424 if (!reason.empty())
425 {
426 if (!Utf8toWStr(reason, wReason))
427 {
428 return false;
429 }
430
431 if (!WStrToUtf8(wReason, strReason))
432 {
433 return false;
434 }
435 }
436
437 int32 delay = TimeStringToSecs(time);
438 if (delay <= 0)
439 {
440 delay = Acore::StringTo<int32>(time).value_or(0);
441 }
442
443 if (delay <= 0)
444 {
446 return false;
447 }
448
449 if (exitCode && *exitCode >= 0 && *exitCode <= 125)
450 {
451 sWorld->ShutdownServ(delay, SHUTDOWN_MASK_RESTART | SHUTDOWN_MASK_IDLE, *exitCode);
452 }
453 else
454 {
455 sWorld->ShutdownServ(delay, SHUTDOWN_MASK_RESTART | SHUTDOWN_MASK_IDLE, RESTART_EXIT_CODE, strReason);
456 }
457
458 return true;
459 }
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
std::int32_t int32
Definition: Define.h:103
@ LANG_BAD_VALUE
Definition: Language.h:147
@ RESTART_EXIT_CODE
Definition: World.h:56
@ SHUTDOWN_MASK_RESTART
Definition: World.h:48
@ SHUTDOWN_MASK_IDLE
Definition: World.h:49
void SendErrorMessage(uint32 entry)
Definition: Chat.cpp:218

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
462 {
463 std::wstring wReason = std::wstring();
464 std::string strReason = std::string();
465
466 if (time.empty())
467 {
468 return false;
469 }
470
471 if (Acore::StringTo<int32>(time).value_or(0) < 0)
472 {
474 return false;
475 }
476
477 if (!reason.empty())
478 {
479 if (!Utf8toWStr(reason, wReason))
480 {
481 return false;
482 }
483
484 if (!WStrToUtf8(wReason, strReason))
485 {
486 return false;
487 }
488 }
489
490 int32 delay = TimeStringToSecs(time);
491 if (delay <= 0)
492 {
493 delay = Acore::StringTo<int32>(time).value_or(0);
494 }
495
496 if (delay <= 0)
497 {
499 return false;
500 }
501
502 if (exitCode && *exitCode >= 0 && *exitCode <= 125)
503 {
504 sWorld->ShutdownServ(delay, SHUTDOWN_MASK_IDLE, *exitCode);
505 }
506 else
507 {
508 sWorld->ShutdownServ(delay, SHUTDOWN_MASK_IDLE, SHUTDOWN_EXIT_CODE, strReason);
509 }
510
511 return true;
512 }

References LANG_BAD_VALUE, ChatHandler::SendErrorMessage(), SHUTDOWN_EXIT_CODE, SHUTDOWN_MASK_IDLE, sWorld, TimeStringToSecs(), Utf8toWStr(), and WStrToUtf8().

Referenced by GetCommands().

◆ HandleServerInfoCommand()

static bool server_commandscript::HandleServerInfoCommand ( ChatHandler handler)
inlinestatic

Can't use sWorld->ShutdownMsg here in case of console command

259 {
260 std::string realmName = sWorld->GetRealmName();
261 uint32 playerCount = sWorld->GetPlayerCount();
262 uint32 activeSessionCount = sWorld->GetActiveSessionCount();
263 uint32 queuedSessionCount = sWorld->GetQueuedSessionCount();
264 uint32 connPeak = sWorld->GetMaxActiveSessionCount();
265
267 if (!queuedSessionCount)
268 handler->PSendSysMessage("Connected players: {}. Characters in world: {}.", activeSessionCount, playerCount);
269 else
270 handler->PSendSysMessage("Connected players: {}. Characters in world: {}. Queue: {}.", activeSessionCount, playerCount, queuedSessionCount);
271
272 handler->PSendSysMessage("Connection peak: {}.", connPeak);
274 handler->PSendSysMessage("Update time diff: {}ms. Last {} diffs summary:", sWorldUpdateTime.GetLastUpdateTime(), sWorldUpdateTime.GetDatasetSize());
275 handler->PSendSysMessage("|- Mean: {}ms", sWorldUpdateTime.GetAverageUpdateTime());
276 handler->PSendSysMessage("|- Median: {}ms", sWorldUpdateTime.GetPercentile(50));
277 handler->PSendSysMessage("|- Percentiles (95, 99, max): {}ms, {}ms, {}ms",
281
283 if (sWorld->IsShuttingDown())
284 handler->PSendSysMessage(LANG_SHUTDOWN_TIMELEFT, secsToTimeString(sWorld->GetShutDownTimeLeft()).append("."));
285
286 return true;
287 }
std::string secsToTimeString(uint64 timeInSecs, bool shortText)
Definition: Util.cpp:73
WorldUpdateTime sWorldUpdateTime
Definition: UpdateTime.cpp:27
@ LANG_UPTIME
Definition: Language.h:45
@ LANG_SHUTDOWN_TIMELEFT
Definition: Language.h:52
AC_COMMON_API char const * GetFullVersion()
Definition: GitRevision.cpp:82
Seconds GetUptime()
Uptime.
Definition: GameTime.cpp:58
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

References UpdateTime::GetAverageUpdateTime(), UpdateTime::GetDatasetSize(), GitRevision::GetFullVersion(), UpdateTime::GetLastUpdateTime(), UpdateTime::GetPercentile(), GameTime::GetUptime(), LANG_SHUTDOWN_TIMELEFT, LANG_UPTIME, ChatHandler::PSendSysMessage(), secsToTimeString(), sWorld, and sWorldUpdateTime.

Referenced by GetCommands(), and HandleServerDebugCommand().

◆ HandleServerMotdCommand()

static bool server_commandscript::HandleServerMotdCommand ( ChatHandler handler)
inlinestatic
290 {
291 handler->PSendSysMessage(LANG_MOTD_CURRENT, sMotdMgr->GetMotd());
292 return true;
293 }
#define sMotdMgr
Definition: MotdMgr.h:44
@ LANG_MOTD_CURRENT
Definition: Language.h:88

References LANG_MOTD_CURRENT, ChatHandler::PSendSysMessage(), and sMotdMgr.

Referenced by GetCommands().

◆ HandleServerRestartCommand()

static bool server_commandscript::HandleServerRestartCommand ( ChatHandler handler,
std::string  time,
Optional< int32 exitCode,
Tail  reason 
)
inlinestatic
356 {
357 std::wstring wReason = std::wstring();
358 std::string strReason = std::string();
359
360 if (time.empty())
361 {
362 return false;
363 }
364
365 if (Acore::StringTo<int32>(time).value_or(0) < 0)
366 {
368 return false;
369 }
370
371 if (!reason.empty())
372 {
373 if (!Utf8toWStr(reason, wReason))
374 {
375 return false;
376 }
377
378 if (!WStrToUtf8(wReason, strReason))
379 {
380 return false;
381 }
382 }
383
384 int32 delay = TimeStringToSecs(time);
385 if (delay <= 0)
386 {
387 delay = Acore::StringTo<int32>(time).value_or(0);
388 }
389
390 if (delay <= 0)
391 {
393 return false;
394 }
395
396 if (exitCode && *exitCode >= 0 && *exitCode <= 125)
397 {
398 sWorld->ShutdownServ(delay, SHUTDOWN_MASK_RESTART, *exitCode);
399 }
400 else
401 {
402 sWorld->ShutdownServ(delay, SHUTDOWN_MASK_RESTART, RESTART_EXIT_CODE, strReason);
403 }
404
405 return true;
406 }

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
554 {
555 if (StringStartsWith("on", *args))
556 {
558 sWorld->SetClosed(true);
559 return true;
560 }
561 else if (StringStartsWith("off", *args))
562 {
564 sWorld->SetClosed(false);
565 return true;
566 }
567
569 return false;
570 }
bool StringStartsWith(std::string_view haystack, std::string_view needle)
Definition: Util.h:401
@ LANG_USE_BOL
Definition: Language.h:303
@ LANG_WORLD_CLOSED
Definition: Language.h:1171
@ LANG_WORLD_OPENED
Definition: Language.h:1172

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
574 {
575 sLog->SetLogLevel(name, level, isLogger);
576 return true;
577 }
#define sLog
Definition: Log.h:125

References sLog.

Referenced by GetCommands().

◆ HandleServerSetMotdCommand()

static bool server_commandscript::HandleServerSetMotdCommand ( ChatHandler handler,
Optional< int32 realmId,
Tail  motd 
)
inlinestatic
524 {
525 std::wstring wMotd = std::wstring();
526 std::string strMotd = std::string();
527
528 if (!realmId)
529 realmId = static_cast<int32>(realm.Id.Realm);
530
531 if (motd.empty())
532 return false;
533
534 if (!Utf8toWStr(motd, wMotd))
535 return false;
536
537 if (!WStrToUtf8(wMotd, strMotd))
538 return false;
539
540 LoginDatabaseTransaction trans = LoginDatabase.BeginTransaction();
541 LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_REP_MOTD);
542 stmt->SetData(0, realmId.value());
543 stmt->SetData(1, strMotd);
544 trans->Append(stmt);
545 LoginDatabase.CommitTransaction(trans);
546
547 sMotdMgr->LoadMotd();
548 handler->PSendSysMessage(LANG_MOTD_NEW, realmId.value(), strMotd);
549 return true;
550 }
@ LANG_MOTD_NEW
Definition: Language.h:890
SQLTransaction< LoginDatabaseConnection > LoginDatabaseTransaction
Definition: DatabaseEnvFwd.h:71
@ LOGIN_REP_MOTD
Definition: LoginDatabase.h:101
Definition: PreparedStatement.h:158
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:78

References Realm::Id, LANG_MOTD_NEW, LOGIN_REP_MOTD, LoginDatabase, ChatHandler::PSendSysMessage(), realm, RealmHandle::Realm, PreparedStatementBase::SetData(), sMotdMgr, Utf8toWStr(), and WStrToUtf8().

Referenced by GetCommands().

◆ HandleServerShutDownCancelCommand()

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

References sWorld.

Referenced by GetCommands().

◆ HandleServerShutDownCommand()

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

References LANG_BAD_VALUE, ChatHandler::SendErrorMessage(), SHUTDOWN_EXIT_CODE, sWorld, TimeStringToSecs(), Utf8toWStr(), and WStrToUtf8().

Referenced by GetCommands().