mirror of
https://github.com/thepigeongenerator/mcaselector-lite.git
synced 2025-12-18 09:45:45 +01:00
Compare commits
3 Commits
bc8803525d
...
5b5f1f54af
| Author | SHA1 | Date | |
|---|---|---|---|
| 5b5f1f54af | |||
| f1141e0db4 | |||
| 15942b47f5 |
@@ -14,7 +14,7 @@ static void mvchunks(u8 *restrict buf, u8 *src, u8 *dst, int src_s, int src_e) {
|
||||
assert(src > dst);
|
||||
u32 *table = (u32 *)buf;
|
||||
size_t len = src - dst; // acquire the amount of bytes that we shall move
|
||||
assert(len % 0x1000);
|
||||
assert(!(len % 0x1000));
|
||||
|
||||
// count how many bytes we need to move, whilst updating location data
|
||||
size_t blen = 0;
|
||||
@@ -69,7 +69,8 @@ size_t mcx_delchunk_range(u8 *restrict buf, int start, int end) {
|
||||
}
|
||||
|
||||
// move the remaining chunks down
|
||||
mvchunks(buf, src, dst, start, end);
|
||||
if (end < 0x3FF)
|
||||
mvchunks(buf, src, dst, end, 0x3FF);
|
||||
return src - dst;
|
||||
}
|
||||
|
||||
@@ -103,19 +104,3 @@ size_t mcx_calcsize(const u8 *restrict buf) {
|
||||
size += *(buf + (i * 4) + 3);
|
||||
return (size * 0x1000) + 0x2000;
|
||||
}
|
||||
|
||||
/* an `*.mcX` contains a `0x2000` byte long table, the first `0x1000` containing
|
||||
* `0x400` entries of chunk data.
|
||||
* This chunk data is big-endian, where bytes `0xFFFFFF00` represent the `0x1000` sector offset.
|
||||
* From the start, and bytes `0x000000FF` represent the length in `0x1000` sectors. */
|
||||
void mcx_index(const u8 *restrict buf, struct mcx_chunk *restrict chunks) {
|
||||
const u32 *ptr = (u32 *)buf;
|
||||
for (uint i = 0; i < 0x400; i++) {
|
||||
u32 dat = be32toh(ptr[i]);
|
||||
chunks[i] = (struct mcx_chunk){
|
||||
.idx = (dat >> 8) * 0x1000,
|
||||
.len = (dat & 0xFF) * 0x1000,
|
||||
.time = be32toh(ptr[i + 0x400]),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,22 +35,3 @@ size_t mcx_delchunk_bulk(u8 *restrict buf, const u16 *restrict chunks, int chunk
|
||||
|
||||
/* Computes the byte size of the `*.mcX` file in `buf` and returns it. */
|
||||
size_t mcx_calcsize(const u8 *restrict buf) NONNULL((1)) PURE;
|
||||
|
||||
/* indexes the chunks in an `*.mcX` file, writing `0x400` of entries to `chunks` */
|
||||
void mcx_index(const u8 *restrict buf, struct mcx_chunk *restrict chunks) NONNULL((1, 2));
|
||||
|
||||
/* the MCR (Minecraft region) and MCA (Minecraft anvil) files are similar
|
||||
* MCA is the newer variant, where it includes:
|
||||
* - a world height of 256, rather than 128.
|
||||
* - block IDs have been extended to 4096 from 256
|
||||
* - block ordering is now YZX, rather than XZY.
|
||||
* - biomes are included in the data per XZ column.
|
||||
* MCR start with an 8KiB header, split in two 4KiB tables
|
||||
* - the first containing the offsets of chunks in the region file itself.
|
||||
* - the second providing timestamps on when they were last updated.
|
||||
* -
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user