fix: ini files with BOM and new online fix location

This commit is contained in:
Zamitto 2024-10-14 20:48:41 -03:00
parent e9186e0a3c
commit 64c16e82b4
2 changed files with 20 additions and 1 deletions

View File

@ -56,6 +56,10 @@ const getPathFromCracker = (cracker: Cracker) => {
folderPath: path.join(publicDocuments, "OnlineFix"),
fileLocation: ["Stats", "Achievements.ini"],
},
{
folderPath: path.join(publicDocuments, "OnlineFix"),
fileLocation: ["Achievements.ini"],
},
];
}

View File

@ -73,7 +73,12 @@ export const parseAchievementFile = (
const iniParse = (filePath: string) => {
try {
const lines = readFileSync(filePath, "utf-8").split(/[\r\n]+/);
const fileContent = readFileSync(filePath, "utf-8");
const lines =
fileContent.charCodeAt(0) === 0xfeff
? fileContent.slice(1).split(/[\r\n]+/)
: fileContent.split(/[\r\n]+/);
let objectName = "";
const object: Record<string, Record<string, string | number>> = {};
@ -117,6 +122,16 @@ const processOnlineFix = (unlockedAchievements: any): UnlockedAchievement[] => {
name: achievement,
unlockTime: unlockedAchievement.timestamp * 1000,
});
} else if (unlockedAchievement?.Achieved == "true") {
const unlockTime = unlockedAchievement.TimeUnlocked;
parsedUnlockedAchievements.push({
name: achievement,
unlockTime:
unlockTime.length === 7
? unlockTime * 1000 * 1000
: unlockTime * 1000,
});
}
}