From b96631051d5878db998ecaf547a3c60a1e4c35c6 Mon Sep 17 00:00:00 2001 From: Tau Date: Mon, 8 Apr 2019 13:03:04 -0400 Subject: [PATCH] stub ghost(?) req --- src/idz/decoder/index.ts | 2 ++ src/idz/decoder/loadGhost.ts | 16 ++++++++++++++++ src/idz/encoder/index.ts | 4 ++++ src/idz/encoder/loadGhost.ts | 9 +++++++++ src/idz/handler/index.ts | 4 ++++ src/idz/handler/loadGhost.ts | 7 +++++++ src/idz/request/index.ts | 2 ++ src/idz/request/loadGhost.ts | 8 ++++++++ src/idz/response/index.ts | 2 ++ src/idz/response/loadGhost.ts | 3 +++ 10 files changed, 57 insertions(+) create mode 100644 src/idz/decoder/loadGhost.ts create mode 100644 src/idz/encoder/loadGhost.ts create mode 100644 src/idz/handler/loadGhost.ts create mode 100644 src/idz/request/loadGhost.ts create mode 100644 src/idz/response/loadGhost.ts diff --git a/src/idz/decoder/index.ts b/src/idz/decoder/index.ts index 9f31818..3323191 100644 --- a/src/idz/decoder/index.ts +++ b/src/idz/decoder/index.ts @@ -8,6 +8,7 @@ import { load2on2 } from "./load2on2"; import { loadConfig } from "./loadConfig"; import { loadConfig2 } from "./loadConfig2"; import { loadGeneralReward } from "./loadGeneralReward"; +import { loadGhost } from "./loadGhost"; import { loadProfile } from "./loadProfile"; import { loadRewardTable } from "./loadRewardTable"; import { loadServerList } from "./loadServerList"; @@ -48,6 +49,7 @@ const funcList: ReaderFn[] = [ loadConfig, loadConfig2, loadGeneralReward, + loadGhost, loadProfile, loadRewardTable, loadServerList, diff --git a/src/idz/decoder/loadGhost.ts b/src/idz/decoder/loadGhost.ts new file mode 100644 index 0000000..d28f2bd --- /dev/null +++ b/src/idz/decoder/loadGhost.ts @@ -0,0 +1,16 @@ +import { RequestCode } from "./_defs"; +import { LoadGhostRequest } from "../request/loadGhost"; + +loadGhost.msgCode = 0x00a0 as RequestCode; +loadGhost.msgLen = 0x0010; + +export function loadGhost(buf: Buffer): LoadGhostRequest { + return { + type: "load_ghost_req", + field_0002: buf.readUInt16LE(0x0002), + field_0004: buf.readUInt16LE(0x0004), + field_0008: buf.readUInt32LE(0x0008), + field_000C: buf.readUInt16LE(0x000c), + field_000E: buf.readUInt16LE(0x000e), + }; +} diff --git a/src/idz/encoder/index.ts b/src/idz/encoder/index.ts index ab14ea1..3a72eda 100644 --- a/src/idz/encoder/index.ts +++ b/src/idz/encoder/index.ts @@ -9,6 +9,7 @@ import { load2on2 } from "./load2on2"; import { loadConfig } from "./loadConfig"; import { loadConfig2 } from "./loadConfig2"; import { loadGeneralReward } from "./loadGeneralReward"; +import { loadGhost } from "./loadGhost"; import { loadProfile } from "./loadProfile"; import { loadProfile2 } from "./loadProfile2"; import { loadRewardTable } from "./loadRewardTable"; @@ -50,6 +51,9 @@ function encode(res: Response): Buffer { case "load_general_reward_res": return loadGeneralReward(res); + case "load_ghost_res": + return loadGhost(res); + case "load_profile_v1_res": return loadProfile(res); diff --git a/src/idz/encoder/loadGhost.ts b/src/idz/encoder/loadGhost.ts new file mode 100644 index 0000000..30f398b --- /dev/null +++ b/src/idz/encoder/loadGhost.ts @@ -0,0 +1,9 @@ +import { LoadGhostResponse } from "../response/loadGhost"; + +export function loadGhost(res: LoadGhostResponse): Buffer { + const buf = Buffer.alloc(0x0070); + + buf.writeUInt16LE(0x00a1, 0x0000); + + return buf; +} diff --git a/src/idz/handler/index.ts b/src/idz/handler/index.ts index 4460a0a..228bf65 100644 --- a/src/idz/handler/index.ts +++ b/src/idz/handler/index.ts @@ -6,6 +6,7 @@ import { load2on2 } from "./load2on2"; import { loadConfig } from "./loadConfig"; import { loadConfig2 } from "./loadConfig2"; import { loadGeneralReward } from "./loadGeneralReward"; +import { loadGhost } from "./loadGhost"; import { loadProfile } from "./loadProfile"; import { loadReward as loadRewardTable } from "./loadRewardTable"; import { loadServerList } from "./loadServerList"; @@ -58,6 +59,9 @@ export async function dispatch(w: World, req: Request): Promise { case "load_general_reward_req": return loadGeneralReward(w, req); + case "load_ghost_req": + return loadGhost(w, req); + case "load_profile_req": return loadProfile(w, req); diff --git a/src/idz/handler/loadGhost.ts b/src/idz/handler/loadGhost.ts new file mode 100644 index 0000000..bca3982 --- /dev/null +++ b/src/idz/handler/loadGhost.ts @@ -0,0 +1,7 @@ +import { LoadGhostRequest } from "../request/loadGhost"; +import { LoadGhostResponse } from "../response/loadGhost"; +import { World } from "../world"; + +export function loadGhost(w: World, req: LoadGhostRequest): LoadGhostResponse { + return { type: "load_ghost_res" }; +} diff --git a/src/idz/request/index.ts b/src/idz/request/index.ts index a2396fe..cea92cb 100644 --- a/src/idz/request/index.ts +++ b/src/idz/request/index.ts @@ -6,6 +6,7 @@ import { Load2on2Request } from "./load2on2"; import { LoadConfigRequest } from "./loadConfig"; import { LoadConfigRequest2 } from "./loadConfig2"; import { LoadGeneralRewardRequest } from "./loadGeneralReward"; +import { LoadGhostRequest } from "./loadGhost"; import { LoadProfileRequest } from "./loadProfile"; import { LoadRewardTableRequest } from "./loadRewardTable"; import { LoadServerListRequest } from "./loadServerList"; @@ -39,6 +40,7 @@ export type Request = | LoadConfigRequest | LoadConfigRequest2 | LoadGeneralRewardRequest + | LoadGhostRequest | LoadProfileRequest | LoadRewardTableRequest | LoadServerListRequest diff --git a/src/idz/request/loadGhost.ts b/src/idz/request/loadGhost.ts new file mode 100644 index 0000000..c0b1a48 --- /dev/null +++ b/src/idz/request/loadGhost.ts @@ -0,0 +1,8 @@ +export interface LoadGhostRequest { + type: "load_ghost_req"; + field_0002: number; // u16 + field_0004: number; // u16 + field_0008: number; // u32 + field_000C: number; // u16 + field_000E: number; // u16 +} diff --git a/src/idz/response/index.ts b/src/idz/response/index.ts index e88baeb..a7e8c10 100644 --- a/src/idz/response/index.ts +++ b/src/idz/response/index.ts @@ -6,6 +6,7 @@ import { Load2on2Response } from "./load2on2"; import { LoadConfigResponse } from "./loadConfig"; import { LoadConfigResponse2 } from "./loadConfig2"; import { LoadGeneralRewardResponse } from "./loadGeneralReward"; +import { LoadGhostResponse } from "./loadGhost"; import { LoadProfileResponse } from "./loadProfile"; import { LoadProfileResponse2 } from "./loadProfile2"; import { LoadRewardTableResponse } from "./loadRewardTable"; @@ -31,6 +32,7 @@ export type Response = | LoadConfigResponse | LoadConfigResponse2 | LoadGeneralRewardResponse + | LoadGhostResponse | LoadProfileResponse | LoadProfileResponse2 | LoadRewardTableResponse diff --git a/src/idz/response/loadGhost.ts b/src/idz/response/loadGhost.ts new file mode 100644 index 0000000..fbc3dde --- /dev/null +++ b/src/idz/response/loadGhost.ts @@ -0,0 +1,3 @@ +export interface LoadGhostResponse { + type: "load_ghost_res"; +}