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
+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"]}`);
}
}