Skip to content

Commit 79cef77

Browse files
committed
fix p2d breaks due to fromKBinXml nolonger calls toObject
1 parent 7b3b893 commit 79cef77

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/database.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Logger } from "@cordisjs/logger";
22
import { MongoClient } from "mongodb";
33
import config from "./utils/config.js";
44
import { PlayerPlayData } from "./types/p2d/index.js";
5-
import { fromKBinXml } from "./utils/kbinxml.js";
5+
import { fromKBinXml, toObject } from "./utils/kbinxml.js";
66
import { Pdata } from "./types/p2d/pdata.js";
77

88
interface DatabaseMeta {
@@ -27,7 +27,7 @@ export async function initMongoDb() {
2727
const cursor = playDataCol.find({});
2828
const tasks = [];
2929
for await (const player of cursor) {
30-
const { pdata } = fromKBinXml(player.pdata.buffer) as { pdata: Pdata };
30+
const { pdata } = toObject(fromKBinXml(player.pdata.buffer)) as { pdata: Pdata };
3131

3232
tasks.push(playDataCol.updateOne({ _id: player._id }, {
3333
$set: {

src/services/p2d/user.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Binary, Db } from "mongodb";
22
import { inject, injectable } from "tsyringe";
33
import { PlayerPlayData, PlayerMusicData, PlayerPlayLog, PlayerCourseLog, PlayerCustomizeSetting, PlayerRivalData } from "../../types/p2d/index.js";
44
import { Pdata } from "../../types/p2d/pdata.js";
5-
import { fromKBinXml } from "../../utils/kbinxml.js";
5+
import { fromKBinXml, toObject } from "../../utils/kbinxml.js";
66

77
@injectable()
88
export class UserService {
@@ -153,11 +153,11 @@ export class UserService {
153153
const binary = await this.getPDataBinary(player);
154154
if (!binary) return undefined;
155155

156-
return fromKBinXml(binary.pdata).pdata;
156+
return toObject(fromKBinXml(binary.pdata)).pdata;
157157
}
158158

159159
upsertPDataBinary(player: string, pdata: Buffer, check_sum: string) {
160-
const unpacked = fromKBinXml(pdata) as { pdata: Pdata };
160+
const unpacked = toObject(fromKBinXml(pdata)) as { pdata: Pdata };
161161
const { djname, infinitas_id } = unpacked.pdata.player;
162162

163163
return this.playDataCol

0 commit comments

Comments
 (0)