idz: Tweak how request variants are modelled

This commit is contained in:
Tau
2019-11-06 17:28:30 -05:00
parent 6b58c4d722
commit 5bac5b6abc
8 changed files with 73 additions and 51 deletions
+1 -5
View File
@@ -13,7 +13,6 @@ import { loadGarage } from "./loadGarage";
import { loadGeneralReward } from "./loadGeneralReward";
import { loadGhost } from "./loadGhost";
import { loadProfile } from "./loadProfile";
import { loadProfile2 } from "./loadProfile2";
import { loadRewardTable } from "./loadRewardTable";
import { loadServerList } from "./loadServerList";
import { loadStocker } from "./loadStocker";
@@ -64,12 +63,9 @@ function encode(res: Response): Buffer {
case "load_ghost_res":
return loadGhost(res);
case "load_profile_v1_res":
case "load_profile_res":
return loadProfile(res);
case "load_profile_v2_res":
return loadProfile2(res);
case "load_reward_table_res":
return loadRewardTable(res);
+12 -4
View File
@@ -1,10 +1,18 @@
import { loadProfile1 } from "./loadProfile1";
import { loadProfile2 } from "./loadProfile2";
import { LoadProfileResponse } from "../response/loadProfile";
// Sending this causes an error
export function loadProfile(res: LoadProfileResponse) {
const buf = Buffer.alloc(0x0c60);
switch (res.format) {
case 1:
return loadProfile1(res);
buf.writeInt16LE(0x0064, 0x0000);
case 2:
return loadProfile2(res);
return buf;
default:
const exhaust: never = res;
throw new Error(`Unsupported profile response format ${res["format"]}`);
}
}
+12
View File
@@ -0,0 +1,12 @@
import { LoadProfileResponse1 } from "../response/loadProfile";
// Sending this causes an error in v1.21, so it is currently unmapped and
// unimplemented.
export function loadProfile1(res: LoadProfileResponse1) {
const buf = Buffer.alloc(0x0c60);
buf.writeInt16LE(0x0064, 0x0000);
return buf;
}
+1 -1
View File
@@ -4,7 +4,7 @@ import { bitmap } from "./_bitmap";
import { car } from "./_car";
import { chara } from "./_chara";
import { mission } from "./_mission";
import { LoadProfileResponse2 } from "../response/loadProfile2";
import { LoadProfileResponse2 } from "../response/loadProfile";
export function loadProfile2(res: LoadProfileResponse2) {
const buf = Buffer.alloc(0x0d30);