From dcb4f12a99b52fcf945260af2e9a63c9a6bb6864 Mon Sep 17 00:00:00 2001 From: BemaniWitch Date: Sat, 31 Oct 2020 15:33:59 -0400 Subject: [PATCH] idz: Add UpdateExpedition command --- src/idz/userdb/decoder/updateExpedition.ts | 13 +++++++++++++ src/idz/userdb/encoder/updateExpedition.ts | 18 ++++++++++++++++++ src/idz/userdb/handler/updateExpedition.ts | 14 ++++++++++++++ src/idz/userdb/request/updateExpedition.ts | 4 ++++ src/idz/userdb/response/updateExpedition.ts | 4 ++++ 5 files changed, 53 insertions(+) create mode 100644 src/idz/userdb/decoder/updateExpedition.ts create mode 100644 src/idz/userdb/encoder/updateExpedition.ts create mode 100644 src/idz/userdb/handler/updateExpedition.ts create mode 100644 src/idz/userdb/request/updateExpedition.ts create mode 100644 src/idz/userdb/response/updateExpedition.ts diff --git a/src/idz/userdb/decoder/updateExpedition.ts b/src/idz/userdb/decoder/updateExpedition.ts new file mode 100644 index 0000000..056a631 --- /dev/null +++ b/src/idz/userdb/decoder/updateExpedition.ts @@ -0,0 +1,13 @@ +import { UpdateExpeditionRequest } from "../request/updateExpedition"; + +updateExpedition.msgCode = 0x013F; +updateExpedition.msgLen = 0x0010; + +export function updateExpedition( + buf: Buffer +): UpdateExpeditionRequest { + return { + type: "update_expedition_req", + expeditionRequestType: buf.readUInt32LE(0x0004), + }; +} diff --git a/src/idz/userdb/encoder/updateExpedition.ts b/src/idz/userdb/encoder/updateExpedition.ts new file mode 100644 index 0000000..a864c2b --- /dev/null +++ b/src/idz/userdb/encoder/updateExpedition.ts @@ -0,0 +1,18 @@ +import { UpdateExpeditionResponse } from "../response/updateExpedition"; + +export function updateExpedition(res: UpdateExpeditionResponse) { + let buf: Buffer; + + if (res.expeditionType == 0) { + buf = Buffer.alloc(0x0040); + buf.writeInt16LE(1, 0x0000); + } else { + buf = Buffer.alloc(0x19f0); + buf.writeInt16LE(0x0140, 0x0000); + // Experiments used to live here, removed because they're a not-really + // working mess. Hopefully, one day there will be beautiful code + // here, that works and makes people happy. One day. + } + + return buf; +} diff --git a/src/idz/userdb/handler/updateExpedition.ts b/src/idz/userdb/handler/updateExpedition.ts new file mode 100644 index 0000000..1a88c0c --- /dev/null +++ b/src/idz/userdb/handler/updateExpedition.ts @@ -0,0 +1,14 @@ +import { UpdateExpeditionRequest } from "../request/updateExpedition"; +import { UpdateExpeditionResponse } from "../response/updateExpedition"; +import { Repositories } from "../repo"; + +export async function updateExpedition( + w: Repositories, + req: UpdateExpeditionRequest +): Promise { + + return { + type: "update_expedition_res", + expeditionType: req.expeditionRequestType, + }; +} diff --git a/src/idz/userdb/request/updateExpedition.ts b/src/idz/userdb/request/updateExpedition.ts new file mode 100644 index 0000000..966a45b --- /dev/null +++ b/src/idz/userdb/request/updateExpedition.ts @@ -0,0 +1,4 @@ +export interface UpdateExpeditionRequest { + type: "update_expedition_req"; + expeditionRequestType: number; +} diff --git a/src/idz/userdb/response/updateExpedition.ts b/src/idz/userdb/response/updateExpedition.ts new file mode 100644 index 0000000..0f4e385 --- /dev/null +++ b/src/idz/userdb/response/updateExpedition.ts @@ -0,0 +1,4 @@ +export interface UpdateExpeditionResponse { + type: "update_expedition_res"; + expeditionType: number; +}