aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/ServerChunkCache.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Minecraft.Client/ServerChunkCache.cpp')
-rw-r--r--Minecraft.Client/ServerChunkCache.cpp57
1 files changed, 38 insertions, 19 deletions
diff --git a/Minecraft.Client/ServerChunkCache.cpp b/Minecraft.Client/ServerChunkCache.cpp
index 54312ffa..c7d70c7d 100644
--- a/Minecraft.Client/ServerChunkCache.cpp
+++ b/Minecraft.Client/ServerChunkCache.cpp
@@ -80,31 +80,54 @@ vector<LevelChunk *> *ServerChunkCache::getLoadedChunkList()
return &m_loadedChunkList;
}
-void ServerChunkCache::drop(const int x, const int z)
+void ServerChunkCache::drop(int x, int z)
{
- const int ix = x + XZOFFSET;
- const int iz = z + XZOFFSET;
- if ((ix < 0) || (ix >= XZSIZE)) return;
- if ((iz < 0) || (iz >= XZSIZE)) return;
- const int idx = ix * XZSIZE + iz;
- LevelChunk* chunk = cache[idx];
-
- if (chunk != nullptr)
- {
- const auto it = std::find(m_loadedChunkList.begin(), m_loadedChunkList.end(), chunk);
- if (it != m_loadedChunkList.end()) m_loadedChunkList.erase(it);
+ // 4J - we're not dropping things anymore now that we have a fixed sized cache
+#ifdef _LARGE_WORLDS
- cache[idx] = nullptr;
- chunk->loaded = false;
+ bool canDrop = false;
+// if (level->dimension->mayRespawn())
+// {
+// Pos *spawnPos = level->getSharedSpawnPos();
+// int xd = x * 16 + 8 - spawnPos->x;
+// int zd = z * 16 + 8 - spawnPos->z;
+// delete spawnPos;
+// int r = 128;
+// if (xd < -r || xd > r || zd < -r || zd > r)
+// {
+// canDrop = true;
+//}
+// }
+// else
+ {
+ canDrop = true;
+ }
+ if(canDrop)
+ {
+ int ix = x + XZOFFSET;
+ int iz = z + XZOFFSET;
+ // Check we're in range of the stored level
+ if( ( ix < 0 ) || ( ix >= XZSIZE ) ) return;
+ if( ( iz < 0 ) || ( iz >= XZSIZE ) ) return;
+ int idx = ix * XZSIZE + iz;
+ LevelChunk *chunk = cache[idx];
+
+ if(chunk)
+ {
+ m_toDrop.push_back(chunk);
+ }
}
+#endif
}
void ServerChunkCache::dropAll()
{
+#ifdef _LARGE_WORLDS
for (LevelChunk *chunk : m_loadedChunkList)
{
drop(chunk->x, chunk->z);
- }
+}
+#endif
}
// 4J - this is the original (and virtual) interface to create
@@ -934,10 +957,6 @@ bool ServerChunkCache::tick()
m_unloadedCache[idx] = chunk;
cache[idx] = nullptr;
}
- else
- {
- continue;
- }
}
m_toDrop.pop_front();
}