summaryrefslogtreecommitdiffstats
path: root/src/WorldStorage/WorldStorage.cpp
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-09-09 01:55:21 +0200
committerHowaner <franzi.moos@googlemail.com>2014-09-09 01:55:21 +0200
commit6fb0a76b1eab47a806723b0a856609e19c5c14f9 (patch)
treec6d8712bdc4167e51d030277b28256c9bb0efe7c /src/WorldStorage/WorldStorage.cpp
parentPlayerSpawn packet: Send the correct uuid. (diff)
parentcapitalisation error (diff)
downloadcuberite-6fb0a76b1eab47a806723b0a856609e19c5c14f9.tar
cuberite-6fb0a76b1eab47a806723b0a856609e19c5c14f9.tar.gz
cuberite-6fb0a76b1eab47a806723b0a856609e19c5c14f9.tar.bz2
cuberite-6fb0a76b1eab47a806723b0a856609e19c5c14f9.tar.lz
cuberite-6fb0a76b1eab47a806723b0a856609e19c5c14f9.tar.xz
cuberite-6fb0a76b1eab47a806723b0a856609e19c5c14f9.tar.zst
cuberite-6fb0a76b1eab47a806723b0a856609e19c5c14f9.zip
Diffstat (limited to 'src/WorldStorage/WorldStorage.cpp')
-rw-r--r--src/WorldStorage/WorldStorage.cpp48
1 files changed, 20 insertions, 28 deletions
diff --git a/src/WorldStorage/WorldStorage.cpp b/src/WorldStorage/WorldStorage.cpp
index 707e8f929..179cf9393 100644
--- a/src/WorldStorage/WorldStorage.cpp
+++ b/src/WorldStorage/WorldStorage.cpp
@@ -141,9 +141,11 @@ size_t cWorldStorage::GetSaveQueueLength(void)
-void cWorldStorage::QueueLoadChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, bool a_Generate)
+void cWorldStorage::QueueLoadChunk(int a_ChunkX, int a_ChunkZ)
{
- m_LoadQueue.EnqueueItem(sChunkLoad(a_ChunkX, a_ChunkY, a_ChunkZ, a_Generate));
+ ASSERT(m_World->IsChunkQueued(a_ChunkX, a_ChunkZ));
+
+ m_LoadQueue.EnqueueItem(cChunkCoords(a_ChunkX, a_ChunkZ));
m_Event.Set();
}
@@ -151,9 +153,11 @@ void cWorldStorage::QueueLoadChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, boo
-void cWorldStorage::QueueSaveChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
+void cWorldStorage::QueueSaveChunk(int a_ChunkX, int a_ChunkZ)
{
- m_SaveQueue.EnqueueItemIfNotPresent(cChunkCoords(a_ChunkX, a_ChunkY, a_ChunkZ));
+ ASSERT(m_World->IsChunkValid(a_ChunkX, a_ChunkZ));
+
+ m_SaveQueue.EnqueueItemIfNotPresent(cChunkCoords(a_ChunkX, a_ChunkZ));
m_Event.Set();
}
@@ -161,9 +165,9 @@ void cWorldStorage::QueueSaveChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
-void cWorldStorage::UnqueueLoad(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
+void cWorldStorage::UnqueueLoad(int a_ChunkX, int a_ChunkZ)
{
- m_LoadQueue.Remove(sChunkLoad(a_ChunkX, a_ChunkY, a_ChunkZ, true));
+ m_LoadQueue.Remove(cChunkCoords(a_ChunkX, a_ChunkZ));
}
@@ -242,22 +246,14 @@ void cWorldStorage::Execute(void)
bool cWorldStorage::LoadOneChunk(void)
{
- sChunkLoad ToLoad(0, 0, 0, false);
+ cChunkCoords ToLoad(0, 0);
bool ShouldLoad = m_LoadQueue.TryDequeueItem(ToLoad);
- if (ShouldLoad && !LoadChunk(ToLoad.m_ChunkX, ToLoad.m_ChunkY, ToLoad.m_ChunkZ))
+
+ if (ShouldLoad)
{
- if (ToLoad.m_Generate)
- {
- // The chunk couldn't be loaded, generate it:
- m_World->GetGenerator().QueueGenerateChunk(ToLoad.m_ChunkX, ToLoad.m_ChunkY, ToLoad.m_ChunkZ);
- }
- else
- {
- // TODO: Notify the world that the load has failed:
- // m_World->ChunkLoadFailed(ToLoad.m_ChunkX, ToLoad.m_ChunkY, ToLoad.m_ChunkZ);
- }
+ return LoadChunk(ToLoad.m_ChunkX, ToLoad.m_ChunkZ);
}
- return ShouldLoad;
+ return false;
}
@@ -266,7 +262,7 @@ bool cWorldStorage::LoadOneChunk(void)
bool cWorldStorage::SaveOneChunk(void)
{
- cChunkCoords ToSave(0, 0, 0);
+ cChunkCoords ToSave(0, 0);
bool ShouldSave = m_SaveQueue.TryDequeueItem(ToSave);
if (ShouldSave && m_World->IsChunkValid(ToSave.m_ChunkX, ToSave.m_ChunkZ))
{
@@ -283,15 +279,11 @@ bool cWorldStorage::SaveOneChunk(void)
-bool cWorldStorage::LoadChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
+bool cWorldStorage::LoadChunk(int a_ChunkX, int a_ChunkZ)
{
- if (m_World->IsChunkValid(a_ChunkX, a_ChunkZ))
- {
- // Already loaded (can happen, since the queue is async)
- return true;
- }
+ ASSERT(m_World->IsChunkQueued(a_ChunkX, a_ChunkZ));
- cChunkCoords Coords(a_ChunkX, a_ChunkY, a_ChunkZ);
+ cChunkCoords Coords(a_ChunkX, a_ChunkZ);
// First try the schema that is used for saving
if (m_SaveSchema->LoadChunk(Coords))
@@ -309,7 +301,7 @@ bool cWorldStorage::LoadChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
}
// Notify the chunk owner that the chunk failed to load (sets cChunk::m_HasLoadFailed to true):
- m_World->ChunkLoadFailed(a_ChunkX, a_ChunkY, a_ChunkZ);
+ m_World->ChunkLoadFailed(a_ChunkX, a_ChunkZ);
return false;
}