// Copyright 2023, FOSS-VG Developers and Contributers // // Author(s): // BodgeMaster // // This program is free software: you can redistribute it and/or modify it // under the terms of the GNU Affero General Public License as published // by the Free Software Foundation, version 3. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // See the GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // version 3 along with this program. // If not, see https://www.gnu.org/licenses/agpl-3.0.en.html // File structure: // 4K table of uint32_t: pointing to chunks // -> 24bit offset, 8 bit length // -> both offset and length are multiplied by 4096 to get the real value // -> lowest valid offset = 2 // -> chunk is not present if pointer=0 // -> chunk calculation: ((x % 32) + (z % 32) * 32) * 4 // -> what about negative chunks? // 4k table of uint32_t: last modified timestamps // individual chunks // -> 5 byte header // -> 4 byte length // -> 1 byte compression type: 0?? 1->gzip 2->zlib // -> extension idea: support for other compression algorithms // - lzma // - xz // - lz4 // - zstd // -> compressed NBT data #pragma once #include class Region { uint32_t storagePointers[1024]; uint32_t lastModifiedTimestamps[1024]; // Chunk coordinates are uint8_t here bc they are 0<=x<32. uint32_t* coordsToStoragePointer(uint8_t x, uint8_t z) { return &storagePointers[z*32 + x]; } // Chunk coordinates are uint8_t here bc they are 0<=x<32. uint32_t* coordsToLastModified(uint8_t x, uint8_t z) { return &lastModifiedTimestamps[z*32 + x]; } }