- Fixed server error when saving profiles for two Guitar Freaks players at the end of a session. Fixes issue #39.

- Fixed another server error when two players are present, but only one player is using a profile.
- Added support for the "ranking" field. Gitadora will now correctly display your server ranking (based on Skill) on the post-game screen.
- Added logging for profile loading/saving when Asphyxia is running in dev mode.
- Added more logging to mdb (song database) loading.
- "Recommended to friends" songs are now saved and loaded correctly. Since you don't have any friends, this won't be terribly useful, but it does at least provide an extra five slots for saving your favourite songs.
- Fixed "Recommended to friends" song list being incorrectly initialized to "I think about you".
- Removed some unneeded duplicate code.
- Latest getPlayer() and savePlayers() API requests and responses are now saved to file when Asphyxia is in dev mode. Useful for debugging.

NOTE: The above has only been tested on Gitadora Exchain.
This commit is contained in:
Thome Valentin
2022-04-28 10:18:16 +02:00
parent 0773375713
commit 2929045847
8 changed files with 214 additions and 97 deletions
+10 -2
View File
@@ -1,3 +1,5 @@
import Logger from "../../utils/logger";
export interface CommonMusicDataField {
id: KITEM<"s32">;
cont_gf: KITEM<"bool">;
@@ -21,13 +23,17 @@ export enum DATAVersion {
type processRawDataHandler = (path: string) => Promise<CommonMusicData>
const logger = new Logger("mdb")
export async function readXML(path: string) {
logger.debugInfo(`Loading MDB data from ${path}.`)
const xml = await IO.ReadFile(path, 'utf-8');
const json = U.parseXML(xml, false)
return json
}
export async function readJSON(path: string) {
logger.debugInfo(`Loading MDB data from ${path}.`)
const str = await IO.ReadFile(path, 'utf-8');
const json = JSON.parse(str)
return json
@@ -35,16 +41,19 @@ export async function readJSON(path: string) {
export async function readJSONOrXML(jsonPath: string, xmlPath: string, processHandler: processRawDataHandler): Promise<CommonMusicData> {
if (!IO.Exists(jsonPath)) {
logger.debugInfo(`Loading MDB data from ${xmlPath}.`)
const data = await processHandler(xmlPath)
await IO.WriteFile(jsonPath, JSON.stringify(data))
return data
} else {
logger.debugInfo(`Loading MDB data from ${jsonPath}.`)
const json = JSON.parse(await IO.ReadFile(jsonPath, 'utf-8'))
return json
}
}
export async function readB64JSON(b64path: string) {
logger.debugInfo(`Loading MDB data from ${b64path}.`)
const buff = await IO.ReadFile(b64path, 'utf-8');
return JSON.parse(Buffer.from(buff, 'base64').toString('utf-8'));
}
@@ -66,7 +75,7 @@ export function gameVerToDataVer(ver: string): DATAVersion {
export async function processDataBuilder(gameVer: string, processHandler?: processRawDataHandler) {
const ver = gameVerToDataVer(gameVer)
const base = `data/mdb/${ver}`
if (IO.Exists(`${base}.b64`)) {
if (IO.Exists(`${base}.b64`)) {
return await readB64JSON(`${base}.b64`);
}
const { music } = await readJSONOrXML(`${base}.json`, `${base}.xml`, processHandler ?? defaultProcessRawData)
@@ -74,7 +83,6 @@ export async function processDataBuilder(gameVer: string, processHandler?: proce
return { music };
}
export async function defaultProcessRawData(path: string): Promise<CommonMusicData> {
const data = await readXML(path)
const mdb = $(data).elements("mdb.mdb_data");