Created
September 4, 2023 22:49
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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