idz: Fix _team encoders

This commit is contained in:
BemaniWitch 2021-02-03 18:12:11 -05:00 committed by Tau
parent f0771b5791
commit 3cdfef2ea8
2 changed files with 64 additions and 17 deletions

View File

@ -3,19 +3,14 @@ import { CreateAutoTeamResponse } from "../response/createAutoTeam";
import { LoadTeamResponse } from "../response/loadTeam";
import { encodeChara1 } from "./_chara";
function _team(
res: CreateAutoTeamResponse | LoadTeamResponse,
msgCode: number
function _team1(
msgCode: number,
res: CreateAutoTeamResponse | LoadTeamResponse
) {
const buf = Buffer.alloc(0x0ca0);
if (res.type === "create_auto_team_res") {
buf.writeInt16LE(0x007c, 0x0000);
} else {
buf.writeInt16LE(0x0078, 0x0000);
}
const leader = res.members.find(item => item.leader === true);
buf.writeInt16LE(msgCode, 0x0000);
buf.writeUInt32LE(res.team.extId, 0x000c);
writeSjisStr(buf, 0x0010, 0x0024, leader ? leader.profile.name : "Error");
writeSjisStr(buf, 0x0024, 0x0044, res.team.name);
@ -27,7 +22,59 @@ function _team(
buf.writeUInt32LE(leader ? leader.profile.aimeId : 0, 0x0080);
for (let i = 0; i < 6; i++) {
const base = 0x011c + i * 0x005c;
const base = 0x011c + i * 0x005c; // Differs between v1 and v2
const member = res.members[i];
if (member === undefined) {
break;
}
const { profile, chara } = member;
const accessTime = (profile.accessTime.getTime() / 1000) | 0;
buf.writeInt32LE(profile.aimeId, base + 0x0000);
writeSjisStr(buf, 0x0004, 0x0018, profile.name);
buf.writeInt32LE(profile.lv, base + 0x0018);
buf.writeInt32LE(0, base + 0x0024); // Month points, TODO
buf.writeUInt32LE(accessTime, base + 0x0034);
encodeChara1(chara).copy(buf, base + 0x0044);
}
// Team Time Attack:
/*for (let i = 0; i < 6; i++) {
const base = 0x0344 + 0x20 * i;
buf.writeInt16LE(0x00001, base + 0x0000);
buf.writeInt8(0x02, base + 0x0003);
buf.writeInt32LE(0x00000003, base + 0x0004);
iconv.encode("str\0", "shift_jis").copy(buf, base + 0x0008);
buf.writeInt32LE(0x00000004, base + 0x001c);
}*/
return buf;
}
function _team2(
msgCode: number,
res: CreateAutoTeamResponse | LoadTeamResponse
) {
const buf = Buffer.alloc(0x0ca0);
const leader = res.members.find(item => item.leader === true);
buf.writeInt16LE(msgCode, 0x0000);
buf.writeUInt32LE(res.team.extId, 0x000c);
writeSjisStr(buf, 0x0010, 0x0024, leader ? leader.profile.name : "Error");
writeSjisStr(buf, 0x0024, 0x0044, res.team.name);
writeSjisStr(buf, 0x0044, 0x00d8, process.env.SHOP_NAME || "");
buf.writeUInt32LE(res.team.nameBg, 0x00d8);
buf.writeUInt32LE(res.team.nameFx, 0x00dc);
buf.fill(0xff, 0x00e0, 0x00f9); // Bitset: Unlocked BGs probably
buf.fill(0xff, 0x00f9, 0x0101); // Bitset: Unlocked FX probably
buf.writeUInt32LE(leader ? leader.profile.aimeId : 0, 0x0080);
for (let i = 0; i < 6; i++) {
const base = 0x0120 + i * 0x005c; // Differs between v1 and v2
const member = res.members[i];
if (member === undefined) {
@ -61,17 +108,17 @@ function _team(
}
export function createAutoTeam1(res: CreateAutoTeamResponse): Buffer {
return _team(res, 0x007c);
return _team1(0x007c, res);
}
export function loadTeam1(res: LoadTeamResponse): Buffer {
return _team(res, 0x0078);
return _team1(0x0078, res);
}
export function createAutoTeam2(res: CreateAutoTeamResponse): Buffer {
return _team(res, 0x0078);
return _team2(0x0078, res);
}
export function loadTeam2(res: LoadTeamResponse): Buffer {
return _team(res, 0x0074);
return _team2(0x0074, res);
}

View File

@ -232,7 +232,7 @@ function encode130(res: Response): Buffer {
return loadStocker2(res);
case "load_team_res":
return loadTeam2(res);
return loadTeam1(res);
case "load_team_ranking_res":
return loadTeamRanking2(res);
@ -343,7 +343,7 @@ function encode210(res: Response): Buffer {
return loadStocker1(res);
case "load_team_res":
return loadTeam1(res);
return loadTeam2(res);
case "load_team_ranking_res":
return loadTeamRanking1(res);