summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-28 13:11:14 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-28 13:11:14 +0100
commit013ae71c871c81437a1bad197e0bf7481d02b4a6 (patch)
tree13191934b88edd6d8ecaab43c82425c5dd719264
parentImplemented synchronous chunk loading; optimized cChunkStay interface for speed (though still unused ;) (diff)
downloadcuberite-013ae71c871c81437a1bad197e0bf7481d02b4a6.tar
cuberite-013ae71c871c81437a1bad197e0bf7481d02b4a6.tar.gz
cuberite-013ae71c871c81437a1bad197e0bf7481d02b4a6.tar.bz2
cuberite-013ae71c871c81437a1bad197e0bf7481d02b4a6.tar.lz
cuberite-013ae71c871c81437a1bad197e0bf7481d02b4a6.tar.xz
cuberite-013ae71c871c81437a1bad197e0bf7481d02b4a6.tar.zst
cuberite-013ae71c871c81437a1bad197e0bf7481d02b4a6.zip
Diffstat (limited to '')
-rw-r--r--source/WorldStorage.cpp3
-rw-r--r--source/cChunk.cpp16
-rw-r--r--source/cChunk.h3
-rw-r--r--source/cChunkMap.cpp20
-rw-r--r--source/cChunkMap.h3
-rw-r--r--source/cFileFormatUpdater.cpp23
-rw-r--r--source/cWorld.cpp9
-rw-r--r--source/cWorld.h3
-rw-r--r--source/cWorldGenerator.cpp15
9 files changed, 89 insertions, 6 deletions
diff --git a/source/WorldStorage.cpp b/source/WorldStorage.cpp
index 17c58c549..2bebbbad5 100644
--- a/source/WorldStorage.cpp
+++ b/source/WorldStorage.cpp
@@ -415,6 +415,9 @@ 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);
+
return false;
}
diff --git a/source/cChunk.cpp b/source/cChunk.cpp
index 14f99c1d9..476f829d7 100644
--- a/source/cChunk.cpp
+++ b/source/cChunk.cpp
@@ -204,6 +204,20 @@ void cChunk::MarkLoaded(void)
+void cChunk::MarkLoadFailed(void)
+{
+ if (m_IsValid)
+ {
+ return;
+ }
+
+ m_HasLoadFailed = true;
+}
+
+
+
+
+
void cChunk::GetAllData(cChunkDataCallback * a_Callback)
{
a_Callback->BlockData(m_BlockData);
@@ -262,6 +276,8 @@ void cChunk::SetAllData(const char * a_BlockData, cEntityList & a_Entities, cBlo
CreateBlockEntities();
CalculateHeightmap();
+
+ m_HasLoadFailed = false;
}
diff --git a/source/cChunk.h b/source/cChunk.h
index 3dc1c56fd..cc9585810 100644
--- a/source/cChunk.h
+++ b/source/cChunk.h
@@ -121,6 +121,7 @@ public:
bool IsValid(void) const {return m_IsValid; } // Returns true if the chunk is valid (loaded / generated)
void SetValid(bool a_SendToClients = true); // Also wakes up all clients attached to this chunk to let them finish logging in
bool IsDirty(void) const {return m_IsDirty; } // Returns true if the chunk has changed since it was last saved
+ bool HasLoadFailed(void) const {return m_HasLoadFailed; } // Returns true if the chunk failed to load and hasn't been generated since then
bool CanUnload(void);
/*
@@ -133,6 +134,7 @@ public:
void MarkSaving(void); // Marks the chunk as being saved.
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
+ void MarkLoadFailed(void); // Marks the chunk as failed to load. Ignored is the chunk is already valid
/// Gets all chunk data, calls the a_Callback's methods for each data type
void GetAllData(cChunkDataCallback * a_Callback);
@@ -231,6 +233,7 @@ private:
bool m_IsValid; // True if the chunk is loaded / generated
bool m_IsDirty; // True if the chunk has changed since it was last saved
bool m_IsSaving; // True if the chunk is being saved
+ bool m_HasLoadFailed; // True if chunk failed to load and hasn't been generated yet since then
cCriticalSection m_CSBlockLists;
std::map< unsigned int, int > m_ToTickBlocks;
diff --git a/source/cChunkMap.cpp b/source/cChunkMap.cpp
index 2f4d39ca2..0485df1eb 100644
--- a/source/cChunkMap.cpp
+++ b/source/cChunkMap.cpp
@@ -782,6 +782,11 @@ bool cChunkMap::LoadChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
// Already loaded
return true;
}
+ if (Chunk->HasLoadFailed())
+ {
+ // Already tried loading and it failed
+ return false;
+ }
}
return m_World->GetStorage().LoadChunk(a_ChunkX, a_ChunkY, a_ChunkZ);
}
@@ -803,6 +808,21 @@ void cChunkMap::LoadChunks(const cChunkCoordsList & a_Chunks)
+void cChunkMap::ChunkLoadFailed(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
+{
+ cCSLock Lock(m_CSLayers);
+ cChunkPtr Chunk = GetChunkNoLoad(a_ChunkX, a_ChunkY, a_ChunkZ);
+ if (Chunk == NULL)
+ {
+ return;
+ }
+ Chunk->MarkLoadFailed();
+}
+
+
+
+
+
void cChunkMap::UpdateSign(int a_X, int a_Y, int a_Z, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4)
{
cCSLock Lock(m_CSLayers);
diff --git a/source/cChunkMap.h b/source/cChunkMap.h
index 1b7192a92..a4593529b 100644
--- a/source/cChunkMap.h
+++ b/source/cChunkMap.h
@@ -89,6 +89,9 @@ public:
/// Loads the chunks specified. Doesn't report failure, other than chunks being !IsValid()
void LoadChunks(const cChunkCoordsList & a_Chunks);
+ /// Marks the chunk as failed-to-load:
+ void ChunkLoadFailed(int a_ChunkX, int a_ChunkY, int a_ChunkZ);
+
void UpdateSign(int a_X, int a_Y, int a_Z, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4);
/// Marks (a_Stay == true) or unmarks (a_Stay == false) chunks as non-unloadable; to be used only by cChunkStay!
diff --git a/source/cFileFormatUpdater.cpp b/source/cFileFormatUpdater.cpp
index e117c8075..d17a35bb0 100644
--- a/source/cFileFormatUpdater.cpp
+++ b/source/cFileFormatUpdater.cpp
@@ -2,21 +2,32 @@
#include "Globals.h"
#include "cFileFormatUpdater.h"
-#include "cMCLogger.h"
#include "Vector3d.h"
#include "Vector3f.h"
#include "cItem.h"
#include <json/json.h>
+
+
+
+
typedef std::list< std::string > StringList;
StringList GetDirectoryContents( const char* a_Directory );
+
+
+
+
void cFileFormatUpdater::UpdateFileFormat()
{
UpdatePlayersOfWorld("world");
}
+
+
+
+
// Convert player .bin files to JSON
void cFileFormatUpdater::UpdatePlayersOfWorld( const char* a_WorldName )
{
@@ -138,10 +149,6 @@ void cFileFormatUpdater::PlayerBINtoJSON( const char* a_FileName )
-
-
-
-
// Helper function
StringList GetDirectoryContents( const char* a_Directory )
{
@@ -177,4 +184,8 @@ StringList GetDirectoryContents( const char* a_Directory )
#endif
return AllFiles;
-} \ No newline at end of file
+}
+
+
+
+
diff --git a/source/cWorld.cpp b/source/cWorld.cpp
index e59476863..cc7f0b88b 100644
--- a/source/cWorld.cpp
+++ b/source/cWorld.cpp
@@ -1306,6 +1306,15 @@ void cWorld::LoadChunks(const cChunkCoordsList & a_Chunks)
+void cWorld::ChunkLoadFailed(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
+{
+ m_ChunkMap->ChunkLoadFailed(a_ChunkX, a_ChunkY, a_ChunkZ);
+}
+
+
+
+
+
void cWorld::UpdateSign(int a_X, int a_Y, int a_Z, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4)
{
m_ChunkMap->UpdateSign(a_X, a_Y, a_Z, a_Line1, a_Line2, a_Line3, a_Line4);
diff --git a/source/cWorld.h b/source/cWorld.h
index a0dd435d9..f8d6fe1bc 100644
--- a/source/cWorld.h
+++ b/source/cWorld.h
@@ -133,6 +133,9 @@ public:
/// Loads the chunks specified. Doesn't report failure, other than chunks being !IsValid()
void LoadChunks(const cChunkCoordsList & a_Chunks);
+ /// Marks the chunk as failed-to-load:
+ void ChunkLoadFailed(int a_ChunkX, int a_ChunkY, int a_ChunkZ);
+
void UpdateSign(int a_X, int a_Y, int a_Z, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4);
/// Marks (a_Stay == true) or unmarks (a_Stay == false) chunks as non-unloadable. To be used only by cChunkStay!
diff --git a/source/cWorldGenerator.cpp b/source/cWorldGenerator.cpp
index 5d9f82bae..a0c670eae 100644
--- a/source/cWorldGenerator.cpp
+++ b/source/cWorldGenerator.cpp
@@ -94,6 +94,21 @@ void cWorldGenerator::GenerateChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, ch
void cWorldGenerator::PostGenerateChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
{
// Check the chunk just generated and all its 8-way neighbors
+
+ // Make the chunks stay loaded in the surrounding 5x5 area:
+ cChunkStay Stay(m_World);
+ Stay.Add(a_ChunkX, a_ChunkY, a_ChunkZ);
+ for (int x = -2; x <= 2; x++)
+ {
+ for (int z = -2; z <= 2; z++)
+ {
+ Stay.Add(a_ChunkX + x, a_ChunkY, a_ChunkZ + z);
+ } // for z
+ } // for x
+ Stay.Enable();
+
+ m_World->LoadChunks(Stay);
+
CheckNeighbors(a_ChunkX, a_ChunkY, a_ChunkZ);
for (int i = 0; i < ARRAYCOUNT(g_NeighborCoords); i++)
{