mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-18 16:38:42 +01:00
225 lines
9.3 KiB
Plaintext
225 lines
9.3 KiB
Plaintext
From 4d350eb6e28edb588b49a80b3cd46cb5035509f8 Mon Sep 17 00:00:00 2001
|
|
From: ariel- <ariel-@users.noreply.github.com>
|
|
Date: Tue, 6 Mar 2018 18:05:49 -0300
|
|
Subject: [PATCH] serv debug
|
|
|
|
---
|
|
revision_data.h.in.cmake | 3 +
|
|
src/common/GitRevision.cpp | 10 +++
|
|
src/common/GitRevision.h | 2 +
|
|
src/server/scripts/Commands/cs_server.cpp | 117 +++++++++++++++++++++++++++++-
|
|
4 files changed, 131 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/revision_data.h.in.cmake b/revision_data.h.in.cmake
|
|
index ebaf103e4b..7974e54daa 100644
|
|
--- a/revision_data.h.in.cmake
|
|
+++ b/revision_data.h.in.cmake
|
|
@@ -4,6 +4,9 @@
|
|
#define _DATE "@rev_date@"
|
|
#define _BRANCH "@rev_branch@"
|
|
#define _CMAKE_COMMAND R"(@CMAKE_COMMAND@)"
|
|
+ #define _CMAKE_VERSION R"(@CMAKE_VERSION@)"
|
|
+ #define _CMAKE_HOST_SYSTEM_NAME R"(@CMAKE_HOST_SYSTEM_NAME@)"
|
|
+ #define _CMAKE_HOST_SYSTEM_VERSION R"(@CMAKE_HOST_SYSTEM_VERSION@)"
|
|
#define _SOURCE_DIRECTORY R"(@CMAKE_SOURCE_DIR@)"
|
|
#define _BUILD_DIRECTORY R"(@BUILDDIR@)"
|
|
#define _MYSQL_EXECUTABLE R"(@MYSQL_EXECUTABLE@)"
|
|
diff --git a/src/common/GitRevision.cpp b/src/common/GitRevision.cpp
|
|
index 7bf4525605..3d0a87a259 100644
|
|
--- a/src/common/GitRevision.cpp
|
|
+++ b/src/common/GitRevision.cpp
|
|
@@ -38,6 +38,16 @@ char const* GitRevision::GetCMakeCommand()
|
|
return _CMAKE_COMMAND;
|
|
}
|
|
|
|
+char const* GitRevision::GetCMakeVersion()
|
|
+{
|
|
+ return _CMAKE_VERSION;
|
|
+}
|
|
+
|
|
+char const* GitRevision::GetHostOSVersion()
|
|
+{
|
|
+ return _CMAKE_HOST_SYSTEM_NAME R"( )" _CMAKE_HOST_SYSTEM_VERSION;
|
|
+}
|
|
+
|
|
char const* GitRevision::GetBuildDirectory()
|
|
{
|
|
return _BUILD_DIRECTORY;
|
|
diff --git a/src/common/GitRevision.h b/src/common/GitRevision.h
|
|
index e1a46b4b0d..c6d3fc5289 100644
|
|
--- a/src/common/GitRevision.h
|
|
+++ b/src/common/GitRevision.h
|
|
@@ -26,6 +26,8 @@ namespace GitRevision
|
|
TC_COMMON_API char const* GetDate();
|
|
TC_COMMON_API char const* GetBranch();
|
|
TC_COMMON_API char const* GetCMakeCommand();
|
|
+ TC_COMMON_API char const* GetCMakeVersion();
|
|
+ TC_COMMON_API char const* GetHostOSVersion();
|
|
TC_COMMON_API char const* GetBuildDirectory();
|
|
TC_COMMON_API char const* GetSourceDirectory();
|
|
TC_COMMON_API char const* GetMySQLExecutable();
|
|
diff --git a/src/server/scripts/Commands/cs_server.cpp b/src/server/scripts/Commands/cs_server.cpp
|
|
index 52c4ed557c..a4bd11a0c7 100644
|
|
--- a/src/server/scripts/Commands/cs_server.cpp
|
|
+++ b/src/server/scripts/Commands/cs_server.cpp
|
|
@@ -25,6 +25,7 @@ EndScriptData */
|
|
#include "ScriptMgr.h"
|
|
#include "Chat.h"
|
|
#include "Config.h"
|
|
+#include "DatabaseEnv.h"
|
|
#include "GameTime.h"
|
|
#include "GitRevision.h"
|
|
#include "Language.h"
|
|
@@ -32,12 +33,21 @@ EndScriptData */
|
|
#include "ObjectAccessor.h"
|
|
#include "Player.h"
|
|
#include "RBAC.h"
|
|
+#include "Realm.h"
|
|
#include "ServerMotd.h"
|
|
#include "UpdateTime.h"
|
|
#include "Util.h"
|
|
+#include "VMapFactory.h"
|
|
#include "World.h"
|
|
#include "WorldSession.h"
|
|
|
|
+#include <numeric>
|
|
+
|
|
+#include <boost/filesystem.hpp>
|
|
+#include <mysql_version.h>
|
|
+#include <openssl/crypto.h>
|
|
+#include <openssl/opensslv.h>
|
|
+
|
|
class server_commandscript : public CommandScript
|
|
{
|
|
public:
|
|
@@ -82,6 +92,7 @@ public:
|
|
static std::vector<ChatCommand> serverCommandTable =
|
|
{
|
|
{ "corpses", rbac::RBAC_PERM_COMMAND_SERVER_CORPSES, true, &HandleServerCorpsesCommand, "" },
|
|
+ { "debug", rbac::RBACPermissions(0), true, &HandleServerDebugCommand, "" },
|
|
{ "exit", rbac::RBAC_PERM_COMMAND_SERVER_EXIT, true, &HandleServerExitCommand, "" },
|
|
{ "idlerestart", rbac::RBAC_PERM_COMMAND_SERVER_IDLERESTART, true, nullptr, "", serverIdleRestartCommandTable },
|
|
{ "idleshutdown", rbac::RBAC_PERM_COMMAND_SERVER_IDLESHUTDOWN, true, nullptr, "", serverIdleShutdownCommandTable },
|
|
@@ -107,6 +118,110 @@ 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 = Trinity::StringFormat("Realmlist (Realm Id: %u) configured in port %" PRIu16, realm.Id.Realm, dbPort);
|
|
+ else
|
|
+ dbPortOutput = Trinity::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 Boost version: %i.%i.%i", BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100);
|
|
+ handler->PSendSysMessage("Using MySQL version: %s", MYSQL_SERVER_VERSION);
|
|
+ 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.append(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());
|
|
+ return true;
|
|
+ }
|
|
+
|
|
static bool HandleServerInfoCommand(ChatHandler* handler, char const* /*args*/)
|
|
{
|
|
uint32 playersNum = sWorld->GetPlayerCount();
|
|
@@ -118,7 +233,7 @@ public:
|
|
std::string uptime = secsToTimeString(GameTime::GetUptime());
|
|
uint32 updateTime = sWorldUpdateTime.GetLastUpdateTime();
|
|
|
|
- handler->SendSysMessage(GitRevision::GetFullVersion());
|
|
+ handler->PSendSysMessage("%s", GitRevision::GetFullVersion());
|
|
handler->PSendSysMessage(LANG_CONNECTED_PLAYERS, playersNum, maxPlayersNum);
|
|
handler->PSendSysMessage(LANG_CONNECTED_USERS, activeClientsNum, maxActiveClientsNum, queuedClientsNum, maxQueuedClientsNum);
|
|
handler->PSendSysMessage(LANG_UPTIME, uptime.c_str());
|
|
--
|
|
2.13.2.windows.1
|