From 9f6b0e59c8a22f53bd5910f602834cc7d60ce13c Mon Sep 17 00:00:00 2001 From: Tau Date: Sun, 1 Nov 2020 16:09:05 -0500 Subject: [PATCH] idz: Explicitly split team msg encoders --- src/idz/userdb/encoder/_team.ts | 13 ++++++++++++- src/idz/userdb/encoder/index.ts | 10 +++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/idz/userdb/encoder/_team.ts b/src/idz/userdb/encoder/_team.ts index 5ca8584..a82e405 100644 --- a/src/idz/userdb/encoder/_team.ts +++ b/src/idz/userdb/encoder/_team.ts @@ -3,7 +3,10 @@ import { CreateAutoTeamResponse } from "../response/createAutoTeam"; import { LoadTeamResponse } from "../response/loadTeam"; import { encodeChara } from "./_chara"; -export function _team(res: CreateAutoTeamResponse | LoadTeamResponse) { +function _team( + res: CreateAutoTeamResponse | LoadTeamResponse, + msgCode: number +) { const buf = Buffer.alloc(0x0ca0); if (res.type === "create_auto_team_res") { @@ -56,3 +59,11 @@ export function _team(res: CreateAutoTeamResponse | LoadTeamResponse) { return buf; } + +export function createAutoTeam(res: CreateAutoTeamResponse): Buffer { + return _team(res, 0x007c); +} + +export function loadTeam(res: LoadTeamResponse): Buffer { + return _team(res, 0x0078); +} diff --git a/src/idz/userdb/encoder/index.ts b/src/idz/userdb/encoder/index.ts index 6fab4a8..db3cfa6 100644 --- a/src/idz/userdb/encoder/index.ts +++ b/src/idz/userdb/encoder/index.ts @@ -1,6 +1,6 @@ import logger from "debug"; -import { _team } from "./_team"; +import { createAutoTeam, loadTeam } from "./_team"; import { checkTeamName } from "./checkTeamName"; import { createProfile } from "./createProfile"; import { createTeam } from "./createTeam"; @@ -46,7 +46,7 @@ function encode110(res: Response): Buffer { return checkTeamName(res); case "create_auto_team_res": - return _team(res); + return createAutoTeam(res); case "create_profile_res": return createProfile(res); @@ -94,7 +94,7 @@ function encode110(res: Response): Buffer { return loadStocker(res); case "load_team_res": - return _team(res); + return loadTeam(res); case "load_team_ranking_res": return loadTeamRanking(res); @@ -151,7 +151,7 @@ function encode130(res: Response): Buffer { return checkTeamName(res); case "create_auto_team_res": - return _team(res); + return createAutoTeam(res); case "create_profile_res": return createProfile(res); @@ -199,7 +199,7 @@ function encode130(res: Response): Buffer { return loadStocker(res); case "load_team_res": - return _team(res); + return loadTeam(res); case "load_team_ranking_res": return loadTeamRanking(res);