mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
feat: add 3dm file inside game directory
This commit is contained in:
parent
94e242168c
commit
5e313a0374
5 changed files with 65 additions and 17 deletions
|
@ -62,9 +62,7 @@ export const checkAchievementFileChange = async (games: Game[]) => {
|
||||||
const achievementFileInsideDirectory =
|
const achievementFileInsideDirectory =
|
||||||
findAchievementFileInExecutableDirectory(game);
|
findAchievementFileInExecutableDirectory(game);
|
||||||
|
|
||||||
if (achievementFileInsideDirectory) {
|
gameAchievementFiles.push(...achievementFileInsideDirectory);
|
||||||
gameAchievementFiles.push(achievementFileInsideDirectory);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!gameAchievementFiles.length) continue;
|
if (!gameAchievementFiles.length) continue;
|
||||||
|
|
||||||
|
|
|
@ -136,6 +136,10 @@ const getPathFromCracker = async (cracker: Cracker) => {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cracker === Cracker._3dm) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
achievementsLogger.error(`Cracker ${cracker} not implemented`);
|
achievementsLogger.error(`Cracker ${cracker} not implemented`);
|
||||||
throw new Error(`Cracker ${cracker} not implemented`);
|
throw new Error(`Cracker ${cracker} not implemented`);
|
||||||
};
|
};
|
||||||
|
@ -163,22 +167,33 @@ export const findAchievementFiles = async (game: Game) => {
|
||||||
|
|
||||||
export const findAchievementFileInExecutableDirectory = (
|
export const findAchievementFileInExecutableDirectory = (
|
||||||
game: Game
|
game: Game
|
||||||
): AchievementFile | null => {
|
): AchievementFile[] => {
|
||||||
if (!game.executablePath) {
|
if (!game.executablePath) {
|
||||||
return null;
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const steamDataPath = path.join(
|
return [
|
||||||
|
{
|
||||||
|
type: Cracker.userstats,
|
||||||
|
filePath: path.join(
|
||||||
game.executablePath,
|
game.executablePath,
|
||||||
"..",
|
"..",
|
||||||
"SteamData",
|
"SteamData",
|
||||||
"user_stats.ini"
|
"user_stats.ini"
|
||||||
);
|
),
|
||||||
|
},
|
||||||
return {
|
{
|
||||||
type: Cracker.userstats,
|
type: Cracker._3dm,
|
||||||
filePath: steamDataPath,
|
filePath: path.join(
|
||||||
};
|
game.executablePath,
|
||||||
|
"..",
|
||||||
|
"3DMGAME",
|
||||||
|
"Player",
|
||||||
|
"stats",
|
||||||
|
"achievements.ini"
|
||||||
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const findAllAchievementFiles = async () => {
|
export const findAllAchievementFiles = async () => {
|
||||||
|
|
|
@ -45,6 +45,11 @@ export const parseAchievementFile = async (
|
||||||
return processSkidrow(parsed);
|
return processSkidrow(parsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type === Cracker._3dm) {
|
||||||
|
const parsed = await iniParse(filePath);
|
||||||
|
return process3DM(parsed);
|
||||||
|
}
|
||||||
|
|
||||||
achievementsLogger.log(`${type} achievements found on ${filePath}`);
|
achievementsLogger.log(`${type} achievements found on ${filePath}`);
|
||||||
return [];
|
return [];
|
||||||
};
|
};
|
||||||
|
@ -139,6 +144,28 @@ const processGoldberg = (unlockedAchievements: any): UnlockedAchievement[] => {
|
||||||
return newUnlockedAchievements;
|
return newUnlockedAchievements;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const process3DM = (unlockedAchievements: any): UnlockedAchievement[] => {
|
||||||
|
const newUnlockedAchievements: UnlockedAchievement[] = [];
|
||||||
|
|
||||||
|
const achievements = unlockedAchievements["State"];
|
||||||
|
const times = unlockedAchievements["Time"];
|
||||||
|
|
||||||
|
for (const achievement of Object.keys(achievements)) {
|
||||||
|
if (achievements[achievement] == "0101") {
|
||||||
|
const time = times[achievement];
|
||||||
|
|
||||||
|
newUnlockedAchievements.push({
|
||||||
|
name: achievement,
|
||||||
|
unlockTime: new DataView(
|
||||||
|
new Uint8Array(Buffer.from(time.toString(), "hex")).buffer
|
||||||
|
).getUint32(0, true),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return newUnlockedAchievements;
|
||||||
|
};
|
||||||
|
|
||||||
const processDefault = (unlockedAchievements: any): UnlockedAchievement[] => {
|
const processDefault = (unlockedAchievements: any): UnlockedAchievement[] => {
|
||||||
const newUnlockedAchievements: UnlockedAchievement[] = [];
|
const newUnlockedAchievements: UnlockedAchievement[] = [];
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import { parseAchievementFile } from "./parse-achievement-file";
|
||||||
import { mergeAchievements } from "./merge-achievements";
|
import { mergeAchievements } from "./merge-achievements";
|
||||||
import type { UnlockedAchievement } from "@types";
|
import type { UnlockedAchievement } from "@types";
|
||||||
import { getGameAchievementData } from "./get-game-achievement-data";
|
import { getGameAchievementData } from "./get-game-achievement-data";
|
||||||
|
import { achievementsLogger } from "../logger";
|
||||||
|
|
||||||
export const updateAllLocalUnlockedAchievements = async () => {
|
export const updateAllLocalUnlockedAchievements = async () => {
|
||||||
const gameAchievementFilesMap = await findAllAchievementFiles();
|
const gameAchievementFilesMap = await findAllAchievementFiles();
|
||||||
|
@ -47,10 +48,16 @@ export const updateAllLocalUnlockedAchievements = async () => {
|
||||||
achievementFile.filePath,
|
achievementFile.filePath,
|
||||||
achievementFile.type
|
achievementFile.type
|
||||||
);
|
);
|
||||||
console.log("Parsed for", game.title, parsedAchievements);
|
|
||||||
if (parsedAchievements.length) {
|
if (parsedAchievements.length) {
|
||||||
unlockedAchievements.push(...parsedAchievements);
|
unlockedAchievements.push(...parsedAchievements);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
achievementsLogger.log(
|
||||||
|
"Achievement file for",
|
||||||
|
game.title,
|
||||||
|
achievementFile.filePath
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
mergeAchievements(objectId, "steam", unlockedAchievements, false);
|
mergeAchievements(objectId, "steam", unlockedAchievements, false);
|
||||||
|
|
|
@ -35,4 +35,5 @@ export enum Cracker {
|
||||||
skidrow = "SKIDROW",
|
skidrow = "SKIDROW",
|
||||||
creamAPI = "CreamAPI",
|
creamAPI = "CreamAPI",
|
||||||
smartSteamEmu = "SmartSteamEmu",
|
smartSteamEmu = "SmartSteamEmu",
|
||||||
|
_3dm = "3dm",
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue