Refactor repository layer (and implement garage)

This commit is contained in:
Tau
2019-11-06 17:28:29 -05:00
parent f224e466c5
commit a4a6550abb
31 changed files with 452 additions and 238 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
import { Car } from "../model/car";
import { Car, CarSelector } from "../model/car";
export function car(buf: Buffer): Car {
const field_04: number[] = [];
@@ -11,7 +11,7 @@ export function car(buf: Buffer): Car {
field_00: buf.readUInt16LE(0x0000),
field_02: buf.readUInt16LE(0x0002),
field_04,
field_44: buf.readUInt16LE(0x0044),
selector: buf.readUInt16LE(0x0044) as CarSelector,
field_46: buf.readUInt16LE(0x0046),
field_48: buf.readUInt16LE(0x0048),
field_4A: buf.readUInt16LE(0x004a),
+3 -3
View File
@@ -29,10 +29,10 @@ export function saveProfile(buf: Buffer): SaveProfileRequest {
storyRows.push(row);
}
const coursePlays = new Array();
const coursePlays = new Map<number, number>();
for (let i = 0x0000; i < 0x0020; i += 2) {
coursePlays.push(buf.readUInt16LE(0x04c0 + i));
for (let i = 0; i < 16; i++) {
coursePlays.set(i, buf.readUInt16LE(0x04c0 + 2 * i));
}
return {
+3
View File
@@ -2,6 +2,7 @@ import { bitmap } from "./_bitmap";
import { chara } from "./_chara";
import { RequestCode } from "./_defs";
import { BackgroundCode, Id } from "../model/base";
import { CarSelector } from "../model/car";
import { Profile } from "../model/profile";
import { SaveStockerRequest } from "../request/saveStocker";
@@ -12,7 +13,9 @@ export function saveStocker(buf: Buffer): SaveStockerRequest {
return {
type: "save_stocker_req",
profileId: buf.readUInt32LE(0x0004) as Id<Profile>,
backgrounds: bitmap(buf.slice(0x0008, 0x002c)) as BackgroundCode[],
selectedCar: buf.readUInt16LE(0x009c) as CarSelector,
chara: chara(buf.slice(0x009e, 0x00b2)),
};
}