diff --git a/iidx@asphyxia/handlers/music.ts b/iidx@asphyxia/handlers/music.ts index 5dfb152..5042b41 100644 --- a/iidx@asphyxia/handlers/music.ts +++ b/iidx@asphyxia/handlers/music.ts @@ -659,13 +659,15 @@ export const musiccrate: EPR = async (info, data, send) => { let cFlgs: Record = {}, fcFlgs: Record = {}, - totalFlgs: Record = {}, - cFlgArray: number[], fcFlgArray: number[], totalArray: number[]; + totalFlgs: Record = {}; scores.forEach((res) => { - totalArray = Array(10).fill(0); - cFlgArray = Array(10).fill(0); - fcFlgArray = Array(10).fill(0); + let mVersion = Math.floor(res.mid / 1000); + if (mVersion > version) return; + + let totalArray = Array(10).fill(0); + let cFlgArray = Array(10).fill(0); + let fcFlgArray = Array(10).fill(0); for (let a = 0; a < 10; a++) { if (res.cArray[a] != 0) totalArray[a] += 1; @@ -673,18 +675,20 @@ export const musiccrate: EPR = async (info, data, send) => { if (res.cArray[a] == 7) fcFlgArray[a] += 1; } - totalFlgs[res.mid] = totalArray; - cFlgs[res.mid] = cFlgArray; - fcFlgs[res.mid] = fcFlgArray; + let temp_mid = version < 20 ? NewMidToOldMid(res.mid) : res.mid; + totalFlgs[temp_mid] = totalArray; + cFlgs[temp_mid] = cFlgArray; + fcFlgs[temp_mid] = fcFlgArray; }); let c = []; - let indices = [1, 2, 3, 6, 7, 8]; for (const key in totalFlgs) { - let cRate = Array(10).fill(-1); - let fcRate = Array(10).fill(-1); + let cRate = Array(10).fill(0); + let fcRate = Array(10).fill(0); + + for (let a = 0; a < 10; a++) { + if (totalFlgs[key][a] == 0) continue; - for (let a = 0; a < cRate.length; a++) { if (version > 23) { cRate[a] = Math.round((cFlgs[key][a] / totalFlgs[key][a]) * 1000); fcRate[a] = Math.round((fcFlgs[key][a] / totalFlgs[key][a]) * 1000); @@ -694,20 +698,16 @@ export const musiccrate: EPR = async (info, data, send) => { } } - if (version > 26) { + let indices = [1, 2, 3, 6, 7, 8]; + if (version < 27) { + c.push( + K.ARRAY("u8", [...indices.map(i => cRate[i]), ...indices.map(i => fcRate[i])], { mid: key }), + ); + } + else { c.push( K.ARRAY("s32", [...cRate, ...fcRate], { mid: key }), ); - } else { - if (version < 20) { // TODO:: figure out why this doesn't work in older than Lincle // - c.push( - K.ARRAY("u8", [...indices.map(i => cRate[i])], { mid: String(NewMidToOldMid(Number(key))) }), - ); - } else { - c.push( - K.ARRAY("u8", [...indices.map(i => cRate[i]), ...indices.map(i => fcRate[i])], { mid: key }), - ); - } } }