refactor: WorldRegions and chunks saving

This commit is contained in:
MihailRis
2024-06-07 14:04:25 +03:00
parent f206042b00
commit c67e4b04bb
8 changed files with 50 additions and 45 deletions
+7 -4
View File
@@ -113,8 +113,11 @@ bool Chunk::decode(const ubyte* data) {
ubyte bst1 = data[CHUNK_VOL*2 + i];
ubyte bst2 = data[CHUNK_VOL*3 + i];
vox.id = (blockid_t(bid1) << 8) | (blockid_t(bid2));
vox.state = int2blockstate((blockstate_t(bst1) << 8) | (blockstate_t(bst2)));
vox.id = (static_cast<blockid_t>(bid1) << 8) |
static_cast<blockid_t>(bid2);
vox.state = int2blockstate(
(static_cast<blockstate_t>(bst1) << 8) |
static_cast<blockstate_t>(bst2));
}
return true;
}
@@ -122,8 +125,8 @@ bool Chunk::decode(const ubyte* data) {
void Chunk::convert(ubyte* data, const ContentLUT* lut) {
for (uint i = 0; i < CHUNK_VOL; i++) {
// see encode method to understand what the hell is going on here
blockid_t id = ((blockid_t(data[i]) << 8) |
blockid_t(data[CHUNK_VOL+i]));
blockid_t id = ((static_cast<blockid_t>(data[i]) << 8) |
static_cast<blockid_t>(data[CHUNK_VOL+i]));
blockid_t replacement = lut->getBlockId(id);
data[i] = replacement >> 8;
data[CHUNK_VOL+i] = replacement & 0xFF;