diff --git a/gitadora@asphyxia/README.md b/gitadora@asphyxia/README.md index 06b6548..72c32eb 100644 --- a/gitadora@asphyxia/README.md +++ b/gitadora@asphyxia/README.md @@ -1,6 +1,6 @@ GITADORA Plugin for Asphyxia-Core ================================= -![Version: v1.1.0](https://img.shields.io/badge/version-v1.1.0-blue) +![Version: v1.1.1](https://img.shields.io/badge/version-v1.1.1-blue) This plugin is based on converted from public-exported Asphyxia's Routes. @@ -29,8 +29,14 @@ Known Issues Release Notes ============= -v1.1.0 (Current) +v1.1.1 (Current) ---------------- + * fix: Error when create new profile on exchain. + * fix: last song doesn't work correctly. + * misc: Add logger for tracking problem. + +v1.1.0 +------ * NEX+AGE Support (Not full support.) * Restructure bit for maintaining. diff --git a/gitadora@asphyxia/handlers/MusicList.ts b/gitadora@asphyxia/handlers/MusicList.ts index 5f46c55..d33e988 100644 --- a/gitadora@asphyxia/handlers/MusicList.ts +++ b/gitadora@asphyxia/handlers/MusicList.ts @@ -1,6 +1,9 @@ import { getVersion } from "../utils"; import { defaultProcessRawData, processDataBuilder } from "../data/mdb" import { CommonMusicDataField, readJSONOrXML, readXML } from "../data/mdb"; +import Logger from "../utils/logger" + +const logger = new Logger("MusicList") export const playableMusic: EPR = async (info, data, send) => { const version = getVersion(info); @@ -10,8 +13,8 @@ export const playableMusic: EPR = async (info, data, send) => { music = (await defaultProcessRawData('data/mdb/custom.xml')).music } } catch (e) { - console.error(e.stack); - console.error("Fallback: Using default MDB method.") + logger.warn("Read Custom MDB failed. Using default MDB as a fallback.") + logger.debugWarn(e.stack); music = []; } diff --git a/gitadora@asphyxia/handlers/profiles.ts b/gitadora@asphyxia/handlers/profiles.ts index c93ccbd..121549b 100644 --- a/gitadora@asphyxia/handlers/profiles.ts +++ b/gitadora@asphyxia/handlers/profiles.ts @@ -391,20 +391,11 @@ export const getPlayer: EPR = async (info, data, send) => { player: K.ATTR({ 'no': `${no}` }, { now_date: K.ITEM('u64', time), secretmusic: { // TODO: FIX THIS - music: _.merge(_.range(0,2800), _.range(5000, 5100)).map(mid => { - return { - musicid: K.ITEM('s32', mid), - seq: K.ITEM('u16', 255), - kind: K.ITEM('s32', 40), - } - }), - }, - trbitem: { // TODO: FIX THIS - item: _.range(0,750).map(id => { - return { - itemid: K.ITEM('s32', id), - } - }), + music: { + musicid: K.ITEM('s32', 0), + seq: K.ITEM('u16', 255), + kind: K.ITEM('s32', 40), + } }, chara_list: {}, title_parts: {}, diff --git a/gitadora@asphyxia/index.ts b/gitadora@asphyxia/index.ts index 7940f4d..7902cc6 100644 --- a/gitadora@asphyxia/index.ts +++ b/gitadora@asphyxia/index.ts @@ -3,6 +3,9 @@ import { playableMusic } from "./handlers/MusicList" import { getPlayer, check, regist, savePlayer } from "./handlers/profiles"; import { updatePlayerInfo } from "./handlers/webui"; import { isAsphyxiaDebugMode, isRequiredCoreVersion } from "./utils"; +import Logger from "./utils/logger"; + +const logger = new Logger("main") export function register() { if(!isRequiredCoreVersion(1, 20)) { @@ -63,11 +66,12 @@ export function register() { MultiRoute('gametop.get', getPlayer); MultiRoute('gameend.regist', savePlayer); + // Misc + R.Route('bemani_gakuen.get_music_info', true) + R.Unhandled(async (info, data, send) => { if (["eventlog"].includes(info.module)) return; - console.error(`Received Unhandled Response on ${info.method} by ${info.model}/${info.module}`) - if (isAsphyxiaDebugMode()){ - console.error(`Received Request: ${JSON.stringify(data, null, 4)}`) - } + logger.error(`Received Unhandled Request on Method "${info.method}" by ${info.model}/${info.module}`) + logger.debugError(`Received Request: ${JSON.stringify(data, null, 4)}`) }) } \ No newline at end of file diff --git a/gitadora@asphyxia/utils/logger.ts b/gitadora@asphyxia/utils/logger.ts new file mode 100644 index 0000000..254ff74 --- /dev/null +++ b/gitadora@asphyxia/utils/logger.ts @@ -0,0 +1,62 @@ +import { isAsphyxiaDebugMode } from "."; + +export default class Logger { + public category: string | null; + + public constructor(category?: string) { + this.category = (category == null) ? null : `[${category}]` + } + + + public error(...args: any[]) { + this.argsHandler(console.error, ...args) + } + + public debugError(...args: any[]) { + if (isAsphyxiaDebugMode()) { + this.argsHandler(console.error, ...args) + } + } + + + public warn(...args: any[]) { + this.argsHandler(console.warn, ...args) + } + + public debugWarn(...args: any[]) { + if (isAsphyxiaDebugMode()) { + this.argsHandler(console.warn, ...args) + } + } + + + public info(...args: any[]) { + this.argsHandler(console.info, ...args) + } + + public debugInfo(...args: any[]) { + if (isAsphyxiaDebugMode()) { + this.argsHandler(console.info, ...args) + } + } + + + public log(...args: any[]) { + this.argsHandler(console.log, ...args) + } + + public debugLog(...args: any[]) { + if (isAsphyxiaDebugMode()) { + this.argsHandler(console.log, ...args) + } + } + + + private argsHandler(target: Function, ...args: any[]) { + if (this.category == null) { + target(...args) + } else { + target(this.category, ...args) + } + } +} \ No newline at end of file