summaryrefslogtreecommitdiffstats
path: root/source/Chunk.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-28 14:18:03 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-28 14:18:03 +0200
commit9cd633348697862121a916d0b1f894fbf5ad457c (patch)
treefd41c0d12161b36920c4439759dbf7d3bf8a2151 /source/Chunk.cpp
parentChunk / ChunkMap: Added support for unbounded querying blocktype-only or blockmeta-only (diff)
downloadcuberite-9cd633348697862121a916d0b1f894fbf5ad457c.tar
cuberite-9cd633348697862121a916d0b1f894fbf5ad457c.tar.gz
cuberite-9cd633348697862121a916d0b1f894fbf5ad457c.tar.bz2
cuberite-9cd633348697862121a916d0b1f894fbf5ad457c.tar.lz
cuberite-9cd633348697862121a916d0b1f894fbf5ad457c.tar.xz
cuberite-9cd633348697862121a916d0b1f894fbf5ad457c.tar.zst
cuberite-9cd633348697862121a916d0b1f894fbf5ad457c.zip
Diffstat (limited to 'source/Chunk.cpp')
-rw-r--r--source/Chunk.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/source/Chunk.cpp b/source/Chunk.cpp
index 14b4acba7..a119c7c61 100644
--- a/source/Chunk.cpp
+++ b/source/Chunk.cpp
@@ -2354,6 +2354,72 @@ cChunk * cChunk::GetRelNeighborChunk(int a_RelX, int a_RelZ)
+cChunk * cChunk::GetRelNeighborChunkAdjustCoords(int & a_RelX, int & a_RelZ)
+{
+ bool ReturnThis = true;
+ int RelX = a_RelX;
+ int RelZ = a_RelZ;
+ if (a_RelX < 0)
+ {
+ if (m_NeighborXM != NULL)
+ {
+ RelX = a_RelX + cChunkDef::Width;
+ cChunk * Candidate = m_NeighborXM->GetRelNeighborChunkAdjustCoords(RelX, RelZ);
+ if (Candidate != NULL)
+ {
+ a_RelX = RelX;
+ a_RelZ = RelZ;
+ return Candidate;
+ }
+ }
+ // Going X-first failed, but if the request is crossing Z as well, let's try the Z-first later on.
+ ReturnThis = false;
+ }
+ else if (a_RelX >= cChunkDef::Width)
+ {
+ if (m_NeighborXP != NULL)
+ {
+ RelX = a_RelX - cChunkDef::Width;
+ cChunk * Candidate = m_NeighborXP->GetRelNeighborChunkAdjustCoords(RelX, RelZ);
+ if (Candidate != NULL)
+ {
+ a_RelX = RelX;
+ a_RelZ = RelZ;
+ return Candidate;
+ }
+ }
+ // Going X-first failed, but if the request is crossing Z as well, let's try the Z-first later on.
+ ReturnThis = false;
+ }
+
+ if (a_RelZ < 0)
+ {
+ if (m_NeighborZM != NULL)
+ {
+ a_RelZ += cChunkDef::Width;
+ return m_NeighborZM->GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ);
+ // For requests crossing both X and Z, the X-first way has been already tried
+ }
+ return NULL;
+ }
+ else if (a_RelZ >= cChunkDef::Width)
+ {
+ if (m_NeighborZP != NULL)
+ {
+ a_RelZ -= cChunkDef::Width;
+ return m_NeighborZP->GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ);
+ // For requests crossing both X and Z, the X-first way has been already tried
+ }
+ return NULL;
+ }
+
+ return (ReturnThis ? this : NULL);
+}
+
+
+
+
+
void cChunk::BroadcastAttachEntity(const cEntity & a_Entity, const cEntity * a_Vehicle)
{
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )