diff --git a/nostalgia@asphyxia/data/ForteMusic.ts b/nostalgia@asphyxia/data/ForteMusic.ts index e8eaf8c..ec8760e 100644 --- a/nostalgia@asphyxia/data/ForteMusic.ts +++ b/nostalgia@asphyxia/data/ForteMusic.ts @@ -1,12 +1,12 @@ import { CommonMusicDataField, readB64JSON, readXML } from "./helper"; -export async function processData() { +export async function processData(): Promise { if (IO.Exists("data/forte_mdb.json.b64")) { return await readB64JSON("data/forte_mdb.json.b64"); } const data = await readJSONOrXML("data/forte_mdb.json", "data/forte_mdb.xml") // await IO.WriteFile("data/forte_mdb.json.b64", Buffer.from(JSON.stringify(data)).toString("base64")) - return data + return data; } export async function processMdbData(path: string): Promise { diff --git a/nostalgia@asphyxia/handler/common.ts b/nostalgia@asphyxia/handler/common.ts index 47b9bf4..fc4522f 100644 --- a/nostalgia@asphyxia/handler/common.ts +++ b/nostalgia@asphyxia/handler/common.ts @@ -99,10 +99,18 @@ export const get_music_info: EPR = async (info, data, send) => { })); } + const music_list = async () => { + const music_list = await processData() + music_list.music_spec = music_list.music_spec.filter( (v) => + parseInt(v["@attr"].index, 10) <= version.getMusicMaxIndex() + ) + return music_list; + } + const versionObject = version.isFirstOrForte() ? { permitted_list: forte_permitted_list, - music_list: await processData() + music_list: await music_list() } : { permitted_list, diff --git a/nostalgia@asphyxia/handler/player.ts b/nostalgia@asphyxia/handler/player.ts index 7ae979b..fe2dd58 100644 --- a/nostalgia@asphyxia/handler/player.ts +++ b/nostalgia@asphyxia/handler/player.ts @@ -51,7 +51,7 @@ const getPlayerData = async (refid: string, info: EamuseInfo, name?: string) => const brooch: any[] = []; for (const b in p.brooches) { - if (parseInt(b, 10) > version.getBroochMaxIndex()) continue; // Forte Brooch is ~147. + if (parseInt(b, 10) > version.getBroochMaxIndex()) continue; const bData = p.brooches[b]; brooch.push(K.ATTR({ index: b }, { watch_count: K.ITEM('s32', bData.watch), @@ -63,6 +63,7 @@ const getPlayerData = async (refid: string, info: EamuseInfo, name?: string) => // Unlock brooches for (let i = 101; i <= 124; ++i) { + if (i > version.getBroochMaxIndex()) continue; brooch.push(K.ATTR({ index: `${i}` }, { 'watch_count': K.ITEM('s32', 0), 'level': K.ITEM('s8', 1), diff --git a/nostalgia@asphyxia/utils.ts b/nostalgia@asphyxia/utils.ts index 3d8f281..b56e6ad 100644 --- a/nostalgia@asphyxia/utils.ts +++ b/nostalgia@asphyxia/utils.ts @@ -1,14 +1,14 @@ type NostalgiaVersions = 'First' | 'Forte' | 'Op2' | 'Op3' -type NostalgiaNumericTypes = 'music_index' | 'sheet_type' | 'brooch_index' +type NostalgiaNumericTypes = 'music_index' | 'sheet_type' | 'brooch_index' | 'event_index' export class NosVersionHelper { public version: NostalgiaVersions - private table = { // FIXME: Op3 is placeholder + private table = { // FIXME: All of Op3 values are placeholder music_index: { First: 87, Forte: 195, Op2: 315, Op3: 500 }, brooch_index: { First: 120, Forte: 147, Op2: 148, Op3: 200 }, sheet_type: { First: 2, Forte: 2, Op2: 3, Op3: 3 }, - event_index: { First: 5, Forte: 10, Op2: 17, Op3: 20 } // FIXME: First And Op3 is placeholder + event_index: { First: 10, Forte: 10, Op2: 17, Op3: 20 } } constructor (info: EamuseInfo) {