1
0

Merge pull request #2433 from cuberite/WarningFixTrial

Some warning fixes
This commit is contained in:
Mattes D 2015-08-18 08:49:39 +02:00
commit 5ea1b9cee1
9 changed files with 70 additions and 39 deletions

View File

@ -19,7 +19,9 @@
#ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockLightValue #ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockLightValue
static int tolua_get_AllToLua_g_BlockLightValue(lua_State* tolua_S) static int tolua_get_AllToLua_g_BlockLightValue(lua_State* tolua_S)
{ {
BLOCKTYPE BlockType; cLuaState LuaState(tolua_S);
int BlockType = 0;
#ifndef TOLUA_RELEASE #ifndef TOLUA_RELEASE
{ {
tolua_Error tolua_err; tolua_Error tolua_err;
@ -29,12 +31,12 @@ static int tolua_get_AllToLua_g_BlockLightValue(lua_State* tolua_S)
} }
} }
#endif #endif
BlockType = static_cast<BLOCKTYPE>(tolua_tonumber(tolua_S, 2, 0)); LuaState.GetStackValue(2, BlockType);
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID)) if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
{ {
tolua_error(tolua_S, "array indexing out of range.", nullptr); tolua_error(tolua_S, "array indexing out of range.", nullptr);
} }
tolua_pushnumber(tolua_S, static_cast<lua_Number>(cBlockInfo::GetLightValue(BlockType))); LuaState.Push(cBlockInfo::GetLightValue(static_cast<BLOCKTYPE>(BlockType)));
return 1; return 1;
} }
#endif // #ifndef TOLUA_DISABLE #endif // #ifndef TOLUA_DISABLE
@ -47,7 +49,9 @@ static int tolua_get_AllToLua_g_BlockLightValue(lua_State* tolua_S)
#ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockSpreadLightFalloff #ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockSpreadLightFalloff
static int tolua_get_AllToLua_g_BlockSpreadLightFalloff(lua_State* tolua_S) static int tolua_get_AllToLua_g_BlockSpreadLightFalloff(lua_State* tolua_S)
{ {
BLOCKTYPE BlockType; cLuaState LuaState(tolua_S);
int BlockType = 0;
#ifndef TOLUA_RELEASE #ifndef TOLUA_RELEASE
{ {
tolua_Error tolua_err; tolua_Error tolua_err;
@ -57,12 +61,12 @@ static int tolua_get_AllToLua_g_BlockSpreadLightFalloff(lua_State* tolua_S)
} }
} }
#endif #endif
BlockType = static_cast<BLOCKTYPE>(tolua_tonumber(tolua_S, 2, 0)); LuaState.GetStackValue(2, BlockType);
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID)) if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
{ {
tolua_error(tolua_S, "array indexing out of range.", nullptr); tolua_error(tolua_S, "array indexing out of range.", nullptr);
} }
tolua_pushnumber(tolua_S, static_cast<lua_Number>(cBlockInfo::GetSpreadLightFalloff(BlockType))); LuaState.Push(cBlockInfo::GetSpreadLightFalloff(static_cast<BLOCKTYPE>(BlockType)));
return 1; return 1;
} }
#endif // #ifndef TOLUA_DISABLE #endif // #ifndef TOLUA_DISABLE
@ -75,7 +79,9 @@ static int tolua_get_AllToLua_g_BlockSpreadLightFalloff(lua_State* tolua_S)
#ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockTransparent #ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockTransparent
static int tolua_get_AllToLua_g_BlockTransparent(lua_State* tolua_S) static int tolua_get_AllToLua_g_BlockTransparent(lua_State* tolua_S)
{ {
BLOCKTYPE BlockType; cLuaState LuaState(tolua_S);
int BlockType = 0;
#ifndef TOLUA_RELEASE #ifndef TOLUA_RELEASE
{ {
tolua_Error tolua_err; tolua_Error tolua_err;
@ -85,12 +91,12 @@ static int tolua_get_AllToLua_g_BlockTransparent(lua_State* tolua_S)
} }
} }
#endif #endif
BlockType = static_cast<BLOCKTYPE>(tolua_tonumber(tolua_S, 2, 0)); LuaState.GetStackValue(2, BlockType);
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID)) if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
{ {
tolua_error(tolua_S, "array indexing out of range.", nullptr); tolua_error(tolua_S, "array indexing out of range.", nullptr);
} }
tolua_pushboolean(tolua_S, cBlockInfo::IsTransparent(BlockType)); LuaState.Push(cBlockInfo::IsTransparent(static_cast<BLOCKTYPE>(BlockType)));
return 1; return 1;
} }
#endif // #ifndef TOLUA_DISABLE #endif // #ifndef TOLUA_DISABLE
@ -103,7 +109,9 @@ static int tolua_get_AllToLua_g_BlockTransparent(lua_State* tolua_S)
#ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockOneHitDig #ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockOneHitDig
static int tolua_get_AllToLua_g_BlockOneHitDig(lua_State* tolua_S) static int tolua_get_AllToLua_g_BlockOneHitDig(lua_State* tolua_S)
{ {
BLOCKTYPE BlockType; cLuaState LuaState(tolua_S);
int BlockType = 0;
#ifndef TOLUA_RELEASE #ifndef TOLUA_RELEASE
{ {
tolua_Error tolua_err; tolua_Error tolua_err;
@ -113,12 +121,12 @@ static int tolua_get_AllToLua_g_BlockOneHitDig(lua_State* tolua_S)
} }
} }
#endif #endif
BlockType = static_cast<BLOCKTYPE>(tolua_tonumber(tolua_S, 2, 0)); LuaState.GetStackValue(2, BlockType);
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID)) if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
{ {
tolua_error(tolua_S, "array indexing out of range.", nullptr); tolua_error(tolua_S, "array indexing out of range.", nullptr);
} }
tolua_pushboolean(tolua_S, cBlockInfo::IsOneHitDig(BlockType)); LuaState.Push(cBlockInfo::IsOneHitDig(static_cast<BLOCKTYPE>(BlockType)));
return 1; return 1;
} }
#endif // #ifndef TOLUA_DISABLE #endif // #ifndef TOLUA_DISABLE
@ -131,7 +139,9 @@ static int tolua_get_AllToLua_g_BlockOneHitDig(lua_State* tolua_S)
#ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockPistonBreakable #ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockPistonBreakable
static int tolua_get_AllToLua_g_BlockPistonBreakable(lua_State* tolua_S) static int tolua_get_AllToLua_g_BlockPistonBreakable(lua_State* tolua_S)
{ {
BLOCKTYPE BlockType; cLuaState LuaState(tolua_S);
int BlockType = 0;
#ifndef TOLUA_RELEASE #ifndef TOLUA_RELEASE
{ {
tolua_Error tolua_err; tolua_Error tolua_err;
@ -141,12 +151,12 @@ static int tolua_get_AllToLua_g_BlockPistonBreakable(lua_State* tolua_S)
} }
} }
#endif #endif
BlockType = static_cast<BLOCKTYPE>(tolua_tonumber(tolua_S, 2, 0)); LuaState.GetStackValue(2, BlockType);
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID)) if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
{ {
tolua_error(tolua_S, "array indexing out of range.", nullptr); tolua_error(tolua_S, "array indexing out of range.", nullptr);
} }
tolua_pushboolean(tolua_S, cBlockInfo::IsPistonBreakable(BlockType)); LuaState.Push(cBlockInfo::IsPistonBreakable(static_cast<BLOCKTYPE>(BlockType)));
return 1; return 1;
} }
#endif // #ifndef TOLUA_DISABLE #endif // #ifndef TOLUA_DISABLE
@ -159,7 +169,9 @@ static int tolua_get_AllToLua_g_BlockPistonBreakable(lua_State* tolua_S)
#ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockIsSnowable #ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockIsSnowable
static int tolua_get_AllToLua_g_BlockIsSnowable(lua_State* tolua_S) static int tolua_get_AllToLua_g_BlockIsSnowable(lua_State* tolua_S)
{ {
BLOCKTYPE BlockType; cLuaState LuaState(tolua_S);
int BlockType = 0;
#ifndef TOLUA_RELEASE #ifndef TOLUA_RELEASE
{ {
tolua_Error tolua_err; tolua_Error tolua_err;
@ -169,12 +181,12 @@ static int tolua_get_AllToLua_g_BlockIsSnowable(lua_State* tolua_S)
} }
} }
#endif #endif
BlockType = static_cast<BLOCKTYPE>(tolua_tonumber(tolua_S, 2, 0)); LuaState.GetStackValue(2, BlockType);
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID)) if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
{ {
tolua_error(tolua_S, "array indexing out of range.", nullptr); tolua_error(tolua_S, "array indexing out of range.", nullptr);
} }
tolua_pushboolean(tolua_S, cBlockInfo::IsSnowable(BlockType)); LuaState.Push(cBlockInfo::IsSnowable(static_cast<BLOCKTYPE>(BlockType)));
return 1; return 1;
} }
#endif // #ifndef TOLUA_DISABLE #endif // #ifndef TOLUA_DISABLE
@ -187,7 +199,9 @@ static int tolua_get_AllToLua_g_BlockIsSnowable(lua_State* tolua_S)
#ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockIsSolid #ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockIsSolid
static int tolua_get_AllToLua_g_BlockIsSolid(lua_State* tolua_S) static int tolua_get_AllToLua_g_BlockIsSolid(lua_State* tolua_S)
{ {
BLOCKTYPE BlockType; cLuaState LuaState(tolua_S);
int BlockType = 0;
#ifndef TOLUA_RELEASE #ifndef TOLUA_RELEASE
{ {
tolua_Error tolua_err; tolua_Error tolua_err;
@ -197,12 +211,12 @@ static int tolua_get_AllToLua_g_BlockIsSolid(lua_State* tolua_S)
} }
} }
#endif #endif
BlockType = static_cast<BLOCKTYPE>(tolua_tonumber(tolua_S, 2, 0)); LuaState.GetStackValue(2, BlockType);
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID)) if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
{ {
tolua_error(tolua_S, "array indexing out of range.", nullptr); tolua_error(tolua_S, "array indexing out of range.", nullptr);
} }
tolua_pushboolean(tolua_S, static_cast<bool>(cBlockInfo::IsSolid(BlockType))); LuaState.Push(cBlockInfo::IsSolid(static_cast<BLOCKTYPE>(BlockType)));
return 1; return 1;
} }
#endif // #ifndef TOLUA_DISABLE #endif // #ifndef TOLUA_DISABLE
@ -215,7 +229,9 @@ static int tolua_get_AllToLua_g_BlockIsSolid(lua_State* tolua_S)
#ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockFullyOccupiesVoxel #ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockFullyOccupiesVoxel
static int tolua_get_AllToLua_g_BlockFullyOccupiesVoxel(lua_State* tolua_S) static int tolua_get_AllToLua_g_BlockFullyOccupiesVoxel(lua_State* tolua_S)
{ {
BLOCKTYPE BlockType; cLuaState LuaState(tolua_S);
int BlockType = 0;
#ifndef TOLUA_RELEASE #ifndef TOLUA_RELEASE
{ {
tolua_Error tolua_err; tolua_Error tolua_err;
@ -225,12 +241,12 @@ static int tolua_get_AllToLua_g_BlockFullyOccupiesVoxel(lua_State* tolua_S)
} }
} }
#endif #endif
BlockType = static_cast<BLOCKTYPE>(tolua_tonumber(tolua_S, 2, 0)); LuaState.GetStackValue(2, BlockType);
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID)) if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
{ {
tolua_error(tolua_S, "array indexing out of range.", nullptr); tolua_error(tolua_S, "array indexing out of range.", nullptr);
} }
tolua_pushboolean(tolua_S, static_cast<bool>(cBlockInfo::FullyOccupiesVoxel(BlockType))); LuaState.Push(cBlockInfo::FullyOccupiesVoxel(static_cast<BLOCKTYPE>(BlockType)));
return 1; return 1;
} }
#endif // #ifndef TOLUA_DISABLE #endif // #ifndef TOLUA_DISABLE

View File

@ -159,7 +159,7 @@ static int tolua_UncompressStringZLIB(lua_State * tolua_S)
// Get the params: // Get the params:
AString ToUncompress; AString ToUncompress;
size_t UncompressedSize; size_t UncompressedSize = 0;
S.GetStackValues(1, ToUncompress, UncompressedSize); S.GetStackValues(1, ToUncompress, UncompressedSize);
// Compress the string: // Compress the string:

View File

@ -263,7 +263,9 @@ public:
// Get parameters: // Get parameters:
Ty1 * Self = nullptr; Ty1 * Self = nullptr;
int BlockX, BlockY, BlockZ; int BlockX = 0;
int BlockY = 0;
int BlockZ = 0;
cLuaState::cRef FnRef; cLuaState::cRef FnRef;
L.GetStackValues(1, Self, BlockX, BlockY, BlockZ, FnRef); L.GetStackValues(1, Self, BlockX, BlockY, BlockZ, FnRef);
if (Self == nullptr) if (Self == nullptr)
@ -327,7 +329,8 @@ public:
// Get parameters: // Get parameters:
Ty1 * Self = nullptr; Ty1 * Self = nullptr;
int ChunkX, ChunkZ; int ChunkX = 0;
int ChunkZ = 0;
cLuaState::cRef FnRef; cLuaState::cRef FnRef;
L.GetStackValues(1, Self, ChunkX, ChunkZ, FnRef); L.GetStackValues(1, Self, ChunkX, ChunkZ, FnRef);
if (Self == nullptr) if (Self == nullptr)

View File

@ -49,7 +49,7 @@ static int tolua_cNetwork_Connect(lua_State * L)
// Read the params: // Read the params:
AString Host; AString Host;
int Port; int Port = 0;
S.GetStackValues(2, Host, Port); S.GetStackValues(2, Host, Port);
// Check validity: // Check validity:
@ -888,7 +888,7 @@ static int tolua_cUDPEndpoint_Send(lua_State * L)
// Get the data to send: // Get the data to send:
AString Data, RemotePeer; AString Data, RemotePeer;
int RemotePort; int RemotePort = 0;
S.GetStackValues(2, Data, RemotePeer, RemotePort); S.GetStackValues(2, Data, RemotePeer, RemotePort);
// Check the port: // Check the port:

View File

@ -129,7 +129,9 @@ static int tolua_cWorld_GetBlockInfo(lua_State * tolua_S)
// Get params: // Get params:
cWorld * Self = nullptr; cWorld * Self = nullptr;
int BlockX, BlockY, BlockZ; int BlockX = 0;
int BlockY = 0;
int BlockZ = 0;
L.GetStackValues(1, Self, BlockX, BlockY, BlockZ); L.GetStackValues(1, Self, BlockX, BlockY, BlockZ);
if (Self == nullptr) if (Self == nullptr)
{ {
@ -176,7 +178,9 @@ static int tolua_cWorld_GetBlockTypeMeta(lua_State * tolua_S)
// Get params: // Get params:
cWorld * Self = nullptr; cWorld * Self = nullptr;
int BlockX, BlockY, BlockZ; int BlockX = 0;
int BlockY = 0;
int BlockZ = 0;
L.GetStackValues(1, Self, BlockX, BlockY, BlockZ); L.GetStackValues(1, Self, BlockX, BlockY, BlockZ);
if (Self == nullptr) if (Self == nullptr)
{ {
@ -220,7 +224,9 @@ static int tolua_cWorld_GetSignLines(lua_State * tolua_S)
// Get params: // Get params:
cWorld * Self = nullptr; cWorld * Self = nullptr;
int BlockX, BlockY, BlockZ; int BlockX = 0;
int BlockY = 0;
int BlockZ = 0;
L.GetStackValues(1, Self, BlockX, BlockY, BlockZ); L.GetStackValues(1, Self, BlockX, BlockY, BlockZ);
if (Self == nullptr) if (Self == nullptr)
{ {
@ -267,7 +273,8 @@ static int tolua_cWorld_PrepareChunk(lua_State * tolua_S)
// Read the params: // Read the params:
cWorld * world = nullptr; cWorld * world = nullptr;
int chunkX = 0, chunkZ = 0; int chunkX = 0;
int chunkZ = 0;
L.GetStackValues(1, world, chunkX, chunkZ); L.GetStackValues(1, world, chunkX, chunkZ);
if (world == nullptr) if (world == nullptr)
{ {
@ -401,7 +408,9 @@ static int tolua_cWorld_SetSignLines(lua_State * tolua_S)
// Get params: // Get params:
cWorld * Self = nullptr; cWorld * Self = nullptr;
int BlockX, BlockY, BlockZ; int BlockX = 0;
int BlockY = 0;
int BlockZ = 0;
AString Line1, Line2, Line3, Line4; AString Line1, Line2, Line3, Line4;
L.GetStackValues(1, Self, BlockX, BlockY, BlockZ, Line1, Line2, Line3, Line4); L.GetStackValues(1, Self, BlockX, BlockY, BlockZ, Line1, Line2, Line3, Line4);
if (Self == nullptr) if (Self == nullptr)
@ -518,7 +527,8 @@ static int tolua_cWorld_TryGetHeight(lua_State * tolua_S)
// Get params: // Get params:
cWorld * self = nullptr; cWorld * self = nullptr;
int BlockX, BlockZ; int BlockX = 0;
int BlockZ = 0;
L.GetStackValues(1, self, BlockX, BlockZ); L.GetStackValues(1, self, BlockX, BlockZ);
if (self == nullptr) if (self == nullptr)
{ {

View File

@ -45,7 +45,7 @@ public:
} }
// Farmland too dry. If nothing is growing on top, turn back to dirt: // Farmland too dry. If nothing is growing on top, turn back to dirt:
BLOCKTYPE UpperBlock = (a_RelY >= cChunkDef::Height - 1) ? E_BLOCK_AIR : a_Chunk.GetBlock(a_RelX, a_RelY + 1, a_RelZ); BLOCKTYPE UpperBlock = (a_RelY >= cChunkDef::Height - 1) ? static_cast<BLOCKTYPE>(E_BLOCK_AIR) : a_Chunk.GetBlock(a_RelX, a_RelY + 1, a_RelZ);
switch (UpperBlock) switch (UpperBlock)
{ {
case E_BLOCK_CROPS: case E_BLOCK_CROPS:

View File

@ -38,7 +38,7 @@ cChunkMap::cChunkMap(cWorld * a_World) :
m_World(a_World), m_World(a_World),
m_Pool( m_Pool(
new cListAllocationPool<cChunkData::sChunkSection, 1600>( new cListAllocationPool<cChunkData::sChunkSection, 1600>(
std::auto_ptr<cAllocationPool<cChunkData::sChunkSection>::cStarvationCallbacks>( std::unique_ptr<cAllocationPool<cChunkData::sChunkSection>::cStarvationCallbacks>(
new cStarvationCallbacks() new cStarvationCallbacks()
) )
) )

View File

@ -508,7 +508,7 @@ private:
/** The cChunkStay descendants that are currently enabled in this chunkmap */ /** The cChunkStay descendants that are currently enabled in this chunkmap */
cChunkStays m_ChunkStays; cChunkStays m_ChunkStays;
std::auto_ptr<cAllocationPool<cChunkData::sChunkSection> > m_Pool; std::unique_ptr<cAllocationPool<cChunkData::sChunkSection> > m_Pool;
cChunkPtr GetChunk (int a_ChunkX, int a_ChunkZ); // Also queues the chunk for loading / generating if not valid cChunkPtr GetChunk (int a_ChunkX, int a_ChunkZ); // Also queues the chunk for loading / generating if not valid
cChunkPtr GetChunkNoGen (int a_ChunkX, int a_ChunkZ); // Also queues the chunk for loading if not valid; doesn't generate cChunkPtr GetChunkNoGen (int a_ChunkX, int a_ChunkZ); // Also queues the chunk for loading if not valid; doesn't generate

View File

@ -123,7 +123,7 @@ bool cServerHandleImpl::Listen(UInt16 a_Port)
// Set up the main socket: // Set up the main socket:
// It should listen on IPv6 with IPv4 fallback, when available; IPv4 when IPv6 is not available. // It should listen on IPv6 with IPv4 fallback, when available; IPv4 when IPv6 is not available.
bool NeedsTwoSockets = false; bool NeedsTwoSockets = false;
int err; int err = 0;
evutil_socket_t MainSock = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP); evutil_socket_t MainSock = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP);
if (!IsValidSocket(MainSock)) if (!IsValidSocket(MainSock))
@ -271,6 +271,8 @@ bool cServerHandleImpl::Listen(UInt16 a_Port)
return true; // Report as success, the primary socket is working return true; // Report as success, the primary socket is working
} }
UNUSED(err);
m_SecondaryConnListener = evconnlistener_new(cNetworkSingleton::Get().GetEventBase(), Callback, this, LEV_OPT_CLOSE_ON_FREE | LEV_OPT_REUSEABLE, 0, SecondSock); m_SecondaryConnListener = evconnlistener_new(cNetworkSingleton::Get().GetEventBase(), Callback, this, LEV_OPT_CLOSE_ON_FREE | LEV_OPT_REUSEABLE, 0, SecondSock);
return true; return true;
} }