the big refactor + extracted data classes from coders/json to data/dynamic

This commit is contained in:
MihailRis
2024-01-17 16:32:53 +03:00
parent 34d4500e24
commit 377c8e5029
36 changed files with 908 additions and 875 deletions
+1 -2
View File
@@ -4,7 +4,7 @@
#include <stdlib.h>
#include "../constants.h"
struct ChunkFlag{
struct ChunkFlag {
static const int MODIFIED = 0x1;
static const int READY = 0x2;
static const int LOADED = 0x4;
@@ -37,7 +37,6 @@ public:
Chunk* clone() const;
// flags getters/setters below
inline void setFlags(int mask, bool value){
if (value)
flags |= mask;
+1 -4
View File
@@ -22,7 +22,7 @@ Chunks::Chunks(int w, int d,
LevelEvents* events,
const Content* content)
: content(content),
contentIds(content->indices),
contentIds(content->getIndices()),
chunks(w*d),
chunksSecond(w*d),
w(w), d(d), ox(ox), oz(oz),
@@ -32,9 +32,6 @@ Chunks::Chunks(int w, int d,
chunksCount = 0;
}
Chunks::~Chunks(){
}
voxel* Chunks::get(int x, int y, int z){
x -= ox * CHUNK_W;
z -= oz * CHUNK_D;
+1 -1
View File
@@ -34,7 +34,7 @@ public:
Chunks(int w, int d, int ox, int oz,
WorldFiles* worldFiles, LevelEvents* events, const Content* content);
~Chunks();
~Chunks() = default;
bool putChunk(std::shared_ptr<Chunk> chunk);
+3 -6
View File
@@ -17,9 +17,6 @@
ChunksStorage::ChunksStorage(Level* level) : level(level) {
}
ChunksStorage::~ChunksStorage() {
}
void ChunksStorage::store(std::shared_ptr<Chunk> chunk) {
chunksMap[glm::ivec2(chunk->x, chunk->z)] = chunk;
}
@@ -61,7 +58,7 @@ std::shared_ptr<Chunk> ChunksStorage::create(int x, int z) {
if (data) {
chunk->decode(data.get());
chunk->setLoaded(true);
verifyLoadedChunk(level->content->indices, chunk.get());
verifyLoadedChunk(level->content->getIndices(), chunk.get());
}
light_t* lights = wfile->getLights(chunk->x, chunk->z);
@@ -75,7 +72,7 @@ std::shared_ptr<Chunk> ChunksStorage::create(int x, int z) {
// some magic code
void ChunksStorage::getVoxels(VoxelsVolume* volume, bool backlight) const {
const Content* content = level->content;
const ContentIndices* indices = content->indices;
auto indices = content->getIndices();
voxel* voxels = volume->getVoxels();
light_t* lights = volume->getLights();
int x = volume->getX();
@@ -115,7 +112,7 @@ void ChunksStorage::getVoxels(VoxelsVolume* volume, bool backlight) const {
}
}
} else {
const std::shared_ptr<Chunk>& chunk = found->second;
auto& chunk = found->second;
const voxel* cvoxels = chunk->voxels;
const light_t* clights = chunk->lightmap->getLights();
for (int ly = y; ly < y + h; ly++) {
+1 -1
View File
@@ -18,7 +18,7 @@ class ChunksStorage {
std::unordered_map<glm::ivec2, std::shared_ptr<Chunk>> chunksMap;
public:
ChunksStorage(Level* level);
virtual ~ChunksStorage();
~ChunksStorage() = default;
std::shared_ptr<Chunk> get(int x, int z) const;
void store(std::shared_ptr<Chunk> chunk);