Skip to content

Commit

Permalink
Merge pull request #182 from KotRikD/fix/converts
Browse files Browse the repository at this point in the history
Fix pp on converted plays
  • Loading branch information
cyperdark authored Sep 6, 2024
2 parents 3fe5a19 + 3a87d64 commit 7a75986
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
4 changes: 3 additions & 1 deletion packages/tosu/src/entities/BeatmapPpData/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export class BeatmapPPData extends AbstractEntity {
return this.beatmap;
}

updateMapMetadata(currentMods: number) {
updateMapMetadata(currentMods: number, currentMode: number) {
try {
const startTime = performance.now();

Expand Down Expand Up @@ -279,6 +279,8 @@ export class BeatmapPPData extends AbstractEntity {
}

this.beatmap = new rosu.Beatmap(this.beatmapContent);
if (this.beatmap.mode !== currentMode)
this.beatmap.convert(currentMode);

const beatmapCheckTime = performance.now();
const totalTime = (beatmapCheckTime - startTime).toFixed(2);
Expand Down
6 changes: 3 additions & 3 deletions packages/tosu/src/entities/MenuData/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ export class MenuData extends AbstractEntity {
return 'not-ready';
}

// [Base - 0x33]
this.MenuGameMode = process.readPointer(baseAddr - 0x33);

// [[Beatmap] + 0x6C]
const newMD5 = process.readSharpString(
process.readInt(beatmapAddr + 0x6c)
Expand Down Expand Up @@ -88,9 +91,6 @@ export class MenuData extends AbstractEntity {
this.MD5 = newMD5;
this.Path = newPath;

// [Base - 0x33]
this.MenuGameMode = process.readPointer(baseAddr - 0x33);

// [Base - 0x33] + 0xC
this.Plays = process.readInt(
process.readInt(baseAddr - 0x33) + 0xc
Expand Down
15 changes: 12 additions & 3 deletions packages/tosu/src/objects/instanceManager/osuInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,14 @@ export class OsuInstance {
? resultsScreenData.Mods
: allTimesData.MenuMods;

const currentState = `${menuData.MD5}:${menuData.MenuGameMode}:${currentMods}`;
const currentMode =
allTimesData.Status === 2
? gamePlayData.Mode
: allTimesData.Status === 7
? resultsScreenData.Mode
: menuData.MenuGameMode;

const currentState = `${menuData.MD5}:${currentMode}:${currentMods}`;
const updateGraph =
this.previousState !== currentState ||
this.previousMP3Length !== menuData.MP3Length;
Expand All @@ -299,8 +306,10 @@ export class OsuInstance {
allTimesData.GameFolder &&
this.previousState !== currentState
) {
const metadataUpdate =
beatmapPpData.updateMapMetadata(currentMods);
const metadataUpdate = beatmapPpData.updateMapMetadata(
currentMods,
currentMode
);
if (metadataUpdate === 'not-ready') {
await sleep(config.pollRate);
continue;
Expand Down

0 comments on commit 7a75986

Please sign in to comment.