forked from Kolyah35/minecraft-pe-0.6.1
eeee it doesnt work 😭
This commit is contained in:
@@ -1,14 +1,10 @@
|
||||
#ifndef _MINECRAFT_WORLD_LEVELCONSTANTS_H_
|
||||
#define _MINECRAFT_WORLD_LEVELCONSTANTS_H_
|
||||
|
||||
#pragma once
|
||||
|
||||
const int LEVEL_HEIGHT = 128;
|
||||
const int CHUNK_CACHE_WIDTH = 16; // in chunks
|
||||
int CHUNK_CACHE_WIDTH = 16; // in chunks
|
||||
const int CHUNK_WIDTH = 16; // in blocks
|
||||
const int CHUNK_DEPTH = 16;
|
||||
const int LEVEL_WIDTH = CHUNK_CACHE_WIDTH * CHUNK_WIDTH;
|
||||
const int LEVEL_DEPTH = CHUNK_CACHE_WIDTH * CHUNK_DEPTH;
|
||||
int LEVEL_WIDTH = CHUNK_CACHE_WIDTH * CHUNK_WIDTH;
|
||||
int LEVEL_DEPTH = CHUNK_CACHE_WIDTH * CHUNK_DEPTH;
|
||||
const int CHUNK_COLUMNS = CHUNK_WIDTH * CHUNK_DEPTH;
|
||||
const int CHUNK_BLOCK_COUNT = CHUNK_COLUMNS * LEVEL_HEIGHT;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -24,7 +24,8 @@ public:
|
||||
isChunkCache = true;
|
||||
//emptyChunk = new EmptyLevelChunk(level_, emptyChunkBlocks, 0, 0);
|
||||
emptyChunk = new EmptyLevelChunk(level_, NULL, 0, 0);
|
||||
memset(chunks, 0, sizeof(LevelChunk*) * CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH);
|
||||
|
||||
chunks = (LevelChunk *)malloc(CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH);
|
||||
}
|
||||
|
||||
~ChunkCache() {
|
||||
@@ -33,10 +34,10 @@ public:
|
||||
|
||||
for (int i = 0; i < CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH; i++)
|
||||
{
|
||||
if (chunks[i])
|
||||
if (&chunks[i])
|
||||
{
|
||||
chunks[i]->deleteBlockData();
|
||||
delete chunks[i];
|
||||
chunks[i].deleteBlockData();
|
||||
delete &chunks[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,7 +56,7 @@ public:
|
||||
int xs = x & (CHUNK_CACHE_WIDTH - 1);
|
||||
int zs = z & (CHUNK_CACHE_WIDTH - 1);
|
||||
int slot = xs + zs * CHUNK_CACHE_WIDTH;
|
||||
return chunks[slot] != NULL && (chunks[slot] == emptyChunk || chunks[slot]->isAt(x, z));
|
||||
return &chunks[slot] != NULL && (&chunks[slot] == emptyChunk || chunks[slot].isAt(x, z));
|
||||
}
|
||||
|
||||
LevelChunk* create(int x, int z) {
|
||||
@@ -75,10 +76,10 @@ public:
|
||||
int zs = z & (CHUNK_CACHE_WIDTH - 1);
|
||||
int slot = xs + zs * CHUNK_CACHE_WIDTH;
|
||||
if (!hasChunk(x, z)) {
|
||||
if (chunks[slot] != NULL) {
|
||||
chunks[slot]->unload();
|
||||
save(chunks[slot]);
|
||||
saveEntities(chunks[slot]);
|
||||
if (&chunks[slot] != NULL) {
|
||||
chunks[slot].unload();
|
||||
save(&chunks[slot]);
|
||||
saveEntities(&chunks[slot]);
|
||||
}
|
||||
|
||||
LevelChunk* newChunk = load(x, z);
|
||||
@@ -93,7 +94,7 @@ public:
|
||||
//return emptyChunk;
|
||||
updateLights = true;
|
||||
}
|
||||
chunks[slot] = newChunk;
|
||||
chunks[slot] = *newChunk;
|
||||
newChunk->lightLava();
|
||||
|
||||
if (updateLights)
|
||||
@@ -114,23 +115,23 @@ public:
|
||||
//level->updateLight(LightLayer::Block, x * 16, 0, z * 16, x * 16 + 15, 128, z * 16 + 15);
|
||||
}
|
||||
|
||||
if (chunks[slot] != NULL) {
|
||||
chunks[slot]->load();
|
||||
if (&chunks[slot] != NULL) {
|
||||
chunks[slot].load();
|
||||
}
|
||||
|
||||
if (!chunks[slot]->terrainPopulated && hasChunk(x + 1, z + 1) && hasChunk(x, z + 1) && hasChunk(x + 1, z)) postProcess(this, x, z);
|
||||
if (!chunks[slot].terrainPopulated && hasChunk(x + 1, z + 1) && hasChunk(x, z + 1) && hasChunk(x + 1, z)) postProcess(this, x, z);
|
||||
if (hasChunk(x - 1, z) && !getChunk(x - 1, z)->terrainPopulated && hasChunk(x - 1, z + 1) && hasChunk(x, z + 1) && hasChunk(x - 1, z)) postProcess(this, x - 1, z);
|
||||
if (hasChunk(x, z - 1) && !getChunk(x, z - 1)->terrainPopulated && hasChunk(x + 1, z - 1) && hasChunk(x, z - 1) && hasChunk(x + 1, z)) postProcess(this, x, z - 1);
|
||||
if (hasChunk(x - 1, z - 1) && !getChunk(x - 1, z - 1)->terrainPopulated && hasChunk(x - 1, z - 1) && hasChunk(x, z - 1) && hasChunk(x - 1, z)) postProcess(this, x - 1, z - 1);
|
||||
}
|
||||
xLast = x;
|
||||
zLast = z;
|
||||
last = chunks[slot];
|
||||
last = &chunks[slot];
|
||||
|
||||
//sw.stop();
|
||||
//sw.printEvery(500000, "ChunkCache::load: ");
|
||||
|
||||
return chunks[slot];
|
||||
return &chunks[slot];
|
||||
}
|
||||
|
||||
Biome::MobList getMobsAt(const MobCategory& mobCategory, int x, int y, int z) {
|
||||
@@ -254,7 +255,7 @@ private:
|
||||
LevelChunk* emptyChunk;
|
||||
ChunkSource* source;
|
||||
ChunkStorage* storage;
|
||||
LevelChunk* chunks[CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH];
|
||||
LevelChunk* chunks;
|
||||
Level* level;
|
||||
|
||||
LevelChunk* last;
|
||||
|
||||
@@ -122,8 +122,8 @@ public:
|
||||
unsigned char updateMap[CHUNK_COLUMNS]; // marks regions within block columns that have been modified
|
||||
int minHeight;
|
||||
|
||||
const int x, z;
|
||||
const int xt, zt;
|
||||
int x, z;
|
||||
int xt, zt;
|
||||
|
||||
bool terrainPopulated;
|
||||
bool unsaved;
|
||||
|
||||
Reference in New Issue
Block a user