mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 09:17:18 +00:00
feat(Core/Command): server debug (#6007)
* initial work * fix query * load * clean up * remove from startup * ACE * remove static * Update MySQLThreading.cpp * not used * Update MySQLThreading.cpp * unit testing * Update WorldMock.h * show Boost ver * Update WorldMock.h * include * Now we have boost::filesystem woo * fix build * fix typo
This commit is contained in:
@@ -15,12 +15,20 @@ EndScriptData */
|
||||
#include "Chat.h"
|
||||
#include "Config.h"
|
||||
#include "GitRevision.h"
|
||||
#include "VMapManager2.h"
|
||||
#include "VMapFactory.h"
|
||||
#include "Language.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "Player.h"
|
||||
#include "Realm.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "ServerMotd.h"
|
||||
#include "StringConvert.h"
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/version.hpp>
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/opensslv.h>
|
||||
#include <numeric>
|
||||
|
||||
class server_commandscript : public CommandScript
|
||||
{
|
||||
@@ -64,6 +72,7 @@ public:
|
||||
static std::vector<ChatCommand> serverCommandTable =
|
||||
{
|
||||
{ "corpses", SEC_GAMEMASTER, true, &HandleServerCorpsesCommand, "" },
|
||||
{ "debug", SEC_ADMINISTRATOR, true, &HandleServerDebugCommand, "" },
|
||||
{ "exit", SEC_CONSOLE, true, &HandleServerExitCommand, "" },
|
||||
{ "idlerestart", SEC_CONSOLE, true, nullptr, "", serverIdleRestartCommandTable },
|
||||
{ "idleshutdown", SEC_CONSOLE, true, nullptr, "", serverIdleShutdownCommandTable },
|
||||
@@ -89,6 +98,114 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleServerDebugCommand(ChatHandler* handler, char const* /*args*/)
|
||||
{
|
||||
uint16 worldPort = uint16(sWorld->getIntConfig(CONFIG_PORT_WORLD));
|
||||
std::string dbPortOutput;
|
||||
|
||||
{
|
||||
uint16 dbPort = 0;
|
||||
if (QueryResult res = LoginDatabase.PQuery("SELECT port FROM realmlist WHERE id = %u", realm.Id.Realm))
|
||||
dbPort = (*res)[0].GetUInt16();
|
||||
|
||||
if (dbPort)
|
||||
dbPortOutput = acore::StringFormat("Realmlist (Realm Id: %u) configured in port %" PRIu16, realm.Id.Realm, dbPort);
|
||||
else
|
||||
dbPortOutput = acore::StringFormat("Realm Id: %u not found in `realmlist` table. Please check your setup", realm.Id.Realm);
|
||||
}
|
||||
|
||||
handler->PSendSysMessage("%s", GitRevision::GetFullVersion());
|
||||
handler->PSendSysMessage("Using SSL version: %s (library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));
|
||||
handler->PSendSysMessage("Using ACE version: %s", ACE_VERSION);
|
||||
handler->PSendSysMessage("Using Boost version: %i.%i.%i", BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100);
|
||||
handler->PSendSysMessage("Using MySQL version: %u", MySQL::GetLibraryVersion());
|
||||
handler->PSendSysMessage("Using CMake version: %s", GitRevision::GetCMakeVersion());
|
||||
|
||||
handler->PSendSysMessage("Compiled on: %s", GitRevision::GetHostOSVersion());
|
||||
|
||||
handler->PSendSysMessage("Worldserver listening connections on port %" PRIu16, worldPort);
|
||||
handler->PSendSysMessage("%s", dbPortOutput.c_str());
|
||||
|
||||
bool vmapIndoorCheck = sWorld->getBoolConfig(CONFIG_VMAP_INDOOR_CHECK);
|
||||
bool vmapLOSCheck = VMAP::VMapFactory::createOrGetVMapManager()->isLineOfSightCalcEnabled();
|
||||
bool vmapHeightCheck = VMAP::VMapFactory::createOrGetVMapManager()->isHeightCalcEnabled();
|
||||
|
||||
bool mmapEnabled = sWorld->getBoolConfig(CONFIG_ENABLE_MMAPS);
|
||||
|
||||
std::string dataDir = sWorld->GetDataPath();
|
||||
std::vector<std::string> subDirs;
|
||||
subDirs.emplace_back("maps");
|
||||
if (vmapIndoorCheck || vmapLOSCheck || vmapHeightCheck)
|
||||
{
|
||||
handler->PSendSysMessage("VMAPs status: Enabled. LineOfSight: %i, getHeight: %i, indoorCheck: %i", vmapLOSCheck, vmapHeightCheck, vmapIndoorCheck);
|
||||
subDirs.emplace_back("vmaps");
|
||||
}
|
||||
else
|
||||
handler->SendSysMessage("VMAPs status: Disabled");
|
||||
|
||||
if (mmapEnabled)
|
||||
{
|
||||
handler->SendSysMessage("MMAPs status: Enabled");
|
||||
subDirs.emplace_back("mmaps");
|
||||
}
|
||||
else
|
||||
handler->SendSysMessage("MMAPs status: Disabled");
|
||||
|
||||
for (std::string const& subDir : subDirs)
|
||||
{
|
||||
boost::filesystem::path mapPath(dataDir);
|
||||
mapPath /= subDir;
|
||||
|
||||
if (!boost::filesystem::exists(mapPath))
|
||||
{
|
||||
handler->PSendSysMessage("%s directory doesn't exist!. Using path: %s", subDir.c_str(), mapPath.generic_string().c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
auto end = boost::filesystem::directory_iterator();
|
||||
std::size_t folderSize = std::accumulate(boost::filesystem::directory_iterator(mapPath), end, std::size_t(0), [](std::size_t val, boost::filesystem::path const& mapFile)
|
||||
{
|
||||
if (boost::filesystem::is_regular_file(mapFile))
|
||||
val += boost::filesystem::file_size(mapFile);
|
||||
return val;
|
||||
});
|
||||
|
||||
handler->PSendSysMessage("%s directory located in %s. Total size: " SZFMTD " bytes", subDir.c_str(), mapPath.generic_string().c_str(), folderSize);
|
||||
}
|
||||
|
||||
LocaleConstant defaultLocale = sWorld->GetDefaultDbcLocale();
|
||||
uint32 availableLocalesMask = (1 << defaultLocale);
|
||||
|
||||
for (uint8 i = 0; i < TOTAL_LOCALES; ++i)
|
||||
{
|
||||
LocaleConstant locale = static_cast<LocaleConstant>(i);
|
||||
if (locale == defaultLocale)
|
||||
continue;
|
||||
|
||||
if (sWorld->GetAvailableDbcLocale(locale) != defaultLocale)
|
||||
availableLocalesMask |= (1 << locale);
|
||||
}
|
||||
|
||||
std::string availableLocales;
|
||||
for (uint8 i = 0; i < TOTAL_LOCALES; ++i)
|
||||
{
|
||||
if (!(availableLocalesMask & (1 << i)))
|
||||
continue;
|
||||
|
||||
availableLocales += localeNames[i];
|
||||
if (i != TOTAL_LOCALES - 1)
|
||||
availableLocales += " ";
|
||||
}
|
||||
|
||||
handler->PSendSysMessage("Using %s DBC Locale as default. All available DBC locales: %s", localeNames[defaultLocale], availableLocales.c_str());
|
||||
|
||||
handler->PSendSysMessage("Using World DB: %s", sWorld->GetDBVersion());
|
||||
handler->PSendSysMessage("Using World DB Revision: %s", sWorld->GetWorldDBRevision());
|
||||
handler->PSendSysMessage("Using Character DB Revision: %s", sWorld->GetCharacterDBRevision());
|
||||
handler->PSendSysMessage("Using Auth DB Revision: %s", sWorld->GetAuthDBRevision());
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleServerInfoCommand(ChatHandler* handler, char const* /*args*/)
|
||||
{
|
||||
std::string realmName = sWorld->GetRealmName();
|
||||
|
||||
Reference in New Issue
Block a user