Fix GITADORA Plugin errors when launch asphyxia with devmode.

This commit is contained in:
James Liu 2025-12-03 09:19:10 +00:00
parent aaa4a93f57
commit d863a522b1
5 changed files with 32 additions and 7 deletions

View File

@ -46,7 +46,15 @@ export async function readMDBFile(path: string, processHandler?: processRawDataH
break; break;
case '.b64': case '.b64':
const buff = await IO.ReadFile(path, 'utf-8'); const buff = await IO.ReadFile(path, 'utf-8');
const json = Buffer.from(buff, 'base64').toString('utf-8') const bufferCtor = (globalThis as {
Buffer?: {
from(input: string, encoding: string): { toString(encoding: string): string }
}
}).Buffer
if (!bufferCtor) {
throw new Error('Buffer is not available in the current environment.')
}
const json = bufferCtor.from(buff, 'base64').toString('utf-8')
// Uncomment to save the decoded base64 file as JSON. // Uncomment to save the decoded base64 file as JSON.
// await IO.WriteFile(path.replace(".b64",".json"), json) // await IO.WriteFile(path.replace(".b64",".json"), json)
result = JSON.parse(json) result = JSON.parse(json)

View File

@ -60,7 +60,6 @@ export async function applySharedFavoriteMusicToExtra(refid : string, extra : Ex
let favoriteMusic = await loadFavoriteMusic(refid) let favoriteMusic = await loadFavoriteMusic(refid)
if (favoriteMusic == null) { if (favoriteMusic == null) {
logger.debugInfo(`No shared favourite music available for profile ${refid}. Using game specific favorites. Favorites will be saved as shared favorites at the end of the game session.`);
return return
} }
@ -84,10 +83,17 @@ export async function saveFavoriteMusic(refid: string, data : FavoriteMusic) : P
}, data) }, data)
} }
export async function loadFavoriteMusic(refid : string) : Promise<FavoriteMusic> export async function loadFavoriteMusic(refid : string) : Promise<FavoriteMusic | null>
{ {
return await DB.FindOne<FavoriteMusic>(refid, { const favoriteMusic = await DB.FindOne<FavoriteMusic>(refid, {
collection: 'favoritemusic' collection: 'favoritemusic'
}) })
if (!favoriteMusic) {
logger.debugInfo(`No shared favourite music available for profile ${refid}. Using game specific favorites. Favorites will be saved as shared favorites at the end of the game session.`);
return null
}
return favoriteMusic
} }

View File

@ -1,3 +1,5 @@
/// <reference lib="es2020.bigint" />
import { getEncoreStageData } from "../data/extrastage"; import { getEncoreStageData } from "../data/extrastage";
import Logger from "../utils/logger"; import Logger from "../utils/logger";

View File

@ -1,3 +1,5 @@
/// <reference lib="es2020.bigint" />
import { getDefaultPlayerInfo, PlayerInfo } from "../models/playerinfo"; import { getDefaultPlayerInfo, PlayerInfo } from "../models/playerinfo";
import { PlayerRanking } from "../models/playerranking"; import { PlayerRanking } from "../models/playerranking";
import { getDefaultProfile, Profile } from "../models/profile"; import { getDefaultProfile, Profile } from "../models/profile";

View File

@ -8,7 +8,14 @@ export const isDM = (info: EamuseInfo) => {
export const getVersion = (info: EamuseInfo) => { export const getVersion = (info: EamuseInfo) => {
const moduleName: string = info.module; const moduleName: string = info.module;
return moduleName.match(/([^_]*)_(.*)/)[1]; const moduleMatch = moduleName.match(/([^_]*)_(.*)/);
if (moduleMatch && moduleMatch[1]) {
return moduleMatch[1];
}
console.error(`Unable to parse version from module name "${moduleName}".`);
return "unknown";
}; };
export function isRequiredCoreVersion(major: number, minor: number) { export function isRequiredCoreVersion(major: number, minor: number) {
@ -19,8 +26,8 @@ export function isRequiredCoreVersion(major: number, minor: number) {
}; };
export function isAsphyxiaDebugMode() : boolean { export function isAsphyxiaDebugMode() : boolean {
const argv = process.argv const argv = (globalThis as { process?: { argv?: string[] } }).process?.argv ?? [];
return argv.includes("--dev") || argv.includes("--console") return argv.includes("--dev") || argv.includes("--console");
} }
export function isSharedFavoriteMusicEnabled() : boolean{ export function isSharedFavoriteMusicEnabled() : boolean{