From cfb75cb2a56fbd72bb176d9b254fb9ac3eb140ce Mon Sep 17 00:00:00 2001 From: Mikhail Babynichev Date: Fri, 8 Mar 2024 09:47:31 +0300 Subject: [PATCH] fix: reset TUPD on slot swap --- .../entities/TourneyUserProfileData/index.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/packages/tosu/src/entities/TourneyUserProfileData/index.ts b/packages/tosu/src/entities/TourneyUserProfileData/index.ts index 71ff366f..f2202add 100644 --- a/packages/tosu/src/entities/TourneyUserProfileData/index.ts +++ b/packages/tosu/src/entities/TourneyUserProfileData/index.ts @@ -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; @@ -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`); @@ -31,6 +49,7 @@ export class TourneyUserProfileData extends AbstractEntity { ); if (!spectatingUserDrawable) { wLogger.debug('TUPD(updateState) Slot is not equiped'); + this.resetState(); return; } @@ -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);