Improved code
* Fixed some issues * Fixed standard violation
This commit is contained in:
parent
7d03876a3e
commit
d8aa0b0ec7
14
src/Log.cpp
14
src/Log.cpp
@ -134,14 +134,15 @@ void cLog::Log(const char * a_Format, va_list argList, bool a_ReplaceCurrentLine
|
||||
__android_log_print(ANDROID_LOG_ERROR, "MCServer", "%s", Line.c_str() );
|
||||
//CallJavaFunction_Void_String(g_JavaThread, "AddToLog", Line );
|
||||
#else
|
||||
size_t LineLength = Line.length();
|
||||
|
||||
if (m_LastStringSize == 0)
|
||||
m_LastStringSize = LineLength;
|
||||
|
||||
if (a_ReplaceCurrentLine)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (m_LastStringSize == 0)
|
||||
{
|
||||
m_LastStringSize = Line.length();
|
||||
}
|
||||
else if (Line.length() < m_LastStringSize) // If last printed line was longer than current, clear this line
|
||||
if (LineLength < m_LastStringSize) // If last printed line was longer than current, clear this line
|
||||
{
|
||||
for (size_t X = 0; X != m_LastStringSize; ++X)
|
||||
{
|
||||
@ -162,6 +163,9 @@ void cLog::Log(const char * a_Format, va_list argList, bool a_ReplaceCurrentLine
|
||||
{
|
||||
printf("%s", Line.c_str());
|
||||
}
|
||||
|
||||
m_LastStringSize = LineLength;
|
||||
|
||||
#endif
|
||||
|
||||
#if defined (_WIN32) && defined(_DEBUG)
|
||||
|
@ -11,6 +11,10 @@
|
||||
cMCLogger * cMCLogger::s_MCLogger = NULL;
|
||||
bool g_ShouldColorOutput = false;
|
||||
|
||||
/** Flag to show whether a 'replace line' log command has been issued
|
||||
Used to decide when to put a newline */
|
||||
bool g_BeginLineUpdate = false;
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <io.h> // Needed for _isatty(), not available on Linux
|
||||
|
||||
@ -123,14 +127,14 @@ void cMCLogger::Log(const char * a_Format, va_list a_ArgList, bool a_ShouldRepla
|
||||
{
|
||||
cCSLock Lock(m_CriticalSection);
|
||||
|
||||
if (!m_BeginLineUpdate && a_ShouldReplaceLine)
|
||||
if (!g_BeginLineUpdate && a_ShouldReplaceLine)
|
||||
{
|
||||
a_ShouldReplaceLine = false; // Print a normal line first if this is the initial replace line
|
||||
m_BeginLineUpdate = true;
|
||||
g_BeginLineUpdate = true;
|
||||
}
|
||||
else if (m_BeginLineUpdate && !a_ShouldReplaceLine)
|
||||
else if (g_BeginLineUpdate && !a_ShouldReplaceLine)
|
||||
{
|
||||
m_BeginLineUpdate = false;
|
||||
g_BeginLineUpdate = false;
|
||||
}
|
||||
|
||||
if (a_ShouldReplaceLine)
|
||||
|
@ -51,10 +51,6 @@ private:
|
||||
|
||||
/// Common initialization for all constructors, creates a logfile with the specified name and assigns s_MCLogger to this
|
||||
void InitLog(const AString & a_FileName);
|
||||
|
||||
/** Flag to show whether a 'replace line' log command has been issued
|
||||
Used to decide when to put a newline */
|
||||
bool m_BeginLineUpdate = false;
|
||||
}; // tolua_export
|
||||
|
||||
|
||||
|
@ -111,6 +111,7 @@ protected:
|
||||
cSleep::MilliSleep(100);
|
||||
if (m_ShouldTerminate)
|
||||
{
|
||||
LOGREPLACELINE("World successfully loaded!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -161,6 +162,7 @@ protected:
|
||||
cSleep::MilliSleep(100);
|
||||
if (m_ShouldTerminate)
|
||||
{
|
||||
LOGREPLACELINE("Lighting successful!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user