From 75c5b3d32afdb34b824daafaa6d4300b9a8ec06b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 24 Nov 2014 20:58:18 +0300 Subject: Add option to disable logging for better performance while connected to server. --- src/defaults.cpp | 1 + src/game.cpp | 3 +++ src/gui/widgets/tabs/setup_perfomance.cpp | 9 ++++++++- src/logger.cpp | 11 +++++++++++ src/settings.h | 4 +++- 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/defaults.cpp b/src/defaults.cpp index a383c02f6..81b1abff1 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -369,6 +369,7 @@ DefaultsData* getConfigDefaults() AddDEF("showserverpos", false); AddDEF("textureSize", "1024,1024,1024,1024,1024,1024"); AddDEF("ignorelogpackets", ""); + AddDEF("disableLoggingInGame", false); return configData; } diff --git a/src/game.cpp b/src/game.cpp index 0451dd516..675667cf0 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -409,10 +409,13 @@ Game::Game() : if (localPlayer) localPlayer->updatePets(); + + settings.disableLoggingInGame = config.getBoolValue("disableLoggingInGame"); } Game::~Game() { + settings.disableLoggingInGame = false; touchManager.setInGame(false); config.write(); serverConfig.write(); diff --git a/src/gui/widgets/tabs/setup_perfomance.cpp b/src/gui/widgets/tabs/setup_perfomance.cpp index 247419f7b..a6a8d80c0 100644 --- a/src/gui/widgets/tabs/setup_perfomance.cpp +++ b/src/gui/widgets/tabs/setup_perfomance.cpp @@ -129,7 +129,6 @@ Setup_Perfomance::Setup_Perfomance(const Widget2 *const widget) : new SetupItemLabel(_("Different options (enable or disable can " "improve performance)"), "", this); - mTexturesList->fillFromArray(&texturesList[0], texturesListSize); // TRANSLATORS: settings option new SetupItemDropDown(_("Enable texture compression (OpenGL)"), "", @@ -157,6 +156,14 @@ Setup_Perfomance::Setup_Perfomance(const Widget2 *const widget) : "", "uselonglivesounds", this, "uselonglivesoundsEvent"); + // TRANSLATORS: settings group + new SetupItemLabel(_("Critical options (DO NOT change if you don't " + "know what it duing)"), "", this); + + // TRANSLATORS: settings option + new SetupItemCheckBox(_("Disable logging in game (do not enable)"), + "", "disableLoggingInGame", this, "disableLoggingInGameEvent"); + setDimension(Rect(0, 0, 550, 350)); } diff --git a/src/logger.cpp b/src/logger.cpp index 2b80602e8..5a3efb0ee 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -22,6 +22,8 @@ #include "logger.h" +#include "settings.h" + #include #include @@ -180,6 +182,9 @@ void Logger::dlog2(const std::string &str, void Logger::log1(const char *const buf) { + if (settings.disableLoggingInGame) + return; + // Get the current system time timeval tv; gettimeofday(&tv, nullptr); @@ -198,6 +203,9 @@ void Logger::log1(const char *const buf) void Logger::log(const char *const log_text, ...) { + if (settings.disableLoggingInGame) + return; + unsigned size = 1024; if (strlen(log_text) * 3 > size) size = static_cast(strlen(log_text) * 3); @@ -232,6 +240,9 @@ void Logger::log(const char *const log_text, ...) void Logger::log_r(const char *const log_text, ...) { + if (settings.disableLoggingInGame) + return; + SDL_mutexP(mMutex); unsigned size = 1024; diff --git a/src/settings.h b/src/settings.h index 1362672aa..f344f9f15 100644 --- a/src/settings.h +++ b/src/settings.h @@ -74,7 +74,8 @@ class Settings final disableGameModifiers(false), awayMode(false), pseudoAwayMode(false), - fixDeadAnimation(true) + fixDeadAnimation(true), + disableLoggingInGame(false) { } std::string updateHost; @@ -118,6 +119,7 @@ class Settings final bool awayMode; bool pseudoAwayMode; bool fixDeadAnimation; + bool disableLoggingInGame; }; extern Settings settings; -- cgit v1.2.3-70-g09d2