Skip to content

Commit

Permalink
feat: read user leaderboard id
Browse files Browse the repository at this point in the history
  • Loading branch information
KotRikD committed Dec 7, 2024
1 parent 6ba5b75 commit 27477b3
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/tosu/src/api/types/v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ export interface Leaderboard {
isFailed: boolean;
position: number;
team: number;
userId: number;
name: string;
score: number;
accuracy: number;
Expand Down
1 change: 1 addition & 0 deletions packages/tosu/src/api/utils/buildResultV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const convertMemoryPlayerToResult = (
position: memoryPlayer.position,
team: memoryPlayer.team,

userId: memoryPlayer.userId,
name: memoryPlayer.name,

score: memoryPlayer.score,
Expand Down
2 changes: 2 additions & 0 deletions packages/tosu/src/memory/lazer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,12 @@ export class LazerMemory extends AbstractMemory<LazerPatternData> {

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),
Expand Down
9 changes: 9 additions & 0 deletions packages/tosu/src/memory/stable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,16 @@ export class StableMemory extends AbstractMemory<OsuPatternData> {
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)
),
Expand Down
1 change: 1 addition & 0 deletions packages/tosu/src/states/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface KeyOverlay {
}

export interface LeaderboardPlayer {
userId: number;
name: string;
score: number;
combo: number;
Expand Down

0 comments on commit 27477b3

Please sign in to comment.