diff options
-rw-r--r-- | CMakeLists.txt | 55 | ||||
-rw-r--r-- | CONTRIBUTORS | 1 | ||||
-rw-r--r-- | MCServer/Plugins/APIDump/Hooks/OnPlayerFished.lua | 2 | ||||
-rw-r--r-- | MCServer/Plugins/APIDump/Hooks/OnPlayerFishing.lua | 2 | ||||
-rw-r--r-- | src/BlockArea.cpp | 2 | ||||
-rw-r--r-- | src/BlockTracer.h | 25 | ||||
-rw-r--r-- | src/ByteBuffer.cpp | 7 | ||||
-rw-r--r-- | src/ByteBuffer.h | 2 | ||||
-rw-r--r-- | src/ClientHandle.cpp | 1 | ||||
-rw-r--r-- | src/Entities/Player.cpp | 4 | ||||
-rw-r--r-- | src/Inventory.cpp | 4 | ||||
-rw-r--r-- | src/LightingThread.cpp | 3 | ||||
-rw-r--r-- | src/LineBlockTracer.cpp | 1 | ||||
-rw-r--r-- | src/Root.cpp | 4 | ||||
-rw-r--r-- | src/Server.cpp | 5 | ||||
-rw-r--r-- | src/Simulator/NoopFluidSimulator.h | 10 | ||||
-rw-r--r-- | src/WebAdmin.cpp | 3 | ||||
-rw-r--r-- | src/World.cpp | 4 | ||||
-rw-r--r-- | src/World.h | 1 |
19 files changed, 90 insertions, 46 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 0df702b29..d2afceaab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,20 +35,24 @@ MARK_AS_ADVANCED( CMAKE_EXE_LINKER_FLAGS_PROFILE CMAKE_SHARED_LINKER_FLAGS_PROFILE ) -if(UNIX) -set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DNDEBUG") -set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DNDEBUG") -set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D_DEBUG") -set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -D_DEBUG") +# Add the preprocessor macros used for distinguishing between debug and release builds (CMake does this automatically for MSVC): +if (NOT MSVC) + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG") + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG") + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG") endif() -if(WIN32) +if(MSVC) + # Make build use multiple threads under MSVC: add_flags("/MP") else() + # Let gcc / clang know that we're compiling a multi-threaded app: add_flags("-pthread") endif() -if(FORCE_32) +# Allow for a forced 32-bit build under 32-bit OS: +if (FORCE_32) add_flags(-m32) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32") set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -m32") @@ -64,21 +68,21 @@ if(FORCE_32) set(CMAKE_MODULE_LINKER_FLAGS_PROFILE "${CMAKE_MODULE_LINKER_FLAGS_PROFILE} -m32") endif() -set(CMAKE_CXX_FLAGS_RELEASE_BAK "${CMAKE_CXX_FLAGS_RELEASE}") -set(CMAKE_C_FLAGS_RELEASE_BAK "${CMAKE_C_FLAGS_RELEASE}") -if (UNIX) +# Set lower warnings-level for the libraries: +if (MSVC) + # Remove /W3 from command line -- cannot just cancel it later with /w like in unix, MSVC produces a D9025 warning (option1 overriden by option2) + string(REPLACE "/W3" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") + string(REPLACE "/W3" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") + string(REPLACE "/W3" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") + string(REPLACE "/W3" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") +else() set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -w") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -w") -else() - #remove /W3 from command line -- cannot just cancel it later with /w like in unix because of D9025 - #only remove frome relase as we force release - string(REPLACE "/W3" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") - string(REPLACE "/W3" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -w") + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -w") endif() -set(CMAKE_BUILD_TYPE_BAK ${CMAKE_BUILD_TYPE}) -set(CMAKE_BUILD_TYPE "Release") - +# Under clang, we need to disable ASM support in CryptoPP: if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") add_definitions(-DCRYPTOPP_DISABLE_ASM) endif() @@ -91,6 +95,7 @@ endif() # The Expat library is linked in statically, make the source files aware of that: add_definitions(-DXML_STATIC) +# Include all the libraries: add_subdirectory(lib/inifile/) add_subdirectory(lib/jsoncpp/) add_subdirectory(lib/cryptopp/) @@ -102,16 +107,13 @@ add_subdirectory(lib/expat/) add_subdirectory(lib/luaexpat/) add_subdirectory(lib/md5/) -set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE_BAK}") -set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE_BAK}") - -#TODo: set -Wall -Werror -Wextra -if(UNIX) +# Re-add the maximum warning level: +# We do not do that for MSVC since MSVC produces an awful lot of warnings for its own STL headers; +# the important warnings will be turned on using #pragma in Globals.h +if (NOT MSVC) + #TODO: set -Wall -Werror -Wextra add_flags("-Wall -Wextra") -else() - add_flags("/Wall") endif() -set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE_BAK}") if (NOT WIN32) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rdynamic") @@ -120,5 +122,6 @@ if (NOT WIN32) set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_PROFILE} -rdynamic") endif() + add_subdirectory (src) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index bd6b204a4..150bcf09e 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -19,5 +19,6 @@ SamJBarney worktycho Sxw1212 tonibm19 +Diusrex Please add yourself to this list if you contribute to MCServer. diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerFished.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerFished.lua index 40dd6b3cf..4e093f4ae 100644 --- a/MCServer/Plugins/APIDump/Hooks/OnPlayerFished.lua +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerFished.lua @@ -17,4 +17,4 @@ return callback is called for this event. ]], }, -- HOOK_PLAYER_FISHED -};
\ No newline at end of file +}; diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerFishing.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerFishing.lua index 3b4731091..c5aaecd92 100644 --- a/MCServer/Plugins/APIDump/Hooks/OnPlayerFishing.lua +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerFishing.lua @@ -18,4 +18,4 @@ return callback is called for this event and the player doesn't get his reward. ]], }, -- HOOK_PLAYER_FISHING -};
\ No newline at end of file +}; diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index 1148908c6..dd8e0da31 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -28,6 +28,8 @@ template<typename Combinator> void InternalMergeBlocks( Combinator a_Combinator ) { + UNUSED(a_SrcSizeY); + UNUSED(a_DstSizeY); for (int y = 0; y < a_SizeY; y++) { int SrcBaseY = (y + a_SrcOffY) * a_SrcSizeX * a_SrcSizeZ; diff --git a/src/BlockTracer.h b/src/BlockTracer.h index d0a34811d..40d80da1a 100644 --- a/src/BlockTracer.h +++ b/src/BlockTracer.h @@ -36,7 +36,14 @@ public: /** Called on each block encountered along the path, including the first block (path start), if chunk data is not loaded When this callback returns true, the tracing is aborted. */ - virtual bool OnNextBlockNoData(int a_BlockX, int a_BlockY, int a_BlockZ, char a_EntryFace) { return false; } + virtual bool OnNextBlockNoData(int a_BlockX, int a_BlockY, int a_BlockZ, char a_EntryFace) + { + UNUSED(a_BlockX); + UNUSED(a_BlockY); + UNUSED(a_BlockZ); + UNUSED(a_EntryFace); + return false; + } /** Called when the path goes out of world, either below (a_BlockY < 0) or above (a_BlockY >= cChunkDef::Height) The coords specify the exact point at which the path exited the world. @@ -44,7 +51,13 @@ public: Note that some paths can go out of the world and come back again (parabola), in such a case this callback is followed by OnIntoWorld() and further OnNextBlock() calls */ - virtual bool OnOutOfWorld(double a_BlockX, double a_BlockY, double a_BlockZ) { return false; } + virtual bool OnOutOfWorld(double a_BlockX, double a_BlockY, double a_BlockZ) + { + UNUSED(a_BlockX); + UNUSED(a_BlockY); + UNUSED(a_BlockZ); + return false; + } /** Called when the path goes into the world, from either below (a_BlockY < 0) or above (a_BlockY >= cChunkDef::Height) The coords specify the exact point at which the path entered the world. @@ -52,7 +65,13 @@ public: Note that some paths can go out of the world and come back again (parabola), in such a case this callback is followed by further OnNextBlock() calls */ - virtual bool OnIntoWorld(double a_BlockX, double a_BlockY, double a_BlockZ) { return false; } + virtual bool OnIntoWorld(double a_BlockX, double a_BlockY, double a_BlockZ) + { + UNUSED(a_BlockX); + UNUSED(a_BlockY); + UNUSED(a_BlockZ); + return false; + } /** Called when the path is sure not to hit any more blocks. Note that for some shapes this might never happen (line with constant Y) diff --git a/src/ByteBuffer.cpp b/src/ByteBuffer.cpp index 64c03d0d3..e06f63a0e 100644 --- a/src/ByteBuffer.cpp +++ b/src/ByteBuffer.cpp @@ -773,7 +773,7 @@ void cByteBuffer::ReadAll(AString & a_Data) -bool cByteBuffer::ReadToByteBuffer(cByteBuffer & a_Dst, int a_NumBytes) +bool cByteBuffer::ReadToByteBuffer(cByteBuffer & a_Dst, size_t a_NumBytes) { if (!a_Dst.CanWriteBytes(a_NumBytes) || !CanReadBytes(a_NumBytes)) { @@ -781,9 +781,10 @@ bool cByteBuffer::ReadToByteBuffer(cByteBuffer & a_Dst, int a_NumBytes) return false; } char buf[1024]; - while (a_NumBytes > 0) + // > 0 without generating warnings about unsigned comparisons where size_t is unsigned + while (a_NumBytes != 0) { - int num = (a_NumBytes > sizeof(buf)) ? sizeof(buf) : a_NumBytes; + size_t num = (a_NumBytes > sizeof(buf)) ? sizeof(buf) : a_NumBytes; VERIFY(ReadBuf(buf, num)); VERIFY(a_Dst.Write(buf, num)); a_NumBytes -= num; diff --git a/src/ByteBuffer.h b/src/ByteBuffer.h index 06c846fa9..cbce119b1 100644 --- a/src/ByteBuffer.h +++ b/src/ByteBuffer.h @@ -110,7 +110,7 @@ public: void ReadAll(AString & a_Data); /// Reads the specified number of bytes and writes it into the destinatio bytebuffer. Returns true on success. - bool ReadToByteBuffer(cByteBuffer & a_Dst, int a_NumBytes); + bool ReadToByteBuffer(cByteBuffer & a_Dst, size_t a_NumBytes); /// Removes the bytes that have been read from the ringbuffer void CommitRead(void); diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 99df47bfb..17412c265 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1409,6 +1409,7 @@ void cClientHandle::SendData(const char * a_Data, int a_Size) void cClientHandle::MoveToWorld(cWorld & a_World, bool a_SendRespawnPacket) { + UNUSED(a_World); ASSERT(m_Player != NULL); if (a_SendRespawnPacket) diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 67d5a47ef..bc92790aa 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -908,8 +908,8 @@ bool cPlayer::IsGameModeSurvival(void) const bool cPlayer::IsGameModeAdventure(void) const { - return (m_GameMode == gmCreative) || // Either the player is explicitly in Adventure - ((m_GameMode == gmNotSet) && m_World->IsGameModeCreative()); // or they inherit from the world and the world is Adventure + return (m_GameMode == gmAdventure) || // Either the player is explicitly in Adventure + ((m_GameMode == gmNotSet) && m_World->IsGameModeAdventure()); // or they inherit from the world and the world is Adventure } diff --git a/src/Inventory.cpp b/src/Inventory.cpp index a9b4ab9c5..a7f77cf6d 100644 --- a/src/Inventory.cpp +++ b/src/Inventory.cpp @@ -57,6 +57,8 @@ int cInventory::HowManyCanFit(const cItem & a_ItemStack, bool a_ConsiderEmptySlo int cInventory::HowManyCanFit(const cItem & a_ItemStack, int a_BeginSlotNum, int a_EndSlotNum, bool a_ConsiderEmptySlots) { + + UNUSED(a_ConsiderEmptySlots); if ((a_BeginSlotNum < 0) || (a_BeginSlotNum >= invNumSlots)) { LOGWARNING("%s: Bad BeginSlotNum, got %d, there are %d slots; correcting to 0.", __FUNCTION__, a_BeginSlotNum, invNumSlots - 1); @@ -96,8 +98,6 @@ int cInventory::HowManyCanFit(const cItem & a_ItemStack, int a_BeginSlotNum, int - - int cInventory::AddItem(const cItem & a_Item, bool a_AllowNewStacks, bool a_tryToFillEquippedFirst) { cItem ToAdd(a_Item); diff --git a/src/LightingThread.cpp b/src/LightingThread.cpp index d7e60e458..7c3cc9c76 100644 --- a/src/LightingThread.cpp +++ b/src/LightingThread.cpp @@ -189,7 +189,7 @@ void cLightingThread::ChunkReady(int a_ChunkX, int a_ChunkZ) { if ( (itr->x - a_ChunkX >= -1) && (itr->x - a_ChunkX <= 1) && - (itr->x - a_ChunkX >= -1) && (itr->x - a_ChunkX <= 1) + (itr->z - a_ChunkZ >= -1) && (itr->z - a_ChunkZ <= 1) ) { // It is a neighbor @@ -495,6 +495,7 @@ void cLightingThread::CalcLightStep( int & a_NumSeedsOut, unsigned char * a_IsSeedOut, unsigned int * a_SeedIdxOut ) { + UNUSED(a_IsSeedIn); int NumSeedsOut = 0; for (int i = 0; i < a_NumSeedsIn; i++) { diff --git a/src/LineBlockTracer.cpp b/src/LineBlockTracer.cpp index 9fcbca915..110c6b5dc 100644 --- a/src/LineBlockTracer.cpp +++ b/src/LineBlockTracer.cpp @@ -196,7 +196,6 @@ bool cLineBlockTracer::Item(cChunk * a_Chunk) ASSERT((m_CurrentY >= 0) && (m_CurrentY < cChunkDef::Height)); // This should be provided by FixStartAboveWorld() / FixStartBelowWorld() // This is the actual line tracing loop. - bool Finished = false; while (true) { // Report the current block through the callbacks: diff --git a/src/Root.cpp b/src/Root.cpp index 16a521698..fa1fdb37a 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -701,9 +701,9 @@ int cRoot::GetPhysicalRAMUsage(void) { AString Line; std::getline(StatFile, Line); - if (strncmp(Line.c_str(), "VmRSS:", 7) == 0) + if (strncmp(Line.c_str(), "VmRSS:", 6) == 0) { - int res = atoi(Line.c_str() + 8); + int res = atoi(Line.c_str() + 7); return (res == 0) ? -1 : res; // If parsing failed, return -1 } } diff --git a/src/Server.cpp b/src/Server.cpp index a93be9a5b..7dedc3904 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -173,6 +173,7 @@ void cServer::ClientMovedToWorld(const cClientHandle * a_Client) void cServer::PlayerCreated(const cPlayer * a_Player) { + UNUSED(a_Player); // To avoid deadlocks, the player count is not handled directly, but rather posted onto the tick thread cCSLock Lock(m_CSPlayerCountDiff); m_PlayerCountDiff += 1; @@ -184,6 +185,7 @@ void cServer::PlayerCreated(const cPlayer * a_Player) void cServer::PlayerDestroying(const cPlayer * a_Player) { + UNUSED(a_Player); // To avoid deadlocks, the player count is not handled directly, but rather posted onto the tick thread cCSLock Lock(m_CSPlayerCountDiff); m_PlayerCountDiff -= 1; @@ -514,6 +516,7 @@ void cServer::ExecuteConsoleCommand(const AString & a_Cmd, cCommandOutputCallbac void cServer::PrintHelp(const AStringVector & a_Split, cCommandOutputCallback & a_Output) { + UNUSED(a_Split); typedef std::pair<AString, AString> AStringPair; typedef std::vector<AStringPair> AStringPairs; @@ -525,6 +528,8 @@ void cServer::PrintHelp(const AStringVector & a_Split, cCommandOutputCallback & virtual bool Command(const AString & a_Command, const cPlugin * a_Plugin, const AString & a_Permission, const AString & a_HelpString) override { + UNUSED(a_Plugin); + UNUSED(a_Permission); if (!a_HelpString.empty()) { m_Commands.push_back(AStringPair(a_Command, a_HelpString)); diff --git a/src/Simulator/NoopFluidSimulator.h b/src/Simulator/NoopFluidSimulator.h index 8f894433f..9113aec3c 100644 --- a/src/Simulator/NoopFluidSimulator.h +++ b/src/Simulator/NoopFluidSimulator.h @@ -27,8 +27,14 @@ public: } // cSimulator overrides: - virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override {} - virtual void Simulate(float a_Dt) override {} + virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override + { + UNUSED(a_BlockX); + UNUSED(a_BlockY); + UNUSED(a_BlockZ); + UNUSED(a_Chunk); + } + virtual void Simulate(float a_Dt) override { UNUSED(a_Dt);} } ; diff --git a/src/WebAdmin.cpp b/src/WebAdmin.cpp index a1f0842aa..e6a5a01b3 100644 --- a/src/WebAdmin.cpp +++ b/src/WebAdmin.cpp @@ -305,6 +305,7 @@ void cWebAdmin::HandleWebadminRequest(cHTTPConnection & a_Connection, cHTTPReque void cWebAdmin::HandleRootRequest(cHTTPConnection & a_Connection, cHTTPRequest & a_Request) { + UNUSED(a_Request); static const char LoginForm[] = \ "<h1>MCServer WebAdmin</h1>" \ "<center>" \ @@ -450,6 +451,7 @@ AString cWebAdmin::GetBaseURL(const AStringVector & a_URLSplit) void cWebAdmin::OnRequestBegun(cHTTPConnection & a_Connection, cHTTPRequest & a_Request) { + UNUSED(a_Connection); const AString & URL = a_Request.GetURL(); if ( (strncmp(URL.c_str(), "/webadmin", 9) == 0) || @@ -473,6 +475,7 @@ void cWebAdmin::OnRequestBegun(cHTTPConnection & a_Connection, cHTTPRequest & a_ void cWebAdmin::OnRequestBody(cHTTPConnection & a_Connection, cHTTPRequest & a_Request, const char * a_Data, int a_Size) { + UNUSED(a_Connection); cRequestData * Data = (cRequestData *)(a_Request.GetUserData()); if (Data == NULL) { diff --git a/src/World.cpp b/src/World.cpp index 28c46c27e..cc543d460 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -723,6 +723,7 @@ void cWorld::Tick(float a_Dt, int a_LastTickDurationMSec) void cWorld::TickWeather(float a_Dt) { + UNUSED(a_Dt); // There are no weather changes anywhere but in the Overworld: if (GetDimension() != dimOverworld) { @@ -794,7 +795,7 @@ void cWorld::TickMobs(float a_Dt) cMonster::mfAmbient, cMonster::mfWater, } ; - for (int i = 0; i < ARRAYCOUNT(AllFamilies); i++) + for (size_t i = 0; i < ARRAYCOUNT(AllFamilies); i++) { cMonster::eFamily Family = AllFamilies[i]; int SpawnDelay = cMonster::GetSpawnDelay(Family); @@ -1643,6 +1644,7 @@ int cWorld::SpawnExperienceOrb(double a_X, double a_Y, double a_Z, int a_Reward) void cWorld::SpawnPrimedTNT(double a_X, double a_Y, double a_Z, double a_FuseTimeInSec, double a_InitialVelocityCoeff) { + UNUSED(a_InitialVelocityCoeff); cTNTEntity * TNT = new cTNTEntity(a_X, a_Y, a_Z, a_FuseTimeInSec); TNT->Initialize(this); // TODO: Add a bit of speed in horiz and vert axes, based on the a_InitialVelocityCoeff diff --git a/src/World.h b/src/World.h index c067252d9..67f1275c0 100644 --- a/src/World.h +++ b/src/World.h @@ -78,6 +78,7 @@ public: class cTask { public: + virtual ~cTask(){}; virtual void Run(cWorld & a_World) = 0; } ; |