idz: Split/fix loadConfig messages

This commit is contained in:
Tau
2021-02-03 23:43:42 +00:00
committed by Tau
parent 5cc68bd339
commit 0e788638bb
10 changed files with 131 additions and 44 deletions
+12 -7
View File
@@ -10,7 +10,12 @@ import {
load2on2Info, load2on2Info,
load2on2RankingPoints2, load2on2RankingPoints2,
} from "./load2on2"; } from "./load2on2";
import { loadConfig1, loadConfig2 } from "./loadConfig"; import {
loadConfigA_1,
loadConfigB_1,
loadConfigA_2,
loadConfigB_2,
} from "./loadConfig";
import { loadEventInfo1, loadEventInfo2 } from "./loadEventInfo"; import { loadEventInfo1, loadEventInfo2 } from "./loadEventInfo";
import { loadGacha1, loadGacha2 } from "./loadGacha"; import { loadGacha1, loadGacha2 } from "./loadGacha";
import { loadGarage1, loadGarage2 } from "./loadGarage"; import { loadGarage1, loadGarage2 } from "./loadGarage";
@@ -92,8 +97,8 @@ const funcList110: ReaderFn[] = [
createTeam1, createTeam1,
discoverProfile1, discoverProfile1,
load2on2RankingPoints1, load2on2RankingPoints1,
loadConfig1, loadConfigA_1,
loadConfig2, loadConfigB_1,
loadEventInfo1, loadEventInfo1,
loadGacha1, loadGacha1,
loadGarage1, loadGarage1,
@@ -138,8 +143,8 @@ const funcList130: ReaderFn[] = [
discoverProfile1, discoverProfile1,
load2on2Info, load2on2Info,
updateStoryClearNum2, updateStoryClearNum2,
loadConfig1, loadConfigA_1,
loadConfig2, loadConfigB_1,
loadEventInfo1, loadEventInfo1,
loadGacha1, loadGacha1,
loadGarage1, loadGarage1,
@@ -184,8 +189,8 @@ const funcList210: ReaderFn[] = [
load2on2Info, load2on2Info,
load2on2RankingPoints2, load2on2RankingPoints2,
updateStoryClearNum3, updateStoryClearNum3,
loadConfig1, loadConfigA_2,
loadConfig2, loadConfigB_2,
loadEventInfo2, loadEventInfo2,
loadGacha2, loadGacha2,
loadGarage2, loadGarage2,
+23 -9
View File
@@ -1,15 +1,29 @@
import { LoadConfigRequest } from "../request/loadConfig"; import { LoadConfigRequestA, LoadConfigRequestB } from "../request/loadConfig";
loadConfig1.msgCode = 0x0004; loadConfigA_1.msgCode = 0x0004;
loadConfig1.msgLen = 0x0050; loadConfigA_1.msgLen = 0x0050;
export function loadConfig1(): LoadConfigRequest { export function loadConfigA_1(): LoadConfigRequestA {
return { type: "load_config_req" }; return { type: "load_config_A_req" };
} }
loadConfig2.msgCode = 0x00ab; loadConfigB_1.msgCode = 0x00ab;
loadConfig2.msgLen = 0x0010; loadConfigB_1.msgLen = 0x0010;
export function loadConfig2(): LoadConfigRequest { export function loadConfigB_1(): LoadConfigRequestB {
return { type: "load_config_req" }; return { type: "load_config_B_req" };
}
loadConfigA_2.msgCode = 0x0004;
loadConfigA_2.msgLen = 0x0050;
export function loadConfigA_2(): LoadConfigRequestA {
return { type: "load_config_A_req" };
}
loadConfigB_2.msgCode = 0x00a0;
loadConfigB_2.msgLen = 0x0010;
export function loadConfigB_2(): LoadConfigRequestB {
return { type: "load_config_B_req" };
} }
+21 -7
View File
@@ -19,7 +19,12 @@ import {
load2on2RankingPoints2, load2on2RankingPoints2,
load2on2Info2, load2on2Info2,
} from "./load2on2"; } from "./load2on2";
import { loadConfig1, loadConfig2 } from "./loadConfig"; import {
loadConfigA_1,
loadConfigB_1,
loadConfigA_2,
loadConfigB_2,
} from "./loadConfig";
import { loadEventInfo1, loadEventInfo2 } from "./loadEventInfo"; import { loadEventInfo1, loadEventInfo2 } from "./loadEventInfo";
import { loadGacha1, loadGacha2 } from "./loadGacha"; import { loadGacha1, loadGacha2 } from "./loadGacha";
import { loadGarage1, loadGarage2 } from "./loadGarage"; import { loadGarage1, loadGarage2 } from "./loadGarage";
@@ -80,8 +85,11 @@ function encode110(res: Response): Buffer {
case "load_2on2_info_res": case "load_2on2_info_res":
return load2on2Info1(res); return load2on2Info1(res);
case "load_config_res": case "load_config_A_res":
return loadConfig1(res); return loadConfigA_1(res);
case "load_config_B_res":
return loadConfigB_1(res);
case "load_event_info_res": case "load_event_info_res":
return loadEventInfo1(res); return loadEventInfo1(res);
@@ -188,8 +196,11 @@ function encode130(res: Response): Buffer {
case "load_2on2_info_res": case "load_2on2_info_res":
return load2on2Info1(res); return load2on2Info1(res);
case "load_config_res": case "load_config_A_res":
return loadConfig2(res); return loadConfigA_1(res);
case "load_config_B_res":
return loadConfigB_1(res);
case "load_event_info_res": case "load_event_info_res":
return loadEventInfo2(res); return loadEventInfo2(res);
@@ -296,8 +307,11 @@ function encode210(res: Response): Buffer {
case "load_2on2_info_res": case "load_2on2_info_res":
return load2on2Info2(res); return load2on2Info2(res);
case "load_config_res": case "load_config_A_res":
return loadConfig2(res); return loadConfigA_2(res);
case "load_config_B_res":
return loadConfigB_2(res);
case "load_event_info_res": case "load_event_info_res":
return loadEventInfo1(res); return loadEventInfo1(res);
+25 -3
View File
@@ -1,6 +1,9 @@
import { LoadConfigResponse } from "../response/loadConfig"; import {
LoadConfigResponseA,
LoadConfigResponseB,
} from "../response/loadConfig";
export function loadConfig1(res: LoadConfigResponse) { export function loadConfigA_1(res: LoadConfigResponseA) {
const buf = Buffer.alloc(0x01a0); const buf = Buffer.alloc(0x01a0);
buf.writeInt16LE(0x0005, 0x0000); buf.writeInt16LE(0x0005, 0x0000);
@@ -10,7 +13,7 @@ export function loadConfig1(res: LoadConfigResponse) {
return buf; return buf;
} }
export function loadConfig2(res: LoadConfigResponse) { export function loadConfigB_1(res: LoadConfigResponseB) {
const buf = Buffer.alloc(0x0230); const buf = Buffer.alloc(0x0230);
buf.writeInt16LE(0x00ac, 0x0000); buf.writeInt16LE(0x00ac, 0x0000);
@@ -18,3 +21,22 @@ export function loadConfig2(res: LoadConfigResponse) {
return buf; return buf;
} }
export function loadConfigA_2(res: LoadConfigResponseA) {
const buf = Buffer.alloc(0x05e0);
buf.writeInt16LE(0x0005, 0x0000);
buf.writeInt8(res.status, 0x0002);
buf.writeUInt16LE(res.serverVersion, 0x0016);
return buf;
}
export function loadConfigB_2(res: LoadConfigResponseB) {
const buf = Buffer.alloc(0x0240);
buf.writeInt16LE(0x00a1, 0x0000);
buf.writeInt8(res.status, 0x0002);
return buf;
}
+6 -3
View File
@@ -4,7 +4,7 @@ import { createProfile } from "./createProfile";
import { createTeam } from "./createTeam"; import { createTeam } from "./createTeam";
import { discoverProfile } from "./discoverProfile"; import { discoverProfile } from "./discoverProfile";
import { load2on2Info, load2on2RankingPoints } from "./load2on2"; import { load2on2Info, load2on2RankingPoints } from "./load2on2";
import { loadConfig } from "./loadConfig"; import { loadConfig1, loadConfig2 } from "./loadConfig";
import { loadEventInfo } from "./loadEventInfo"; import { loadEventInfo } from "./loadEventInfo";
import { loadGacha } from "./loadGacha"; import { loadGacha } from "./loadGacha";
import { loadGarage } from "./loadGarage"; import { loadGarage } from "./loadGarage";
@@ -68,8 +68,11 @@ export async function dispatch(
case "load_2on2_ranking_points_req": case "load_2on2_ranking_points_req":
return load2on2RankingPoints(w, req); return load2on2RankingPoints(w, req);
case "load_config_req": case "load_config_A_req":
return loadConfig(w, req); return loadConfig1(w, req, clientHello);
case "load_config_B_req":
return loadConfig2(w, req);
case "discover_profile_req": case "discover_profile_req":
return discoverProfile(w, req); return discoverProfile(w, req);
+25 -7
View File
@@ -1,14 +1,32 @@
import { LoadConfigRequest } from "../request/loadConfig"; import { LoadConfigRequestA, LoadConfigRequestB } from "../request/loadConfig";
import { LoadConfigResponse } from "../response/loadConfig"; import {
LoadConfigResponseA,
LoadConfigResponseB,
} from "../response/loadConfig";
import { Repositories } from "../repo"; import { Repositories } from "../repo";
import { ClientHello } from "../../common";
export function loadConfig( export function loadConfig1(
w: Repositories, w: Repositories,
req: LoadConfigRequest req: LoadConfigRequestA,
): LoadConfigResponse { clientHello: ClientHello
): LoadConfigResponseA {
return { return {
type: "load_config_res", type: "load_config_A_res",
status: 1,
// Only advertise up to v210 for now, advertising v230 to the v230 client
// will activate a bunch of stuff that's currently broken.
serverVersion: Math.min(parseInt(clientHello.protocol), 210),
};
}
export function loadConfig2(
w: Repositories,
req: LoadConfigRequestB
): LoadConfigResponseB {
return {
type: "load_config_B_res",
status: 1, status: 1,
serverVersion: 130,
}; };
} }
+3 -2
View File
@@ -4,7 +4,7 @@ import { CreateTeamRequest } from "./createTeam";
import { DiscoverProfileRequest } from "./discoverProfile"; import { DiscoverProfileRequest } from "./discoverProfile";
import { CreateAutoTeamRequest } from "./createAutoTeam"; import { CreateAutoTeamRequest } from "./createAutoTeam";
import { Load2on2InfoRequest, Load2on2RankingPointsRequest } from "./load2on2"; import { Load2on2InfoRequest, Load2on2RankingPointsRequest } from "./load2on2";
import { LoadConfigRequest } from "./loadConfig"; import { LoadConfigRequestA, LoadConfigRequestB } from "./loadConfig";
import { LoadEventInfoRequest } from "./loadEventInfo"; import { LoadEventInfoRequest } from "./loadEventInfo";
import { LoadGachaRequest } from "./loadGacha"; import { LoadGachaRequest } from "./loadGacha";
import { LoadGarageRequest } from "./loadGarage"; import { LoadGarageRequest } from "./loadGarage";
@@ -48,7 +48,8 @@ export type Request =
| DiscoverProfileRequest | DiscoverProfileRequest
| Load2on2InfoRequest | Load2on2InfoRequest
| Load2on2RankingPointsRequest | Load2on2RankingPointsRequest
| LoadConfigRequest | LoadConfigRequestA
| LoadConfigRequestB
| LoadEventInfoRequest | LoadEventInfoRequest
| LoadGachaRequest | LoadGachaRequest
| LoadGarageRequest | LoadGarageRequest
+6 -2
View File
@@ -1,3 +1,7 @@
export interface LoadConfigRequest { export interface LoadConfigRequestA {
type: "load_config_req"; type: "load_config_A_req";
}
export interface LoadConfigRequestB {
type: "load_config_B_req";
} }
+3 -2
View File
@@ -8,7 +8,7 @@ import {
Load2on2InfoResponse, Load2on2InfoResponse,
Load2on2RankingPointsResponse, Load2on2RankingPointsResponse,
} from "./load2on2"; } from "./load2on2";
import { LoadConfigResponse } from "./loadConfig"; import { LoadConfigResponseA, LoadConfigResponseB } from "./loadConfig";
import { LoadEventInfoResponse } from "./loadEventInfo"; import { LoadEventInfoResponse } from "./loadEventInfo";
import { LoadGachaResponse } from "./loadGacha"; import { LoadGachaResponse } from "./loadGacha";
import { LoadGarageResponse } from "./loadGarage"; import { LoadGarageResponse } from "./loadGarage";
@@ -43,7 +43,8 @@ export type Response =
| GenericResponse | GenericResponse
| Load2on2InfoResponse | Load2on2InfoResponse
| Load2on2RankingPointsResponse | Load2on2RankingPointsResponse
| LoadConfigResponse | LoadConfigResponseA
| LoadConfigResponseB
| LoadEventInfoResponse | LoadEventInfoResponse
| LoadGachaResponse | LoadGachaResponse
| LoadGarageResponse | LoadGarageResponse
+7 -2
View File
@@ -1,5 +1,10 @@
export interface LoadConfigResponse { export interface LoadConfigResponseA {
type: "load_config_res"; type: "load_config_A_res";
status: number; status: number;
serverVersion: number; serverVersion: number;
} }
export interface LoadConfigResponseB {
type: "load_config_B_res";
status: number;
}