Add LoadGeneralRewardResponse notes

Mapped this out while investigating an issue that turned out to be
unrelated, may as well check in my findings.
This commit is contained in:
Tau 2019-04-16 10:15:02 -04:00
parent 141cb4b90c
commit ec1ccb7f7a
3 changed files with 31 additions and 3 deletions

View File

@ -1,10 +1,29 @@
import iconv = require("iconv-lite");
import { LoadGeneralRewardResponse } from "../response/loadGeneralReward";
// A generic response is acceptable too so why even bother with this..
export function loadGeneralReward(res: LoadGeneralRewardResponse) {
const buf = Buffer.alloc(0x0330);
buf.writeInt16LE(0x009d, 0x0000);
// Traversal code shat out by MSVC uses shifted pointers and neither the
// beginning nor the end of each entry in this array gets read, so the true
// start of the array and offsets of each item's fields are still uncertain.
for (let i = 0; i < 10 && i < res.items.length; i++) {
const item = res.items[i];
const base = 0x04 + 0x50 * i;
iconv.encode(item.field_04, "shift_jis").copy(buf, base + 0x04);
buf.writeUInt32LE(item.field_2C, base + 0x2c);
buf.writeUInt8(item.field_38, base + 0x38);
buf.writeUInt8(item.field_39, base + 0x39);
for (let j = 0; j < 4 && j < item.field_3C.length; j++) {
buf.writeUInt32LE(item.field_3C[j], base + 0x3c + 4 * j);
}
}
return buf;
}

View File

@ -1,11 +1,12 @@
import { LoadGeneralRewardRequest } from "../request/loadGeneralReward";
import { GenericResponse } from "../response/generic";
import { LoadGeneralRewardResponse } from "../response/loadGeneralReward";
import { World } from "../world";
export function loadGeneralReward(
w: World,
req: LoadGeneralRewardRequest
): GenericResponse {
): LoadGeneralRewardResponse | GenericResponse {
// A non-generic response is also accepted, but why bother
return { type: "generic_res" };
}

View File

@ -1,4 +1,12 @@
export interface LoadGeneralRewardItem {
field_04: string; // 40 chars max
field_2C: number; // payload?
field_38: number; // u8
field_39: number; // u8
field_3C: number[]; // u32 * 4
}
export interface LoadGeneralRewardResponse {
type: "load_general_reward_res";
// TODO
items: LoadGeneralRewardItem[];
}