Skip to content

Commit

Permalink
fix: update game time pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
xxCherry authored and KotRikD committed Aug 7, 2024
1 parent 35e9826 commit cf6d758
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 28 deletions.
32 changes: 5 additions & 27 deletions packages/tosu/src/entities/AllTimesData/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,7 @@ import { wLogger } from '@tosu/common';

import { AbstractEntity } from '@/entities/AbstractEntity';

// NOTE: NOT AVAILABLE IN TOURNAMENT MODE!!!!
const GAME_TIME_PTR = {
pattern: '8B 35 ?? ?? ?? ?? 8B C6 B9',
offset: 0x2
};

export class AllTimesData extends AbstractEntity {
gameTimePtr: number = 0;

IsWatchingReplay: number = 0;
isReplayUiHidden: boolean = false;
ShowInterface: boolean = false;
Expand Down Expand Up @@ -53,15 +45,17 @@ export class AllTimesData extends AbstractEntity {
skinDataAddr,
settingsClassAddr,
canRunSlowlyAddr,
rulesetsAddr
rulesetsAddr,
gameTimePtr
} = patterns.getPatterns([
'statusPtr',
'menuModsPtr',
'chatCheckerAddr',
'skinDataAddr',
'settingsClassAddr',
'canRunSlowlyAddr',
'rulesetsAddr'
'rulesetsAddr',
'gameTimePtr'
]);

// [Status - 0x4]
Expand All @@ -73,6 +67,7 @@ export class AllTimesData extends AbstractEntity {
this.IsWatchingReplay = process.readByte(
process.readInt(canRunSlowlyAddr + 0x46)
);
this.GameTime = process.readPointer(gameTimePtr);
this.MemorySongsFolder = process.readSharpString(
process.readInt(
process.readInt(
Expand Down Expand Up @@ -117,23 +112,6 @@ export class AllTimesData extends AbstractEntity {
return;
}

if (
!this.osuInstance.isTourneyManager &&
!this.osuInstance.isTourneySpectator
) {
if (this.gameTimePtr === 0) {
this.gameTimePtr = await process.scanAsync(
GAME_TIME_PTR.pattern
);
wLogger.debug('ATD(updateState) gameTimePtr area found');
return;
} else {
this.GameTime = process.readPointer(
this.gameTimePtr + GAME_TIME_PTR.offset
);
}
}

this.resetReportCount('ATD(updateState)');
} catch (exc) {
this.reportError(
Expand Down
4 changes: 4 additions & 0 deletions packages/tosu/src/objects/instanceManager/osuInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ const SCAN_PATTERNS: {
spectatingUserPtr: {
pattern: '8B 0D ?? ?? ?? ?? 85 C0 74 05 8B 50 30',
offset: -0x4
},
gameTimePtr: {
pattern: 'A1 ?? ?? ?? ?? 89 46 04 8B D6 E8',
offset: 0x1
}
};

Expand Down
4 changes: 3 additions & 1 deletion packages/tosu/src/objects/memoryPatterns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface PatternData {
userProfilePtr: number;
rawLoginStatusPtr: number;
spectatingUserPtr: number;
gameTimePtr: number;
}

export class MemoryPatterns {
Expand All @@ -40,7 +41,8 @@ export class MemoryPatterns {
getAudioLengthPtr: 0,
userProfilePtr: 0,
rawLoginStatusPtr: 0,
spectatingUserPtr: 0
spectatingUserPtr: 0,
gameTimePtr: 0
};

if (process.platform !== 'win32') {
Expand Down

0 comments on commit cf6d758

Please sign in to comment.