From fad6f366b4a88eaa2b3f63c27e6e64deb94b1946 Mon Sep 17 00:00:00 2001 From: Quinn Date: Wed, 27 Aug 2025 11:41:31 +0200 Subject: [PATCH] fix: `mcx_delchunk` was not updating the byte offset of affected chunks. --- src/dat/mcx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/dat/mcx.c b/src/dat/mcx.c index d518cdc..5b7c062 100644 --- a/src/dat/mcx.c +++ b/src/dat/mcx.c @@ -14,6 +14,7 @@ void mcx_delchunk(u8 *restrict buf, int chunk) { u32 *table = (u32 *)buf; size_t bidx = (table[chunk] >> 8) * 0x1000; // compute the byte offset the chunk starts at size_t blen = (table[chunk] & 0xFF) * 0x1000; // compute the byte length of the chunk + size_t slen = (table[chunk] & 0xFF); // acquire the sector length of the chunk table[chunk] = 0; table[chunk + 0x400] = time(NULL); // assign the current time to the timestamp, for correctness NOTE: might need to zero-out instead @@ -23,8 +24,10 @@ void mcx_delchunk(u8 *restrict buf, int chunk) { // count the amount of bytes that we must move blen = 0; - for (chunk++; chunk < 0x400; chunk++) + for (chunk++; chunk < 0x400; chunk++) { blen += table[chunk] & 0xFF * 0x1000; + table[chunk] -= htobe32(slen << 8); + } memmove(head, tail, blen); }