idz: Add new saveExpedition msg format

This commit is contained in:
Tau
2019-11-06 17:28:30 -05:00
parent 0f67c00664
commit 2f48efdbb9
6 changed files with 79 additions and 10 deletions
+30 -2
View File
@@ -1,6 +1,25 @@
import { SaveExpeditionResponse } from "../response/saveExpedition";
import {
SaveExpeditionResponse,
SaveExpeditionResponse1,
SaveExpeditionResponse2,
} from "../response/saveExpedition";
export function saveExpedition(res: SaveExpeditionResponse) {
export function saveExpedition(res: SaveExpeditionResponse): Buffer {
switch (res.format) {
case 1:
return saveExpedition1(res);
case 2:
return saveExpedition2(res);
default:
const exhaust: never = res;
throw new Error(`Unsupported data format ${res["format"]}`);
}
}
function saveExpedition1(res: SaveExpeditionResponse1): Buffer {
// in awe of the size of this lad
const buf = Buffer.alloc(0x17c0);
@@ -8,3 +27,12 @@ export function saveExpedition(res: SaveExpeditionResponse) {
return buf;
}
function saveExpedition2(res: SaveExpeditionResponse2): Buffer {
// absolute unit
const buf = Buffer.alloc(0x18ac);
buf.writeUInt16LE(0x0140, 0x0000);
return buf;
}