');
+ }
+ parent.append(patch)
+
+ }
+
+ updateUI(file) {
+ // This converts bytes from the file to big endian by shifting each
+ // byte `i` bytes to the left then doing a bitwise OR to add the less
+ // significant bytes that were gathered at earlier iterations of loop
+ var val = 0;
+ for (var i = 0; i < this.size; i++) {
+ val = (file[this.offset + i] << (8 * i)) | val;
+ }
+
+ this.number.value = val;
+ }
+
+ validatePatch(file) {
+ return;
+ }
+
+ applyPatch(file) {
+ // Convert user inputted number to little endian
+ const view = new DataView(new ArrayBuffer(this.size * 2));
+ view.setInt32(1, this.number.value, true);
+
+ for (var i = 0; i < this.size; i++) {
+ var val = view.getInt32(1);
+
+ // Shift off less significant bytes
+ val = val >> ((this.size - 1 - i) * 8);
+
+ // Mask off more significant bytes
+ val = val & 0xFF;
+
+ // Write this byte
+ file[this.offset + i] = val;
+ }
+ }
+}
+
var loadPatch = function(_this, self, patcher) {
patcher.loadPatchUI();
patcher.updatePatchUI();
@@ -363,6 +444,9 @@ class Patcher {
if(mod.type === "union") {
this.mods.push(new UnionPatch(mod));
}
+ if(mod.type === "number") {
+ this.mods.push(new NumberPatch(mod));
+ }
} else { // standard patch
this.mods.push(new StandardPatch(mod));
}