Skip to content

Commit

Permalink
Merge pull request #285 from tosuapp/fix/beatmap-status
Browse files Browse the repository at this point in the history
Update beatmap status even if checksum the same
  • Loading branch information
cyperdark authored Jan 24, 2025
2 parents df7e8cd + ee75d4a commit 0f0fb3a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
16 changes: 10 additions & 6 deletions packages/tosu/src/memory/lazer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1875,8 +1875,15 @@ export class LazerMemory extends AbstractMemory<LazerPatternData> {
const checksum = this.process.readSharpStringPtr(beatmap.info + 0x58);

const gamemode = this.readGamemode();
const rankedStatus = Number(
this.lazerToStableStatus[this.process.readInt(beatmap.info + 0x88)]
);
if (checksum === previousChecksum) {
return gamemode;
return {
type: 'checksum',
gamemode,
rankedStatus
};
}

const metadata = this.process.readIntPtr(beatmap.info + 0x30);
Expand All @@ -1896,6 +1903,7 @@ export class LazerMemory extends AbstractMemory<LazerPatternData> {
);

return {
type: 'update',
gamemode,
checksum,
filename: this.toLazerPath(hash),
Expand All @@ -1915,11 +1923,7 @@ export class LazerMemory extends AbstractMemory<LazerPatternData> {
difficulty: difficultyName,
mapID: this.process.readInt(beatmap.info + 0x8c),
setID: this.process.readInt(beatmap.setInfo + 0x30),
rankedStatus: Number(
this.lazerToStableStatus[
this.process.readInt(beatmap.info + 0x88)
]
),
rankedStatus,
objectCount: this.process.readInt(beatmap.info + 0x94)
};
}
Expand Down
9 changes: 7 additions & 2 deletions packages/tosu/src/memory/stable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -785,9 +785,14 @@ export class StableMemory extends AbstractMemory<OsuPatternData> {
const filename = this.process.readSharpString(
this.process.readInt(beatmapAddr + 0x90)
);
const rankedStatus = this.process.readInt(beatmapAddr + 0x12c);

if (checksum === previousChecksum || !filename.endsWith('.osu')) {
return gamemode;
return {
type: 'checksum',
gamemode,
rankedStatus
};
}

const plays = this.process.readInt(
Expand Down Expand Up @@ -827,10 +832,10 @@ export class StableMemory extends AbstractMemory<OsuPatternData> {
);
const mapID = this.process.readInt(beatmapAddr + 0xc8);
const setID = this.process.readInt(beatmapAddr + 0xcc);
const rankedStatus = this.process.readInt(beatmapAddr + 0x12c);
const objectCount = this.process.readInt(beatmapAddr + 0xf8);

return {
type: 'update',
gamemode,
checksum,
filename,
Expand Down
7 changes: 6 additions & 1 deletion packages/tosu/src/memory/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export type IGlobalPrecise = { time: number } | Error;

export type IMenu =
| {
type: 'update';
gamemode: number;
checksum: string;
filename: string;
Expand All @@ -142,8 +143,12 @@ export type IMenu =
rankedStatus: number;
objectCount: number;
}
| {
type: 'checksum';
gamemode: number;
rankedStatus: number;
}
| string
| number
| Error;

export type IMP3Length = number | Error;
Expand Down
5 changes: 3 additions & 2 deletions packages/tosu/src/states/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ export class Menu extends AbstractState {
);
return 'not-ready';
}
if (typeof result === 'number') {
if (result.type === 'checksum') {
// update gamemoe in menu, even if beatmap is the same
this.gamemode = result;
this.gamemode = result.gamemode;
this.rankedStatus = result.rankedStatus;
return;
}

Expand Down

0 comments on commit 0f0fb3a

Please sign in to comment.