summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt7
-rw-r--r--tests/ChunkData/ArraytoCoord.cpp116
-rw-r--r--tests/ChunkData/CMakeLists.txt25
-rw-r--r--tests/ChunkData/Coordinates.cpp143
-rw-r--r--tests/ChunkData/Copies.cpp193
-rw-r--r--tests/ChunkData/creatable.cpp9
-rw-r--r--tests/TestGlobals.h139
7 files changed, 632 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
new file mode 100644
index 000000000..1fbd88f04
--- /dev/null
+++ b/tests/CMakeLists.txt
@@ -0,0 +1,7 @@
+cmake_minimum_required (VERSION 2.6)
+
+enable_testing()
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+
+add_subdirectory(ChunkData)
diff --git a/tests/ChunkData/ArraytoCoord.cpp b/tests/ChunkData/ArraytoCoord.cpp
new file mode 100644
index 000000000..fe82a3a7b
--- /dev/null
+++ b/tests/ChunkData/ArraytoCoord.cpp
@@ -0,0 +1,116 @@
+
+#include "TestGlobals.h"
+#include "ChunkData.h"
+
+
+
+int main(int argc, char** argv)
+{
+ {
+ // Test first segment
+ cChunkData buffer;
+
+ BLOCKTYPE* SrcBlockBuffer = new BLOCKTYPE[16 * 16 * 256];
+ memset(SrcBlockBuffer, 0x00, 16 * 16 * 256);
+ SrcBlockBuffer[7+4*16+5*16*16] = 0xCD;
+ buffer.SetBlocks(SrcBlockBuffer);
+ testassert(buffer.GetBlock(7,5,4) == 0xCD);
+ delete SrcBlockBuffer;
+ SrcBlockBuffer = NULL;
+
+ NIBBLETYPE * SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
+ memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 /2);
+ SrcNibbleBuffer[(6+1*16+2*16*16)/2] = 0xE;
+ buffer.SetMeta(SrcNibbleBuffer);
+ testassert(buffer.GetMeta(6,2,1) == 0xE);
+ delete SrcNibbleBuffer;
+ SrcNibbleBuffer = NULL;
+
+ SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
+ memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 /2);
+ SrcNibbleBuffer[(6+1*16+2*16*16)/2] = 0xE;
+ buffer.SetLight(SrcNibbleBuffer);
+ testassert(buffer.GetBlockLight(6,2,1) == 0xE);
+ delete SrcNibbleBuffer;
+ SrcNibbleBuffer = NULL;
+
+ SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
+ memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 /2);
+ SrcNibbleBuffer[(6+1*16+2*16*16)/2] = 0xE;
+ buffer.SetSkyLight(SrcNibbleBuffer);
+ testassert(buffer.GetSkyLight(6,2,1) == 0xE);
+ delete SrcNibbleBuffer;
+ SrcNibbleBuffer = NULL;
+ }
+
+ {
+ // test following segment
+ cChunkData buffer;
+
+ BLOCKTYPE* SrcBlockBuffer = new BLOCKTYPE[16 * 16 * 256];
+ memset(SrcBlockBuffer, 0x00, 16 * 16 * 256);
+ SrcBlockBuffer[7+4*16+24*16*16] = 0xCD;
+ buffer.SetBlocks(SrcBlockBuffer);
+ testassert(buffer.GetBlock(7,24,4) == 0xCD);
+ delete SrcBlockBuffer;
+ SrcBlockBuffer = NULL;
+
+ NIBBLETYPE * SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
+ memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 /2);
+ SrcNibbleBuffer[(6+1*16+24*16*16)/2] = 0xE;
+ buffer.SetMeta(SrcNibbleBuffer);
+ testassert(buffer.GetMeta(6,24,1) == 0xE);
+ delete SrcNibbleBuffer;
+ SrcNibbleBuffer = NULL;
+
+ SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
+ memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 /2);
+ SrcNibbleBuffer[(6+1*16+24*16*16)/2] = 0xE;
+ buffer.SetLight(SrcNibbleBuffer);
+ testassert(buffer.GetBlockLight(6,24,1) == 0xE);
+ delete SrcNibbleBuffer;
+ SrcNibbleBuffer = NULL;
+
+ SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
+ memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 /2);
+ SrcNibbleBuffer[(6+1*16+24*16*16)/2] = 0xE;
+ buffer.SetSkyLight(SrcNibbleBuffer);
+ testassert(buffer.GetSkyLight(6,24,1) == 0xE);
+ delete SrcNibbleBuffer;
+ SrcNibbleBuffer = NULL;
+ }
+
+ {
+ // test zeros
+ cChunkData buffer;
+
+ BLOCKTYPE* SrcBlockBuffer = new BLOCKTYPE[16 * 16 * 256];
+ memset(SrcBlockBuffer, 0x00, 16 * 16 * 256);
+ buffer.SetBlocks(SrcBlockBuffer);
+ testassert(buffer.GetBlock(7,24,4) == 0x00);
+ delete SrcBlockBuffer;
+ SrcBlockBuffer = NULL;
+
+ NIBBLETYPE * SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
+ memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 /2);
+ buffer.SetMeta(SrcNibbleBuffer);
+ testassert(buffer.GetMeta(6,24,1) == 0x0);
+ delete SrcNibbleBuffer;
+ SrcNibbleBuffer = NULL;
+
+ SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
+ memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 /2);
+ buffer.SetLight(SrcNibbleBuffer);
+ testassert(buffer.GetBlockLight(6,24,1) == 0x0);
+ delete SrcNibbleBuffer;
+ SrcNibbleBuffer = NULL;
+
+ SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
+ memset(SrcNibbleBuffer, 0xFF, 16 * 16 * 256 /2);
+ buffer.SetSkyLight(SrcNibbleBuffer);
+ testassert(buffer.GetSkyLight(6,24,1) == 0xF);
+ delete SrcNibbleBuffer;
+ SrcNibbleBuffer = NULL;
+ }
+}
+
diff --git a/tests/ChunkData/CMakeLists.txt b/tests/ChunkData/CMakeLists.txt
new file mode 100644
index 000000000..3f6653bb5
--- /dev/null
+++ b/tests/ChunkData/CMakeLists.txt
@@ -0,0 +1,25 @@
+cmake_minimum_required (VERSION 2.6)
+
+enable_testing()
+
+include_directories(${CMAKE_SOURCE_DIR}/src/)
+
+add_library(ChunkBuffer ${CMAKE_SOURCE_DIR}/src/ChunkData.cpp)
+
+
+add_executable(creatable-exe creatable.cpp)
+target_link_libraries(creatable-exe ChunkBuffer)
+add_test(NAME creatable-test COMMAND creatable-exe)
+
+add_executable(coordinates-exe Coordinates.cpp)
+target_link_libraries(coordinates-exe ChunkBuffer)
+add_test(NAME coordinates-test COMMAND coordinates-exe)
+
+add_executable(copies-exe Copies.cpp)
+target_link_libraries(copies-exe ChunkBuffer)
+add_test(NAME copies-test COMMAND copies-exe)
+
+add_executable(arraystocoords-exe ArraytoCoord.cpp)
+target_link_libraries(arraystocoords-exe ChunkBuffer)
+add_test(NAME arraystocoords-test COMMAND arraystocoords-exe)
+
diff --git a/tests/ChunkData/Coordinates.cpp b/tests/ChunkData/Coordinates.cpp
new file mode 100644
index 000000000..c0c46000e
--- /dev/null
+++ b/tests/ChunkData/Coordinates.cpp
@@ -0,0 +1,143 @@
+
+#include "TestGlobals.h"
+#include "ChunkData.h"
+
+
+
+int main(int argc, char** argv)
+{
+ {
+ cChunkData buffer;
+
+ // Empty chunks
+ buffer.SetBlock(0,0,0, 0xAB);
+ testassert(buffer.GetBlock(0,0,0) == 0xAB);
+ buffer.SetMeta(0,16,0, 0xC);
+ testassert(buffer.GetMeta(0,16,0) == 0xC);
+
+ // loaded but not written segments
+ testassert(buffer.GetBlock(1,0,0) == 0x0);
+ testassert(buffer.GetMeta(1,16,0) == 0x0);
+
+ // Notloaded segments
+ testassert(buffer.GetBlock(0,32,0) == 0x0);
+ testassert(buffer.GetMeta(0,48,0) == 0x0);
+
+ // Out of Range
+ CheckAsserts(
+ buffer.SetBlock(-1, 0, 0, 0);
+ );
+ CheckAsserts(
+ buffer.SetBlock(0, -1, 0, 0);
+ );
+ CheckAsserts(
+ buffer.SetBlock(0, 0, -1, 0);
+ );
+ CheckAsserts(
+ buffer.SetBlock(256, 0, 0, 0);
+ );
+ CheckAsserts(
+ buffer.SetBlock(0, 256, 0, 0);
+ );
+ CheckAsserts(
+ buffer.SetBlock(0, 0, 256, 0);
+ );
+
+ // Out of Range
+ CheckAsserts(
+ buffer.GetBlock(-1, 0, 0);
+ );
+ CheckAsserts(
+ buffer.GetBlock(0, -1, 0);
+ );
+ CheckAsserts(
+ buffer.GetBlock(0, 0, -1);
+ );
+ CheckAsserts(
+ buffer.GetBlock(256, 0, 0);
+ );
+ CheckAsserts(
+ buffer.GetBlock(0, 256, 0);
+ );
+ CheckAsserts(
+ buffer.GetBlock(0, 0, 256);
+ );
+
+ // Out of Range
+ CheckAsserts(
+ buffer.SetMeta(-1, 0, 0, 0);
+ );
+ CheckAsserts(
+ buffer.SetMeta(0, -1, 0, 0);
+ );
+ CheckAsserts(
+ buffer.SetMeta(0, 0, -1, 0);
+ );
+ CheckAsserts(
+ buffer.SetMeta(256, 0, 0, 0);
+ );
+ CheckAsserts(
+ buffer.SetMeta(0, 256, 0, 0);
+ );
+ CheckAsserts(
+ buffer.SetMeta(0, 0, 256, 0);
+ );
+
+ // Out of Range
+ CheckAsserts(
+ buffer.GetMeta(-1, 0, 0);
+ );
+ CheckAsserts(
+ buffer.GetMeta(0, -1, 0);
+ );
+ CheckAsserts(
+ buffer.GetMeta(0, 0, -1);
+ );
+ CheckAsserts(
+ buffer.GetMeta(256, 0, 0);
+ );
+ CheckAsserts(
+ buffer.GetMeta(0, 256, 0);
+ );
+ CheckAsserts(
+ buffer.GetMeta(0, 0, 256);
+ );
+ }
+
+ {
+ cChunkData buffer;
+
+ // Zero's
+ buffer.SetBlock(0,0,0, 0x0);
+ buffer.SetBlock(0,0,1, 0xAB);
+ testassert(buffer.GetBlock(0,0,0) == 0x0);
+ testassert(buffer.GetBlock(0,0,1) == 0xAB);
+
+ buffer.SetMeta(0,16,0, 0x0);
+ buffer.SetMeta(0,16,1, 0xC);
+ testassert(buffer.GetMeta(0,16,0) == 0x0);
+ testassert(buffer.GetMeta(0,16,1) == 0xC);
+ }
+
+
+ {
+ // Operator =
+ cChunkData buffer;
+ buffer.SetBlock(0,0,0,0x42);
+ cChunkData copy;
+ #if __cplusplus < 201103L
+ copy = buffer;
+ #else
+ copy = std::move(buffer);
+ #endif
+ testassert(copy.GetBlock(0,0,0) == 0x42);
+ #if __cplusplus < 201103L
+ copy = copy;
+ #else
+ copy = std::move(copy);
+ #endif
+ testassert(copy.GetBlock(0,0,0) == 0x42);
+ }
+
+ return 0;
+}
diff --git a/tests/ChunkData/Copies.cpp b/tests/ChunkData/Copies.cpp
new file mode 100644
index 000000000..145ffd8e0
--- /dev/null
+++ b/tests/ChunkData/Copies.cpp
@@ -0,0 +1,193 @@
+
+#include "TestGlobals.h"
+#include "ChunkData.h"
+
+
+
+int main(int argc, char** argv)
+{
+ {
+ cChunkData buffer;
+
+ buffer.SetBlock(3,1,4,0xDE);
+ buffer.SetMeta(3,1,4,0xA);
+
+ cChunkData copy = buffer.Copy();
+ testassert(copy.GetBlock(3,1,4) == 0xDE);
+ testassert(copy.GetMeta(3,1,4) == 0xA);
+
+ BLOCKTYPE * SrcBlockBuffer = new BLOCKTYPE[16 * 16 * 256];
+ for (int i = 0; i < 16 * 16 * 256; i += 4)
+ {
+ SrcBlockBuffer[i+0] = 0xDE;
+ SrcBlockBuffer[i+1] = 0xAD;
+ SrcBlockBuffer[i+2] = 0xBE;
+ SrcBlockBuffer[i+3] = 0xEF;
+ }
+
+ buffer.SetBlocks(SrcBlockBuffer);
+ BLOCKTYPE * DstBlockBuffer = new BLOCKTYPE[16 * 16 * 256];
+ buffer.CopyBlocks(DstBlockBuffer);
+ testassert(memcmp(SrcBlockBuffer, DstBlockBuffer, (16 * 16 * 256) -1) == 0);
+ delete SrcBlockBuffer;
+ delete DstBlockBuffer;
+ SrcBlockBuffer = NULL;
+ DstBlockBuffer = NULL;
+
+ SrcBlockBuffer = new BLOCKTYPE[16 * 16 * 256];
+ memset(SrcBlockBuffer, 0x00, 16 * 16 * 256);
+ buffer.SetBlocks(SrcBlockBuffer);
+ DstBlockBuffer = new BLOCKTYPE[16 * 16 * 256];
+ buffer.CopyBlocks(DstBlockBuffer);
+ testassert(memcmp(SrcBlockBuffer, DstBlockBuffer, (16 * 16 * 256) -1) == 0);
+ delete SrcBlockBuffer;
+ delete DstBlockBuffer;
+ SrcBlockBuffer = NULL;
+ DstBlockBuffer = NULL;
+
+ }
+ {
+ cChunkData buffer;
+
+ NIBBLETYPE * SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
+ for (int i = 0; i < 16 * 16 * 256 / 2; i += 4)
+ {
+ SrcNibbleBuffer[i+0] = 0xEF;
+ SrcNibbleBuffer[i+1] = 0xDE;
+ SrcNibbleBuffer[i+2] = 0xAD;
+ SrcNibbleBuffer[i+3] = 0xBE;
+ }
+
+ buffer.SetMeta(SrcNibbleBuffer);
+ NIBBLETYPE * DstNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/ 2];
+ buffer.CopyMeta(DstNibbleBuffer);
+ testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 /2) -1) == 0);
+ delete SrcNibbleBuffer;
+ delete DstNibbleBuffer;
+ SrcNibbleBuffer = NULL;
+ DstNibbleBuffer = NULL;
+
+ SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
+ memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 /2);
+ buffer.SetMeta(SrcNibbleBuffer);
+ DstNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/ 2];
+ buffer.CopyMeta(DstNibbleBuffer);
+ testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 /2) -1) == 0);
+ delete SrcNibbleBuffer;
+ delete DstNibbleBuffer;
+ SrcNibbleBuffer = NULL;
+ DstNibbleBuffer = NULL;
+
+ }
+ {
+ cChunkData buffer;
+
+ NIBBLETYPE * SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
+ for (int i = 0; i < 16 * 16 * 256 / 2; i += 4)
+ {
+ SrcNibbleBuffer[i+0] = 0xDE;
+ SrcNibbleBuffer[i+1] = 0xAD;
+ SrcNibbleBuffer[i+2] = 0xBE;
+ SrcNibbleBuffer[i+3] = 0xEF;
+ }
+
+ buffer.SetLight(SrcNibbleBuffer);
+ NIBBLETYPE * DstNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/ 2];
+ buffer.CopyLight(DstNibbleBuffer);
+ testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 /2) -1) == 0);
+ delete SrcNibbleBuffer;
+ delete DstNibbleBuffer;
+ SrcNibbleBuffer = NULL;
+ DstNibbleBuffer = NULL;
+
+ SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
+ memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 /2);
+ buffer.SetLight(SrcNibbleBuffer);
+ DstNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/ 2];
+ buffer.CopyLight(DstNibbleBuffer);
+ testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 /2) -1) == 0);
+ delete SrcNibbleBuffer;
+ delete DstNibbleBuffer;
+ SrcNibbleBuffer = NULL;
+ DstNibbleBuffer = NULL;
+
+
+ }
+ {
+ cChunkData buffer;
+
+ NIBBLETYPE * SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
+ for (int i = 0; i < 16 * 16 * 256 / 2; i += 4)
+ {
+ SrcNibbleBuffer[i+0] = 0xAD;
+ SrcNibbleBuffer[i+1] = 0xBE;
+ SrcNibbleBuffer[i+2] = 0xEF;
+ SrcNibbleBuffer[i+3] = 0xDE;
+ }
+
+ buffer.SetSkyLight(SrcNibbleBuffer);
+ NIBBLETYPE * DstNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/ 2];
+ buffer.CopySkyLight(DstNibbleBuffer);
+ testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 /2) -1) == 0);
+ delete SrcNibbleBuffer;
+ delete DstNibbleBuffer;
+ SrcNibbleBuffer = NULL;
+ DstNibbleBuffer = NULL;
+
+
+ SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
+ memset(SrcNibbleBuffer, 0xFF, 16 * 16 * 256 /2);
+ buffer.SetSkyLight(SrcNibbleBuffer);
+ DstNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/ 2];
+ buffer.CopySkyLight(DstNibbleBuffer);
+ testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 /2) -1) == 0);
+ delete SrcNibbleBuffer;
+ delete DstNibbleBuffer;
+ SrcNibbleBuffer = NULL;
+ DstNibbleBuffer = NULL;
+
+ }
+ {
+ cChunkData buffer;
+
+ BLOCKTYPE * SrcBlockBuffer = new BLOCKTYPE[16 * 16 * 256];
+ memset(SrcBlockBuffer, 0x00, 16 * 16 * 256);
+ BLOCKTYPE * DstBlockBuffer = new BLOCKTYPE[16 * 16 * 256];
+ buffer.CopyBlocks(DstBlockBuffer);
+ testassert(memcmp(SrcBlockBuffer, DstBlockBuffer, (16 * 16 * 256) -1) == 0);
+ delete SrcBlockBuffer;
+ delete DstBlockBuffer;
+ SrcBlockBuffer = NULL;
+ DstBlockBuffer = NULL;
+
+ NIBBLETYPE * SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
+ memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 /2);
+ NIBBLETYPE * DstNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/ 2];
+ buffer.CopyMeta(DstNibbleBuffer);
+ testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 /2) -1) == 0);
+ delete SrcNibbleBuffer;
+ delete DstNibbleBuffer;
+ SrcNibbleBuffer = NULL;
+ DstNibbleBuffer = NULL;
+
+ SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
+ memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 /2);
+ DstNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/ 2];
+ buffer.CopyLight(DstNibbleBuffer);
+ testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 /2) -1) == 0);
+ delete SrcNibbleBuffer;
+ delete DstNibbleBuffer;
+ SrcNibbleBuffer = NULL;
+ DstNibbleBuffer = NULL;
+
+ SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
+ memset(SrcNibbleBuffer, 0xFF, 16 * 16 * 256 /2);
+ DstNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/ 2];
+ buffer.CopySkyLight(DstNibbleBuffer);
+ testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 /2) -1) == 0);
+ delete SrcNibbleBuffer;
+ delete DstNibbleBuffer;
+ SrcNibbleBuffer = NULL;
+ DstNibbleBuffer = NULL;
+ }
+}
diff --git a/tests/ChunkData/creatable.cpp b/tests/ChunkData/creatable.cpp
new file mode 100644
index 000000000..74025cb14
--- /dev/null
+++ b/tests/ChunkData/creatable.cpp
@@ -0,0 +1,9 @@
+
+#include "TestGlobals.h"
+#include "ChunkData.h"
+
+int main(int argc, char** argv)
+{
+ cChunkData buffer;
+ return 0;
+}
diff --git a/tests/TestGlobals.h b/tests/TestGlobals.h
new file mode 100644
index 000000000..bb25bd20a
--- /dev/null
+++ b/tests/TestGlobals.h
@@ -0,0 +1,139 @@
+
+
+#include <cstdarg>
+#include <cstdio>
+#include <cstdlib>
+
+
+// Compiler-dependent stuff:
+#if defined(_MSC_VER)
+ // MSVC produces warning C4481 on the override keyword usage, so disable the warning altogether
+ #pragma warning(disable:4481)
+
+ // Disable some warnings that we don't care about:
+ #pragma warning(disable:4100) // Unreferenced formal parameter
+
+ // Useful warnings from warning level 4:
+ #pragma warning(3 : 4127) // Conditional expression is constant
+ #pragma warning(3 : 4189) // Local variable is initialized but not referenced
+ #pragma warning(3 : 4245) // Conversion from 'type1' to 'type2', signed/unsigned mismatch
+ #pragma warning(3 : 4310) // Cast truncates constant value
+ #pragma warning(3 : 4389) // Signed/unsigned mismatch
+ #pragma warning(3 : 4505) // Unreferenced local function has been removed
+ #pragma warning(3 : 4701) // Potentially unitialized local variable used
+ #pragma warning(3 : 4702) // Unreachable code
+ #pragma warning(3 : 4706) // Assignment within conditional expression
+
+ // Disabling this warning, because we know what we're doing when we're doing this:
+ #pragma warning(disable: 4355) // 'this' used in initializer list
+
+ // Disabled because it's useless:
+ #pragma warning(disable: 4512) // 'class': assignment operator could not be generated - reported for each class that has a reference-type member
+
+ // 2014_01_06 xoft: Disabled this warning because MSVC is stupid and reports it in obviously wrong places
+ // #pragma warning(3 : 4244) // Conversion from 'type1' to 'type2', possible loss of data
+
+ #define OBSOLETE __declspec(deprecated)
+
+ // No alignment needed in MSVC
+ #define ALIGN_8
+ #define ALIGN_16
+
+ #define FORMATSTRING(formatIndex, va_argsIndex)
+
+ // MSVC has its own custom version of zu format
+ #define SIZE_T_FMT "%Iu"
+ #define SIZE_T_FMT_PRECISION(x) "%" #x "Iu"
+ #define SIZE_T_FMT_HEX "%Ix"
+
+ #define NORETURN __declspec(noreturn)
+
+#elif defined(__GNUC__)
+
+ // TODO: Can GCC explicitly mark classes as abstract (no instances can be created)?
+ #define abstract
+
+ // override is part of c++11
+ #if __cplusplus < 201103L
+ #define override
+ #endif
+
+ #define OBSOLETE __attribute__((deprecated))
+
+ #define ALIGN_8 __attribute__((aligned(8)))
+ #define ALIGN_16 __attribute__((aligned(16)))
+
+ // Some portability macros :)
+ #define stricmp strcasecmp
+
+ #define FORMATSTRING(formatIndex, va_argsIndex) __attribute__((format (printf, formatIndex, va_argsIndex)))
+
+ #define SIZE_T_FMT "%zu"
+ #define SIZE_T_FMT_PRECISION(x) "%" #x "zu"
+ #define SIZE_T_FMT_HEX "%zx"
+
+ #define NORETURN __attribute((__noreturn__))
+
+#else
+
+ #error "You are using an unsupported compiler, you might need to #define some stuff here for your compiler"
+
+ /*
+ // Copy and uncomment this into another #elif section based on your compiler identification
+
+ // Explicitly mark classes as abstract (no instances can be created)
+ #define abstract
+
+ // Mark virtual methods as overriding (forcing them to have a virtual function of the same signature in the base class)
+ #define override
+
+ // Mark functions as obsolete, so that their usage results in a compile-time warning
+ #define OBSOLETE
+
+ // Mark types / variables for alignment. Do the platforms need it?
+ #define ALIGN_8
+ #define ALIGN_16
+ */
+
+#endif
+
+
+
+// Integral types with predefined sizes:
+typedef long long Int64;
+typedef int Int32;
+typedef short Int16;
+
+typedef unsigned long long UInt64;
+typedef unsigned int UInt32;
+typedef unsigned short UInt16;
+
+typedef unsigned char Byte;
+
+class cAssertFailure
+{
+};
+
+#define ASSERT(x) do { if (!(x)) { throw cAssertFailure();} } while (0)
+#define testassert(x) do { if(!(x)) { exit(1); } } while (0)
+#define CheckAsserts(x) do { try {x} catch (cAssertFailure) { break; } exit(1); } while (0)
+
+#ifndef TOLUA_TEMPLATE_BIND
+#define TOLUA_TEMPLATE_BIND(x)
+#endif
+
+// A macro that is used to mark unused function parameters, to avoid pedantic warnings in gcc
+#define UNUSED(X) (void)(X)
+
+// Logging functions
+void LOGERROR(const char* a_Format, ...) FORMATSTRING(1,2);
+
+void LOGERROR(const char* a_Format, ...)
+{
+ va_list argList;
+ va_start(argList, a_Format);
+ vprintf(a_Format, argList);
+ va_end(argList);
+}
+
+