[DiscordArchive] Is there a program to remove missing models/eff...
[DiscordArchive] Is there a program to remove missing models/eff...
Archived author: Drikish • Posted: 2024-11-22T03:07:36.303000+00:00
Original source
```js
while (reader.leftPointer < reader.buffer.length) {
// Read Chunk Name then progress
chunkName = reader.readBytesAsString(4);
reader.progressPointer(4); // Move beyond chunk name
chunkSize = reader.readChunkSize();
reader.progressPointer(4); // Move beyond chunk Size
// Hold info about the chunk data start and end
const chunkDataEnd = reader.leftPointer + chunkSize;
// -- Start ---
// If the chunk is not KNCM then move on
if (chunkName !== 'KNCM') {
if (chunkName === 'XETM' && mtexFound === false) { // If its the MTEX Chunk and we haven't found it yet
let currentString = '';
let stringCounter = 0;
const mtexChunkEnd = reader.leftPointer + chunkSize;
while (reader.leftPointer < mtexChunkEnd) {
let b = reader.readByte();
reader.progressPointer(1); // Move One Byte forward for next round
if (b === 0x00) {
textureTable.set(stringCounter, currentString); // Store the string in the map with the counter
currentString = ''; // Reset the string for the next entry
stringCounter++; // Increment the string counter
} else {
currentString += String.fromCharCode(b);
}
}
mtexFound = true;
} else {
reader.progressPointer(chunkSize)
}
}
```
Archived author: Drikish • Posted: 2024-11-22T03:07:40.865000+00:00
Original source
```js
// If its a MCNK sub-chunk
if (chunkName === "KNCM") { // Were 8 bytes in at this point after reading chunk and size
// console.log(`Inside: ${chunkName} at position - ${reader.getPointerPosition()}`)
while (reader.leftPointer < chunkDataEnd) { // Sub-Chunks start straight after the MCNK chunk
const subChunkName = reader.readBytesAsString(4);
reader.progressPointer(4);
const subChunkSize = reader.readChunkSize();
reader.progressPointer(4);
const subChunkEnd = reader.leftPointer + subChunkSize;
if (subChunkName !== 'YLCM') {
reader.progressPointer(subChunkSize);
continue;
}
if (subChunkName === 'YLCM') { // Were 8 bytes in at this point after reading chunk and size
const layerCount = subChunkSize / 16; // Up to 4 layers, each is 16 bytes, see how many 16 bytes we have...
// Loop through the layers 16 bytes
for (let index = 0; index < layerCount; index++) {
const textureReferenceId = reader.readChunkSize(); // First 4 bytes is integer of the texture reference
// console.log("Texture: " + textureReferenceId)
reader.progressPointer(12); // Skip 12 bytes, first 4 for above and 8 we ignore
// This is the ground effect ID to change
// const currentGroundEffectId = reader.readChunkSize();
const textureName = textureTable.get(textureReferenceId)
const newGroundEffectsId = this.config.groundEffectsMap.get(textureName)
if (newGroundEffectsId) {
// console.log(textureName)
// console.log(newGroundEffectsId)
// if ID Doesn't exist then don't bother writing anything in
reader.writeChunkSize(newGroundEffectsId)
} else {
reader.writeChunkSize(0) // Write 0 into this because we dont have a reference ground effect id in DBC
}
// console.log("Original: " + currentGroundEffectId)
// const updatedGroundEffectsID = reader.readChunkSize();
// console.log("New: " + updatedGroundEffectsID)
reader.progressPointer(4) // Move to end of the 16 bytes to start next layer
}
// Move reader to end of the chunk safely
reader.movePointerToOffset(subChunkEnd);
}
} // End of sub-chunk while
// Move to End of main chunk to start checking next main chunk
reader.movePointerToOffset(chunkDataEnd)
}
} // end of main chunk while
```
Archived author: Drikish • Posted: 2024-11-22T03:08:28.032000+00:00
Original source
Not exactly a graceful way of handling it as I don't have a library to parse the files so doing it manually but it works a charm and takes milliseconds
Archived author: Drikish • Posted: 2024-11-22T03:08:53.631000+00:00
Original source
I base it off the GE_Data that exists the big JSON file
Archived author: Drikish • Posted: 2024-11-22T03:09:06.898000+00:00
Original source
and I ported down the DBC's for ground effects from retail so there are values for every texture
Archived author: SleepyPasta • Posted: 2024-11-23T02:05:38.284000+00:00
Original source
Thank you, I finally got it to work