Skip to content

Instantly share code, notes, and snippets.

@wkronemeijer
Created September 4, 2023 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wkronemeijer/891c35a1d02a8bedfb747d5b9449aaa7 to your computer and use it in GitHub Desktop.
Save wkronemeijer/891c35a1d02a8bedfb747d5b9449aaa7 to your computer and use it in GitHub Desktop.
Moves the normal layout of a Path of Exile hideout to the scourged version, and vice versa.
const { readFileSync, writeFileSync } = require("fs");
const { resolve } = require("path");
const FlippedBit = 0b1000_0000;
const ScourgedBit = 0b0100_0000;
const VariationBitMask = 0b0011_1111;
function check(condition, message = "assertion failed") {
if (!condition) {
console.error(message);
process.exit(-1);
}
}
const file = process.argv[2];
check(file !== undefined, "missing target file");
const sourceFile = resolve(file);
const targetFile = sourceFile.replace(/\.hideout$/, ".scourged.hideout");
const encoding = "utf-8";
const sourceContent = readFileSync(sourceFile, encoding);
const targetContent = sourceContent.replaceAll(
/"fv": (\d+)/g,
(_, digits) => {
const oldValue = Number(digits);
check(Number.isInteger(oldValue));
const newValue = oldValue ^ ScourgedBit;
return `"fv": ${newValue}`;
},
);
writeFileSync(targetFile, targetContent, encoding);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment