summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTycho <work.tycho+git@gmail.com>2014-05-21 21:18:09 +0200
committerTycho <work.tycho+git@gmail.com>2014-05-21 21:18:09 +0200
commitbd880603a560160d247d79a2fdeb3fbab26994f0 (patch)
tree6b358262ddfe8ffb42940eb362de0aa8ea6e1532 /src
parentFixed stylistic issues (diff)
downloadcuberite-bd880603a560160d247d79a2fdeb3fbab26994f0.tar
cuberite-bd880603a560160d247d79a2fdeb3fbab26994f0.tar.gz
cuberite-bd880603a560160d247d79a2fdeb3fbab26994f0.tar.bz2
cuberite-bd880603a560160d247d79a2fdeb3fbab26994f0.tar.lz
cuberite-bd880603a560160d247d79a2fdeb3fbab26994f0.tar.xz
cuberite-bd880603a560160d247d79a2fdeb3fbab26994f0.tar.zst
cuberite-bd880603a560160d247d79a2fdeb3fbab26994f0.zip
Diffstat (limited to '')
-rw-r--r--src/Chunk.h6
-rw-r--r--src/ChunkData.h10
2 files changed, 9 insertions, 7 deletions
diff --git a/src/Chunk.h b/src/Chunk.h
index 4f6c4cf0a..2de45919e 100644
--- a/src/Chunk.h
+++ b/src/Chunk.h
@@ -328,11 +328,11 @@ public:
}
inline void SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta)
{
- if (!(GetMeta(a_RelX, a_RelY, a_RelZ) == a_Meta))
+ bool hasChanged = m_ChunkData.SetMeta(a_RelX, a_RelY, a_RelZ, a_Meta);
+ if (hasChanged)
{
MarkDirty();
- m_ChunkData.SetMeta(a_RelX, a_RelY, a_RelZ, a_Meta);
-
+
m_PendingSendBlocks.push_back(sSetBlock(m_PosX, m_PosZ, a_RelX, a_RelY, a_RelZ, GetBlock(a_RelX, a_RelY, a_RelZ), a_Meta));
}
}
diff --git a/src/ChunkData.h b/src/ChunkData.h
index 24a437629..73b1e8c6a 100644
--- a/src/ChunkData.h
+++ b/src/ChunkData.h
@@ -167,7 +167,7 @@ public:
return 0;
}
- void SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Nibble)
+ bool SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Nibble)
{
if (
(a_RelX >= cChunkDef::Width) || (a_RelX < 0) ||
@@ -176,7 +176,7 @@ public:
)
{
ASSERT(!"cChunkData::SetMeta(): index out of range!");
- return;
+ return false;
}
int Section = a_RelY / CHUNK_SECTION_HEIGHT;
@@ -184,21 +184,23 @@ public:
{
if((a_Nibble & 0xf) == 0x00)
{
- return;
+ return false;
}
m_Sections[Section] = Allocate();
if(m_Sections[Section] != NULL)
{
ASSERT(!"Failed to allocate a new section in Chunkbuffer");
- return;
+ return false;
}
ZeroSection(m_Sections[Section]);
}
int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ);
+ NIBBLETYPE oldval = m_Sections[Section]->m_BlockMeta[Index / 2] >> ((Index & 1) * 4) & 0xf;
m_Sections[Section]->m_BlockMeta[Index / 2] = static_cast<NIBBLETYPE>(
(m_Sections[Section]->m_BlockMeta[Index / 2] & (0xf0 >> ((Index & 1) * 4))) | // The untouched nibble
((a_Nibble & 0x0f) << ((Index & 1) * 4)) // The nibble being set
);
+ return oldval == a_Nibble;
}
NIBBLETYPE GetBlockLight(int a_RelX, int a_RelY, int a_RelZ) const