idz: Split/fix loadGhost encoder

This commit is contained in:
BemaniWitch 2021-02-03 18:16:54 -05:00 committed by Tau
parent 59ec2bf576
commit 1f141cb706
2 changed files with 14 additions and 6 deletions

View File

@ -29,7 +29,7 @@ import { loadEventInfo1, loadEventInfo2 } from "./loadEventInfo";
import { loadGacha1, loadGacha2 } from "./loadGacha";
import { loadGarage1, loadGarage2 } from "./loadGarage";
import { loadGeneralReward } from "./loadGeneralReward";
import { loadGhost } from "./loadGhost";
import { loadGhost1, loadGhost2 } from "./loadGhost";
import { loadProfile2 } from "./loadProfile2";
import { loadProfile3 } from "./loadProfile3";
import { loadProfile4 } from "./loadProfile4";
@ -106,7 +106,7 @@ function encode110(res: Response): Buffer {
return loadGeneralReward(res);
case "load_ghost_res":
return loadGhost(res);
return loadGhost1(res);
case "load_profile_res":
return loadProfile2(res);
@ -217,7 +217,7 @@ function encode130(res: Response): Buffer {
return loadGeneralReward(res);
case "load_ghost_res":
return loadGhost(res);
return loadGhost1(res);
case "load_profile_res":
return loadProfile3(res);
@ -328,7 +328,7 @@ function encode210(res: Response): Buffer {
return loadGeneralReward(res);
case "load_ghost_res":
return loadGhost(res);
return loadGhost2(res);
case "load_profile_res":
return loadProfile4(res);

View File

@ -1,11 +1,11 @@
import { LoadGhostResponse } from "../response/loadGhost";
export function loadGhost(res: LoadGhostResponse): Buffer {
function _loadGhost(msgCode: number, res: LoadGhostResponse): Buffer {
const buf = Buffer.alloc(0x0070);
// No idea what any of this even does.
buf.writeUInt16LE(0x00a1, 0x0000);
buf.writeUInt16LE(msgCode, 0x0000);
buf.writeUInt16LE(0x0005, 0x0002); // Chunk presence flags: 4 | 1
for (let i = 0; i < 2; i++) {
@ -29,3 +29,11 @@ export function loadGhost(res: LoadGhostResponse): Buffer {
return buf;
}
export function loadGhost1(res: LoadGhostResponse): Buffer {
return _loadGhost(0x00a1, res);
}
export function loadGhost2(res: LoadGhostResponse): Buffer {
return _loadGhost(0x0096, res);
}