consolidate car load/save

This commit is contained in:
Tau
2019-11-06 17:28:29 -05:00
parent d62864efb5
commit f6c711631a
21 changed files with 178 additions and 21 deletions
+27
View File
@@ -0,0 +1,27 @@
import { Car } from "../model/car";
export function car(buf: Buffer): Car {
const field_04: number[] = [];
for (let i = 0; i < 32; i++) {
field_04.push(buf.readUInt16LE(0x0004 + 2 * i));
}
return {
field_00: buf.readUInt16LE(0x0000),
field_02: buf.readUInt16LE(0x0002),
field_04,
model: buf.readUInt16LE(0x0044),
color: buf.readUInt16LE(0x0046),
transmission: buf.readUInt16LE(0x0048),
field_4A: buf.readUInt16LE(0x004a),
field_4C: buf.readUInt32LE(0x004c),
field_50_lo: buf.readUInt32LE(0x0050),
field_50_hi: buf.readUInt32LE(0x0054),
field_58: buf.readUInt16LE(0x0058),
field_5A: buf.readUInt8(0x005a),
field_5B: buf.readUInt8(0x005b),
field_5C: buf.readUInt16LE(0x005c),
field_5E: buf.readUInt16LE(0x005e),
};
}
+2 -10
View File
@@ -2,6 +2,7 @@ import iconv = require("iconv-lite");
import { RequestCode } from "../defs";
import { CreateProfileRequest } from "../request/createProfile";
import { car } from "./_car";
createProfile.msgCode = 0x0066 as RequestCode;
createProfile.msgLen = 0x00c0;
@@ -16,16 +17,7 @@ export function createProfile(buf: Buffer): CreateProfileRequest {
"shift_jis"
),
field_0034: buf.readUInt32LE(0x0034),
field_0040: buf.slice(0x0040, 0x0084),
car_type: buf.readUInt16LE(0x0084),
car_color: buf.readUInt16LE(0x0086),
transmission: buf.readUInt16LE(0x0088) === 0 ? "auto" : "manual",
field_008A: buf.readUInt16LE(0x008a),
field_008C: buf.readUInt16LE(0x008c),
field_0090:
BigInt(buf.readUInt32LE(0x0090)) |
(BigInt(buf.readUInt32LE(0x0094)) << 32n),
field_009C: buf.readUInt16LE(0x009c),
car: car(buf.slice(0x0040, 0x00a0)),
gender: buf.readUInt16LE(0x00a0) === 0 ? "male" : "female",
field_00A2: buf.readUInt16LE(0x00a2),
field_00A4: buf.readUInt16LE(0x00a4),
+2
View File
@@ -16,6 +16,7 @@ import { loadTeamRanking, loadTeamRanking2 } from "./loadTeamRanking";
import { lockGarage } from "./lockGarage";
import { lockProfile } from "./lockProfile";
import { saveExpedition } from "./saveExpedition";
import { saveGarage } from "./saveGarage";
import { saveProfile } from "./saveProfile";
import { saveSettings } from "./saveSettings";
import { saveStocker } from "./saveStocker";
@@ -52,6 +53,7 @@ const funcList: ReaderFn[] = [
lockGarage,
lockProfile,
saveExpedition,
saveGarage,
saveProfile,
saveSettings,
saveStocker,
+23
View File
@@ -0,0 +1,23 @@
import { car } from "./_car";
import { RequestCode } from "../defs";
import { SaveGarageRequest } from "../request/saveGarage";
saveGarage.msgCode = 0x008e as RequestCode;
saveGarage.msgLen = 0x0090;
export function saveGarage(buf: Buffer): SaveGarageRequest {
const field_0068: number[] = [];
for (let offset = 0x0068; offset < 0x007c; offset += 2) {
field_0068.push(buf.readUInt16LE(offset));
}
return {
type: "save_garage_req",
profileId: buf.readUInt32LE(0x0004),
payload: car(buf.slice(0x0008, 0x0068)),
field_0068,
field_0080: buf.readUInt8(0x0080),
field_0081: buf.readUInt8(0x0081) !== 0,
};
}