FIX: compilation

This commit is contained in:
2026-05-02 21:31:48 +03:00
parent de72a9a3b7
commit 3e48c7fabd
8 changed files with 33 additions and 23 deletions

View File

@@ -560,8 +560,8 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& source, ChunkDat
int rx = packet->x << 4;
int rz = packet->z << 4;
unsigned char readBlockBuffer[setSize];
unsigned char readDataBuffer[setSize / 2];
unsigned char* readBlockBuffer = new unsigned char[setSize];
unsigned char* readDataBuffer = new unsigned char[setSize / 2];
for (int i = 0; i < LevelConstants::CHUNK_COLUMNS; i++)
{
@@ -631,6 +631,9 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& source, ChunkDat
}
}
delete[] readBlockBuffer;
delete[] readDataBuffer;
if (recalcHeight)
{
// chunk->recalcHeightmap();

View File

@@ -29,6 +29,9 @@
#include "../Difficulty.h"
#include "../../network/packet/ExplodePacket.h"
const int Level::DEPTH = LevelConstants::LEVEL_HEIGHT;
const int Level::SEA_LEVEL = Level::DEPTH / 2 - 1;
Level::Level(LevelStorage* levelStorage, const std::string& levelName, const LevelSettings& settings, int generatorVersion, Dimension* fixedDimension /* = NULL */)
: levelStorage(levelStorage),
isClientSide(false),

View File

@@ -67,8 +67,8 @@ class Level: public LevelSource
public:
static const int MAX_LEVEL_SIZE = 32000000;
const short DEPTH = LevelConstants::LEVEL_HEIGHT;
const short SEA_LEVEL = DEPTH / 2 - 1;
static const int DEPTH;
static const int SEA_LEVEL;
static const int MAX_BRIGHTNESS = 15;
static const int TICKS_PER_DAY = SharedConstants::TicksPerSecond * 60 * 16;// SharedConstants::TicksPerSecond * 60 * 12; // ORG:20*60*20

View File

@@ -1,7 +1,10 @@
#include "LevelConstants.h"
int LevelConstants::LEVEL_HEIGHT = 128;
int LevelConstants::CHUNK_CACHE_WIDTH = 16; // in chunks
int LevelConstants::CHUNK_WIDTH = 16; // in blocks
int LevelConstants::CHUNK_DEPTH = 16;
int LevelConstants::LEVEL_WIDTH = LevelConstants::CHUNK_CACHE_WIDTH * CHUNK_WIDTH;
int LevelConstants::LEVEL_DEPTH = LevelConstants::CHUNK_CACHE_WIDTH * CHUNK_DEPTH;
int LevelConstants::CHUNK_COLUMNS = LevelConstants::CHUNK_WIDTH * LevelConstants::CHUNK_DEPTH;
int LevelConstants::CHUNK_BLOCK_COUNT = LevelConstants::CHUNK_COLUMNS * LevelConstants::LEVEL_HEIGHT;

View File

@@ -5,8 +5,8 @@ public:
static int CHUNK_CACHE_WIDTH; // in chunks
static int LEVEL_WIDTH;
static int LEVEL_DEPTH;
static int LEVEL_HEIGHT;
static int CHUNK_WIDTH; // in blocks
static int CHUNK_DEPTH;
static int CHUNK_COLUMNS;

View File

@@ -25,7 +25,7 @@ public:
//emptyChunk = new EmptyLevelChunk(level_, emptyChunkBlocks, 0, 0);
emptyChunk = new EmptyLevelChunk(level_, NULL, 0, 0);
chunks = (LevelChunk *)malloc(LevelConstants::CHUNK_CACHE_WIDTH * LevelConstants::CHUNK_CACHE_WIDTH);
chunks = new LevelChunk *[LevelConstants::CHUNK_CACHE_WIDTH * LevelConstants::CHUNK_CACHE_WIDTH];
}
~ChunkCache() {
@@ -36,8 +36,8 @@ public:
{
if (&chunks[i])
{
chunks[i].deleteBlockData();
delete &chunks[i];
chunks[i]->deleteBlockData();
delete chunks[i];
}
}
}
@@ -56,7 +56,7 @@ public:
int xs = x & (LevelConstants::CHUNK_CACHE_WIDTH - 1);
int zs = z & (LevelConstants::CHUNK_CACHE_WIDTH - 1);
int slot = xs + zs * LevelConstants::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) {
@@ -76,10 +76,10 @@ public:
int zs = z & (LevelConstants::CHUNK_CACHE_WIDTH - 1);
int slot = xs + zs * LevelConstants::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);
@@ -94,7 +94,7 @@ public:
//return emptyChunk;
updateLights = true;
}
chunks[slot] = *newChunk;
chunks[slot] = newChunk;
newChunk->lightLava();
if (updateLights)
@@ -115,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) {
@@ -255,7 +255,7 @@ private:
LevelChunk* emptyChunk;
ChunkSource* source;
ChunkStorage* storage;
LevelChunk* chunks;
LevelChunk** chunks;
Level* level;
LevelChunk* last;

View File

@@ -12,6 +12,7 @@
/*static*/
bool LevelChunk::touchedSky = false;
const int LevelChunk::ChunkBlockCount = LevelConstants::CHUNK_BLOCK_COUNT;
LevelChunk::LevelChunk( Level* level, int x, int z )
: level(level),
@@ -45,8 +46,8 @@ LevelChunk::~LevelChunk()
void LevelChunk::init()
{
heightmap = (char*)malloc(LevelConstants::CHUNK_COLUMNS * sizeof(char));
updateMap = (unsigned char*)malloc(LevelConstants::CHUNK_COLUMNS * sizeof(unsigned char));
heightmap = new char[LevelConstants::CHUNK_COLUMNS];
updateMap = new unsigned char[LevelConstants::CHUNK_COLUMNS];
terrainPopulated = false;
dontSave = false;

View File

@@ -106,7 +106,7 @@ private:
void recalcHeight(int x, int yStart, int z);
public:
static bool touchedSky;
const int ChunkBlockCount = LevelConstants::CHUNK_BLOCK_COUNT;
static const int ChunkBlockCount;
const int ChunkSize = ChunkBlockCount;
static const int UpdateMapBitShift = 4; // power of (LevelConstants::LEVEL_HEIGHT / 8) == 16