Skip to content

Commit

Permalink
Merge pull request #134 from KotRikD/patch/gametime_ptr
Browse files Browse the repository at this point in the history
fix: gameTimePtr isn't available in tournament mode
  • Loading branch information
KotRikD authored May 10, 2024
2 parents 8e472cf + e71ddda commit 0b7a41e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 15 deletions.
35 changes: 29 additions & 6 deletions packages/tosu/src/entities/AllTimesData/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@ 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;
ShowInterface: boolean = false;

Expand Down Expand Up @@ -30,7 +38,7 @@ export class AllTimesData extends AbstractEntity {
this.SongsFolder = value;
}

updateState() {
async updateState() {
try {
const { process, patterns } = this.osuInstance.getServices([
'process',
Expand All @@ -44,17 +52,15 @@ export class AllTimesData extends AbstractEntity {
chatCheckerAddr,
skinDataAddr,
settingsClassAddr,
canRunSlowlyAddr,
gameTimePtr
canRunSlowlyAddr
} = patterns.getPatterns([
'statusPtr',
'playTimeAddr',
'menuModsPtr',
'chatCheckerAddr',
'skinDataAddr',
'settingsClassAddr',
'canRunSlowlyAddr',
'gameTimePtr'
'canRunSlowlyAddr'
]);

const skinOsuAddr = process.readInt(skinDataAddr + 0x7);
Expand All @@ -69,7 +75,6 @@ export class AllTimesData extends AbstractEntity {
this.PlayTime = process.readInt(
process.readInt(playTimeAddr + 0x5)
);
this.GameTime = process.readPointer(gameTimePtr);
// [MenuMods + 0x9]
this.MenuMods = process.readPointer(menuModsPtr);
// ChatChecker - 0x20
Expand Down Expand Up @@ -97,6 +102,24 @@ export class AllTimesData extends AbstractEntity {
)
);

if (
!this.osuInstance.isTourneyManager &&
!this.osuInstance.isTourneySpectator
) {
if (this.gameTimePtr === 0) {
this.gameTimePtr = await process.scanAsync(
GAME_TIME_PTR.pattern,
true
);
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
6 changes: 3 additions & 3 deletions packages/tosu/src/entities/TourneyManagerData/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AbstractEntity } from '@/entities/AbstractEntity';

import { ITourneyManagetChatItem } from './types';

const TOURNAMENT_CHAT_ENGINE = '75 08 8D 65 F4 5B 5E 5F 5D C3 85 D2 74 72';
const TOURNAMENT_CHAT_ENGINE = 'A1 ?? ?? ?? ?? 89 45 F0 8B D1 85 C9 75';

export class TourneyManagerData extends AbstractEntity {
ChatAreaAddr: number = 0;
Expand Down Expand Up @@ -43,7 +43,7 @@ export class TourneyManagerData extends AbstractEntity {
}

if (this.ChatAreaAddr === 0) {
this.ChatAreaAddr = await process.scanAsync(
this.ChatAreaAddr = process.scanSync(
TOURNAMENT_CHAT_ENGINE,
true
);
Expand Down Expand Up @@ -83,7 +83,7 @@ export class TourneyManagerData extends AbstractEntity {
process.readInt(process.readInt(rulesetAddr + 0x34) + 0x4) + 0x4
);

const channelsList = process.readPointer(this.ChatAreaAddr + 0x15);
const channelsList = process.readPointer(this.ChatAreaAddr + 0x1);
const channelsItems = process.readInt(channelsList + 0x4);

const channelsLength = process.readInt(channelsItems + 0x4);
Expand Down
4 changes: 0 additions & 4 deletions packages/tosu/src/objects/instanceManager/osuInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ const SCAN_PATTERNS: {
pattern: 'B8 0B 00 00 8B 35',
offset: -0xb
},
gameTimePtr: {
pattern: '8B 35 ?? ?? ?? ?? 8B C6 B9',
offset: 0x2
},
spectatingUserPtr: {
pattern: '8B 0D ?? ?? ?? ?? 85 C0 74 05 8B 50 30',
offset: -0x4
Expand Down
2 changes: 0 additions & 2 deletions packages/tosu/src/objects/memoryPatterns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export interface PatternData {
getAudioLengthPtr: number;
userProfilePtr: number;
rawLoginStatusPtr: number;
gameTimePtr: number;
spectatingUserPtr: number;
}

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

Expand Down

0 comments on commit 0b7a41e

Please sign in to comment.