-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Manual fixes required for EU4 gamestate data before parsing #39
Comments
Thanks for the report. I don't know what would cause this issue offhand. The good news is that I'm working on an updated engine that handles your attached save flawlessly. In the meantime, if I or someone else comes across a bugfix for this, I'll create a new release. |
Please try installing the
It contains the new engine. Below is some sample code to get you started: const { readFileSync, writeFileSync } = require("fs");
const { Jomini } = require("jomini");
const args = process.argv.slice(2);
if (args.length !== 1) {
console.info("expected one argument for the file path");
process.exit(1);
}
console.time("read file");
const buffer = readFileSync(args[0]);
console.timeLog("read file");
(async function () {
let start = process.hrtime();
console.time("initialize jomini");
const parser = await Jomini.Initialize();
console.timeLog("initialize jomini");
console.time("parse text");
const data = parser.parseText(buffer);
console.timeLog("parse text");
console.time("stringify json");
const json = JSON.stringify(data, null, 2);
console.timeLog("stringify json")
const outFile = `${args[0]}.json`
writeFileSync(outFile, json);
console.log(`json written to ${outFile}`)
})(); The new engine is 3x faster and uses a third of the memory. I've tested on your uploaded save and it works as far as I know. Let me know if this works for you. |
Fixed in latest release |
Hello,
I'm playing an EU4 (v1.30.3) multiplayer game on a weekly basis and parsing the save game to calculate session scores based on some rules we've set.
Essentially once I've unzipped the gamestate file from the save and read it in as a string I go to parse it but encounter some errors. I've manually fixed these on the string before parsing and it now works fine but wondering if I can contribute any examples or help to get these fixed? I'm unsure if they're corruptions that have crept into the file or just weird syntactic edge cases.
I've attached the save mp_Dithmarschen1500_09_10.zip and here's the bodgy code I've put together to fix the string:
The text was updated successfully, but these errors were encountered: