summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-01-31 01:04:57 +0100
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-01-31 01:04:57 +0100
commitd8aa0b0ec7a2ebea2fc157c623ae8cd7d0b6ba1c (patch)
tree85a995786a5f01ea108e9cd292173d282f8853d0 /src
parentAdded LOGREPLACELINE for line replacement (diff)
downloadcuberite-d8aa0b0ec7a2ebea2fc157c623ae8cd7d0b6ba1c.tar
cuberite-d8aa0b0ec7a2ebea2fc157c623ae8cd7d0b6ba1c.tar.gz
cuberite-d8aa0b0ec7a2ebea2fc157c623ae8cd7d0b6ba1c.tar.bz2
cuberite-d8aa0b0ec7a2ebea2fc157c623ae8cd7d0b6ba1c.tar.lz
cuberite-d8aa0b0ec7a2ebea2fc157c623ae8cd7d0b6ba1c.tar.xz
cuberite-d8aa0b0ec7a2ebea2fc157c623ae8cd7d0b6ba1c.tar.zst
cuberite-d8aa0b0ec7a2ebea2fc157c623ae8cd7d0b6ba1c.zip
Diffstat (limited to 'src')
-rw-r--r--src/Log.cpp14
-rw-r--r--src/MCLogger.cpp12
-rw-r--r--src/MCLogger.h4
-rw-r--r--src/World.cpp2
4 files changed, 19 insertions, 13 deletions
diff --git a/src/Log.cpp b/src/Log.cpp
index a23a79ccc..37f1376db 100644
--- a/src/Log.cpp
+++ b/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)
diff --git a/src/MCLogger.cpp b/src/MCLogger.cpp
index 632ea2efe..aebe3e1c9 100644
--- a/src/MCLogger.cpp
+++ b/src/MCLogger.cpp
@@ -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)
diff --git a/src/MCLogger.h b/src/MCLogger.h
index 7bcc195dd..c105ab6e2 100644
--- a/src/MCLogger.h
+++ b/src/MCLogger.h
@@ -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
diff --git a/src/World.cpp b/src/World.cpp
index bac529d4a..f2981bf84 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -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;
}
}