summaryrefslogtreecommitdiffstats
path: root/src/ChunkDef.h
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-04-24 22:49:56 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-04-24 22:49:56 +0200
commitffce8d6907b8b93a2764a67766a40901bcad0835 (patch)
tree50a161ddad62c0293d5f366ae06ec943ab6ddb71 /src/ChunkDef.h
parentReplaced all the .data() calls so the code compiles in VS2008 (diff)
downloadcuberite-ffce8d6907b8b93a2764a67766a40901bcad0835.tar
cuberite-ffce8d6907b8b93a2764a67766a40901bcad0835.tar.gz
cuberite-ffce8d6907b8b93a2764a67766a40901bcad0835.tar.bz2
cuberite-ffce8d6907b8b93a2764a67766a40901bcad0835.tar.lz
cuberite-ffce8d6907b8b93a2764a67766a40901bcad0835.tar.xz
cuberite-ffce8d6907b8b93a2764a67766a40901bcad0835.tar.zst
cuberite-ffce8d6907b8b93a2764a67766a40901bcad0835.zip
Diffstat (limited to '')
-rw-r--r--src/ChunkDef.h77
1 files changed, 10 insertions, 67 deletions
diff --git a/src/ChunkDef.h b/src/ChunkDef.h
index bb9f14bbe..1b3dd3ee0 100644
--- a/src/ChunkDef.h
+++ b/src/ChunkDef.h
@@ -219,24 +219,13 @@ public:
ASSERT((a_Z >= 0) && (a_Z <= Width));
a_BiomeMap[a_X + Width * a_Z] = a_Biome;
}
-
-
- static NIBBLETYPE GetNibble(const NIBBLETYPE * a_Buffer, int a_BlockIdx)
- {
- if ((a_BlockIdx > -1) && (a_BlockIdx < NumBlocks))
- {
- return (a_Buffer[a_BlockIdx / 2] >> ((a_BlockIdx & 1) * 4)) & 0x0f;
- }
- ASSERT(!"cChunkDef::GetNibble(): index out of chunk range!");
- return 0;
- }
static NIBBLETYPE GetNibble(const std::vector<NIBBLETYPE> & a_Buffer, int a_BlockIdx, bool a_IsSkyLightNibble = false)
{
if ((a_BlockIdx > -1) && (a_BlockIdx < NumBlocks))
{
- if (a_Buffer.empty() || ((size_t)(a_BlockIdx / 2) > a_Buffer.size() - 1))
+ if (a_Buffer.empty() || ((size_t)(a_BlockIdx / 2) >= a_Buffer.size()))
{
return (a_IsSkyLightNibble ? 0xff : 0);
}
@@ -245,18 +234,6 @@ public:
ASSERT(!"cChunkDef::GetNibble(): index out of chunk range!");
return 0;
}
-
-
- static NIBBLETYPE GetNibble(const NIBBLETYPE * a_Buffer, int x, int y, int z)
- {
- if ((x < Width) && (x > -1) && (y < Height) && (y > -1) && (z < Width) && (z > -1))
- {
- int Index = MakeIndexNoCheck(x, y, z);
- return (a_Buffer[Index / 2] >> ((Index & 1) * 4)) & 0x0f;
- }
- ASSERT(!"cChunkDef::GetNibble(): coords out of chunk range!");
- return 0;
- }
static NIBBLETYPE GetNibble(const std::vector<NIBBLETYPE> & a_Buffer, int x, int y, int z, bool a_IsSkyLightNibble = false)
@@ -264,7 +241,7 @@ public:
if ((x < Width) && (x > -1) && (y < Height) && (y > -1) && (z < Width) && (z > -1))
{
int Index = MakeIndexNoCheck(x, y, z);
- if (a_Buffer.empty() || ((size_t)(Index / 2) > a_Buffer.size() - 1))
+ if (a_Buffer.empty() || ((size_t)(Index / 2) >= a_Buffer.size()))
{
return (a_IsSkyLightNibble ? 0xff : 0);
}
@@ -275,17 +252,15 @@ public:
}
- static void SetNibble(NIBBLETYPE * a_Buffer, int a_BlockIdx, NIBBLETYPE a_Nibble)
+ static NIBBLETYPE GetNibble(const NIBBLETYPE * a_Buffer, int x, int y, int z)
{
- if ((a_BlockIdx < 0) || (a_BlockIdx >= NumBlocks))
+ if ((x < Width) && (x > -1) && (y < Height) && (y > -1) && (z < Width) && (z > -1))
{
- ASSERT(!"cChunkDef::SetNibble(): index out of range!");
- return;
+ int Index = MakeIndexNoCheck(x, y, z);
+ return (a_Buffer[Index / 2] >> ((Index & 1) * 4)) & 0x0f;
}
- a_Buffer[a_BlockIdx / 2] = static_cast<NIBBLETYPE>(
- (a_Buffer[a_BlockIdx / 2] & (0xf0 >> ((a_BlockIdx & 1) * 4))) | // The untouched nibble
- ((a_Nibble & 0x0f) << ((a_BlockIdx & 1) * 4)) // The nibble being set
- );
+ ASSERT(!"cChunkDef::GetNibble(): coords out of chunk range!");
+ return 0;
}
@@ -296,7 +271,7 @@ public:
ASSERT(!"cChunkDef::SetNibble(): index out of range!");
return;
}
- if (a_Buffer.empty() || ((size_t)(a_BlockIdx / 2) > a_Buffer.size() - 1))
+ if (a_Buffer.empty() || ((size_t)(a_BlockIdx / 2) >= a_Buffer.size()))
{
a_Buffer.resize((size_t)((a_BlockIdx / 2) + 1));
}
@@ -305,26 +280,6 @@ public:
((a_Nibble & 0x0f) << ((a_BlockIdx & 1) * 4)) // The nibble being set
);
}
-
-
- static void SetNibble(NIBBLETYPE * a_Buffer, int x, int y, int z, NIBBLETYPE a_Nibble)
- {
- if (
- (x >= Width) || (x < 0) ||
- (y >= Height) || (y < 0) ||
- (z >= Width) || (z < 0)
- )
- {
- ASSERT(!"cChunkDef::SetNibble(): index out of range!");
- return;
- }
-
- int Index = MakeIndexNoCheck(x, y, z);
- a_Buffer[Index / 2] = static_cast<NIBBLETYPE>(
- (a_Buffer[Index / 2] & (0xf0 >> ((Index & 1) * 4))) | // The untouched nibble
- ((a_Nibble & 0x0f) << ((Index & 1) * 4)) // The nibble being set
- );
- }
static void SetNibble(std::vector<NIBBLETYPE> & a_Buffer, int x, int y, int z, NIBBLETYPE a_Nibble)
@@ -340,7 +295,7 @@ public:
}
int Index = MakeIndexNoCheck(x, y, z);
- if (a_Buffer.empty() || ((size_t)(Index / 2) > a_Buffer.size() - 1))
+ if (a_Buffer.empty() || ((size_t)(Index / 2) >= a_Buffer.size()))
{
a_Buffer.resize((size_t)((Index / 2) + 1));
}
@@ -350,18 +305,6 @@ public:
);
}
-
- inline static NIBBLETYPE GetNibble(const NIBBLETYPE * a_Buffer, const Vector3i & a_BlockPos)
- {
- return GetNibble(a_Buffer, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z );
- }
-
-
- inline static void SetNibble(NIBBLETYPE * a_Buffer, const Vector3i & a_BlockPos, NIBBLETYPE a_Value)
- {
- SetNibble( a_Buffer, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_Value );
- }
-
} ;