diff --git a/src/idz/decoder/_car.ts b/src/idz/decoder/_car.ts index 4eaa8c5..7b9abb8 100644 --- a/src/idz/decoder/_car.ts +++ b/src/idz/decoder/_car.ts @@ -11,9 +11,9 @@ export function car(buf: Buffer): Car { 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_44: buf.readUInt16LE(0x0044), + field_46: buf.readUInt16LE(0x0046), + field_48: buf.readUInt16LE(0x0048), field_4A: buf.readUInt16LE(0x004a), field_4C: buf.readUInt32LE(0x004c), field_50_lo: buf.readUInt32LE(0x0050), diff --git a/src/idz/decoder/index.ts b/src/idz/decoder/index.ts index 79943c3..9f31818 100644 --- a/src/idz/decoder/index.ts +++ b/src/idz/decoder/index.ts @@ -32,6 +32,7 @@ import { loadTopTen } from "./loadTopTen"; import { updateResult } from "./updateResult"; import { updateTeamPoints } from "./updateTeamPoints"; import { updateUiReport } from "./updateUiReport"; +import { updateUserLog } from "./updateUserLog"; export type ReaderFn = ((buf: Buffer) => Request) & { msgCode: RequestCode; @@ -70,6 +71,7 @@ const funcList: ReaderFn[] = [ updateStoryClearNum, updateTeamPoints, updateUiReport, + updateUserLog, ]; const readerFns = new Map(); diff --git a/src/idz/decoder/saveProfile.ts b/src/idz/decoder/saveProfile.ts index 331dc37..c842117 100644 --- a/src/idz/decoder/saveProfile.ts +++ b/src/idz/decoder/saveProfile.ts @@ -1,3 +1,4 @@ +import { car } from "./_car"; import { RequestCode } from "./_defs"; import { Id, TitleCode } from "../model/base"; import { Profile } from "../model/profile"; @@ -35,6 +36,7 @@ export function saveProfile(buf: Buffer): SaveProfileRequest { fame: buf.readUInt32LE(0x0468), dpoint: buf.readUInt32LE(0x0464), titles: bitmap(buf.slice(0x0042, 0x00f6)) as TitleCode[], + car: car(buf.slice(0x0834, 0x0894)), story: { x: buf.readUInt16LE(0x06fc), y: buf.readUInt8(0x06e0), diff --git a/src/idz/decoder/updateUserLog.ts b/src/idz/decoder/updateUserLog.ts new file mode 100644 index 0000000..3722a7a --- /dev/null +++ b/src/idz/decoder/updateUserLog.ts @@ -0,0 +1,9 @@ +import { RequestCode } from "./_defs"; +import { UpdateUserLogRequest } from "../request/updateUserLog"; + +updateUserLog.msgCode = 0x00bd as RequestCode; +updateUserLog.msgLen = 0x0050; + +export function updateUserLog(buf: Buffer): UpdateUserLogRequest { + return { type: "update_user_log_req" }; +} diff --git a/src/idz/encoder/_car.ts b/src/idz/encoder/_car.ts index 76c98a0..3df5758 100644 --- a/src/idz/encoder/_car.ts +++ b/src/idz/encoder/_car.ts @@ -13,9 +13,9 @@ export function car(car: Car): Buffer { ); } - buf.writeUInt16LE(car.model, 0x0044); - buf.writeUInt8(car.color, 0x0046); - buf.writeUInt16LE(car.transmission, 0x0048); + buf.writeUInt16LE(car.field_44, 0x0044); + buf.writeUInt8(car.field_46, 0x0046); + buf.writeUInt16LE(car.field_48, 0x0048); buf.writeUInt16LE(car.field_4A, 0x004a); buf.writeUInt32LE(car.field_4C, 0x004c); buf.writeUInt32LE(car.field_50_lo, 0x0050); diff --git a/src/idz/encoder/loadProfile2.ts b/src/idz/encoder/loadProfile2.ts index 8d1b448..90de233 100644 --- a/src/idz/encoder/loadProfile2.ts +++ b/src/idz/encoder/loadProfile2.ts @@ -36,13 +36,14 @@ export function loadProfile2(res: LoadProfileResponse2) { } } - buf.writeInt16LE(0x0065, 0x0000); - buf.writeInt32LE(res.profileId, 0x03b8); + buf.writeUInt16LE(0x0065, 0x0000); + buf.writeUInt32LE(res.profileId, 0x03b8); buf.writeUInt16LE(res.settings.bgMusic, 0x03c8); - buf.writeInt16LE(res.lv, 0x03cc); + buf.writeUInt16LE(res.lv, 0x03cc); + buf.writeUInt32LE(res.exp, 0x03d0); buf.writeUInt32LE(settingsPack, 0x3d8); - buf.writeInt32LE(res.dpoint, 0x03e8); - buf.writeInt32LE(res.fame, 0x0404); + buf.writeUInt32LE(res.dpoint, 0x03e8); + buf.writeUInt32LE(res.fame, 0x0404); iconv.encode(res.name + "\0", "shift_jis").copy(buf, 0x03ee); buf.writeUInt16LE(res.story.x, 0x06bc); buf.writeUInt8(res.story.y, 0x0670); diff --git a/src/idz/handler/index.ts b/src/idz/handler/index.ts index 5c2e2ae..4460a0a 100644 --- a/src/idz/handler/index.ts +++ b/src/idz/handler/index.ts @@ -27,6 +27,7 @@ import { updateResult } from "./updateResult"; import { updateStoryClearNum } from "./updateStoryClearNum"; import { updateTeamPoints } from "./updateTeamPoints"; import { updateUiReport } from "./updateUiReport"; +import { updateUserLog } from "./updateUserLog"; import { Request } from "../request"; import { Response } from "../response"; import { World } from "../world"; @@ -123,6 +124,9 @@ export async function dispatch(w: World, req: Request): Promise { case "update_ui_report_req": return updateUiReport(w, req); + case "update_user_log_req": + return updateUserLog(w, req); + default: const exhaustCheck: never = req; diff --git a/src/idz/handler/loadProfile.ts b/src/idz/handler/loadProfile.ts index ba519de..b0763e4 100644 --- a/src/idz/handler/loadProfile.ts +++ b/src/idz/handler/loadProfile.ts @@ -21,6 +21,7 @@ export async function loadProfile( name: profile.name, profileId: profile.id, lv: profile.lv, + exp: profile.exp, fame: profile.fame, dpoint: profile.dpoint, teamId: profile.teamId, diff --git a/src/idz/handler/saveProfile.ts b/src/idz/handler/saveProfile.ts index cf4dfe8..c46804e 100644 --- a/src/idz/handler/saveProfile.ts +++ b/src/idz/handler/saveProfile.ts @@ -16,6 +16,7 @@ export async function saveProfile( fame: req.fame, dpoint: req.dpoint, }), + 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/handler/updateUserLog.ts b/src/idz/handler/updateUserLog.ts new file mode 100644 index 0000000..f962046 --- /dev/null +++ b/src/idz/handler/updateUserLog.ts @@ -0,0 +1,10 @@ +import { UpdateUserLogRequest } from "../request/updateUserLog"; +import { GenericResponse } from "../response/generic"; +import { World } from "../world"; + +export function updateUserLog( + w: World, + req: UpdateUserLogRequest +): GenericResponse { + return { type: "generic_res" }; +} diff --git a/src/idz/model/car.ts b/src/idz/model/car.ts index 2da8d32..6f946a9 100644 --- a/src/idz/model/car.ts +++ b/src/idz/model/car.ts @@ -2,9 +2,9 @@ export interface Car { field_00: number; field_02: number; field_04: number[]; - model: number; - color: number; - transmission: number; + field_44: number; + field_46: number; + field_48: number; field_4A: number; field_4C: number; field_50_lo: number; diff --git a/src/idz/request/index.ts b/src/idz/request/index.ts index 7f7bb58..a2396fe 100644 --- a/src/idz/request/index.ts +++ b/src/idz/request/index.ts @@ -28,6 +28,7 @@ import { UpdateResultRequest } from "./updateResult"; import { UpdateStoryClearNumRequest } from "./updateStoryClearNum"; import { UpdateTeamPointsRequest } from "./updateTeamPoints"; import { UpdateUiReportRequest } from "./updateUiReport"; +import { UpdateUserLogRequest } from "./updateUserLog"; export type Request = | CheckRankRequest @@ -59,4 +60,5 @@ export type Request = | UpdateResultRequest | UpdateStoryClearNumRequest | UpdateTeamPointsRequest - | UpdateUiReportRequest; + | UpdateUiReportRequest + | UpdateUserLogRequest; diff --git a/src/idz/request/saveProfile.ts b/src/idz/request/saveProfile.ts index 058bec9..0abcd33 100644 --- a/src/idz/request/saveProfile.ts +++ b/src/idz/request/saveProfile.ts @@ -1,4 +1,5 @@ import { Id, TitleCode } from "../model/base"; +import { Car } from "../model/car"; import { Profile } from "../model/profile"; import { Story } from "../model/story"; @@ -10,5 +11,6 @@ export interface SaveProfileRequest { fame: number; dpoint: number; titles: TitleCode[]; + car: Car; story: Story; } diff --git a/src/idz/request/updateUserLog.ts b/src/idz/request/updateUserLog.ts new file mode 100644 index 0000000..d154f88 --- /dev/null +++ b/src/idz/request/updateUserLog.ts @@ -0,0 +1,3 @@ +export interface UpdateUserLogRequest { + type: "update_user_log_req"; +} diff --git a/src/idz/response/loadProfile2.ts b/src/idz/response/loadProfile2.ts index 3beddfe..cfe9a3d 100644 --- a/src/idz/response/loadProfile2.ts +++ b/src/idz/response/loadProfile2.ts @@ -10,6 +10,7 @@ export interface LoadProfileResponse2 { name: string; profileId: Id; lv: number; + exp: number; fame: number; dpoint: number; teamId?: number;