mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Replace several more globals with locals
This commit is contained in:
@@ -227,12 +227,12 @@ int main(int argc, char * argv[])
|
||||
CConsoleHandler console(callbackFunction);
|
||||
console.start();
|
||||
|
||||
logConfig = new CBasicLogConfigurator(logPath, &console);
|
||||
CBasicLogConfigurator logConfig(logPath, &console);
|
||||
#else
|
||||
logConfig = new CBasicLogConfigurator(logPath, nullptr);
|
||||
CBasicLogConfigurator logConfig(logPath, nullptr);
|
||||
#endif
|
||||
|
||||
logConfig->configureDefault();
|
||||
logConfig.configureDefault();
|
||||
logGlobal->info("Starting client of '%s'", GameConstants::VCMI_VERSION);
|
||||
logGlobal->info("Creating console and configuring logger: %d ms", pomtime.getDiff());
|
||||
logGlobal->info("The log file will be saved to %s", logPath);
|
||||
@@ -289,7 +289,7 @@ int main(int argc, char * argv[])
|
||||
setSettingInteger("general/saveFrequency", "savefrequency", 1);
|
||||
|
||||
// Initialize logging based on settings
|
||||
logConfig->configure();
|
||||
logConfig.configure();
|
||||
logGlobal->debug("settings = %s", settings.toJsonNode().toString());
|
||||
|
||||
// Some basic data validation to produce better error messages in cases of incorrect install
|
||||
|
||||
@@ -27,7 +27,6 @@ VCMI_LIB_NAMESPACE_END
|
||||
#endif
|
||||
|
||||
#ifndef VCMI_WINDOWS
|
||||
using TColor = std::string;
|
||||
#define CONSOLE_GREEN "\x1b[1;32m"
|
||||
#define CONSOLE_RED "\x1b[1;31m"
|
||||
#define CONSOLE_MAGENTA "\x1b[1;35m"
|
||||
@@ -41,7 +40,6 @@ VCMI_LIB_NAMESPACE_END
|
||||
#ifndef __MINGW32__
|
||||
#pragma comment(lib, "dbghelp.lib")
|
||||
#endif
|
||||
typedef WORD TColor;
|
||||
HANDLE handleIn;
|
||||
HANDLE handleOut;
|
||||
HANDLE handleErr;
|
||||
@@ -52,12 +50,8 @@ VCMI_LIB_NAMESPACE_END
|
||||
#define CONSOLE_WHITE FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY
|
||||
#define CONSOLE_GRAY FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE
|
||||
#define CONSOLE_TEAL FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY
|
||||
|
||||
static TColor defErrColor;
|
||||
#endif
|
||||
|
||||
static TColor defColor;
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
#ifdef CREATE_MEMORY_DUMP
|
||||
|
||||
@@ -78,12 +78,22 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
#ifndef VCMI_WINDOWS
|
||||
using TColor = std::string;
|
||||
#else
|
||||
typedef WORD TColor;
|
||||
#endif
|
||||
|
||||
int run();
|
||||
|
||||
void end(); //kills listening thread
|
||||
|
||||
void setColor(EConsoleTextColor::EConsoleTextColor color); //sets color of text appropriate for given logging level
|
||||
|
||||
static TColor defColor;
|
||||
static TColor defErrColor;
|
||||
|
||||
//function to be called when message is received - string: message, bool: whether call was made from in-game console
|
||||
std::function<void(const std::string &, bool)> cb;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "../../lib/CSkillHandler.h"
|
||||
#include "inspector.h"
|
||||
|
||||
static QList<std::pair<QString, QVariant>> LevelIdentifiers
|
||||
static const QList<std::pair<QString, QVariant>> LevelIdentifiers
|
||||
{
|
||||
{QObject::tr("Beginner"), QVariant::fromValue(1)},
|
||||
{QObject::tr("Advanced"), QVariant::fromValue(2)},
|
||||
|
||||
@@ -51,8 +51,6 @@
|
||||
#include "playersettings.h"
|
||||
#include "validator.h"
|
||||
|
||||
static CBasicLogConfigurator * logConfig;
|
||||
|
||||
QJsonValue jsonFromPixmap(const QPixmap &p)
|
||||
{
|
||||
QBuffer buffer;
|
||||
@@ -185,7 +183,7 @@ MainWindow::MainWindow(QWidget* parent) :
|
||||
//configure logging
|
||||
const boost::filesystem::path logPath = VCMIDirs::get().userLogsPath() / "VCMI_Editor_log.txt";
|
||||
console = std::make_unique<CConsoleHandler>();
|
||||
logConfig = new CBasicLogConfigurator(logPath, console.get());
|
||||
logConfig = std::make_unique<CBasicLogConfigurator>(logPath, console.get());
|
||||
logConfig->configureDefault();
|
||||
logGlobal->info("Starting map editor of '%s'", GameConstants::VCMI_VERSION);
|
||||
logGlobal->info("The log file will be saved to %s", logPath);
|
||||
|
||||
@@ -13,6 +13,7 @@ VCMI_LIB_NAMESPACE_BEGIN
|
||||
class CMap;
|
||||
class CampaignState;
|
||||
class CConsoleHandler;
|
||||
class CBasicLogConfigurator;
|
||||
class CGObjectInstance;
|
||||
VCMI_LIB_NAMESPACE_END
|
||||
|
||||
@@ -39,6 +40,7 @@ class MainWindow : public QMainWindow
|
||||
#ifndef VCMI_MOBILE
|
||||
std::unique_ptr<CConsoleHandler> console;
|
||||
#endif
|
||||
std::unique_ptr<CBasicLogConfigurator> logConfig;
|
||||
|
||||
std::unique_ptr<CMap> openMapInternal(const QString &);
|
||||
std::shared_ptr<CampaignState> openCampaignInternal(const QString &);
|
||||
|
||||
Reference in New Issue
Block a user