Introduced Content, ContentIndices, no more integer ids hardcoded, common refactor
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "Chunks.h"
|
||||
#include "ChunksStorage.h"
|
||||
#include "WorldGenerator.h"
|
||||
#include "../content/Content.h"
|
||||
#include "../graphics/Mesh.h"
|
||||
#include "../lighting/Lighting.h"
|
||||
#include "../files/WorldFiles.h"
|
||||
@@ -26,10 +27,15 @@ using std::chrono::microseconds;
|
||||
|
||||
|
||||
ChunksController::ChunksController(Level* level, Chunks* chunks, Lighting* lighting, uint padding)
|
||||
: level(level), chunks(chunks), lighting(lighting), padding(padding) {
|
||||
: level(level),
|
||||
chunks(chunks),
|
||||
lighting(lighting),
|
||||
padding(padding),
|
||||
generator(new WorldGenerator(level->content)) {
|
||||
}
|
||||
|
||||
ChunksController::~ChunksController(){
|
||||
delete generator;
|
||||
}
|
||||
|
||||
void ChunksController::update(int64_t maxDuration) {
|
||||
@@ -50,6 +56,7 @@ void ChunksController::update(int64_t maxDuration) {
|
||||
}
|
||||
|
||||
bool ChunksController::loadVisible(){
|
||||
const Content* content = level->content;
|
||||
const int w = chunks->w;
|
||||
const int d = chunks->d;
|
||||
const int ox = chunks->ox;
|
||||
@@ -99,15 +106,16 @@ bool ChunksController::loadVisible(){
|
||||
chunks->putChunk(chunk);
|
||||
|
||||
if (!chunk->isLoaded()) {
|
||||
WorldGenerator::generate(chunk->voxels, chunk->x, chunk->z, level->world->seed);
|
||||
generator->generate(chunk->voxels, chunk->x, chunk->z, level->world->seed);
|
||||
chunk->setUnsaved(true);
|
||||
}
|
||||
|
||||
chunk->updateHeights();
|
||||
|
||||
ContentIndices* indices = content->indices;
|
||||
for (size_t i = 0; i < CHUNK_VOL; i++) {
|
||||
blockid_t id = chunk->voxels[i].id;
|
||||
if (Block::blocks[id] == nullptr) {
|
||||
if (indices->getBlockDef(id) == nullptr) {
|
||||
std::cout << "corruped block detected at " << i << " of chunk ";
|
||||
std::cout << chunk->x << "x" << chunk->z;
|
||||
std::cout << " -> " << (int)id << std::endl;
|
||||
|
||||
Reference in New Issue
Block a user