mirror of
https://github.com/asphyxia-core/plugins.git
synced 2026-08-24 03:44:07 -05:00
IIDX: Fixed where plugin cannot be compiled (Buffer type)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { IDtoRef, Base64toBuffer, GetVersion, OldMidToNewMid, NewMidToOldMid, ReftoProfile, ReftoPcdata, ClidToPlaySide, ReftoQPRO, NumArrayToString, OldMidToVerMid } from "../util";
|
||||
import { IDtoRef, Base64toNumArray, GetVersion, OldMidToNewMid, NewMidToOldMid, ReftoProfile, ReftoPcdata, ClidToPlaySide, ReftoQPRO, NumArrayToString, OldMidToVerMid, HextoBase64 } from "../util";
|
||||
import { score, score_top } from "../models/score";
|
||||
import { profile } from "../models/profile";
|
||||
import { shop_data } from "../models/shop";
|
||||
@@ -317,9 +317,9 @@ export const musicappoint: EPR = async (info, data, send) => {
|
||||
option2 = music_data.opt2Array[clid];
|
||||
}
|
||||
|
||||
mydata = Base64toBuffer(music_data[clid]);
|
||||
mydata = Base64toNumArray(music_data[clid]);
|
||||
}
|
||||
else mydata = K.ITEM("bin", Base64toBuffer(music_data[clid]));
|
||||
else mydata = K.ITEM("bin", Base64toNumArray(music_data[clid]));
|
||||
}
|
||||
|
||||
/*** ctype
|
||||
@@ -354,7 +354,7 @@ export const musicappoint: EPR = async (info, data, send) => {
|
||||
});
|
||||
if (_.isNaN(other_pcdata) || _.isNil(other_musicdata)) break;
|
||||
|
||||
sdata = K.ITEM("bin", Base64toBuffer(other_musicdata[clid]), {
|
||||
sdata = K.ITEM("bin", Base64toNumArray(other_musicdata[clid]), {
|
||||
score: String(other_musicdata.esArray[clid]),
|
||||
pid: String(other_profile[1]),
|
||||
name: String(other_profile[0]),
|
||||
@@ -371,7 +371,7 @@ export const musicappoint: EPR = async (info, data, send) => {
|
||||
|
||||
if (version >= 27) {
|
||||
let my_gauge_data = null;
|
||||
if (!_.isNil(music_data)) my_gauge_data = Base64toBuffer(music_data[clid + 10]);
|
||||
if (!_.isNil(music_data)) my_gauge_data = Base64toNumArray(music_data[clid + 10]);
|
||||
|
||||
if (!_.isNil(sdata)) {
|
||||
if (_.isNil(other_musicdata.optArray)) { // migration //
|
||||
@@ -379,7 +379,7 @@ export const musicappoint: EPR = async (info, data, send) => {
|
||||
other_musicdata.opt2Array = Array<number>(10).fill(0);
|
||||
}
|
||||
|
||||
let other_data = K.ITEM("bin", Base64toBuffer(other_musicdata[clid]), {
|
||||
let other_data = K.ITEM("bin", Base64toNumArray(other_musicdata[clid]), {
|
||||
score: String(other_musicdata.esArray[clid]),
|
||||
achieve: String(other_pcdata[ClidToPlaySide(clid) + 2]),
|
||||
pid: String(other_profile[1]),
|
||||
@@ -391,7 +391,7 @@ export const musicappoint: EPR = async (info, data, send) => {
|
||||
|
||||
sdata = {
|
||||
...other_data,
|
||||
gauge_data: K.ITEM("bin", Base64toBuffer(other_musicdata[clid + 10]))
|
||||
gauge_data: K.ITEM("bin", Base64toNumArray(other_musicdata[clid + 10]))
|
||||
};
|
||||
|
||||
if (_.isNil(sdata) && !_.isNil(mydata)) {
|
||||
@@ -468,6 +468,7 @@ export const musicreg: EPR = async (info, data, send) => {
|
||||
let gArray = Array<number>(10).fill(0); // GREAT //
|
||||
let mArray = Array<number>(10).fill(0); // MISS //
|
||||
let cArray = Array<number>(10).fill(0); // CLEAR FLAGS //
|
||||
let rArray = Array<number>(10).fill(0); // RANK ID //
|
||||
let esArray = Array<number>(10).fill(0); // EXSCORE //
|
||||
let optArray = Array<number>(10).fill(0); // USED OPTION (CastHour) //
|
||||
let opt2Array = Array<number>(10).fill(0); // USED OPTION (CastHour) //
|
||||
@@ -477,8 +478,10 @@ export const musicreg: EPR = async (info, data, send) => {
|
||||
else if (!_.isNil($(data).attr().dj_level)) rid = parseInt($(data).attr().dj_level);
|
||||
if (rid > -1) console.log(`[music.reg] rank_id : ${rid}`);
|
||||
|
||||
if (version == 15) ghost = Buffer.from($(data).str("ghost"), "hex").toString("base64");
|
||||
if (version == 15) ghost = HextoBase64($(data).str("ghost"));
|
||||
else ghost = $(data).buffer("ghost").toString("base64");
|
||||
|
||||
console.log(ghost);
|
||||
|
||||
if (version >= 27) {
|
||||
ghost_gauge = $(data).buffer("ghost_gauge").toString("base64");
|
||||
@@ -495,6 +498,7 @@ export const musicreg: EPR = async (info, data, send) => {
|
||||
gArray[clid] = gnum;
|
||||
mArray[clid] = mnum;
|
||||
cArray[clid] = cflg;
|
||||
rArray[clid] = rid;
|
||||
esArray[clid] = exscore;
|
||||
optArray[clid] = option;
|
||||
opt2Array[clid] = option_2;
|
||||
@@ -508,12 +512,16 @@ export const musicreg: EPR = async (info, data, send) => {
|
||||
optArray = music_data.optArray;
|
||||
opt2Array = music_data.opt2Array;
|
||||
}
|
||||
if (!_.isNil(music_data.rArray)) {
|
||||
rArray = music_data.rArray;
|
||||
}
|
||||
|
||||
const pExscore = esArray[clid];
|
||||
if (exscore > pExscore) {
|
||||
pgArray[clid] = pgnum;
|
||||
gArray[clid] = gnum;
|
||||
mArray[clid] = mnum;
|
||||
rArray[clid] = rid;
|
||||
esArray[clid] = exscore;
|
||||
optArray[clid] = option;
|
||||
opt2Array[clid] = option_2;
|
||||
@@ -589,6 +597,7 @@ export const musicreg: EPR = async (info, data, send) => {
|
||||
gArray,
|
||||
mArray,
|
||||
cArray,
|
||||
rArray,
|
||||
esArray,
|
||||
optArray,
|
||||
opt2Array,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { pcdata, KDZ_pcdata, IIDX27_pcdata, IIDX28_pcdata, IIDX29_pcdata, IIDX30_pcdata, JDZ_pcdata, LDJ_pcdata, IIDX21_pcdata, IIDX22_pcdata, IIDX23_pcdata, IIDX24_pcdata, IIDX25_pcdata, IIDX26_pcdata, JDJ_pcdata, HDD_pcdata, I00_pcdata } from "../models/pcdata";
|
||||
import { grade } from "../models/grade";
|
||||
import { custom, default_custom } from "../models/custom";
|
||||
import { IDtoCode, IDtoRef, Base64toBuffer, GetVersion, ReftoProfile, ReftoPcdata, ReftoQPRO, appendSettingConverter, NumArrayToString } from "../util";
|
||||
import { IDtoCode, IDtoRef, Base64toNumArray, GetVersion, ReftoProfile, ReftoPcdata, ReftoQPRO, appendSettingConverter, NumArrayToString, NumArraytoHex } from "../util";
|
||||
import { eisei_grade, eisei_grade_data, lightning_musicmemo, lightning_musicmemo_new, lightning_playdata, lightning_settings, lm_playdata, lm_settings, lm_settings_new, musicmemo_data, musicmemo_data_new } from "../models/lightning";
|
||||
import { profile, default_profile } from "../models/profile";
|
||||
import { rival, rival_data } from "../models/rival";
|
||||
@@ -593,9 +593,9 @@ export const pcget: EPR = async (info, data, send) => {
|
||||
|
||||
event = await DB.FindOne(refid, { collection: "event_1", version: version });
|
||||
if (!_.isNil(event)) {
|
||||
event.cf = Base64toBuffer(event.cf).toString("hex");
|
||||
event.pf = Base64toBuffer(event.pf).toString("hex");
|
||||
event.mf = Base64toBuffer(event.mf).toString("hex");
|
||||
event.cf = NumArraytoHex(Base64toNumArray(event.cf));
|
||||
event.pf = NumArraytoHex(Base64toNumArray(event.pf));
|
||||
event.mf = NumArraytoHex(Base64toNumArray(event.mf));
|
||||
}
|
||||
|
||||
return send.pugFile("pug/JDZ/pcget.pug", {
|
||||
@@ -612,9 +612,9 @@ export const pcget: EPR = async (info, data, send) => {
|
||||
event = await DB.FindOne(refid, { collection: "event_1", version: version });
|
||||
|
||||
if (!_.isNil(event)) {
|
||||
event.cf = Base64toBuffer(event.cf).toString("hex");
|
||||
event.qcf = Base64toBuffer(event.qcf).toString("hex");
|
||||
event.piece = Base64toBuffer(event.piece).toString("hex");
|
||||
event.cf = NumArraytoHex(Base64toNumArray(event.cf));
|
||||
event.qcf = NumArraytoHex(Base64toNumArray(event.qcf));
|
||||
event.piece = NumArraytoHex(Base64toNumArray(event.piece));
|
||||
}
|
||||
|
||||
return send.pugFile("pug/KDZ/pcget.pug", {
|
||||
@@ -628,8 +628,8 @@ export const pcget: EPR = async (info, data, send) => {
|
||||
});
|
||||
}
|
||||
else if (version == 20) {
|
||||
if (!_.isNil(pcdata.st_stamp)) pcdata.st_stamp = Base64toBuffer(pcdata.st_stamp).toString("hex");
|
||||
if (!_.isNil(pcdata.st_help)) pcdata.st_help = Base64toBuffer(pcdata.st_help).toString("hex");
|
||||
if (!_.isNil(pcdata.st_stamp)) pcdata.st_stamp = NumArraytoHex(Base64toNumArray(pcdata.st_stamp));
|
||||
if (!_.isNil(pcdata.st_help)) pcdata.st_help = NumArraytoHex(Base64toNumArray(pcdata.st_help));
|
||||
if (_.isNil(pcdata.st_stamp)) pcdata.st_stamp = ""; // migration //
|
||||
|
||||
let link5 = await DB.FindOne(refid, { collection: "event_1", version: version, event_name: "link5" });
|
||||
@@ -638,7 +638,7 @@ export const pcget: EPR = async (info, data, send) => {
|
||||
let blueboss = await DB.FindOne<blueboss>(refid, { collection: "event_1", version: version, event_name: "blueboss" });
|
||||
let yellowboss = await DB.FindOne(refid, { collection: "event_1", version: version, event_name: "yellowboss" });
|
||||
|
||||
if (!_.isNil(blueboss)) blueboss.durability = Base64toBuffer(blueboss.durability).toString("hex");
|
||||
if (!_.isNil(blueboss)) blueboss.durability = NumArraytoHex(Base64toNumArray(blueboss.durability));
|
||||
|
||||
return send.pugFile("pug/LDJ/pcget.pug", {
|
||||
profile,
|
||||
@@ -681,16 +681,16 @@ export const pcget: EPR = async (info, data, send) => {
|
||||
evtArray = [], evtArray2 = [];
|
||||
|
||||
if (version == 21) {
|
||||
if (!_.isNil(pcdata.st_album)) pcdata.st_album = Base64toBuffer(pcdata.st_album).toString("hex");
|
||||
if (!_.isNil(pcdata.st_album)) pcdata.st_album = NumArraytoHex(Base64toNumArray(pcdata.st_album));
|
||||
|
||||
link5 = await DB.FindOne(refid, { collection: "event_1", version: 20, event_name: "link5" });
|
||||
tricolettepark = await DB.FindOne(refid, { collection: "event_1", version: 20, event_name: "tricolettepark" });
|
||||
|
||||
boss1 = await DB.FindOne(refid, { collection: "event_1", version: version, event_name: "boss1" });
|
||||
if (!_.isNil(boss1.durability)) boss1.durability = Base64toBuffer(boss1.durability).toString("hex");
|
||||
if (!_.isNil(boss1.durability)) boss1.durability = NumArraytoHex(Base64toNumArray(boss1.durability));
|
||||
}
|
||||
else if (version == 22) {
|
||||
if (!_.isNil(pcdata.st_album)) pcdata.st_album = Base64toBuffer(pcdata.st_album).toString("hex");
|
||||
if (!_.isNil(pcdata.st_album)) pcdata.st_album = NumArraytoHex(Base64toNumArray(pcdata.st_album));
|
||||
|
||||
chrono_diver = await DB.FindOne(refid, { collection: "event_1", version: version, event_name: "chrono_diver" });
|
||||
pendual_talis = await DB.FindOne(refid, { collection: "event_1", version: version, event_name: "boss_event_3" });
|
||||
@@ -701,7 +701,7 @@ export const pcget: EPR = async (info, data, send) => {
|
||||
qpronicle_phase3 = await DB.FindOne(refid, { collection: "event_1", version: version, event_name: "qpronicle_phase3" });
|
||||
}
|
||||
else if (version == 23) {
|
||||
if (!_.isNil(pcdata.st_tokimeki)) pcdata.st_tokimeki = Base64toBuffer(pcdata.st_tokimeki).toString("hex");
|
||||
if (!_.isNil(pcdata.st_tokimeki)) pcdata.st_tokimeki = NumArraytoHex(Base64toNumArray(pcdata.st_tokimeki));
|
||||
|
||||
open_tokotoko = await DB.FindOne(refid, { collection: "event_1", version: version, event_name: "event1_data" });
|
||||
mystery_line = await DB.FindOne(refid, { collection: "event_1", version: version, event_name: "event2_data" });
|
||||
@@ -712,16 +712,16 @@ export const pcget: EPR = async (info, data, send) => {
|
||||
siege_sinobuz_sub = await DB.Find(refid, { collection: "event_1_sub", version: version, event_name: "event1_data" });
|
||||
siege_sinobuz_sub.forEach((res) => {
|
||||
res.is_clear = Number(res.is_clear);
|
||||
res.ninjyutsu = Base64toBuffer(res.ninjyutsu).toString("hex");
|
||||
res.card_damage = Base64toBuffer(res.card_damage).toString("hex");
|
||||
res.card_clear = Base64toBuffer(res.card_clear).toString("hex");
|
||||
res.ninjyutsu = NumArraytoHex(Base64toNumArray(res.ninjyutsu));
|
||||
res.card_damage = NumArraytoHex(Base64toNumArray(res.card_damage));
|
||||
res.card_clear = NumArraytoHex(Base64toNumArray(res.card_clear));
|
||||
});
|
||||
|
||||
ninja_shichikyoden = await DB.FindOne(refid, { collection: "event_1", version: version, event_name: "event2_data" });
|
||||
if (!_.isNil(ninja_shichikyoden.last_select_dojo))
|
||||
ninja_shichikyoden.last_select_dojo = Base64toBuffer(ninja_shichikyoden.last_select_dojo).toString("hex");
|
||||
ninja_shichikyoden.last_select_dojo = NumArraytoHex(Base64toNumArray(ninja_shichikyoden.last_select_dojo));
|
||||
if (!_.isNil(ninja_shichikyoden.enemy_damage))
|
||||
ninja_shichikyoden.enemy_damage = Base64toBuffer(ninja_shichikyoden.enemy_damage).toString("hex");
|
||||
ninja_shichikyoden.enemy_damage = NumArraytoHex(Base64toNumArray(ninja_shichikyoden.enemy_damage));
|
||||
}
|
||||
else if (version == 25) {
|
||||
rush_cannonracer = await DB.FindOne(refid, { collection: "event_1", version: version, event_name: "event1_data" });
|
||||
@@ -733,11 +733,11 @@ export const pcget: EPR = async (info, data, send) => {
|
||||
else if (version == 26) {
|
||||
mirage_lib = await DB.FindOne(refid, { collection: "event_1", version: version, event_name: "event1_data" });
|
||||
if (!_.isNil(mirage_lib.quiz_control_list))
|
||||
mirage_lib.quiz_control_list = Base64toBuffer(mirage_lib.quiz_control_list).toString("hex");
|
||||
mirage_lib.quiz_control_list = NumArraytoHex(Base64toNumArray(mirage_lib.quiz_control_list));
|
||||
|
||||
mirage_lib_sub = await DB.Find(refid, { collection: "event_1_sub", version: version, event_name: "event1_data" });
|
||||
mirage_lib_sub.forEach((res) => {
|
||||
res.map_route_damage = Base64toBuffer(res.map_route_damage).toString("hex");
|
||||
res.map_route_damage = NumArraytoHex(Base64toNumArray(res.map_route_damage));
|
||||
});
|
||||
|
||||
delabity_lab = await DB.FindOne(refid, { collection: "event_1", version: version, event_name: "event2_data" });
|
||||
@@ -761,10 +761,10 @@ export const pcget: EPR = async (info, data, send) => {
|
||||
}
|
||||
|
||||
if (!_.isNil(pcdata.sp_mlist)) {
|
||||
pcdata.sp_mlist = Base64toBuffer(pcdata.sp_mlist).toString("hex");
|
||||
pcdata.sp_clist = Base64toBuffer(pcdata.sp_clist).toString("hex");
|
||||
pcdata.dp_mlist = Base64toBuffer(pcdata.dp_mlist).toString("hex");
|
||||
pcdata.dp_clist = Base64toBuffer(pcdata.dp_clist).toString("hex");
|
||||
pcdata.sp_mlist = NumArraytoHex(Base64toNumArray(pcdata.sp_mlist));
|
||||
pcdata.sp_clist = NumArraytoHex(Base64toNumArray(pcdata.sp_clist));
|
||||
pcdata.dp_mlist = NumArraytoHex(Base64toNumArray(pcdata.dp_mlist));
|
||||
pcdata.dp_clist = NumArraytoHex(Base64toNumArray(pcdata.dp_clist));
|
||||
}
|
||||
|
||||
if (version >= 30 && lm_music_memo_new.length > 0) {
|
||||
|
||||
@@ -7,6 +7,7 @@ export interface score {
|
||||
gArray: number[];
|
||||
mArray: number[];
|
||||
cArray: number[];
|
||||
rArray: number[];
|
||||
esArray: number[];
|
||||
|
||||
optArray: number[];
|
||||
|
||||
@@ -40,22 +40,20 @@ export function ClidToPlaySide(clid: number) {
|
||||
return clid < 5 ? 0 : 1;
|
||||
}
|
||||
|
||||
export function Base64toBuffer(s: string) {
|
||||
const base64list =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||||
let buffer = Buffer.alloc(0),
|
||||
p = -8,
|
||||
export function Base64toNumArray(s: string) {
|
||||
const base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||||
let p = -8,
|
||||
a = 0,
|
||||
c: number;
|
||||
|
||||
if (_.isNil(s)) return Buffer.alloc(0);
|
||||
c: number,
|
||||
d: number,
|
||||
buffer: number[] = [];
|
||||
|
||||
for (let i = 0; i < s.length; i++) {
|
||||
if ((c = base64list.indexOf(s.charAt(i))) < 0) continue;
|
||||
if (c == 64) break;
|
||||
if ((c = base64Chars.indexOf(s.charAt(i))) < 0) continue;
|
||||
a = (a << 6) | (c & 63);
|
||||
if ((p += 6) >= 0) {
|
||||
buffer = Buffer.concat([buffer, Buffer.from([((a >> p) & 255)])]);
|
||||
d = (a >> p) & 255;
|
||||
if (c !== 64) buffer.push(d);
|
||||
a &= 63;
|
||||
p -= 8;
|
||||
}
|
||||
@@ -64,6 +62,51 @@ export function Base64toBuffer(s: string) {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
export function NumArraytoHex(buff: number[]) {
|
||||
let hexStr = "";
|
||||
for (let i = 0; i < buff.length; i++) {
|
||||
const hex = buff[i].toString(16);
|
||||
const paddedHex = hex.length % 2 ? "0" + hex : hex;
|
||||
|
||||
hexStr += paddedHex;
|
||||
}
|
||||
|
||||
return hexStr;
|
||||
}
|
||||
|
||||
export function HextoBase64(hex: string) {
|
||||
const buffer = [];
|
||||
const base64Chars =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||||
let base64String = "";
|
||||
let i = 0;
|
||||
|
||||
for (let i = 0; i < hex.length; i += 2) {
|
||||
const hexByte = hex.substr(i, 2);
|
||||
const byteValue = parseInt(hexByte, 16);
|
||||
buffer.push(byteValue);
|
||||
}
|
||||
|
||||
while (i < buffer.length) {
|
||||
const byte1 = buffer[i++] || 0;
|
||||
const byte2 = buffer[i++] || 0;
|
||||
const byte3 = buffer[i++] || 0;
|
||||
|
||||
const enc1 = byte1 >> 2;
|
||||
const enc2 = ((byte1 & 3) << 4) | (byte2 >> 4);
|
||||
const enc3 = ((byte2 & 15) << 2) | (byte3 >> 6);
|
||||
const enc4 = byte3 & 63;
|
||||
|
||||
base64String +=
|
||||
base64Chars.charAt(enc1) +
|
||||
base64Chars.charAt(enc2) +
|
||||
(i <= buffer.length + 2 ? base64Chars.charAt(enc3) : "=") +
|
||||
(i <= buffer.length + 1 ? base64Chars.charAt(enc4) : "=");
|
||||
}
|
||||
|
||||
return base64String;
|
||||
}
|
||||
|
||||
export function NumArrayToString(bits: number[], numArray: number[]): string {
|
||||
const characters = "0123456789:;abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
let byteSum = 0;
|
||||
|
||||
Reference in New Issue
Block a user