summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--CMakeLists.txt5
-rw-r--r--SetFlags.cmake9
-rw-r--r--src/AllocationPool.h8
-rw-r--r--src/Bindings/LuaState.cpp17
-rw-r--r--src/Bindings/LuaState.h2
-rw-r--r--src/ByteBuffer.cpp2
-rw-r--r--src/ByteBuffer.h2
-rw-r--r--src/Chunk.cpp4
-rw-r--r--src/ChunkGeneratorThread.cpp7
-rw-r--r--src/CraftingRecipes.cpp4
-rw-r--r--src/Generating/Caves.cpp12
-rw-r--r--src/Generating/ChunkDesc.cpp4
-rw-r--r--src/Generating/ChunkDesc.h4
-rw-r--r--src/Generating/CompoGen.cpp4
-rw-r--r--src/Generating/Ravines.cpp12
-rw-r--r--src/Generating/RoughRavines.cpp4
-rw-r--r--src/Globals.h30
-rw-r--r--src/LinearUpscale.h16
-rw-r--r--src/Logger.cpp2
-rw-r--r--src/LoggerListeners.cpp2
-rw-r--r--src/LoggerSimple.h8
-rw-r--r--src/MemorySettingsRepository.h8
-rw-r--r--src/OSSupport/IsThread.cpp6
-rw-r--r--src/Protocol/Protocol_1_8.cpp4
-rw-r--r--src/Resources/Cuberite.rc22
-rw-r--r--src/World.cpp4
-rw-r--r--src/WorldStorage/MapSerializer.cpp8
-rw-r--r--src/WorldStorage/ScoreboardSerializer.cpp4
-rw-r--r--src/main.cpp2
-rw-r--r--src/mbedTLS++/SslConfig.cpp6
-rw-r--r--tests/TestHelpers.h8
31 files changed, 99 insertions, 131 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 50ed801e7..70f25184a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -45,11 +45,6 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
-# TODO: use standard NDEBUG in place of _DEBUG
-if("${CMAKE_BUILD_TYPE}" MATCHES "DEBUG")
- add_definitions(-D_DEBUG)
-endif()
-
# The need for speed (in Release):
if(WHOLE_PROGRAM_OPTIMISATION)
include(CheckIPOSupported)
diff --git a/SetFlags.cmake b/SetFlags.cmake
index ff1b4bad4..2900418ea 100644
--- a/SetFlags.cmake
+++ b/SetFlags.cmake
@@ -88,15 +88,6 @@ function(set_global_flags)
# Make build use Unicode:
add_compile_definitions(UNICODE _UNICODE)
- else()
- # TODO: is this needed? NDEBUG is standard. Also, why are we using _DEBUG?
- # Add the preprocessor macros used for distinguishing between debug and release builds (CMake does this automatically for 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_COVERAGE "${CMAKE_CXX_FLAGS_COVERAGE} -D_DEBUG")
- set(CMAKE_C_FLAGS_COVERAGE "${CMAKE_C_FLAGS_COVERAGE} -D_DEBUG")
- set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG")
- set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG")
endif()
# Allow for a forced 32-bit build under 64-bit OS:
diff --git a/src/AllocationPool.h b/src/AllocationPool.h
index 78bb87eee..0af56ce2f 100644
--- a/src/AllocationPool.h
+++ b/src/AllocationPool.h
@@ -100,7 +100,7 @@ public:
void * space = malloc(sizeof(T));
if (space != nullptr)
{
- #if defined(_MSC_VER) && defined(_DEBUG)
+ #if defined(_MSC_VER) && !defined(NDEBUG)
// The debugging-new that is set up using macros in Globals.h doesn't support the placement-new syntax used here.
// Temporarily disable the macro
#pragma push_macro("new")
@@ -109,7 +109,7 @@ public:
return new(space) T;
- #if defined(_MSC_VER) && defined(_DEBUG)
+ #if defined(_MSC_VER) && !defined(NDEBUG)
// Re-enable the debugging-new macro
#pragma pop_macro("new")
#endif
@@ -127,7 +127,7 @@ public:
}
// placement new, used to initalize the object
- #if defined(_MSC_VER) && defined(_DEBUG)
+ #if defined(_MSC_VER) && !defined(NDEBUG)
// The debugging-new that is set up using macros in Globals.h doesn't support the placement-new syntax used here.
// Temporarily disable the macro
#pragma push_macro("new")
@@ -136,7 +136,7 @@ public:
T * ret = new (m_FreeList.front()) T;
- #if defined(_MSC_VER) && defined(_DEBUG)
+ #if defined(_MSC_VER) && !defined(NDEBUG)
// Re-enable the debugging-new macro
#pragma pop_macro("new")
#endif
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp
index 81dcb0e67..8c47ab322 100644
--- a/src/Bindings/LuaState.cpp
+++ b/src/Bindings/LuaState.cpp
@@ -388,10 +388,8 @@ cLuaState::cStackTable::cStackTable(cLuaState & a_LuaState, int a_StackPos):
void cLuaState::cStackTable::ForEachArrayElement(cFunctionRef<bool(cLuaState & a_LuaState, int a_Index)> a_ElementCallback) const
{
- auto numElements = luaL_getn(m_LuaState, m_StackPos);
- #ifdef _DEBUG
- auto stackTop = lua_gettop(m_LuaState);
- #endif
+ const auto numElements = luaL_getn(m_LuaState, m_StackPos);
+ [[maybe_unused]] const auto stackTop = lua_gettop(m_LuaState);
for (int idx = 1; idx <= numElements; idx++)
{
// Push the idx-th element of the array onto stack top and call the callback:
@@ -413,9 +411,7 @@ void cLuaState::cStackTable::ForEachArrayElement(cFunctionRef<bool(cLuaState & a
void cLuaState::cStackTable::ForEachElement(cFunctionRef<bool(cLuaState & a_LuaState)> a_ElementCallback) const
{
- #ifdef _DEBUG
- auto stackTop = lua_gettop(m_LuaState);
- #endif
+ [[maybe_unused]] const auto stackTop = lua_gettop(m_LuaState);
lua_pushvalue(m_LuaState, m_StackPos); // Stk: <table>
lua_pushnil(m_LuaState); // Stk: <table> nil
while (lua_next(m_LuaState, -2)) // Stk: <table> <key> <val>
@@ -2255,11 +2251,10 @@ int cLuaState::CopyStackFrom(cLuaState & a_SrcLuaState, int a_SrcStart, int a_Sr
bool cLuaState::CopyTableFrom(cLuaState & a_SrcLuaState, int a_SrcStackIdx, int a_NumAllowedNestingLevels)
{
+ [[maybe_unused]] const auto srcTop = lua_gettop(a_SrcLuaState);
+ [[maybe_unused]] const auto dstTop = lua_gettop(m_LuaState);
+
// Create the dest table:
- #ifdef _DEBUG
- auto srcTop = lua_gettop(a_SrcLuaState);
- auto dstTop = lua_gettop(m_LuaState);
- #endif
lua_createtable(m_LuaState, 0, 0); // DST: <table>
lua_pushvalue(a_SrcLuaState, a_SrcStackIdx); // SRC: <table>
lua_pushnil(a_SrcLuaState); // SRC: <table> <key>
diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h
index b3f567ecb..8798b2b68 100644
--- a/src/Bindings/LuaState.h
+++ b/src/Bindings/LuaState.h
@@ -58,7 +58,7 @@ class cLuaState
{
public:
- #ifdef _DEBUG
+ #ifndef NDEBUG
/** Asserts that the Lua stack has the same amount of entries when this object is destructed, as when it was constructed.
Used for checking functions that should preserve Lua stack balance. */
class cStackBalanceCheck
diff --git a/src/ByteBuffer.cpp b/src/ByteBuffer.cpp
index 2de6aec60..3891af247 100644
--- a/src/ByteBuffer.cpp
+++ b/src/ByteBuffer.cpp
@@ -115,7 +115,7 @@ bool cByteBuffer::Write(const void * a_Bytes, size_t a_Count)
// Store the current free space for a check after writing:
size_t CurFreeSpace = GetFreeSpace();
- #ifdef _DEBUG
+ #ifndef NDEBUG
size_t CurReadableSpace = GetReadableSpace();
#endif
size_t WrittenBytes = 0;
diff --git a/src/ByteBuffer.h b/src/ByteBuffer.h
index cbf215f38..f730c594e 100644
--- a/src/ByteBuffer.h
+++ b/src/ByteBuffer.h
@@ -149,7 +149,7 @@ protected:
size_t m_WritePos; // Where the data ends in the ringbuffer
size_t m_ReadPos; // Where the next read will start in the ringbuffer
- #ifdef _DEBUG
+ #ifndef NDEBUG
/** The ID of the thread currently accessing the object.
Used for checking that only one thread accesses the object at a time, via cSingleThreadAccessChecker. */
mutable std::thread::id m_ThreadID;
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index e8757158e..94bb425e1 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -338,7 +338,7 @@ void cChunk::SetAllData(cSetChunkData & a_SetChunkData)
m_BlockEntities = std::move(a_SetChunkData.GetBlockEntities());
// Check that all block entities have a valid blocktype at their respective coords (DEBUG-mode only):
- #ifdef _DEBUG
+ #ifndef NDEBUG
for (auto & KeyPair : m_BlockEntities)
{
cBlockEntity * Block = KeyPair.second.get();
@@ -346,7 +346,7 @@ void cChunk::SetAllData(cSetChunkData & a_SetChunkData)
BLOCKTYPE WorldBlockType = GetBlock(Block->GetRelX(), Block->GetPosY(), Block->GetRelZ());
ASSERT(WorldBlockType == EntityBlockType);
} // for KeyPair - m_BlockEntities
- #endif // _DEBUG
+ #endif // !NDEBUG
// Set all block entities' World variable:
for (auto & KeyPair : m_BlockEntities)
diff --git a/src/ChunkGeneratorThread.cpp b/src/ChunkGeneratorThread.cpp
index cb68c6831..b9c105d0b 100644
--- a/src/ChunkGeneratorThread.cpp
+++ b/src/ChunkGeneratorThread.cpp
@@ -250,15 +250,10 @@ void cChunkGeneratorThread::DoGenerate(cChunkCoords a_Coords)
m_Generator->Generate(ChunkDesc);
m_PluginInterface->CallHookChunkGenerated(ChunkDesc);
- #ifdef _DEBUG
+ #ifndef NDEBUG
// Verify that the generator has produced valid data:
ChunkDesc.VerifyHeightmap();
#endif
m_ChunkSink->OnChunkGenerated(ChunkDesc);
}
-
-
-
-
-
diff --git a/src/CraftingRecipes.cpp b/src/CraftingRecipes.cpp
index d08a3943c..bc1df4812 100644
--- a/src/CraftingRecipes.cpp
+++ b/src/CraftingRecipes.cpp
@@ -196,9 +196,7 @@ void cCraftingGrid::Dump(void)
{
for (int y = 0; y < m_Height; y++) for (int x = 0; x < m_Width; x++)
{
- #ifdef _DEBUG
- int idx = x + m_Width * y;
- #endif
+ [[maybe_unused]] const int idx = x + m_Width * y;
LOGD("Slot (%d, %d): Type %d, health %d, count %d",
x, y, m_Items[idx].m_ItemType, m_Items[idx].m_ItemDamage, m_Items[idx].m_ItemCount
);
diff --git a/src/Generating/Caves.cpp b/src/Generating/Caves.cpp
index 0d22d5b96..39497b45f 100644
--- a/src/Generating/Caves.cpp
+++ b/src/Generating/Caves.cpp
@@ -105,9 +105,9 @@ public:
cChunkDef::HeightMap & a_HeightMap
);
- #ifdef _DEBUG
+ #ifndef NDEBUG
AString ExportAsSVG(int a_Color, int a_OffsetX, int a_OffsetZ) const;
- #endif // _DEBUG
+ #endif // !NDEBUG
} ;
typedef std::vector<cCaveTunnel *> cCaveTunnels;
@@ -530,7 +530,7 @@ void cCaveTunnel::ProcessChunk(
} // for itr - m_Points[]
/*
- #ifdef _DEBUG
+ #ifndef NDEBUG
// For debugging purposes, outline the shape of the cave using glowstone, after carving the entire cave:
for (cCaveDefPoints::const_iterator itr = m_Points.begin(), end = m_Points.end(); itr != end; ++itr)
{
@@ -545,7 +545,7 @@ void cCaveTunnel::ProcessChunk(
cChunkDef::SetBlock(a_BlockTypes, DifX, itr->m_BlockY, DifZ, E_BLOCK_GLOWSTONE);
}
} // for itr - m_Points[]
- #endif // _DEBUG
+ #endif // !NDEBUG
//*/
}
@@ -553,7 +553,7 @@ void cCaveTunnel::ProcessChunk(
-#ifdef _DEBUG
+#ifndef NDEBUG
AString cCaveTunnel::ExportAsSVG(int a_Color, int a_OffsetX, int a_OffsetZ) const
{
AString SVG;
@@ -568,7 +568,7 @@ AString cCaveTunnel::ExportAsSVG(int a_Color, int a_OffsetX, int a_OffsetZ) cons
SVG.append("\"/>\n");
return SVG;
}
-#endif // _DEBUG
+#endif // !NDEBUG
diff --git a/src/Generating/ChunkDesc.cpp b/src/Generating/ChunkDesc.cpp
index 340e3f805..b4b8e8868 100644
--- a/src/Generating/ChunkDesc.cpp
+++ b/src/Generating/ChunkDesc.cpp
@@ -647,7 +647,7 @@ void cChunkDesc::CompressBlockMetas(cChunkDef::BlockNibbles & a_DestMetas)
-#ifdef _DEBUG
+#ifndef NDEBUG
void cChunkDesc::VerifyHeightmap(void)
{
@@ -669,7 +669,7 @@ void cChunkDesc::VerifyHeightmap(void)
} // for x
}
-#endif // _DEBUG
+#endif // !NDEBUG
diff --git a/src/Generating/ChunkDesc.h b/src/Generating/ChunkDesc.h
index a488d2a96..d10159dc9 100644
--- a/src/Generating/ChunkDesc.h
+++ b/src/Generating/ChunkDesc.h
@@ -229,10 +229,10 @@ public:
/** Compresses the metas from the BlockArea format (1 meta per byte) into regular format (2 metas per byte) */
void CompressBlockMetas(cChunkDef::BlockNibbles & a_DestMetas);
- #ifdef _DEBUG
+ #ifndef NDEBUG
/** Verifies that the heightmap corresponds to blocktype contents; if not, asserts on that column */
void VerifyHeightmap(void);
- #endif // _DEBUG
+ #endif // !NDEBUG
private:
cChunkCoords m_Coords;
diff --git a/src/Generating/CompoGen.cpp b/src/Generating/CompoGen.cpp
index f17846359..7cc8fa095 100644
--- a/src/Generating/CompoGen.cpp
+++ b/src/Generating/CompoGen.cpp
@@ -364,13 +364,13 @@ cCompoGenCache::~cCompoGenCache()
void cCompoGenCache::ComposeTerrain(cChunkDesc & a_ChunkDesc, const cChunkDesc::Shape & a_Shape)
{
- #ifdef _DEBUG
+ #ifndef NDEBUG
if (((m_NumHits + m_NumMisses) % 1024) == 10)
{
// LOGD("CompoGenCache: %d hits, %d misses, saved %.2f %%", m_NumHits, m_NumMisses, 100.0 * m_NumHits / (m_NumHits + m_NumMisses));
// LOGD("CompoGenCache: Avg cache chain length: %.2f", static_cast<float>(m_TotalChain) / m_NumHits);
}
- #endif // _DEBUG
+ #endif // !NDEBUG
int ChunkX = a_ChunkDesc.GetChunkX();
int ChunkZ = a_ChunkDesc.GetChunkZ();
diff --git a/src/Generating/Ravines.cpp b/src/Generating/Ravines.cpp
index a9574a8b7..0714bde9b 100644
--- a/src/Generating/Ravines.cpp
+++ b/src/Generating/Ravines.cpp
@@ -63,10 +63,10 @@ public:
cRavine(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ, int a_Size, cNoise & a_Noise);
- #ifdef _DEBUG
+ #ifndef NDEBUG
/** Exports itself as a SVG line definition */
AString ExportAsSVG(int a_Color, int a_OffsetX = 0, int a_OffsetZ = 0) const;
- #endif // _DEBUG
+ #endif // !NDEBUG
protected:
// cGridStructGen::cStructure overrides:
@@ -277,7 +277,7 @@ void cStructGenRavines::cRavine::FinishLinear(void)
-#ifdef _DEBUG
+#ifndef NDEBUG
AString cStructGenRavines::cRavine::ExportAsSVG(int a_Color, int a_OffsetX, int a_OffsetZ) const
{
AString SVG;
@@ -318,7 +318,7 @@ AString cStructGenRavines::cRavine::ExportAsSVG(int a_Color, int a_OffsetX, int
}
return SVG;
}
-#endif // _DEBUG
+#endif // !NDEBUG
@@ -349,13 +349,13 @@ void cStructGenRavines::cRavine::DrawIntoChunk(cChunkDesc & a_ChunkDesc)
int DifZ = BlockStartZ - itr->m_BlockZ; // substitution for faster calc
for (int x = 0; x < cChunkDef::Width; x++) for (int z = 0; z < cChunkDef::Width; z++)
{
- #ifdef _DEBUG
+ #ifndef NDEBUG
// DEBUG: Make the ravine shapepoints visible on a single layer (so that we can see with Minutor what's going on)
if ((DifX + x == 0) && (DifZ + z == 0))
{
a_ChunkDesc.SetBlockType(x, 4, z, E_BLOCK_LAPIS_ORE);
}
- #endif // _DEBUG
+ #endif // !NDEBUG
int DistSq = (DifX + x) * (DifX + x) + (DifZ + z) * (DifZ + z);
if (DistSq <= RadiusSq)
diff --git a/src/Generating/RoughRavines.cpp b/src/Generating/RoughRavines.cpp
index fe425757f..a39f7922d 100644
--- a/src/Generating/RoughRavines.cpp
+++ b/src/Generating/RoughRavines.cpp
@@ -181,13 +181,13 @@ protected:
float DifZ = BlockStartZ - itr->m_Z; // substitution for faster calc
for (int x = 0; x < cChunkDef::Width; x++) for (int z = 0; z < cChunkDef::Width; z++)
{
- #ifdef _DEBUG
+ #ifndef NDEBUG
// DEBUG: Make the roughravine shapepoints visible on a single layer (so that we can see with Minutor what's going on)
if ((FloorC(DifX + x) == 0) && (FloorC(DifZ + z) == 0))
{
a_ChunkDesc.SetBlockType(x, 4, z, E_BLOCK_LAPIS_ORE);
}
- #endif // _DEBUG
+ #endif // !NDEBUG
// If the column is outside the enlarged radius, bail out completely
float DistSq = (DifX + x) * (DifX + x) + (DifZ + z) * (DifZ + z);
diff --git a/src/Globals.h b/src/Globals.h
index cdfea9e5a..7b488326f 100644
--- a/src/Globals.h
+++ b/src/Globals.h
@@ -45,22 +45,20 @@
// Use non-standard defines in <cmath>
#define _USE_MATH_DEFINES
- #ifdef _DEBUG
+ #ifndef NDEBUG
// Override the "new" operator to include file and line specification for debugging memory leaks
// Ref.: https://social.msdn.microsoft.com/Forums/en-US/ebc7dd7a-f3c6-49f1-8a60-e381052f21b6/debugging-memory-leaks?forum=vcgeneral#53f0cc89-62fe-45e8-bbf0-56b89f2a1901
// This causes MSVC Debug runs to produce a report upon program exit, that contains memory-leaks
// together with the file:line information about where the memory was allocated.
// Note that this doesn't work with placement-new, which needs to temporarily #undef the macro
// (See AllocationPool.h for an example).
- #ifdef _DEBUG
- #define _CRTDBG_MAP_ALLOC
- #include <stdlib.h>
- #include <crtdbg.h>
- #define DEBUG_CLIENTBLOCK new(_CLIENT_BLOCK, __FILE__, __LINE__)
- #define new DEBUG_CLIENTBLOCK
- // For some reason this works magically - each "new X" gets replaced as "new(_CLIENT_BLOCK, "file", line) X"
- // The CRT has a definition for this operator new that stores the debugging info for leak-finding later.
- #endif
+ #define _CRTDBG_MAP_ALLOC
+ #include <stdlib.h>
+ #include <crtdbg.h>
+ #define DEBUG_CLIENTBLOCK new(_CLIENT_BLOCK, __FILE__, __LINE__)
+ #define new DEBUG_CLIENTBLOCK
+ // For some reason this works magically - each "new X" gets replaced as "new(_CLIENT_BLOCK, "file", line) X"
+ // The CRT has a definition for this operator new that stores the debugging info for leak-finding later.
#endif
#elif defined(__GNUC__)
@@ -277,10 +275,10 @@ template class SizeChecker<UInt8, 1>;
int lineNumber() const { return mLineNumber; }
};
- #ifdef _DEBUG
- #define ASSERT(x) do { if (!(x)) { throw cAssertFailure(#x, __FILE__, __LINE__);} } while (0)
+ #ifdef NDEBUG
+ #define ASSERT(x)
#else
- #define ASSERT(...)
+ #define ASSERT(x) do { if (!(x)) { throw cAssertFailure(#x, __FILE__, __LINE__);} } while (0)
#endif
// Pretty much the same as ASSERT() but stays in Release builds
@@ -288,10 +286,10 @@ template class SizeChecker<UInt8, 1>;
#else // TEST_GLOBALS
- #ifdef _DEBUG
- #define ASSERT(x) ( !!(x) || ( LOGERROR("Assertion failed: %s, file %s, line %i", #x, __FILE__, __LINE__), std::abort(), 0))
- #else
+ #ifdef NDEBUG
#define ASSERT(x)
+ #else
+ #define ASSERT(x) ( !!(x) || ( LOGERROR("Assertion failed: %s, file %s, line %i", #x, __FILE__, __LINE__), std::abort(), 0))
#endif
// Pretty much the same as ASSERT() but stays in Release builds
diff --git a/src/LinearUpscale.h b/src/LinearUpscale.h
index 349a3a55d..7f3269be5 100644
--- a/src/LinearUpscale.h
+++ b/src/LinearUpscale.h
@@ -123,11 +123,10 @@ template <typename TYPE> void LinearUpscale2DArray(
RatioY[y] = static_cast<TYPE>(y) / a_UpscaleY;
}
+ const int DstSizeX = (a_SrcSizeX - 1) * a_UpscaleX + 1;
+ [[maybe_unused]] const int DstSizeY = (a_SrcSizeY - 1) * a_UpscaleY + 1;
+
// Interpolate each XY cell:
- int DstSizeX = (a_SrcSizeX - 1) * a_UpscaleX + 1;
- #ifdef _DEBUG
- int DstSizeY = (a_SrcSizeY - 1) * a_UpscaleY + 1;
- #endif
for (int y = 0; y < (a_SrcSizeY - 1); y++)
{
int DstY = y * a_UpscaleY;
@@ -204,12 +203,11 @@ template <typename TYPE> void LinearUpscale3DArray(
RatioZ[z] = static_cast<TYPE>(z) / a_UpscaleZ;
}
+ const int DstSizeX = (a_SrcSizeX - 1) * a_UpscaleX + 1;
+ const int DstSizeY = (a_SrcSizeY - 1) * a_UpscaleY + 1;
+ [[maybe_unused]] const int DstSizeZ = (a_SrcSizeZ - 1) * a_UpscaleZ + 1;
+
// Interpolate each XYZ cell:
- int DstSizeX = (a_SrcSizeX - 1) * a_UpscaleX + 1;
- int DstSizeY = (a_SrcSizeY - 1) * a_UpscaleY + 1;
- #ifdef _DEBUG
- int DstSizeZ = (a_SrcSizeZ - 1) * a_UpscaleZ + 1;
- #endif
for (int z = 0; z < (a_SrcSizeZ - 1); z++)
{
int DstZ = z * a_UpscaleZ;
diff --git a/src/Logger.cpp b/src/Logger.cpp
index e8306aa30..434218824 100644
--- a/src/Logger.cpp
+++ b/src/Logger.cpp
@@ -22,7 +22,7 @@ static void WriteLogOpener(fmt::memory_buffer & Buffer)
localtime_r(&rawtime, &timeinfo);
#endif
-#ifdef _DEBUG
+#ifndef NDEBUG
const auto ThreadID = std::hash<std::thread::id>()(std::this_thread::get_id());
fmt::format_to(
Buffer, "[{0:04x}|{1:02d}:{2:02d}:{3:02d}] ",
diff --git a/src/LoggerListeners.cpp b/src/LoggerListeners.cpp
index 19b8c82d7..0d4c6eb1d 100644
--- a/src/LoggerListeners.cpp
+++ b/src/LoggerListeners.cpp
@@ -45,7 +45,7 @@
{
}
- #ifdef _DEBUG
+ #ifndef NDEBUG
virtual void Log(std::string_view a_Message, eLogLevel a_LogLevel) override
{
Super::Log(a_Message, a_LogLevel);
diff --git a/src/LoggerSimple.h b/src/LoggerSimple.h
index 8e51ddedf..7c984d2ca 100644
--- a/src/LoggerSimple.h
+++ b/src/LoggerSimple.h
@@ -79,18 +79,18 @@ void LOGERROR(std::string_view a_Format, const Args & ... args)
// Macro variants
// In debug builds, translate LOGD to LOG, otherwise leave it out altogether:
-#if defined(_DEBUG) || defined(TEST_GLOBALS)
+#if !defined(NDEBUG) || defined(TEST_GLOBALS)
#define LOGD LOG
#else
#define LOGD(...)
-#endif // _DEBUG
+#endif // !NDEBUG
#define LOGWARN LOGWARNING
-#if defined(_DEBUG) || defined(TEST_GLOBALS)
+#if !defined(NDEBUG) || defined(TEST_GLOBALS)
#define FLOGD FLOG
#else
#define FLOGD(...)
-#endif // _DEBUG
+#endif // !NDEBUG
#define FLOGWARN FLOGWARNING
diff --git a/src/MemorySettingsRepository.h b/src/MemorySettingsRepository.h
index 486f6706a..a2dec8548 100644
--- a/src/MemorySettingsRepository.h
+++ b/src/MemorySettingsRepository.h
@@ -52,7 +52,7 @@ private:
struct sValue
{
sValue(AString value):
- #ifdef _DEBUG
+ #ifndef NDEBUG
m_Type(eType::String),
#endif
m_stringValue (std::move(value))
@@ -60,7 +60,7 @@ private:
}
sValue(Int64 value):
- #ifdef _DEBUG
+ #ifndef NDEBUG
m_Type(eType::Int64),
#endif
m_intValue(value)
@@ -68,7 +68,7 @@ private:
}
sValue(bool value):
- #ifdef _DEBUG
+ #ifndef NDEBUG
m_Type(eType::Bool),
#endif
m_boolValue(value)
@@ -81,7 +81,7 @@ private:
private:
- #ifdef _DEBUG
+ #ifndef NDEBUG
enum class eType
{
String,
diff --git a/src/OSSupport/IsThread.cpp b/src/OSSupport/IsThread.cpp
index d60d0d9eb..4190acb26 100644
--- a/src/OSSupport/IsThread.cpp
+++ b/src/OSSupport/IsThread.cpp
@@ -11,7 +11,7 @@
-#if defined(_MSC_VER) && defined(_DEBUG)
+#if defined(_MSC_VER) && !defined(NDEBUG)
// Code adapted from MSDN: https://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx
const DWORD MS_VC_EXCEPTION = 0x406D1388;
@@ -39,7 +39,7 @@
{
}
}
-#endif // _MSC_VER && _DEBUG
+#endif // _MSC_VER && !NDEBUG
@@ -84,7 +84,7 @@ bool cIsThread::Start(void)
// Initialize the thread:
m_Thread = std::thread(&cIsThread::DoExecute, this);
- #if defined (_MSC_VER) && defined(_DEBUG)
+ #if defined(_MSC_VER) && !defined(NDEBUG)
if (!m_ThreadName.empty())
{
SetThreadName(&m_Thread, m_ThreadName.c_str());
diff --git a/src/Protocol/Protocol_1_8.cpp b/src/Protocol/Protocol_1_8.cpp
index a4876c448..cafcfb0ff 100644
--- a/src/Protocol/Protocol_1_8.cpp
+++ b/src/Protocol/Protocol_1_8.cpp
@@ -3913,7 +3913,7 @@ void cProtocol_1_8_0::HandlePacket(cByteBuffer & a_Buffer)
// Unknown packet, already been reported, but without the length. Log the length here:
LOGWARNING("Unhandled packet: type 0x%x, state %d, length %u", PacketType, m_State, a_Buffer.GetUsedSpace());
-#ifdef _DEBUG
+#ifndef NDEBUG
// Dump the packet contents into the log:
a_Buffer.ResetRead();
ContiguousByteBuffer Packet;
@@ -3922,7 +3922,7 @@ void cProtocol_1_8_0::HandlePacket(cByteBuffer & a_Buffer)
AString Out;
CreateHexDump(Out, Packet.data(), Packet.size(), 24);
LOGD("Packet contents:\n%s", Out.c_str());
-#endif // _DEBUG
+#endif // !NDEBUG
// Put a message in the comm log:
if (g_ShouldLogCommIn && m_CommLogFile.IsOpen())
diff --git a/src/Resources/Cuberite.rc b/src/Resources/Cuberite.rc
index 38f0df1df..2f2b4fc93 100644
--- a/src/Resources/Cuberite.rc
+++ b/src/Resources/Cuberite.rc
@@ -16,21 +16,23 @@ BEGIN
2 "A lightweight, fast and extensible game server for Minecraft"
END
-#define VERSION 0,0,13,37
-#define VERSION_STRING "0.0.13.37"
+#define VERSION 1,3,3,7
+#define VERSION_STRING "1.3.3.7"
#define INTERNAL_NAME "MCServer"
#define ORIGINAL_FILENAME "Cuberite.exe"
+#ifdef NDEBUG
+#define FILE_FLAGS 0
+#else
+#define FILE_FLAGS VS_FF_DEBUG
+#endif
+
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
VS_VERSION_INFO VERSIONINFO
FILEVERSION VERSION
PRODUCTVERSION VERSION
FILEFLAGSMASK 0x3fL
-#ifdef _DEBUG
- FILEFLAGS 0x1L
-#else
- FILEFLAGS 0x0L
-#endif
+ FILEFLAGS FILE_FLAGS
FILEOS 0x40004L
FILETYPE VFT_APP
FILESUBTYPE 0
@@ -59,11 +61,7 @@ VS_VERSION_INFO VERSIONINFO
FILEVERSION VERSION
PRODUCTVERSION VERSION
FILEFLAGSMASK 0x3fL
-#ifdef _DEBUG
- FILEFLAGS 0x1L
-#else
- FILEFLAGS 0x0L
-#endif
+ FILEFLAGS FILE_FLAGS
FILEOS 0x40004L
FILETYPE VFT_APP
FILESUBTYPE 0
diff --git a/src/World.cpp b/src/World.cpp
index 7f6fa0d10..361c26f04 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -613,11 +613,11 @@ bool cWorld::SetSpawn(double a_X, double a_Y, double a_Z)
void cWorld::InitializeSpawn(void)
{
// For the debugging builds, don't make the server build too much world upon start:
- #if defined(_DEBUG) || defined(ANDROID)
+ #if !defined(NDEBUG) || defined(ANDROID)
const int DefaultViewDist = 9;
#else
const int DefaultViewDist = 20; // Always prepare an area 20 chunks across, no matter what the actual cClientHandle::VIEWDISTANCE is
- #endif // _DEBUG
+ #endif // !NDEBUG
if (!m_IsSpawnExplicitlySet)
{
diff --git a/src/WorldStorage/MapSerializer.cpp b/src/WorldStorage/MapSerializer.cpp
index 40d428dab..7e67d8059 100644
--- a/src/WorldStorage/MapSerializer.cpp
+++ b/src/WorldStorage/MapSerializer.cpp
@@ -53,10 +53,10 @@ bool cMapSerializer::Save(void)
SaveMapToNBT(Writer);
Writer.Finish();
- #ifdef _DEBUG
+ #ifndef NDEBUG
cParsedNBT TestParse(Writer.GetResult());
ASSERT(TestParse.IsValid());
- #endif // _DEBUG
+ #endif // !NDEBUG
GZipFile::Write(m_Path, Writer.GetResult());
@@ -229,10 +229,10 @@ bool cIDCountSerializer::Save(void)
Writer.Finish();
- #ifdef _DEBUG
+ #ifndef NDEBUG
cParsedNBT TestParse(Writer.GetResult());
ASSERT(TestParse.IsValid());
- #endif // _DEBUG
+ #endif // !NDEBUG
cFile File;
if (!File.Open(m_Path, cFile::fmWrite))
diff --git a/src/WorldStorage/ScoreboardSerializer.cpp b/src/WorldStorage/ScoreboardSerializer.cpp
index 3ad4d42ee..5e644aab9 100644
--- a/src/WorldStorage/ScoreboardSerializer.cpp
+++ b/src/WorldStorage/ScoreboardSerializer.cpp
@@ -60,10 +60,10 @@ bool cScoreboardSerializer::Save(void)
SaveScoreboardToNBT(Writer);
Writer.Finish();
-#ifdef _DEBUG
+#ifndef NDEBUG
cParsedNBT TestParse(Writer.GetResult());
ASSERT(TestParse.IsValid());
-#endif // _DEBUG
+#endif // !NDEBUG
GZipFile::Write(m_Path, Writer.GetResult());
diff --git a/src/main.cpp b/src/main.cpp
index 86f0aa359..f61971e08 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -289,7 +289,7 @@ int main(int argc, char ** argv)
// Only useful when the leak is in the same sequence all the time
// _CrtSetBreakAlloc(85950);
-#endif // _DEBUG && _MSC_VER
+#endif // !NDEBUG && _MSC_VER
std::signal(SIGSEGV, NonCtrlHandler);
std::signal(SIGTERM, NonCtrlHandler);
diff --git a/src/mbedTLS++/SslConfig.cpp b/src/mbedTLS++/SslConfig.cpp
index 4b7882dcf..8ea850c9f 100644
--- a/src/mbedTLS++/SslConfig.cpp
+++ b/src/mbedTLS++/SslConfig.cpp
@@ -13,7 +13,7 @@
// #define ENABLE_SSL_DEBUG_MSG
-#if defined(_DEBUG) && defined(ENABLE_SSL_DEBUG_MSG)
+#if !defined(NDEBUG) && defined(ENABLE_SSL_DEBUG_MSG)
#include "mbedtls/debug.h"
@@ -95,7 +95,7 @@
return 0;
}
}
-#endif // defined(_DEBUG) && defined(ENABLE_SSL_DEBUG_MSG)
+#endif // !defined(NDEBUG) && defined(ENABLE_SSL_DEBUG_MSG)
@@ -238,7 +238,7 @@ std::shared_ptr<cSslConfig> cSslConfig::MakeDefaultConfig(bool a_IsClient)
Ret->SetAuthMode(eSslAuthMode::None); // We cannot verify because we don't have a CA chain
- #ifdef _DEBUG
+ #ifndef NDEBUG
#ifdef ENABLE_SSL_DEBUG_MSG
Ret->SetDebugCallback(&SSLDebugMessage, nullptr);
Ret->SetVerifyCallback(SSLVerifyCert, nullptr);
diff --git a/tests/TestHelpers.h b/tests/TestHelpers.h
index 0ef4014ac..cd1a52998 100644
--- a/tests/TestHelpers.h
+++ b/tests/TestHelpers.h
@@ -199,11 +199,11 @@ public:
/** Checks that the statement causes an ASSERT trigger. */
-#ifdef _DEBUG
- #define TEST_ASSERTS(Stmt) TEST_THROWS(Stmt, cAssertFailure)
-#else
+#ifdef NDEBUG
#define TEST_ASSERTS(Stmt) LOG("Skipped, cannot test in Release mode: TEST_ASSERT(%s); (%s:%d)", #Stmt, __FILE__, __LINE__)
-#endif // else _DEBUG
+#else
+ #define TEST_ASSERTS(Stmt) TEST_THROWS(Stmt, cAssertFailure)
+#endif // else NDEBUG