mirror of
https://github.com/asphyxia-core/plugins.git
synced 2026-04-25 16:21:44 -05:00
Make sure that do not pass invaild value to client
This commit is contained in:
parent
7ab416c917
commit
f63ee8aae8
|
|
@ -1,12 +1,12 @@
|
||||||
import { CommonMusicDataField, readB64JSON, readXML } from "./helper";
|
import { CommonMusicDataField, readB64JSON, readXML } from "./helper";
|
||||||
|
|
||||||
export async function processData() {
|
export async function processData(): Promise<CommonMusicData> {
|
||||||
if (IO.Exists("data/forte_mdb.json.b64")) {
|
if (IO.Exists("data/forte_mdb.json.b64")) {
|
||||||
return await readB64JSON("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")
|
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"))
|
// 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<CommonMusicData> {
|
export async function processMdbData(path: string): Promise<CommonMusicData> {
|
||||||
|
|
|
||||||
|
|
@ -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()
|
const versionObject = version.isFirstOrForte()
|
||||||
? {
|
? {
|
||||||
permitted_list: forte_permitted_list,
|
permitted_list: forte_permitted_list,
|
||||||
music_list: await processData()
|
music_list: await music_list()
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
permitted_list,
|
permitted_list,
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ const getPlayerData = async (refid: string, info: EamuseInfo, name?: string) =>
|
||||||
|
|
||||||
const brooch: any[] = [];
|
const brooch: any[] = [];
|
||||||
for (const b in p.brooches) {
|
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];
|
const bData = p.brooches[b];
|
||||||
brooch.push(K.ATTR({ index: b }, {
|
brooch.push(K.ATTR({ index: b }, {
|
||||||
watch_count: K.ITEM('s32', bData.watch),
|
watch_count: K.ITEM('s32', bData.watch),
|
||||||
|
|
@ -63,6 +63,7 @@ const getPlayerData = async (refid: string, info: EamuseInfo, name?: string) =>
|
||||||
|
|
||||||
// Unlock brooches
|
// Unlock brooches
|
||||||
for (let i = 101; i <= 124; ++i) {
|
for (let i = 101; i <= 124; ++i) {
|
||||||
|
if (i > version.getBroochMaxIndex()) continue;
|
||||||
brooch.push(K.ATTR({ index: `${i}` }, {
|
brooch.push(K.ATTR({ index: `${i}` }, {
|
||||||
'watch_count': K.ITEM('s32', 0),
|
'watch_count': K.ITEM('s32', 0),
|
||||||
'level': K.ITEM('s8', 1),
|
'level': K.ITEM('s8', 1),
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
type NostalgiaVersions = 'First' | 'Forte' | 'Op2' | 'Op3'
|
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 {
|
export class NosVersionHelper {
|
||||||
public version: NostalgiaVersions
|
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 },
|
music_index: { First: 87, Forte: 195, Op2: 315, Op3: 500 },
|
||||||
brooch_index: { First: 120, Forte: 147, Op2: 148, Op3: 200 },
|
brooch_index: { First: 120, Forte: 147, Op2: 148, Op3: 200 },
|
||||||
sheet_type: { First: 2, Forte: 2, Op2: 3, Op3: 3 },
|
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) {
|
constructor (info: EamuseInfo) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user