From 27477b3c7c62d4cb63e6e7cac43fc3123d2f69ff Mon Sep 17 00:00:00 2001 From: Mikhail Babynichev Date: Sat, 7 Dec 2024 09:31:22 +0300 Subject: [PATCH] feat: read user leaderboard id --- packages/tosu/src/api/types/v2.ts | 1 + packages/tosu/src/api/utils/buildResultV2.ts | 1 + packages/tosu/src/memory/lazer.ts | 2 ++ packages/tosu/src/memory/stable.ts | 9 +++++++++ packages/tosu/src/states/types.ts | 1 + 5 files changed, 14 insertions(+) diff --git a/packages/tosu/src/api/types/v2.ts b/packages/tosu/src/api/types/v2.ts index 2adbcda8..ebfeef33 100644 --- a/packages/tosu/src/api/types/v2.ts +++ b/packages/tosu/src/api/types/v2.ts @@ -266,6 +266,7 @@ export interface Leaderboard { isFailed: boolean; position: number; team: number; + userId: number; name: string; score: number; accuracy: number; diff --git a/packages/tosu/src/api/utils/buildResultV2.ts b/packages/tosu/src/api/utils/buildResultV2.ts index 1ea1eb13..0b74ae98 100644 --- a/packages/tosu/src/api/utils/buildResultV2.ts +++ b/packages/tosu/src/api/utils/buildResultV2.ts @@ -49,6 +49,7 @@ const convertMemoryPlayerToResult = ( position: memoryPlayer.position, team: memoryPlayer.team, + userId: memoryPlayer.userId, name: memoryPlayer.name, score: memoryPlayer.score, diff --git a/packages/tosu/src/memory/lazer.ts b/packages/tosu/src/memory/lazer.ts index 57d1ceea..e429ce4e 100644 --- a/packages/tosu/src/memory/lazer.ts +++ b/packages/tosu/src/memory/lazer.ts @@ -540,10 +540,12 @@ export class LazerMemory extends AbstractMemory { const realmUser = this.process.readIntPtr(scoreInfo + 0x48); const username = this.process.readSharpStringPtr(realmUser + 0x18); + const userId = this.process.readInt(realmUser + 0x28); const statistics = this.readStatistics(scoreInfo); return { + userId, name: username, mods, score: this.process.readLong(scoreInfo + 0x98), diff --git a/packages/tosu/src/memory/stable.ts b/packages/tosu/src/memory/stable.ts index cb801885..a8464762 100644 --- a/packages/tosu/src/memory/stable.ts +++ b/packages/tosu/src/memory/stable.ts @@ -1146,7 +1146,16 @@ export class StableMemory extends AbstractMemory { if (mods instanceof Error) mods = Object.assign({}, defaultCalculatedMods); + const scoreAddr = this.process.readIntPtr(base + 0x20); + let userId = 0; + if (scoreAddr !== 0) { + userId = this.process.readInt( + this.process.readIntPtr(scoreAddr + 0x48) + 0x70 + ); + } + return { + userId, name: this.process.readSharpString( this.process.readInt(base + 0x8) ), diff --git a/packages/tosu/src/states/types.ts b/packages/tosu/src/states/types.ts index d1e7337a..b6e60530 100644 --- a/packages/tosu/src/states/types.ts +++ b/packages/tosu/src/states/types.ts @@ -32,6 +32,7 @@ export interface KeyOverlay { } export interface LeaderboardPlayer { + userId: number; name: string; score: number; combo: number;