Skip to content

Commit

Permalink
fix: reset TUPD on slot swap
Browse files Browse the repository at this point in the history
  • Loading branch information
KotRikD committed Mar 10, 2024
1 parent 2c6f601 commit cfb75cb
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/tosu/src/entities/TourneyUserProfileData/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { DataRepo } from '@/entities/DataRepoList';
import { AbstractEntity } from '../AbstractEntity';

export class TourneyUserProfileData extends AbstractEntity {
isDefaultState: boolean = true;

Accuracy: number = 0.0;
RankedScore: number = 0;
PlayCount: number = 0;
Expand All @@ -18,6 +20,22 @@ export class TourneyUserProfileData extends AbstractEntity {
super(services);
}

resetState() {
if (this.isDefaultState) {
return;
}

this.isDefaultState = true;
this.Accuracy = 0.0;
this.RankedScore = 0;
this.PlayCount = 0;
this.GlobalRank = 0;
this.PP = 0;
this.Name = '';
this.Country = '';
this.UserID = 0;
}

updateState() {
wLogger.debug(`TUPD(updateState) Starting`);

Expand All @@ -31,6 +49,7 @@ export class TourneyUserProfileData extends AbstractEntity {
);
if (!spectatingUserDrawable) {
wLogger.debug('TUPD(updateState) Slot is not equiped');
this.resetState();
return;
}

Expand All @@ -55,6 +74,8 @@ export class TourneyUserProfileData extends AbstractEntity {
);
// UserDrawable + 0x70
this.UserID = process.readInt(spectatingUserDrawable + 0x70);

this.isDefaultState = false;
} catch (exc) {
wLogger.error('TUPD(updateState) signature failed');
wLogger.debug(exc);
Expand Down

0 comments on commit cfb75cb

Please sign in to comment.