From 1f141cb706817ee61813c54ca7bc6dfae88fcb86 Mon Sep 17 00:00:00 2001 From: BemaniWitch Date: Wed, 3 Feb 2021 18:16:54 -0500 Subject: [PATCH] idz: Split/fix loadGhost encoder --- src/idz/userdb/encoder/index.ts | 8 ++++---- src/idz/userdb/encoder/loadGhost.ts | 12 ++++++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/idz/userdb/encoder/index.ts b/src/idz/userdb/encoder/index.ts index 989bce5..8b3b2d8 100644 --- a/src/idz/userdb/encoder/index.ts +++ b/src/idz/userdb/encoder/index.ts @@ -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); diff --git a/src/idz/userdb/encoder/loadGhost.ts b/src/idz/userdb/encoder/loadGhost.ts index 035f73d..16db2c4 100644 --- a/src/idz/userdb/encoder/loadGhost.ts +++ b/src/idz/userdb/encoder/loadGhost.ts @@ -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); +}