consolidate car load/save
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { Car } from "../model/car";
|
||||
|
||||
export function car(car: Car): Buffer {
|
||||
const buf = Buffer.alloc(0x0060);
|
||||
|
||||
buf.writeUInt16LE(car.field_00, 0x0000);
|
||||
buf.writeUInt16LE(car.field_02, 0x0002);
|
||||
|
||||
for (let i = 0; i < 32; i++) {
|
||||
buf.writeUInt16LE(
|
||||
i < car.field_04.length ? car.field_04[i] : 0xff00,
|
||||
0x0004 + 2 * i
|
||||
);
|
||||
}
|
||||
|
||||
buf.writeUInt16LE(car.model, 0x0044);
|
||||
buf.writeUInt8(car.color, 0x0046);
|
||||
buf.writeUInt16LE(car.transmission, 0x0048);
|
||||
buf.writeUInt16LE(car.field_4A, 0x004a);
|
||||
buf.writeUInt32LE(car.field_4C, 0x004c);
|
||||
buf.writeUInt32LE(car.field_50_lo, 0x0050);
|
||||
buf.writeUInt32LE(car.field_50_hi, 0x0050);
|
||||
buf.writeUInt8(car.field_58, 0x0058);
|
||||
buf.writeUInt8(car.field_5A, 0x005a);
|
||||
buf.writeUInt8(car.field_5B, 0x005b);
|
||||
buf.writeUInt16LE(car.field_5C, 0x005c);
|
||||
buf.writeUInt16LE(car.field_5E, 0x005e);
|
||||
|
||||
return buf;
|
||||
}
|
||||
@@ -4,7 +4,7 @@ export function discoverProfile(res: DiscoverProfileResponse) {
|
||||
const buf = Buffer.alloc(0x0010);
|
||||
|
||||
buf.writeInt16LE(0x006c, 0x0000);
|
||||
buf.writeInt8(res.result ? 1 : 0, 0x0004);
|
||||
buf.writeInt8(res.exists ? 1 : 0, 0x0004);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import { loadServerList } from "./loadServerList";
|
||||
import { loadStocker } from "./loadStocker";
|
||||
import { loadTeamRanking } from "./loadTeamRanking";
|
||||
import { saveExpedition } from "./saveExpedition";
|
||||
import { saveGarage } from "./saveGarage";
|
||||
import { saveTopic } from "./saveTopic";
|
||||
import { updateProvisionalStoreRank } from "./updateProvisionalStoreRank";
|
||||
import { updateStoryClearNum } from "./updateStoryClearNum";
|
||||
@@ -75,6 +76,9 @@ function encode(res: Response): Buffer {
|
||||
case "save_expedition_res":
|
||||
return saveExpedition(res);
|
||||
|
||||
case "save_garage_res":
|
||||
return saveGarage(res);
|
||||
|
||||
case "unlock_profile_res":
|
||||
return unlockProfile(res);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import iconv = require("iconv-lite");
|
||||
|
||||
import { car } from "./_car";
|
||||
import { LoadProfileResponse2 } from "../response/loadProfile2";
|
||||
|
||||
export function loadProfile2(res: LoadProfileResponse2) {
|
||||
@@ -24,6 +25,7 @@ export function loadProfile2(res: LoadProfileResponse2) {
|
||||
buf.writeInt32LE(res.fame, 0x0404);
|
||||
iconv.encode(res.name + "\0", "shift_jis").copy(buf, 0x03ee);
|
||||
buf.writeInt32LE(res.teamId, 0x07e0);
|
||||
car(res.car).copy(buf, 0xc5c);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import { SaveGarageResponse } from "../response/saveGarage";
|
||||
|
||||
export function saveGarage(res: SaveGarageResponse): Buffer {
|
||||
const buf = Buffer.alloc(0x0010);
|
||||
|
||||
buf.writeUInt16LE(0x008f, 0x0000);
|
||||
buf.writeUInt16LE(res.status, 0x0002);
|
||||
|
||||
return buf;
|
||||
}
|
||||
Reference in New Issue
Block a user