this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

move mapfs chain pointer to decompressedLength field

Previously, END DATA's offset field served dual purpose: 0 for end-of-chain,
or address for next table. Now offset always contains the TOC size (used for
buffer allocation), and chain links are in decompressedLength field.

This eliminates special-case handling for empty archives - both empty and
non-empty archives use the first entry's offset for TOC size.

+7 -4
+7 -4
src/main/java/assets/archive/AssetsArchiveBuilder.kt
··· 9 9 * Binary format: 10 10 * - Header (32 bytes): Magic "MAPFS " + project name (16 bytes) + reserved (10 bytes) 11 11 * - Table of Contents: 76-byte entries (name + offset + compressedSize + decompressedSize) 12 - * - Sentinel Entry: "END DATA\0" + next-node offset (0 = end of chain) 12 + * - Sentinel Entry: "END DATA\0" + TOC size + 0 + next-node offset (0 = end of chain) 13 13 * - Asset Data: Compressed (Yay0) or raw binary data 14 + * 15 + * Note: The sentinel's offset field contains the TOC size, allowing proper buffer allocation 16 + * even for empty archives. The chain pointer is in the decompressedLength field. 14 17 */ 15 18 class AssetsArchiveBuilder(private val projectName: String) { 16 19 private val entries = mutableListOf<AssetsArchiveEntry>() ··· 115 118 buffer.put(sentinelBytes) 116 119 buffer.put(ByteArray(64 - sentinelBytes.size)) // Null padding 117 120 118 - // Next-node offset (4 bytes): 0 = end of chain 119 - buffer.putInt(0) 121 + // Offset (4 bytes): TOC size (used for allocating buffer) 122 + buffer.putInt(tocSize) 120 123 121 124 // Compressed size (4 bytes): 0 122 125 buffer.putInt(0) 123 126 124 - // Decompressed size (4 bytes): 0 127 + // Decompressed size (4 bytes): next-node offset (0 = end of chain) 125 128 buffer.putInt(0) 126 129 } 127 130