summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-04-29 15:41:24 +0200
committermadmaxoft <github@xoft.cz>2014-04-29 15:41:24 +0200
commit7e972f6a5ddb5b0cb7557044085bf1959ae7cb48 (patch)
treefdb6c9a01bfb52dd75d8d5d7afeaff304325615c
parentAdded BiomeToString() API function. (diff)
parentAdded BiomeToString() API function. (diff)
downloadcuberite-7e972f6a5ddb5b0cb7557044085bf1959ae7cb48.tar
cuberite-7e972f6a5ddb5b0cb7557044085bf1959ae7cb48.tar.gz
cuberite-7e972f6a5ddb5b0cb7557044085bf1959ae7cb48.tar.bz2
cuberite-7e972f6a5ddb5b0cb7557044085bf1959ae7cb48.tar.lz
cuberite-7e972f6a5ddb5b0cb7557044085bf1959ae7cb48.tar.xz
cuberite-7e972f6a5ddb5b0cb7557044085bf1959ae7cb48.tar.zst
cuberite-7e972f6a5ddb5b0cb7557044085bf1959ae7cb48.zip
-rw-r--r--src/BlockArea.cpp21
-rw-r--r--src/ChunkDef.h18
-rw-r--r--src/Entities/FallingBlock.cpp2
3 files changed, 29 insertions, 12 deletions
diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp
index f03fc6042..55e8d6849 100644
--- a/src/BlockArea.cpp
+++ b/src/BlockArea.cpp
@@ -13,11 +13,21 @@
-// This wild construct allows us to pass a function argument and still have it inlined by the compiler :)
-/// Merges two blocktypes and blockmetas of the specified sizes and offsets using the specified combinator function
+
+// Disable MSVC warnings: "conditional expression is constant"
+#ifdef _MSC_VER
+ #pragma warning(push)
+ #pragma warning(disable:4127)
+#endif
+
+
+
+
typedef void (CombinatorFunc)(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta);
+// This wild construct allows us to pass a function argument and still have it inlined by the compiler :)
+/// Merges two blocktypes and blockmetas of the specified sizes and offsets using the specified combinator function
template<bool MetasValid, CombinatorFunc Combinator>
void InternalMergeBlocks(
BLOCKTYPE * a_DstTypes, const BLOCKTYPE * a_SrcTypes,
@@ -61,6 +71,8 @@ void InternalMergeBlocks(
+
+
/// Combinator used for cBlockArea::msOverwrite merging
template<bool MetaValid>
void MergeCombinatorOverwrite(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta)
@@ -248,6 +260,11 @@ void MergeCombinatorMask(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE
}
}
+// Re-enable previously disabled MSVC warnings
+#ifdef _MSC_VER
+ #pragma warning(pop)
+#endif
+
diff --git a/src/ChunkDef.h b/src/ChunkDef.h
index 054168bdd..83f3c8f5f 100644
--- a/src/ChunkDef.h
+++ b/src/ChunkDef.h
@@ -246,8 +246,8 @@ public:
{
if ((x < Width) && (x > -1) && (y < Height) && (y > -1) && (z < Width) && (z > -1))
{
- int Index = MakeIndexNoCheck(x, y, z);
- if ((size_t)(Index / 2) >= a_Buffer.size())
+ size_t Index = (size_t)MakeIndexNoCheck(x, y, z);
+ if ((Index / 2) >= a_Buffer.size())
{
return (a_IsSkyLightNibble ? 0xff : 0);
}
@@ -281,7 +281,7 @@ public:
{
a_Buffer.resize((size_t)((a_BlockIdx / 2) + 1));
}
- a_Buffer[(size_t)(a_BlockIdx / 2)] = PackNibble(a_Buffer, a_BlockIdx, a_Nibble);
+ a_Buffer[(size_t)(a_BlockIdx / 2)] = PackNibble(a_Buffer, (size_t)a_BlockIdx, a_Nibble);
}
@@ -297,19 +297,19 @@ public:
return;
}
- int Index = MakeIndexNoCheck(x, y, z);
- if ((size_t)(Index / 2) >= a_Buffer.size())
+ size_t Index = (size_t)MakeIndexNoCheck(x, y, z);
+ if ((Index / 2) >= a_Buffer.size())
{
- a_Buffer.resize((size_t)((Index / 2) + 1));
+ a_Buffer.resize(((Index / 2) + 1));
}
- a_Buffer[(size_t)(Index / 2)] = PackNibble(a_Buffer, Index, a_Nibble);
+ a_Buffer[(Index / 2)] = PackNibble(a_Buffer, Index, a_Nibble);
}
private:
- inline static NIBBLETYPE PackNibble(const COMPRESSED_NIBBLETYPE & a_Buffer, int a_Index, NIBBLETYPE a_Nibble)
+ inline static NIBBLETYPE PackNibble(const COMPRESSED_NIBBLETYPE & a_Buffer, size_t a_Index, NIBBLETYPE a_Nibble)
{
return static_cast<NIBBLETYPE>(
(a_Buffer[a_Index / 2] & (0xf0 >> ((a_Index & 1) * 4))) | // The untouched nibble
@@ -318,7 +318,7 @@ private:
}
- inline static NIBBLETYPE ExpandNibble(const COMPRESSED_NIBBLETYPE & a_Buffer, int a_Index)
+ inline static NIBBLETYPE ExpandNibble(const COMPRESSED_NIBBLETYPE & a_Buffer, size_t a_Index)
{
return (a_Buffer[a_Index / 2] >> ((a_Index & 1) * 4)) & 0x0f;
}
diff --git a/src/Entities/FallingBlock.cpp b/src/Entities/FallingBlock.cpp
index bcdac0291..99bff1100 100644
--- a/src/Entities/FallingBlock.cpp
+++ b/src/Entities/FallingBlock.cpp
@@ -88,7 +88,7 @@ void cFallingBlock::Tick(float a_Dt, cChunk & a_Chunk)
AddPosition(GetSpeed() * MilliDt);
// If not static (One billionth precision) broadcast movement.
- static const float epsilon = 0.000000001;
+ static const float epsilon = 0.000000001f;
if ((fabs(GetSpeedX()) > epsilon) || (fabs(GetSpeedZ()) > epsilon))
{
BroadcastMovementUpdate();