summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Bindings/LuaState.cpp7
-rw-r--r--src/Bindings/ManualBindings.cpp9
-rw-r--r--src/Items/ItemEmptyMap.h6
-rw-r--r--src/Log.cpp4
-rw-r--r--src/Map.cpp2
-rw-r--r--src/MersenneTwister.h2
-rw-r--r--src/WorldStorage/FastNBT.h13
-rw-r--r--src/main.cpp27
8 files changed, 49 insertions, 21 deletions
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp
index ca7f6b255..45a066efe 100644
--- a/src/Bindings/LuaState.cpp
+++ b/src/Bindings/LuaState.cpp
@@ -677,6 +677,11 @@ void cLuaState::Push(void * a_Ptr)
{
ASSERT(IsValid());
+ // Investigate the cause of this - what is the callstack?
+ LOGWARNING("Lua engine encountered an error - attempting to push a plain pointer");
+ LogStackTrace();
+ ASSERT(!"A plain pointer should never be pushed on Lua stack");
+
lua_pushnil(m_LuaState);
m_NumCurrentFunctionArgs += 1;
}
@@ -1265,6 +1270,8 @@ void cLuaState::LogStack(const char * a_Header)
void cLuaState::LogStack(lua_State * a_LuaState, const char * a_Header)
{
+ UNUSED(a_Header); // The param seems unused when compiling for release, so the compiler warns
+
LOGD((a_Header != NULL) ? a_Header : "Lua C API Stack contents:");
for (int i = lua_gettop(a_LuaState); i > 0; i--)
{
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp
index 2f3f3ee91..461186d3b 100644
--- a/src/Bindings/ManualBindings.cpp
+++ b/src/Bindings/ManualBindings.cpp
@@ -1321,7 +1321,9 @@ static int tolua_cPluginManager_ForEachCommand(lua_State * tolua_S)
private:
virtual bool Command(const AString & a_Command, const cPlugin * a_Plugin, const AString & a_Permission, const AString & a_HelpString) override
{
- lua_rawgeti( LuaState, LUA_REGISTRYINDEX, FuncRef); /* Push function reference */
+ UNUSED(a_Plugin);
+
+ lua_rawgeti(LuaState, LUA_REGISTRYINDEX, FuncRef); /* Push function reference */
tolua_pushcppstring(LuaState, a_Command);
tolua_pushcppstring(LuaState, a_Permission);
tolua_pushcppstring(LuaState, a_HelpString);
@@ -1396,7 +1398,10 @@ static int tolua_cPluginManager_ForEachConsoleCommand(lua_State * tolua_S)
private:
virtual bool Command(const AString & a_Command, const cPlugin * a_Plugin, const AString & a_Permission, const AString & a_HelpString) override
{
- lua_rawgeti( LuaState, LUA_REGISTRYINDEX, FuncRef); /* Push function reference */
+ UNUSED(a_Plugin);
+ UNUSED(a_Permission);
+
+ lua_rawgeti(LuaState, LUA_REGISTRYINDEX, FuncRef); /* Push function reference */
tolua_pushcppstring(LuaState, a_Command);
tolua_pushcppstring(LuaState, a_HelpString);
diff --git a/src/Items/ItemEmptyMap.h b/src/Items/ItemEmptyMap.h
index 6618bfce2..f0b1e1424 100644
--- a/src/Items/ItemEmptyMap.h
+++ b/src/Items/ItemEmptyMap.h
@@ -36,10 +36,10 @@ public:
// The map center is fixed at the central point of the 8x8 block of chunks you are standing in when you right-click it.
- const int RegionWidth = cChunkDef::Width * 8 * pow(2.0, (double) DEFAULT_SCALE);
+ const int RegionWidth = cChunkDef::Width * 8;
- int CenterX = floor(a_Player->GetPosX() / (float) RegionWidth) * RegionWidth;
- int CenterZ = floor(a_Player->GetPosZ() / (float) RegionWidth) * RegionWidth;
+ int CenterX = (int)(floor(a_Player->GetPosX() / (float) RegionWidth) * RegionWidth);
+ int CenterZ = (int)(floor(a_Player->GetPosZ() / (float) RegionWidth) * RegionWidth);
cMap * NewMap = a_World->GetMapManager().CreateMap(CenterX, CenterZ, DEFAULT_SCALE);
diff --git a/src/Log.cpp b/src/Log.cpp
index 2d6be0f59..1ea327d5d 100644
--- a/src/Log.cpp
+++ b/src/Log.cpp
@@ -42,7 +42,7 @@ cLog::~cLog()
-cLog* cLog::GetInstance()
+cLog * cLog::GetInstance()
{
if (s_Log != NULL)
{
@@ -92,7 +92,7 @@ void cLog::ClearLog()
if( m_File )
fclose (m_File);
#endif
- m_File = 0;
+ m_File = NULL;
}
diff --git a/src/Map.cpp b/src/Map.cpp
index 337c9cd31..2d8f57168 100644
--- a/src/Map.cpp
+++ b/src/Map.cpp
@@ -357,6 +357,8 @@ void cMap::AddPlayer(cPlayer * a_Player, Int64 a_WorldAge)
MapClient.m_LastUpdate = a_WorldAge;
MapClient.m_SendInfo = true;
MapClient.m_Handle = Handle;
+ MapClient.m_DataUpdate = 0;
+ MapClient.m_NextDecoratorUpdate = 0;
m_Clients.push_back(MapClient);
diff --git a/src/MersenneTwister.h b/src/MersenneTwister.h
index 784ac605d..f4c7b0699 100644
--- a/src/MersenneTwister.h
+++ b/src/MersenneTwister.h
@@ -207,7 +207,7 @@ inline void MTRand::seed( uint32 *const bigSeed, const uint32 seedLength )
initialize(19650218UL);
int i = 1;
uint32 j = 0;
- int k = ( N > seedLength ? N : seedLength );
+ int k = ( (uint32)N > seedLength ? (uint32)N : seedLength );
for( ; k; --k )
{
state[i] =
diff --git a/src/WorldStorage/FastNBT.h b/src/WorldStorage/FastNBT.h
index b84eda1a1..a78b610cb 100644
--- a/src/WorldStorage/FastNBT.h
+++ b/src/WorldStorage/FastNBT.h
@@ -172,8 +172,17 @@ public:
inline float GetFloat(int a_Tag) const
{
ASSERT(m_Tags[a_Tag].m_Type == TAG_Float);
- Int32 tmp = GetBEInt(m_Data + m_Tags[a_Tag].m_DataStart);
- return *((float *)&tmp);
+
+ // Cause a compile-time error if sizeof(int) != sizeof(float)
+ char Check1[sizeof(int) - sizeof(float) + 1]; // sizeof(int) >= sizeof(float)
+ char Check2[sizeof(float) - sizeof(int) + 1]; // sizeof(float) >= sizeof(int)
+ UNUSED(Check1);
+ UNUSED(Check2);
+
+ int i = GetBEInt(m_Data + m_Tags[a_Tag].m_DataStart);
+ float f;
+ memcpy(&f, &i, sizeof(f));
+ return f;
}
inline double GetDouble(int a_Tag) const
diff --git a/src/main.cpp b/src/main.cpp
index 4d2801926..2ae8a413b 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -243,31 +243,36 @@ int main( int argc, char **argv )
// Check if comm logging is to be enabled:
for (int i = 0; i < argc; i++)
{
+ AString Arg(argv[i]);
if (
- (NoCaseCompare(argv[i], "/commlog") == 0) ||
- (NoCaseCompare(argv[i], "/logcomm") == 0)
+ (NoCaseCompare(Arg, "/commlog") == 0) ||
+ (NoCaseCompare(Arg, "/logcomm") == 0)
)
{
g_ShouldLogCommIn = true;
g_ShouldLogCommOut = true;
}
- if (
- (NoCaseCompare(argv[i], "/commlogin") == 0) ||
- (NoCaseCompare(argv[i], "/comminlog") == 0) ||
- (NoCaseCompare(argv[i], "/logcommin") == 0)
+ else if (
+ (NoCaseCompare(Arg, "/commlogin") == 0) ||
+ (NoCaseCompare(Arg, "/comminlog") == 0) ||
+ (NoCaseCompare(Arg, "/logcommin") == 0)
)
{
g_ShouldLogCommIn = true;
}
- if (
- (NoCaseCompare(argv[i], "/commlogout") == 0) ||
- (NoCaseCompare(argv[i], "/commoutlog") == 0) ||
- (NoCaseCompare(argv[i], "/logcommout") == 0)
+ else if (
+ (NoCaseCompare(Arg, "/commlogout") == 0) ||
+ (NoCaseCompare(Arg, "/commoutlog") == 0) ||
+ (NoCaseCompare(Arg, "/logcommout") == 0)
)
{
g_ShouldLogCommOut = true;
}
- }
+ else if (NoCaseCompare(Arg, "nooutbuf") == 0)
+ {
+ setvbuf(stdout, NULL, _IONBF, 0);
+ }
+ } // for i - argv[]
#if !defined(ANDROID_NDK)
try