* Rename StandardOut -> Logger.

This commit is contained in:
iProgramInCpp 2023-08-28 11:01:12 +03:00
parent 5c1ea03747
commit 8fe86fccb5
11 changed files with 38 additions and 38 deletions

View file

@ -12,7 +12,7 @@
#include <shlobj.h>
#include "AppPlatform_windows.hpp"
#include "StandardOut_windows.hpp"
#include "Logger_windows.hpp"
#include "thirdparty/stb_image.h"
#include "thirdparty/stb_image_write.h"
@ -33,14 +33,14 @@ AppPlatform_windows::AppPlatform_windows()
m_MouseDiffX = 0, m_MouseDiffY = 0;
// This initializes the StandardOut singleton to use the Windows-specific variant
// This initializes the Logger singleton to use the Windows-specific variant
// If we didn't initialize it here, the Minecraft class would have our back
m_standardOut = new StandardOut_windows();
m_Logger = new Logger_windows();
}
AppPlatform_windows::~AppPlatform_windows()
{
SAFE_DELETE(m_standardOut);
SAFE_DELETE(m_Logger);
}
int AppPlatform_windows::checkLicense()

View file

@ -16,7 +16,7 @@
#include "client/player/input/Mouse.hpp"
#include "client/player/input/Keyboard.hpp"
#include "common/Utils.hpp"
#include "StandardOut_windows.hpp"
#include "Logger_windows.hpp"
class AppPlatform_windows : public AppPlatform
{
@ -78,6 +78,6 @@ private:
int m_MouseDiffX, m_MouseDiffY;
StandardOut_windows *m_standardOut;
Logger_windows *m_Logger;
};

View file

@ -2,28 +2,28 @@
#include <stdarg.h>
#include <windows.h>
#include "StandardOut_windows.hpp"
#include "Logger_windows.hpp"
#include "common/Util.hpp"
void StandardOut_windows::print(const char* const str)
void Logger_windows::print(const char* const str)
{
StandardOut::print(str);
Logger::print(str);
OutputDebugStringA(str);
OutputDebugStringA("\n");
}
void StandardOut_windows::print(std::string str)
void Logger_windows::print(std::string str)
{
print(str.c_str());
}
void StandardOut_windows::vprintf(const char* const fmt, va_list argPtr)
void Logger_windows::vprintf(const char* const fmt, va_list argPtr)
{
print(Util::vformat(fmt, argPtr));
}
void StandardOut_windows::printf(const char* const fmt, ...)
void Logger_windows::printf(const char* const fmt, ...)
{
va_list argList;
va_start(argList, fmt);

View file

@ -1,9 +1,9 @@
#pragma once
#include <string>
#include "common/StandardOut.hpp"
#include "common/Logger.hpp"
class StandardOut_windows : StandardOut
class Logger_windows : Logger
{
void print(const char* const str) override;
void print(std::string str) override;

View file

@ -383,7 +383,7 @@
<ClInclude Include="$(MC_ROOT)\thirdparty\zlib\zutil.h" />
<ClInclude Include="$(MC_ROOT)\compat\KeyCodes.hpp" />
<ClInclude Include="$(MC_ROOT)\compat\SDLKeyCodes.h" />
<ClInclude Include="$(MC_ROOT)\source\common\StandardOut.hpp" />
<ClInclude Include="..\..\..\source\common\Logger.hpp" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="$(MC_ROOT)\compat\GLExt.cpp" />
@ -391,7 +391,7 @@
<ClCompile Include="$(MC_ROOT)\platforms\windows\AppPlatform_windows.cpp" />
<ClCompile Include="$(MC_ROOT)\platforms\windows\main.cpp" />
<ClCompile Include="$(MC_ROOT)\platforms\windows\SoundSystemWindows.cpp" />
<ClInclude Include="$(MC_ROOT)\platforms\windows\StandardOut_windows.hpp" />
<ClInclude Include="..\Logger_windows.hpp" />
<ClCompile Include="$(MC_ROOT)\source\App.cpp" />
<ClCompile Include="$(MC_ROOT)\source\AppPlatform.cpp" />
<ClCompile Include="$(MC_ROOT)\source\client\gui\components\AvailableGamesList.cpp" />
@ -729,8 +729,8 @@
<ClCompile Include="$(MC_ROOT)\thirdparty\zlib\trees.c" />
<ClCompile Include="$(MC_ROOT)\thirdparty\zlib\uncompr.c" />
<ClCompile Include="$(MC_ROOT)\thirdparty\zlib\zutil.c" />
<ClCompile Include="..\..\..\source\common\StandardOut.cpp" />
<ClCompile Include="..\StandardOut_windows.cpp" />
<ClCompile Include="..\..\..\source\common\Logger.cpp" />
<ClCompile Include="..\Logger_windows.cpp" />
</ItemGroup>
<ItemGroup>
<Text Include="$(MC_ROOT)\thirdparty\raknet\CMakeLists.txt" />

View file

@ -89,7 +89,7 @@ Minecraft::Minecraft() :
m_fLastUpdated = 0;
m_fDeltaTime = 0;
m_standardOut = new StandardOut();
m_Logger = new Logger();
#ifndef ORIGINAL_CODE
m_pTurnInput = new MouseTurnInput(this);
@ -799,7 +799,7 @@ Minecraft::~Minecraft()
SAFE_DELETE(m_pUser);
SAFE_DELETE(m_pLevelStorageSource);
SAFE_DELETE(m_pTurnInput);
SAFE_DELETE(m_standardOut);
SAFE_DELETE(m_Logger);
//@BUG: potentially leaking a CThread instance if this is destroyed early?
}

View file

@ -89,7 +89,7 @@ public:
static int customDebugId;
private:
StandardOut *m_standardOut;
Logger *m_Logger;
public:
bool field_18;

View file

@ -1,45 +1,45 @@
#include <iostream>
#include <stdarg.h>
#include "StandardOut.hpp"
#include "Logger.hpp"
#include "Util.hpp"
StandardOut* StandardOut::m_singleton = nullptr;
Logger* Logger::m_singleton = nullptr;
StandardOut* const StandardOut::singleton()
Logger* const Logger::singleton()
{
return m_singleton;
}
StandardOut::StandardOut()
Logger::Logger()
{
// Stick with the first output handle we get
if (!m_singleton)
m_singleton = this;
}
StandardOut::~StandardOut()
Logger::~Logger()
{
if (m_singleton == this)
m_singleton = nullptr;
}
void StandardOut::print(const char* const str)
void Logger::print(const char* const str)
{
std::cout << str << std::endl;
}
void StandardOut::print(std::string str)
void Logger::print(std::string str)
{
print(str.c_str());
}
void StandardOut::vprintf(const char* const fmt, va_list argPtr)
void Logger::vprintf(const char* const fmt, va_list argPtr)
{
print(Util::vformat(fmt, argPtr));
}
void StandardOut::printf(const char* const fmt, ...)
void Logger::printf(const char* const fmt, ...)
{
va_list argList;
va_start(argList, fmt);

View file

@ -2,15 +2,15 @@
#include <string>
class StandardOut
class Logger
{
private:
static StandardOut* m_singleton;
static Logger* m_singleton;
public:
static StandardOut* const singleton();
static Logger* const singleton();
StandardOut();
~StandardOut();
Logger();
~Logger();
virtual void print(const char* const str);
virtual void print(std::string str);
@ -20,7 +20,7 @@ public:
#ifdef _DEBUG
#define LOG(...) StandardOut::singleton()->printf(__VA_ARGS__)
#define LOG(...) Logger::singleton()->printf(__VA_ARGS__)
#ifdef PLATFORM_ANDROID
#define LOG_I(...) __android_log_print(ANDROID_LOG_INFO, "MinecraftPE", __VA_ARGS__)

View file

@ -46,7 +46,7 @@ std::string Util::stringTrim(const std::string& str)
std::string Util::vformat(const char *fmt, va_list argPtr)
{
char str[1024];
char str[8192];
vsnprintf(str, sizeof(str), fmt, argPtr);

View file

@ -84,7 +84,7 @@ void closedir(DIR* dir);
#endif
#include "../../compat/KeyCodes.hpp"
#include "StandardOut.hpp"
#include "Logger.hpp"
// options:
#include "../../GameMods.hpp"