Remove debug logs
This commit is contained in:
parent
99af2f53e5
commit
fa71f5771e
15
index.js
15
index.js
@ -65,23 +65,20 @@ async function replace() {
|
|||||||
|
|
||||||
// Read .mogg
|
// Read .mogg
|
||||||
const mogg_buffer = await readFile(`mogg_output/${mogg_file}`);
|
const mogg_buffer = await readFile(`mogg_output/${mogg_file}`);
|
||||||
console.log('Mogg', mogg_buffer);
|
|
||||||
|
|
||||||
// Modify .uexp
|
// Modify .uexp
|
||||||
const data_buffer = await readFile(`game_input/${game_file}.uexp`);
|
const data_buffer = await readFile(`game_input/${game_file}.uexp`);
|
||||||
const old_uexp_length = data_buffer.length;
|
const old_uexp_length = data_buffer.length;
|
||||||
|
|
||||||
|
// Get the start offset by getting the first index of MoggSampleResource, then offset by 19
|
||||||
const start_offset = data_buffer.indexOf('MoggSampleResource') + 19;
|
const start_offset = data_buffer.indexOf('MoggSampleResource') + 19;
|
||||||
console.log('uexp', data_buffer);
|
|
||||||
console.log('uexp length', old_uexp_length);
|
|
||||||
|
|
||||||
// Write new MOGG Buffer length + 32 to offset start_offset
|
// Write new MOGG Buffer length + 32 to offset start_offset
|
||||||
data_buffer.writeInt32LE(mogg_buffer.length + 32, start_offset);
|
data_buffer.writeInt32LE(mogg_buffer.length + 32, start_offset);
|
||||||
|
|
||||||
// Write new MOGG Buffer length to offset start_offset + 36, store old for buffering
|
// Write new MOGG Buffer length to offset start_offset + 36, store old for buffering
|
||||||
const old_1_length = data_buffer.readInt32LE(start_offset + 36);
|
const old_1_length = data_buffer.readInt32LE(start_offset + 36);
|
||||||
console.log("Old 1 length", old_1_length);
|
|
||||||
data_buffer.writeInt32LE(mogg_buffer.length, start_offset + 36);
|
data_buffer.writeInt32LE(mogg_buffer.length, start_offset + 36);
|
||||||
console.log("New 1 length", data_buffer.readInt32LE(start_offset + 36));
|
|
||||||
|
|
||||||
// Insert MOGG at start_offset + 36 + 4, then offset to the new position
|
// Insert MOGG at start_offset + 36 + 4, then offset to the new position
|
||||||
const pre_buffer_1 = data_buffer.slice(0, start_offset + 36 + 4);
|
const pre_buffer_1 = data_buffer.slice(0, start_offset + 36 + 4);
|
||||||
@ -94,20 +91,16 @@ async function replace() {
|
|||||||
let final_buffer = song_1_insert_buffer;
|
let final_buffer = song_1_insert_buffer;
|
||||||
const filenameLength = final_buffer.readInt16LE(28);
|
const filenameLength = final_buffer.readInt16LE(28);
|
||||||
const numResourceFiles = final_buffer.readInt16LE(28 + filenameLength + 12);
|
const numResourceFiles = final_buffer.readInt16LE(28 + filenameLength + 12);
|
||||||
console.log(final_buffer.length);
|
|
||||||
if (numResourceFiles === 3) {
|
if (numResourceFiles === 3) {
|
||||||
|
// Get the start offset by getting the first index of MoggSampleResource after our mogg_buffer, then offset by 19
|
||||||
const new_offset = song_1_insert_buffer.indexOf('MoggSampleResource', mogg_buffer.length) + 19;
|
const new_offset = song_1_insert_buffer.indexOf('MoggSampleResource', mogg_buffer.length) + 19;
|
||||||
console.log("New Offset", new_offset);
|
|
||||||
console.log("InsertBufferLength", song_1_insert_buffer.length);
|
|
||||||
|
|
||||||
// Write new MOGG Buffer length + 32 to offset new_offset
|
// Write new MOGG Buffer length + 32 to offset new_offset
|
||||||
song_1_insert_buffer.writeInt32LE(mogg_buffer.length + 32, new_offset);
|
song_1_insert_buffer.writeInt32LE(mogg_buffer.length + 32, new_offset);
|
||||||
|
|
||||||
// Write new MOGG Buffer length to offset new_offset + 36, store old for buffering
|
// Write new MOGG Buffer length to offset new_offset + 36, store old for buffering
|
||||||
const old_2_length = song_1_insert_buffer.readInt32LE(new_offset + 36);
|
const old_2_length = song_1_insert_buffer.readInt32LE(new_offset + 36);
|
||||||
console.log("Old 2 length", old_2_length);
|
|
||||||
song_1_insert_buffer.writeInt32LE(mogg_buffer.length, new_offset + 36);
|
song_1_insert_buffer.writeInt32LE(mogg_buffer.length, new_offset + 36);
|
||||||
console.log("New 2 length", song_1_insert_buffer.readInt32LE(new_offset + 36));
|
|
||||||
|
|
||||||
// Insert MOGG at new_offset + 36 + 4, then offset to the new position
|
// Insert MOGG at new_offset + 36 + 4, then offset to the new position
|
||||||
const pre_buffer_2 = song_1_insert_buffer.slice(0, new_offset + 36 + 4);
|
const pre_buffer_2 = song_1_insert_buffer.slice(0, new_offset + 36 + 4);
|
||||||
@ -122,10 +115,8 @@ async function replace() {
|
|||||||
|
|
||||||
// Modify .uasset
|
// Modify .uasset
|
||||||
const uasset_buffer = await readFile(`game_input/${game_file}.uasset`);
|
const uasset_buffer = await readFile(`game_input/${game_file}.uasset`);
|
||||||
console.log('Uassetbuffer', uasset_buffer);
|
|
||||||
|
|
||||||
const update_size_offset = uasset_buffer.lastIndexOf(old_uexp_length - 4);
|
const update_size_offset = uasset_buffer.lastIndexOf(old_uexp_length - 4);
|
||||||
console.log("Update size offset", update_size_offset);
|
|
||||||
uasset_buffer.writeInt32LE(final_buffer.length - 4, update_size_offset);
|
uasset_buffer.writeInt32LE(final_buffer.length - 4, update_size_offset);
|
||||||
|
|
||||||
// Finally, write
|
// Finally, write
|
||||||
|
Loading…
Reference in New Issue
Block a user