Use newer API for custom MDB. Fix Grafica issue.

This commit is contained in:
DitFranXX
2020-12-03 20:27:26 +09:00
parent 3d3247a98b
commit a8f5b3f082
3 changed files with 22 additions and 10 deletions

View File

@@ -13,7 +13,7 @@ export const shop: EPR = async (info, data, send) => {
export const common: EPR = async (info, data, send) => { export const common: EPR = async (info, data, send) => {
let { music } = U.GetConfig("enable_custom_mdb") let { music } = U.GetConfig("enable_custom_mdb")
? await processMdbData(path.normalize(U.GetConfig("custom_mdb_path"))) ? await processCustomData()
: (await processValidData(info)) : (await processValidData(info))
if (music.length === 0) { if (music.length === 0) {
@@ -70,11 +70,15 @@ export const exception: EPR = async (info, data, send) => {
send.success() send.success()
} }
async function processCustomData() {
return processMdbData("data/custom_mdb.xml")
}
async function processValidData(info: EamuseInfo) { async function processValidData(info: EamuseInfo) {
const version = parseInt(info.model.trim().substr(10), 10) const version = parseInt(info.model.trim().substr(10), 10)
if (version >= 2020102200) { if (version >= 2020102200) {
// MUSECA PLUS // MUSECA PLUS
return await processCommunityPlusData(); processCommunityPlusData();
} else /** if (version > 2016071300) */ { } else /** if (version > 2016071300) */ {
return await processOnePlusHalfData() return await processOnePlusHalfData()
} /** else { } /** else {

View File

@@ -15,9 +15,10 @@ export const load: EPR = async (info, data, send) => {
} }
const item = _.map(profile.item, (v, k) => { const item = _.map(profile.item, (v, k) => {
const id = k.replace("g", "")
return { return {
type: K.ITEM("u8", v.type), type: K.ITEM("u8", v.type),
id: K.ITEM("u32", parseInt(k)), id: K.ITEM("u32", parseInt(id)),
param: K.ITEM("u32", v.param) param: K.ITEM("u32", v.param)
} }
}) })
@@ -98,8 +99,11 @@ export const save: EPR = async (info, data, send) => {
const dbItem = (await DB.FindOne<Profile>(refid, { collection: "profile" })).item const dbItem = (await DB.FindOne<Profile>(refid, { collection: "profile" })).item
for(const item of $(data).elements("item.info")) { for(const item of $(data).elements("item.info")) {
dbItem[item.number("id")] = { const id = item.number("id");
type: item.number("type"), const type = item.number("type")
// Grafica and Mission shares same ID. Why?????
dbItem[type == 16 ? `g${id}` : id] = {
type,
param : item.number("param") param : item.number("param")
} }
} }

View File

@@ -2,6 +2,10 @@ import { common, exception, lounge, shop, hiscore, frozen } from "./handlers/com
import { load, load_m, newProfile, save, save_m } from "./handlers/player"; import { load, load_m, newProfile, save, save_m } from "./handlers/player";
export function register() { export function register() {
if(!R.DataFile) { // TODO: Better implementation.
return console.error("You need newer version of Core.")
}
R.GameCode('PIX'); R.GameCode('PIX');
R.Config("unlock_all_songs", { R.Config("unlock_all_songs", {
@@ -17,11 +21,10 @@ export function register() {
default: false, default: false,
}) })
R.Config("custom_mdb_path", { R.DataFile("data/custom_mdb.xml", {
name: "Custom MDB PATH", accept: ".xml",
desc: "You need to enable Custom MDB option first. USE ABSOLUTE PATH !!", name: "Custom MDB",
type: "string", desc: "You need to enable Custom MDB option first."
default: "",
}) })
const Route = (method: string, handler: EPR | boolean) => { const Route = (method: string, handler: EPR | boolean) => {
@@ -43,6 +46,7 @@ export function register() {
Route("new", newProfile) Route("new", newProfile)
Route("save", save) Route("save", save)
Route("save_m", save_m) Route("save_m", save_m)
//Route("save_c", save_c)
Route("load", load) Route("load", load)
Route("load_m", load_m) Route("load_m", load_m)