summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Chunk.cpp21
-rw-r--r--src/Chunk.h8
-rw-r--r--src/ChunkMap.cpp80
-rw-r--r--src/ChunkMap.h11
-rw-r--r--src/World.cpp10
-rw-r--r--src/World.h7
6 files changed, 9 insertions, 128 deletions
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index 1d5908c5f..84c5e9fc5 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -59,7 +59,6 @@ cChunk::cChunk(
cAllocationPool<cChunkData::sChunkSection> & a_Pool
):
m_Presence(cpInvalid),
- m_ShouldGenerateIfLoadFailed(false),
m_IsLightValid(false),
m_IsDirty(false),
m_IsSaving(false),
@@ -163,15 +162,6 @@ void cChunk::SetPresence(cChunk::ePresence a_Presence)
-void cChunk::SetShouldGenerateIfLoadFailed(bool a_ShouldGenerateIfLoadFailed)
-{
- m_ShouldGenerateIfLoadFailed = a_ShouldGenerateIfLoadFailed;
-}
-
-
-
-
-
void cChunk::MarkRegenerating(void)
{
// Set as queued again:
@@ -267,15 +257,8 @@ void cChunk::MarkLoadFailed(void)
{
ASSERT(m_Presence == cpQueued);
- // If the chunk is marked as needed, generate it:
- if (m_ShouldGenerateIfLoadFailed)
- {
- m_World->GetGenerator().QueueGenerateChunk({m_PosX, m_PosZ}, false);
- }
- else
- {
- m_Presence = cpInvalid;
- }
+ // The chunk is always needed, generate it:
+ m_World->GetGenerator().QueueGenerateChunk({m_PosX, m_PosZ}, false);
}
diff --git a/src/Chunk.h b/src/Chunk.h
index cb258c7f8..855ddfc66 100644
--- a/src/Chunk.h
+++ b/src/Chunk.h
@@ -79,9 +79,6 @@ public:
Wakes up any calls to cChunkMap::GetHeight() when setting to cpPresent. */
void SetPresence(ePresence a_Presence);
- /** Called to indicate whether the chunk should be queued in the generator if it fails to load. Set by cChunkMap::GetChunk(). */
- void SetShouldGenerateIfLoadFailed(bool a_ShouldGenerateIfLoadFailed);
-
/** Marks all clients attached to this chunk as wanting this chunk. Also sets presence to cpQueued. */
void MarkRegenerating(void);
@@ -106,8 +103,7 @@ public:
void MarkSaved(void); // Marks the chunk as saved, if it didn't change from the last call to MarkSaving()
void MarkLoaded(void); // Marks the chunk as freshly loaded. Fails if the chunk is already valid
- /** Marks the chunk as failed to load.
- If m_ShouldGenerateIfLoadFailed is set, queues the chunk for generating. */
+ /** Queues the chunk for generating. */
void MarkLoadFailed(void);
/** Gets all chunk data, calls the a_Callback's methods for each data type */
@@ -576,8 +572,6 @@ private:
/** Holds the presence status of the chunk - if it is present, or in the loader / generator queue, or unloaded */
ePresence m_Presence;
- /** If the chunk fails to load, should it be queued in the generator or reset back to invalid? */
- bool m_ShouldGenerateIfLoadFailed;
bool m_IsLightValid; // True if the blocklight and skylight are calculated
bool m_IsDirty; // True if the chunk has changed since it was last saved
bool m_IsSaving; // True if the chunk is being saved
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index 8b859c1b8..d373e510b 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -1603,16 +1603,6 @@ bool cChunkMap::GetSignLines(int a_BlockX, int a_BlockY, int a_BlockZ, AString &
-void cChunkMap::TouchChunk(int a_ChunkX, int a_ChunkZ)
-{
- cCSLock Lock(m_CSChunks);
- GetChunk(a_ChunkX, a_ChunkZ);
-}
-
-
-
-
-
void cChunkMap::PrepareChunk(int a_ChunkX, int a_ChunkZ, std::unique_ptr<cChunkCoordCallback> a_Callback)
{
cCSLock Lock(m_CSChunks);
@@ -1636,76 +1626,10 @@ void cChunkMap::PrepareChunk(int a_ChunkX, int a_ChunkZ, std::unique_ptr<cChunkC
-bool cChunkMap::GenerateChunk(int a_ChunkX, int a_ChunkZ, cChunkCoordCallback * a_Callback)
+void cChunkMap::GenerateChunk(int a_ChunkX, int a_ChunkZ)
{
cCSLock Lock(m_CSChunks);
- cChunkPtr Chunk = GetChunkNoLoad(a_ChunkX, a_ChunkZ);
- if (Chunk == nullptr)
- {
- // Generic error while getting the chunk - out of memory?
- return false;
- }
-
- // Try loading the chunk:
- if ((Chunk == nullptr) || (!Chunk->IsValid()))
- {
- Chunk->SetPresence(cChunk::cpQueued);
- class cPrepareLoadCallback: public cChunkCoordCallback
- {
- public:
- cPrepareLoadCallback(cWorld & a_CBWorld, cChunkMap & a_CBChunkMap, cChunkCoordCallback * a_CBCallback):
- m_World(a_CBWorld),
- m_ChunkMap(a_CBChunkMap),
- m_Callback(a_CBCallback)
- {
- }
-
- // cChunkCoordCallback override:
- virtual void Call(cChunkCoords a_Coords, bool a_CBIsSuccess) override
- {
- // If success is reported, the chunk is already valid, no need to do anything else:
- if (a_CBIsSuccess)
- {
- if (m_Callback != nullptr)
- {
- m_Callback->Call(a_Coords, true);
- }
- return;
- }
-
- // The chunk failed to load, generate it:
- cCSLock CBLock(m_ChunkMap.m_CSChunks);
- cChunkPtr CBChunk = m_ChunkMap.GetChunkNoLoad(a_Coords.m_ChunkX, a_Coords.m_ChunkZ);
-
- if (CBChunk == nullptr)
- {
- // An error occurred, but we promised to call the callback, so call it even when there's no real chunk data:
- if (m_Callback != nullptr)
- {
- m_Callback->Call(a_Coords, false);
- }
- return;
- }
-
- CBChunk->SetPresence(cChunk::cpQueued);
- m_World.GetGenerator().QueueGenerateChunk(a_Coords, false, m_Callback);
- }
-
- protected:
- cWorld & m_World;
- cChunkMap & m_ChunkMap;
- cChunkCoordCallback * m_Callback;
- };
- m_World->GetStorage().QueueLoadChunk(a_ChunkX, a_ChunkZ, new cPrepareLoadCallback(*m_World, *this, a_Callback));
- return true;
- }
-
- // The chunk is valid, just call the callback:
- if (a_Callback != nullptr)
- {
- a_Callback->Call({a_ChunkX, a_ChunkZ}, true);
- }
- return true;
+ GetChunk(a_ChunkX, a_ChunkZ); // Touches the chunk, loading or generating it
}
diff --git a/src/ChunkMap.h b/src/ChunkMap.h
index e426dd298..27794efa6 100644
--- a/src/ChunkMap.h
+++ b/src/ChunkMap.h
@@ -317,9 +317,6 @@ public:
Returns false if there's no sign at those coords, true if found. */
bool GetSignLines (int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4); // Lua-accessible
- /** Touches the chunk, causing it to be loaded or generated */
- void TouchChunk(int a_ChunkX, int a_ChunkZ);
-
/** Queues the chunk for preparing - making sure that it's generated and lit.
The specified chunk is queued to be loaded or generated, and lit if needed.
The specified callback is called after the chunk has been prepared. If there's no preparation to do, only the callback is called.
@@ -327,12 +324,8 @@ public:
void PrepareChunk(int a_ChunkX, int a_ChunkZ, std::unique_ptr<cChunkCoordCallback> a_CallAfter = {}); // Lua-accessible
/** Queues the chunk for generating.
- First attempts to load the chunk from the storage. If that fails, queues the chunk for generating.
- The specified callback is called after the chunk has been loaded / generated.
- It is legal to call without the callback.
- Returns true if successful, false if not (possibly an out-of-memory error).
- If the return value is true, the callback was / will be called. */
- bool GenerateChunk(int a_ChunkX, int a_ChunkZ, cChunkCoordCallback * a_CallAfter = nullptr); // Lua-accessible
+ First attempts to load the chunk from the storage. If that fails, queues the chunk for generating. */
+ void GenerateChunk(int a_ChunkX, int a_ChunkZ); // Lua-accessible
/** Marks the chunk as failed-to-load */
void ChunkLoadFailed(int a_ChunkX, int a_ChunkZ);
diff --git a/src/World.cpp b/src/World.cpp
index 6a0864410..dfc612229 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -2870,15 +2870,6 @@ void cWorld::RemoveClientFromChunkSender(cClientHandle * a_Client)
-void cWorld::TouchChunk(int a_ChunkX, int a_ChunkZ)
-{
- m_ChunkMap->TouchChunk(a_ChunkX, a_ChunkZ);
-}
-
-
-
-
-
void cWorld::PrepareChunk(int a_ChunkX, int a_ChunkZ, std::unique_ptr<cChunkCoordCallback> a_CallAfter)
{
m_ChunkMap->PrepareChunk(a_ChunkX, a_ChunkZ, std::move(a_CallAfter));
@@ -2980,7 +2971,6 @@ bool cWorld::SetTrapdoorOpen(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_Op
void cWorld::RegenerateChunk(int a_ChunkX, int a_ChunkZ)
{
m_ChunkMap->MarkChunkRegenerating(a_ChunkX, a_ChunkZ);
-
m_Generator.QueueGenerateChunk({a_ChunkX, a_ChunkZ}, true);
}
diff --git a/src/World.h b/src/World.h
index c7485531c..8277f8117 100644
--- a/src/World.h
+++ b/src/World.h
@@ -353,9 +353,6 @@ public:
/** Removes client from ChunkSender's queue of chunks to be sent */
void RemoveClientFromChunkSender(cClientHandle * a_Client);
- /** Touches the chunk, causing it to be loaded or generated */
- void TouchChunk(int a_ChunkX, int a_ChunkZ);
-
/** Queues the chunk for preparing - making sure that it's generated and lit.
The specified chunk is queued to be loaded or generated, and lit if needed.
The specified callback is called after the chunk has been prepared. If there's no preparation to do, only the callback is called.
@@ -377,10 +374,10 @@ public:
/** Set the state of a trapdoor. Returns true if the trapdoor was updated, false if there was no trapdoor at those coords. */
bool SetTrapdoorOpen(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_Open); // tolua_export
- /** Regenerate the given chunk: */
+ /** Regenerate the given chunk. */
void RegenerateChunk(int a_ChunkX, int a_ChunkZ); // tolua_export
- /** Generates the given chunk */
+ /** Generates the given chunk. */
void GenerateChunk(int a_ChunkX, int a_ChunkZ); // tolua_export
/** Queues a chunk for lighting; a_Callback is called after the chunk is lighted */