diff --git a/gitadora@asphyxia/data/mdb/index.ts b/gitadora@asphyxia/data/mdb/index.ts index d81c5bf..73b6dd8 100644 --- a/gitadora@asphyxia/data/mdb/index.ts +++ b/gitadora@asphyxia/data/mdb/index.ts @@ -46,7 +46,15 @@ export async function readMDBFile(path: string, processHandler?: processRawDataH break; case '.b64': 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. // await IO.WriteFile(path.replace(".b64",".json"), json) result = JSON.parse(json) diff --git a/gitadora@asphyxia/handlers/FavoriteMusic.ts b/gitadora@asphyxia/handlers/FavoriteMusic.ts index 1e7a8fc..c22f2a8 100644 --- a/gitadora@asphyxia/handlers/FavoriteMusic.ts +++ b/gitadora@asphyxia/handlers/FavoriteMusic.ts @@ -60,7 +60,6 @@ export async function applySharedFavoriteMusicToExtra(refid : string, extra : Ex let favoriteMusic = await loadFavoriteMusic(refid) 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 } @@ -84,10 +83,17 @@ export async function saveFavoriteMusic(refid: string, data : FavoriteMusic) : P }, data) } -export async function loadFavoriteMusic(refid : string) : Promise +export async function loadFavoriteMusic(refid : string) : Promise { - return await DB.FindOne(refid, { + const favoriteMusic = await DB.FindOne(refid, { 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 } diff --git a/gitadora@asphyxia/handlers/info.ts b/gitadora@asphyxia/handlers/info.ts index 56c2d82..aa2b04b 100644 --- a/gitadora@asphyxia/handlers/info.ts +++ b/gitadora@asphyxia/handlers/info.ts @@ -1,3 +1,5 @@ +/// + import { getEncoreStageData } from "../data/extrastage"; import Logger from "../utils/logger"; diff --git a/gitadora@asphyxia/handlers/profiles.ts b/gitadora@asphyxia/handlers/profiles.ts index 64ab1e6..b39bc0d 100644 --- a/gitadora@asphyxia/handlers/profiles.ts +++ b/gitadora@asphyxia/handlers/profiles.ts @@ -1,3 +1,5 @@ +/// + import { getDefaultPlayerInfo, PlayerInfo } from "../models/playerinfo"; import { PlayerRanking } from "../models/playerranking"; import { getDefaultProfile, Profile } from "../models/profile"; diff --git a/gitadora@asphyxia/utils/index.ts b/gitadora@asphyxia/utils/index.ts index e291863..9642a69 100644 --- a/gitadora@asphyxia/utils/index.ts +++ b/gitadora@asphyxia/utils/index.ts @@ -8,7 +8,14 @@ export const isDM = (info: EamuseInfo) => { export const getVersion = (info: EamuseInfo) => { 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) { @@ -19,8 +26,8 @@ export function isRequiredCoreVersion(major: number, minor: number) { }; export function isAsphyxiaDebugMode() : boolean { - const argv = process.argv - return argv.includes("--dev") || argv.includes("--console") + const argv = (globalThis as { process?: { argv?: string[] } }).process?.argv ?? []; + return argv.includes("--dev") || argv.includes("--console"); } export function isSharedFavoriteMusicEnabled() : boolean{