From 5bca6e8f7021e6dd707632c8c871c03b10fb1e75 Mon Sep 17 00:00:00 2001 From: Tau Date: Mon, 8 Apr 2019 11:22:56 -0400 Subject: [PATCH] update chara-ish fields on profile save --- src/idz/decoder/saveProfile.ts | 4 +++- src/idz/handler/saveProfile.ts | 6 ++++++ src/idz/request/saveProfile.ts | 4 +++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/idz/decoder/saveProfile.ts b/src/idz/decoder/saveProfile.ts index c842117..b0a0b5c 100644 --- a/src/idz/decoder/saveProfile.ts +++ b/src/idz/decoder/saveProfile.ts @@ -1,6 +1,6 @@ import { car } from "./_car"; import { RequestCode } from "./_defs"; -import { Id, TitleCode } from "../model/base"; +import { BackgroundCode, Id, TitleCode } from "../model/base"; import { Profile } from "../model/profile"; import { SaveProfileRequest } from "../request/saveProfile"; import { bitmap } from "./_bitmap"; @@ -35,7 +35,9 @@ export function saveProfile(buf: Buffer): SaveProfileRequest { exp: buf.readUInt32LE(0x0028), fame: buf.readUInt32LE(0x0468), dpoint: buf.readUInt32LE(0x0464), + title: buf.readUInt16LE(0x0040) as TitleCode, titles: bitmap(buf.slice(0x0042, 0x00f6)) as TitleCode[], + background: buf.readUInt8(0x0750) as BackgroundCode, car: car(buf.slice(0x0834, 0x0894)), story: { x: buf.readUInt16LE(0x06fc), diff --git a/src/idz/handler/saveProfile.ts b/src/idz/handler/saveProfile.ts index c46804e..58e2f9a 100644 --- a/src/idz/handler/saveProfile.ts +++ b/src/idz/handler/saveProfile.ts @@ -7,6 +7,7 @@ export async function saveProfile( req: SaveProfileRequest ): Promise { const profile = await w.profile().load(req.profileId); + const chara = await w.chara().load(req.profileId); await Promise.all([ w.profile().save(req.profileId, { @@ -16,6 +17,11 @@ export async function saveProfile( fame: req.fame, dpoint: req.dpoint, }), + w.chara().save(req.profileId, { + ...chara, + title: req.title, + background: req.background, + }), w.car().save(req.profileId, req.car), w.story().save(req.profileId, req.story), w.titles().save(req.profileId, req.titles), diff --git a/src/idz/request/saveProfile.ts b/src/idz/request/saveProfile.ts index 0abcd33..56b2c6b 100644 --- a/src/idz/request/saveProfile.ts +++ b/src/idz/request/saveProfile.ts @@ -1,4 +1,4 @@ -import { Id, TitleCode } from "../model/base"; +import { BackgroundCode, Id, TitleCode } from "../model/base"; import { Car } from "../model/car"; import { Profile } from "../model/profile"; import { Story } from "../model/story"; @@ -10,7 +10,9 @@ export interface SaveProfileRequest { exp: number; fame: number; dpoint: number; + title: TitleCode; titles: TitleCode[]; + background: BackgroundCode; car: Car; story: Story; }