diff --git a/src/typedefs.h b/src/typedefs.h index 920015c6..ac519572 100644 --- a/src/typedefs.h +++ b/src/typedefs.h @@ -5,9 +5,12 @@ #include typedef unsigned int uint; -typedef unsigned char ubyte; + +// use for bytes arrays +typedef uint8_t ubyte; typedef uint8_t blockid_t; +typedef uint8_t blockstate_t; typedef uint16_t light_t; #endif diff --git a/src/voxels/ChunksStorage.cpp b/src/voxels/ChunksStorage.cpp index abdc65d1..082a17e5 100644 --- a/src/voxels/ChunksStorage.cpp +++ b/src/voxels/ChunksStorage.cpp @@ -14,22 +14,18 @@ #include "../lighting/Lightmap.h" #include "../typedefs.h" -using glm::ivec2; -using std::unique_ptr; -using std::shared_ptr; - ChunksStorage::ChunksStorage(Level* level) : level(level) { } ChunksStorage::~ChunksStorage() { } -void ChunksStorage::store(shared_ptr chunk) { - chunksMap[ivec2(chunk->x, chunk->z)] = chunk; +void ChunksStorage::store(std::shared_ptr chunk) { + chunksMap[glm::ivec2(chunk->x, chunk->z)] = chunk; } -shared_ptr ChunksStorage::get(int x, int z) const { - auto found = chunksMap.find(ivec2(x, z)); +std::shared_ptr ChunksStorage::get(int x, int z) const { + auto found = chunksMap.find(glm::ivec2(x, z)); if (found == chunksMap.end()) { return nullptr; } @@ -37,7 +33,7 @@ shared_ptr ChunksStorage::get(int x, int z) const { } void ChunksStorage::remove(int x, int z) { - auto found = chunksMap.find(ivec2(x, z)); + auto found = chunksMap.find(glm::ivec2(x, z)); if (found != chunksMap.end()) { chunksMap.erase(found->first); } @@ -46,9 +42,9 @@ void ChunksStorage::remove(int x, int z) { std::shared_ptr ChunksStorage::create(int x, int z) { World* world = level->world; - auto chunk = shared_ptr(new Chunk(x, z)); + auto chunk = std::shared_ptr(new Chunk(x, z)); store(chunk); - unique_ptr data(world->wfile->getChunk(chunk->x, chunk->z)); + std::unique_ptr data(world->wfile->getChunk(chunk->x, chunk->z)); if (data) { chunk->decode(data.get()); chunk->setLoaded(true); @@ -100,7 +96,7 @@ void ChunksStorage::getVoxels(VoxelsVolume* volume, bool backlight) const { // cw*ch chunks will be scanned for (int cz = scz; cz < scz + ch; cz++) { for (int cx = scx; cx < scx + cw; cx++) { - auto found = chunksMap.find(ivec2(cx, cz)); + auto found = chunksMap.find(glm::ivec2(cx, cz)); if (found == chunksMap.end()) { // no chunk loaded -> filling with BLOCK_VOID for (int ly = y; ly < y + h; ly++) { diff --git a/src/voxels/voxel.h b/src/voxels/voxel.h index 3ff51731..ded557f9 100644 --- a/src/voxels/voxel.h +++ b/src/voxels/voxel.h @@ -17,13 +17,13 @@ const int BLOCK_VARIANT_MASK = 0xF0; struct voxel { blockid_t id; - uint8_t states; + blockstate_t states; inline uint8_t rotation() const { return states & BLOCK_ROT_MASK; } - inline int8_t variant() const { + inline uint8_t variant() const { return (states & BLOCK_VARIANT_MASK) >> 4; } };