Skip to content

Commit

Permalink
Merge pull request #20 from bgreenfield1802/main
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberGiant7 authored Jun 29, 2024
2 parents 7a3be3b + d7ff25d commit 5c36c64
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions assets/js/script.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
const fileSelector = document.getElementById("savefile");
let pattern = new Uint8Array([
255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
]);
// let pattern = new Uint8Array([
// 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
// ]);
const pattern = new Uint8Array([176, 173, 1, 0, 1, 255, 255, 255]);
const pattern_dlc = new Uint8Array([176, 173, 1, 0, 1]);
let isDlcFile = false;

let file_read = null;
let inventory = null;
Expand Down Expand Up @@ -141,7 +144,11 @@ function buffer_equal(buf1, buf2) {
}

function getInventory(slot) {
index = subfinder(slot, pattern) + pattern.byteLength + 56;
index = subfinder(slot, pattern) + pattern.byteLength + 8
if (!index) {
index = subfinder(slot, pattern_dlc) + pattern_dlc.byteLength + 3
isDlcFile = true
}
index1 = subfinder(slot.subarray(index, slot.byteLength), new Uint8Array(50).fill(0)) + index + 6;
return slot.subarray(index, index1);
}
Expand Down Expand Up @@ -179,7 +186,7 @@ function getOwnedAndNot(file_read, selected_slot) {
let saves_array = new Uint8Array(file_read);
let slots = get_slot_ls(saves_array);
let inventory = Array.from(getInventory(slots[selected_slot]));
let id_list = split(inventory, 16);
let id_list = split(inventory, isDlcFile ? 8 : 16)
id_list.forEach((raw_id, index) => (id_list[index] = getIdReversed(raw_id).toUpperCase()));

let owned_items = JSON.parse(JSON.stringify(item_dict_template));
Expand Down

0 comments on commit 5c36c64

Please sign in to comment.