Revert "feat: Feat/expanded worlds (#107)"

This reverts commit 98c33aa677.
This commit is contained in:
pieeebot
2026-05-25 21:06:22 +03:00
parent 4d745ab65c
commit cd50236b8a
7 changed files with 19 additions and 43 deletions

View File

@@ -15,8 +15,8 @@ MultiPlayerChunkCache::MultiPlayerChunkCache(Level *level)
XZSIZE = level->dimension->getXZSize(); // 4J Added
XZOFFSET = XZSIZE/2; // 4J Added
m_XZSize = XZSIZE;
hasData = new bool[LEVEL_MIN_WIDTH * LEVEL_MIN_WIDTH];
memset(hasData, 0, sizeof(bool) * LEVEL_MIN_WIDTH * LEVEL_MIN_WIDTH);
hasData = new bool[XZSIZE * XZSIZE];
memset(hasData, 0, sizeof(bool) * XZSIZE * XZSIZE);
emptyChunk = new EmptyLevelChunk(level, byteArray(16 * 16 * Level::maxBuildHeight), 0, 0);
@@ -93,8 +93,8 @@ MultiPlayerChunkCache::MultiPlayerChunkCache(Level *level)
this->level = level;
this->cache = new LevelChunk *[LEVEL_MIN_WIDTH * LEVEL_MIN_WIDTH];
memset(this->cache, 0, sizeof(LevelChunk*) * LEVEL_MIN_WIDTH * LEVEL_MIN_WIDTH);
this->cache = new LevelChunk *[XZSIZE * XZSIZE];
memset(this->cache, 0, XZSIZE * XZSIZE * sizeof(LevelChunk *));
InitializeCriticalSectionAndSpinCount(&m_csLoadCreate,4000);
}
@@ -129,11 +129,10 @@ bool MultiPlayerChunkCache::reallyHasChunk(int x, int z)
// Check we're in range of the stored level - if we aren't, then consider that we do have that chunk as we'll be able to use the water chunk there
if( ( ix < 0 ) || ( ix >= XZSIZE ) ) return true;
if( ( iz < 0 ) || ( iz >= XZSIZE ) ) return true;
int idx = wrapCoord(x, LEVEL_MIN_WIDTH) * LEVEL_MIN_WIDTH + wrapCoord(z, LEVEL_MIN_WIDTH);
int idx = ix * XZSIZE + iz;
LevelChunk *chunk = cache[idx];
if (chunk == nullptr || chunk->x != x || chunk->z != z)
if( chunk == nullptr )
{
return false;
}
@@ -146,11 +145,10 @@ void MultiPlayerChunkCache::drop(const int x, const int z)
const int iz = z + XZOFFSET;
if ((ix < 0) || (ix >= XZSIZE)) return;
if ((iz < 0) || (iz >= XZSIZE)) return;
int idx = wrapCoord(x, LEVEL_MIN_WIDTH) * LEVEL_MIN_WIDTH + wrapCoord(z, LEVEL_MIN_WIDTH);
const int idx = ix * XZSIZE + iz;
LevelChunk* chunk = cache[idx];
if (chunk != nullptr && !chunk->isEmpty() && chunk->x == x && chunk->z == z)
if (chunk != nullptr && !chunk->isEmpty())
{
// Drop entities in the chunks, especially for the case when a player is dead
// as they will not get the RemoveEntity packet if an entity is removed.
@@ -170,12 +168,11 @@ LevelChunk *MultiPlayerChunkCache::create(int x, int z)
// Check we're in range of the stored level
if( ( ix < 0 ) || ( ix >= XZSIZE ) ) return ( waterChunk ? waterChunk : emptyChunk );
if( ( iz < 0 ) || ( iz >= XZSIZE ) ) return ( waterChunk ? waterChunk : emptyChunk );
int idx = wrapCoord(x, LEVEL_MIN_WIDTH) * LEVEL_MIN_WIDTH + wrapCoord(z, LEVEL_MIN_WIDTH);
int idx = ix * XZSIZE + iz;
LevelChunk *chunk = cache[idx];
LevelChunk *lastChunk = chunk;
if( chunk == nullptr || chunk->x != x || chunk->z != z )
if( chunk == nullptr )
{
EnterCriticalSection(&m_csLoadCreate);
@@ -254,10 +251,10 @@ LevelChunk *MultiPlayerChunkCache::getChunk(int x, int z)
// Check we're in range of the stored level
if( ( ix < 0 ) || ( ix >= XZSIZE ) ) return ( waterChunk ? waterChunk : emptyChunk );
if( ( iz < 0 ) || ( iz >= XZSIZE ) ) return ( waterChunk ? waterChunk : emptyChunk );
int idx = wrapCoord(x, LEVEL_MIN_WIDTH) * LEVEL_MIN_WIDTH + wrapCoord(z, LEVEL_MIN_WIDTH);
int idx = ix * XZSIZE + iz;
LevelChunk *chunk = cache[idx];
if( chunk == nullptr || chunk->x != x || chunk->z != z )
if( chunk == nullptr )
{
return emptyChunk;
}
@@ -316,6 +313,6 @@ void MultiPlayerChunkCache::dataReceived(int x, int z)
// Check we're in range of the stored level
if( ( ix < 0 ) || ( ix >= XZSIZE ) ) return;
if( ( iz < 0 ) || ( iz >= XZSIZE ) ) return;
int idx = wrapCoord(x, LEVEL_MIN_WIDTH) * LEVEL_MIN_WIDTH + wrapCoord(z, LEVEL_MIN_WIDTH);
int idx = ix * XZSIZE + iz;
hasData[idx] = true;
}