From 4ed8030f36a873fdf881f37c6dccbf28029ce22a Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 10 Mar 2015 17:58:46 +0300 Subject: Add option in settings to enable/disable logging unimplimented packets. --- src/client.cpp | 1 + src/defaults.cpp | 1 + src/gui/widgets/tabs/setup_other.cpp | 5 +++++ src/logger.cpp | 6 +++++- src/logger.h | 4 ++++ 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/client.cpp b/src/client.cpp index 1af7d9041..0d44fcbff 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -268,6 +268,7 @@ void Client::gameInit() initFeatures(); logger->log("init 4"); logger->setDebugLog(config.getBoolValue("debugLog")); + logger->setReportUnimplimented(config.getBoolValue("unimplimentedLog")); config.incValue("runcount"); diff --git a/src/defaults.cpp b/src/defaults.cpp index 3d4668e32..82adc3b0c 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -216,6 +216,7 @@ DefaultsData* getConfigDefaults() AddDEF("errorsInDebug", true); AddDEF("tradebot", true); AddDEF("debugLog", false); + AddDEF("unimplimentedLog", false); AddDEF("drawHotKeys", true); AddDEF("serverAttack", true); AddDEF("autofixPos", false); diff --git a/src/gui/widgets/tabs/setup_other.cpp b/src/gui/widgets/tabs/setup_other.cpp index 16d467f77..a20d4472b 100644 --- a/src/gui/widgets/tabs/setup_other.cpp +++ b/src/gui/widgets/tabs/setup_other.cpp @@ -365,6 +365,10 @@ Setup_Other::Setup_Other(const Widget2 *const widget) : new SetupItemTextField(_("Ignore logging packets"), "", "ignorelogpackets", this, "ignorelogpacketsEvent"); + // TRANSLATORS: settings option + new SetupItemCheckBox(_("Log unimplimented packets"), "", + "unimplimentedLog", this, "unimplimentedLogEvent"); + // TRANSLATORS: settings option new SetupItemCheckBox(_("Enable OpenGL log"), "", "debugOpenGL", this, "debugOpenGLEvent"); @@ -425,6 +429,7 @@ void Setup_Other::apply() SetupTabScroll::apply(); logger->setDebugLog(config.getBoolValue("debugLog")); + logger->setReportUnimplimented(config.getBoolValue("unimplimentedLog")); Net::loadIgnorePackets(); } diff --git a/src/logger.cpp b/src/logger.cpp index e5b7264cf..e91480f7f 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -74,7 +74,8 @@ Logger::Logger() : mMutex(SDL_CreateMutex()), mThreadLocked(false), mLogToStandardOut(true), - mDebugLog(false) + mDebugLog(false), + mReportUnimplimented(false) { } @@ -358,6 +359,9 @@ void Logger::error(const std::string &error_text) void Logger::unimplimented(const int id) { + if (!mReportUnimplimented) + return; + const std::string str = strprintf("Unimplimented packet: %d", id); DebugMessageListener::distributeEvent(str); log(str); diff --git a/src/logger.h b/src/logger.h index 4ddf28818..9e82670ad 100644 --- a/src/logger.h +++ b/src/logger.h @@ -130,6 +130,9 @@ class Logger final void setDebugLog(const bool n) { mDebugLog = n; } + void setReportUnimplimented(const bool n) + { mReportUnimplimented = n; } + /** * Log an error and quit. The error will pop-up on Windows and Mac, and * will be printed to standard error everywhere else. @@ -152,6 +155,7 @@ class Logger final volatile bool mThreadLocked; bool mLogToStandardOut; bool mDebugLog; + bool mReportUnimplimented; }; extern Logger *logger; -- cgit v1.2.3-60-g2f50