From 27837012cf57e1172b03d4c05723332b67699ec3 Mon Sep 17 00:00:00 2001 From: evanpelle Date: Sun, 7 Sep 2025 19:42:53 -0700 Subject: [PATCH] perf: Update myplayer only on tick (#2029) ## Description: During replays, myPlayer() was undefined, causing to search through all clients an each call. Instead just update myPlayer on on tick/update. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: evan --- src/core/game/GameView.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/game/GameView.ts b/src/core/game/GameView.ts index 0956542fa..fbb35472d 100644 --- a/src/core/game/GameView.ts +++ b/src/core/game/GameView.ts @@ -443,6 +443,9 @@ export class GameView implements GameMap { ); } }); + + this._myPlayer ??= this.playerByClientID(this._myClientID); + for (const unit of this._units.values()) { unit._wasUpdated = false; unit.lastPos = unit.lastPos.slice(-1); @@ -503,7 +506,6 @@ export class GameView implements GameMap { } myPlayer(): PlayerView | null { - this._myPlayer ??= this.playerByClientID(this._myClientID); return this._myPlayer; }