Merge pull request #345 from mc-server/warningfixes
Fix Some Compiler Warnings
This commit is contained in:
commit
5277360098
18
GNUmakefile
18
GNUmakefile
@ -46,8 +46,9 @@ ifeq ($(release),1)
|
||||
################
|
||||
# release build - fastest run-time, no gdb support
|
||||
################
|
||||
CC_OPTIONS = -s -g -O3 -DNDEBUG
|
||||
CXX_OPTIONS = -s -g -O3 -DNDEBUG
|
||||
|
||||
CC_OPTIONS = -g -O3 -DNDEBUG
|
||||
CXX_OPTIONS = -g -O3 -DNDEBUG
|
||||
LNK_OPTIONS = -pthread -O3
|
||||
BUILDDIR = build/release/
|
||||
|
||||
@ -56,6 +57,7 @@ ifeq ($(profile),1)
|
||||
################
|
||||
# profile build - a release build with symbols and profiling engine built in
|
||||
################
|
||||
|
||||
CC_OPTIONS = -s -g -ggdb -O3 -pg -DNDEBUG
|
||||
CXX_OPTIONS = -s -g -ggdb -O3 -pg -DNDEBUG
|
||||
LNK_OPTIONS = -pthread -ggdb -O3 -pg
|
||||
@ -66,6 +68,7 @@ ifeq ($(pedantic),1)
|
||||
################
|
||||
# pedantic build - basically a debug build with lots of warnings
|
||||
################
|
||||
|
||||
CC_OPTIONS = -s -g -ggdb -D_DEBUG -Wall -Wextra -pedantic -ansi -Wno-long-long
|
||||
CXX_OPTIONS = -s -g -ggdb -D_DEBUG -Wall -Wextra -pedantic -ansi -Wno-long-long
|
||||
LNK_OPTIONS = -pthread -ggdb
|
||||
@ -76,6 +79,7 @@ else
|
||||
# debug build - fully traceable by gdb in C++ code, slowest
|
||||
# Since C code is used only for supporting libraries (zlib, lua), it is still O3-optimized
|
||||
################
|
||||
|
||||
CC_OPTIONS = -s -ggdb -g -D_DEBUG -O3
|
||||
CXX_OPTIONS = -s -ggdb -g -D_DEBUG
|
||||
LNK_OPTIONS = -pthread -g -ggdb
|
||||
@ -84,6 +88,10 @@ endif
|
||||
endif
|
||||
endif
|
||||
|
||||
##################################################
|
||||
# Always be warning.
|
||||
|
||||
CXX_OPTIONS += -Wall
|
||||
|
||||
###################################################
|
||||
# Fix Crypto++ warnings in clang
|
||||
@ -103,7 +111,7 @@ endif
|
||||
|
||||
UNAME := $(shell uname -s)
|
||||
ifeq ($(UNAME),Linux)
|
||||
LNK_LIBS = -lstdc++ -ldl
|
||||
LNK_LIBS = -lstdc++ -ldl -lm
|
||||
else
|
||||
LNK_LIBS = -lstdc++ -lltdl
|
||||
endif
|
||||
@ -140,7 +148,6 @@ endif
|
||||
|
||||
###################################################
|
||||
# INCLUDE directories for MCServer
|
||||
#
|
||||
|
||||
INCLUDE = -I.\
|
||||
-Isource\
|
||||
@ -162,9 +169,6 @@ INCLUDE = -I.\
|
||||
|
||||
###################################################
|
||||
# Build MCServer
|
||||
#
|
||||
|
||||
# 2012_11_08 _X: Removed: squirrel_3_0_1_stable
|
||||
|
||||
SOURCES := $(shell find CryptoPP lua-5.1.4 jsoncpp-src-0.5.0 zlib-1.2.7 source tolua++-1.0.93 iniFile expat '(' -name '*.cpp' -o -name '*.c' ')')
|
||||
SOURCES := $(filter-out %minigzip.c %lua.c %tolua.c %toluabind.c %LeakFinder.cpp %StackWalker.cpp %example.c,$(SOURCES))
|
||||
|
@ -461,23 +461,26 @@ eDimension StringToDimension(const AString & a_DimensionString)
|
||||
/// Translates damage type constant to a string representation (built-in).
|
||||
AString DamageTypeToString(eDamageType a_DamageType)
|
||||
{
|
||||
// Make sure to keep this alpha-sorted.
|
||||
switch (a_DamageType)
|
||||
{
|
||||
case dtAdmin: return "dtAdmin";
|
||||
case dtAttack: return "dtAttack";
|
||||
case dtRangedAttack: return "dtRangedAttack";
|
||||
case dtLightning: return "dtLightning";
|
||||
case dtFalling: return "dtFalling";
|
||||
case dtDrowning: return "dtDrowning";
|
||||
case dtSuffocating: return "dtSuffocation";
|
||||
case dtStarving: return "dtStarving";
|
||||
case dtCactusContact: return "dtCactusContact";
|
||||
case dtLavaContact: return "dtLavaContact";
|
||||
case dtPoisoning: return "dtPoisoning";
|
||||
case dtOnFire: return "dtOnFire";
|
||||
case dtDrowning: return "dtDrowning";
|
||||
case dtEnderPearl: return "dtEnderPearl";
|
||||
case dtFalling: return "dtFalling";
|
||||
case dtFireContact: return "dtFireContact";
|
||||
case dtInVoid: return "dtInVoid";
|
||||
case dtLavaContact: return "dtLavaContact";
|
||||
case dtLightning: return "dtLightning";
|
||||
case dtOnFire: return "dtOnFire";
|
||||
case dtPoisoning: return "dtPoisoning";
|
||||
case dtPotionOfHarming: return "dtPotionOfHarming";
|
||||
case dtAdmin: return "dtAdmin";
|
||||
case dtRangedAttack: return "dtRangedAttack";
|
||||
case dtStarving: return "dtStarving";
|
||||
case dtSuffocating: return "dtSuffocation";
|
||||
|
||||
}
|
||||
|
||||
// Unknown damage type:
|
||||
|
@ -324,7 +324,6 @@ void cCaveTunnel::FinishLinear(void)
|
||||
int sx = (PrevX < x1) ? 1 : -1;
|
||||
int sy = (PrevY < y1) ? 1 : -1;
|
||||
int sz = (PrevZ < z1) ? 1 : -1;
|
||||
int err = dx - dz;
|
||||
int R = itr->m_Radius;
|
||||
|
||||
if (dx >= std::max(dy, dz)) // x dominant
|
||||
@ -462,7 +461,7 @@ void cCaveTunnel::ProcessChunk(
|
||||
int BaseZ = a_ChunkZ * cChunkDef::Width;
|
||||
if (
|
||||
(BaseX > m_MaxBlockX) || (BaseX + cChunkDef::Width < m_MinBlockX) ||
|
||||
(BaseX > m_MaxBlockX) || (BaseX + cChunkDef::Width < m_MinBlockX)
|
||||
(BaseZ > m_MaxBlockZ) || (BaseZ + cChunkDef::Width < m_MinBlockZ)
|
||||
)
|
||||
{
|
||||
// Tunnel does not intersect the chunk at all, bail out
|
||||
@ -951,7 +950,6 @@ void cStructGenDualRidgeCaves::GenStructures(cChunkDesc & a_ChunkDesc)
|
||||
for (int y = 1; y <= Top; ++y)
|
||||
{
|
||||
const float yy = (float)y / 10;
|
||||
const float WaveNoise = 1;
|
||||
float n1 = m_Noise1.CubicNoise3D(xx, yy, zz);
|
||||
float n2 = m_Noise2.CubicNoise3D(xx, yy, zz);
|
||||
float n3 = m_Noise1.CubicNoise3D(xx * 4, yy * 4, zz * 4) / 4;
|
||||
|
@ -371,7 +371,7 @@ void cChunkDesc::ReadBlockArea(cBlockArea & a_Dest, int a_MinRelX, int a_MaxRelX
|
||||
HEIGHTTYPE cChunkDesc::GetMaxHeight(void) const
|
||||
{
|
||||
HEIGHTTYPE MaxHeight = m_HeightMap[0];
|
||||
for (int i = 1; i < ARRAYCOUNT(m_HeightMap); i++)
|
||||
for (unsigned int i = 1; i < ARRAYCOUNT(m_HeightMap); i++)
|
||||
{
|
||||
if (m_HeightMap[i] > MaxHeight)
|
||||
{
|
||||
@ -565,7 +565,7 @@ cBlockEntity * cChunkDesc::GetBlockEntity(int a_RelX, int a_RelY, int a_RelZ)
|
||||
void cChunkDesc::CompressBlockMetas(cChunkDef::BlockNibbles & a_DestMetas)
|
||||
{
|
||||
const NIBBLETYPE * AreaMetas = m_BlockArea.GetBlockMetas();
|
||||
for (int i = 0; i < ARRAYCOUNT(a_DestMetas); i++)
|
||||
for (unsigned int i = 0; i < ARRAYCOUNT(a_DestMetas); i++)
|
||||
{
|
||||
a_DestMetas[i] = AreaMetas[2 * i] | (AreaMetas[2 * i + 1] << 4);
|
||||
}
|
||||
|
@ -15,10 +15,10 @@
|
||||
|
||||
|
||||
/// If the generation queue size exceeds this number, a warning will be output
|
||||
const int QUEUE_WARNING_LIMIT = 1000;
|
||||
const unsigned int QUEUE_WARNING_LIMIT = 1000;
|
||||
|
||||
/// If the generation queue size exceeds this number, chunks with no clients will be skipped
|
||||
const int QUEUE_SKIP_LIMIT = 500;
|
||||
const unsigned int QUEUE_SKIP_LIMIT = 500;
|
||||
|
||||
|
||||
|
||||
|
@ -430,7 +430,7 @@ void cDistortedHeightmap::GetDistortAmpsAt(BiomeNeighbors & a_Neighbors, int a_R
|
||||
// For each biome type that has a nonzero count, calc its amps and add it:
|
||||
NOISE_DATATYPE AmpX = 0;
|
||||
NOISE_DATATYPE AmpZ = 0;
|
||||
for (int i = 0; i < ARRAYCOUNT(BiomeCounts); i++)
|
||||
for (unsigned int i = 0; i < ARRAYCOUNT(BiomeCounts); i++)
|
||||
{
|
||||
AmpX += BiomeCounts[i] * m_GenParam[i].m_DistortAmpX;
|
||||
AmpZ += BiomeCounts[i] * m_GenParam[i].m_DistortAmpZ;
|
||||
|
@ -151,7 +151,7 @@ void cEndGen::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_
|
||||
{
|
||||
if (IsChunkOutsideRange(a_ChunkX, a_ChunkZ))
|
||||
{
|
||||
for (int i = 0; i < ARRAYCOUNT(a_HeightMap); i++)
|
||||
for (unsigned int i = 0; i < ARRAYCOUNT(a_HeightMap); i++)
|
||||
{
|
||||
a_HeightMap[i] = 0;
|
||||
}
|
||||
|
@ -646,14 +646,14 @@ void cMineShaftCorridor::ProcessChunk(cChunkDesc & a_ChunkDesc)
|
||||
Top.p2.y += 1;
|
||||
Top.p1.y = Top.p2.y;
|
||||
a_ChunkDesc.FillRelCuboid(RelBoundingBox, E_BLOCK_AIR, 0);
|
||||
a_ChunkDesc.RandomFillRelCuboid(Top, E_BLOCK_AIR, 0, BlockX ^ BlockZ + BlockX, 8000);
|
||||
a_ChunkDesc.RandomFillRelCuboid(Top, E_BLOCK_AIR, 0, (BlockX ^ (BlockZ + BlockX)), 8000);
|
||||
if (m_SpawnerPosition >= 0)
|
||||
{
|
||||
// Cobwebs around the spider spawner
|
||||
a_ChunkDesc.RandomFillRelCuboid(RelBoundingBox, E_BLOCK_COBWEB, 0, BlockX ^ BlockZ + BlockZ, 8000);
|
||||
a_ChunkDesc.RandomFillRelCuboid(Top, E_BLOCK_COBWEB, 0, BlockX ^ BlockZ + BlockX, 5000);
|
||||
a_ChunkDesc.RandomFillRelCuboid(RelBoundingBox, E_BLOCK_COBWEB, 0, (BlockX ^ (BlockZ + BlockZ)), 8000);
|
||||
a_ChunkDesc.RandomFillRelCuboid(Top, E_BLOCK_COBWEB, 0, (BlockX ^ (BlockZ + BlockX)), 5000);
|
||||
}
|
||||
a_ChunkDesc.RandomFillRelCuboid(Top, E_BLOCK_COBWEB, 0, BlockX ^ BlockZ + BlockX + 10, 500);
|
||||
a_ChunkDesc.RandomFillRelCuboid(Top, E_BLOCK_COBWEB, 0, (BlockX ^ (BlockZ + BlockX + 10)), 500);
|
||||
RelBoundingBox.p1.y = m_BoundingBox.p1.y;
|
||||
RelBoundingBox.p2.y = m_BoundingBox.p1.y;
|
||||
a_ChunkDesc.FloorRelCuboid(RelBoundingBox, E_BLOCK_PLANKS, 0);
|
||||
@ -1034,7 +1034,7 @@ void cMineShaftCrossing::AppendBranches(int a_RecursionLevel, cNoise & a_Noise)
|
||||
{ 5, 5, 2, dirXP},
|
||||
{ 2, 5, 5, dirZP},
|
||||
} ;
|
||||
for (int i = 0; i < ARRAYCOUNT(Exits); i++)
|
||||
for (unsigned int i = 0; i < ARRAYCOUNT(Exits); i++)
|
||||
{
|
||||
if (m_BoundingBox.p1.y + Exits[i].y >= m_BoundingBox.p2.y)
|
||||
{
|
||||
|
@ -170,7 +170,7 @@ void cNoise3DGenerator::Initialize(cWorld * a_World, cIniFile & a_IniFile)
|
||||
|
||||
void cNoise3DGenerator::GenerateBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap)
|
||||
{
|
||||
for (int i = 0; i < ARRAYCOUNT(a_BiomeMap); i++)
|
||||
for (unsigned int i = 0; i < ARRAYCOUNT(a_BiomeMap); i++)
|
||||
{
|
||||
a_BiomeMap[i] = biExtremeHills;
|
||||
}
|
||||
@ -236,7 +236,7 @@ void cNoise3DGenerator::GenerateNoiseArray(int a_ChunkX, int a_ChunkZ, NOISE_DAT
|
||||
// Precalculate a "height" array:
|
||||
NOISE_DATATYPE Height[DIM_X * DIM_Z]; // Output for the cubic noise heightmap ("source")
|
||||
m_Cubic.Generate2D(Height, DIM_X, DIM_Z, StartX / 25, EndX / 25, StartZ / 25, EndZ / 25);
|
||||
for (int i = 0; i < ARRAYCOUNT(Height); i++)
|
||||
for (unsigned int i = 0; i < ARRAYCOUNT(Height); i++)
|
||||
{
|
||||
Height[i] = abs(Height[i]) * m_HeightAmplification + 1;
|
||||
}
|
||||
@ -389,10 +389,6 @@ void cNoise3DComposable::GenerateNoiseArrayIfNeeded(int a_ChunkX, int a_ChunkZ)
|
||||
const int UPSCALE_Y = 4;
|
||||
const int UPSCALE_Z = 8;
|
||||
|
||||
const int DIM_X = 1 + cChunkDef::Width / UPSCALE_X;
|
||||
const int DIM_Y = 1 + cChunkDef::Height / UPSCALE_Y;
|
||||
const int DIM_Z = 1 + cChunkDef::Width / UPSCALE_Z;
|
||||
|
||||
// Precalculate a "height" array:
|
||||
NOISE_DATATYPE Height[17 * 17]; // x + 17 * z
|
||||
for (int z = 0; z < 17; z += UPSCALE_Z)
|
||||
@ -406,7 +402,6 @@ void cNoise3DComposable::GenerateNoiseArrayIfNeeded(int a_ChunkX, int a_ChunkZ)
|
||||
}
|
||||
}
|
||||
|
||||
int idx = 0;
|
||||
for (int y = 0; y < 257; y += UPSCALE_Y)
|
||||
{
|
||||
NOISE_DATATYPE NoiseY = ((NOISE_DATATYPE)y) / m_FrequencyY;
|
||||
|
@ -179,7 +179,7 @@ template<typename TYPE> void LinearUpscale3DArray(
|
||||
// Pre-calculate the upscaling ratios:
|
||||
TYPE RatioX[MAX_UPSCALE_X];
|
||||
TYPE RatioY[MAX_UPSCALE_Y];
|
||||
TYPE RatioZ[MAX_UPSCALE_Y];
|
||||
TYPE RatioZ[MAX_UPSCALE_Z];
|
||||
for (int x = 0; x <= a_UpscaleX; x++)
|
||||
{
|
||||
RatioX[x] = (TYPE)x / a_UpscaleX;
|
||||
|
@ -124,7 +124,7 @@ void cLog::Log(const char * a_Format, va_list argList)
|
||||
#endif
|
||||
if (m_File)
|
||||
{
|
||||
fprintf(m_File, "%s\n", Line.c_str(), m_File);
|
||||
fprintf(m_File, "%s\n", Line.c_str());
|
||||
fflush(m_File);
|
||||
}
|
||||
|
||||
|
@ -114,8 +114,12 @@ void cPluginManager::ReloadPluginsNow(cIniFile & a_SettingsIni)
|
||||
|
||||
cServer::BindBuiltInConsoleCommands();
|
||||
|
||||
unsigned int KeyNum = a_SettingsIni.FindKey("Plugins");
|
||||
// Check if the Plugins section exists.
|
||||
int KeyNum = a_SettingsIni.FindKey("Plugins");
|
||||
|
||||
// If it does, how many plugins are there?
|
||||
unsigned int NumPlugins = ((KeyNum != -1) ? (a_SettingsIni.GetNumValues(KeyNum)) : 0);
|
||||
|
||||
if (KeyNum == -1)
|
||||
{
|
||||
InsertDefaultPlugins(a_SettingsIni);
|
||||
|
Loading…
Reference in New Issue
Block a user