mirror of
https://github.com/thepigeongenerator/mcaselector-lite.git
synced 2025-12-17 06:15:47 +01:00
fix: mcx_delchunk was not updating the byte offset of affected chunks.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user