Improve territory drawing performances (#696)

## Description:
Territory drawing are computing the same information for each pixel
drawn.
A few fixes can noticably improve the performances:
### Caching colors
some colors are computed each time they are retrieved, and according to
the profiler the border color is the most expensive to compute each
frame:


![image](https://github.com/user-attachments/assets/147c2e9d-0ce2-4859-92de-c6f99b763642)


This PR adds a cache for this color. The other colors have almost no
impact on performance, so there's no need to cache them.

After caching:

![image](https://github.com/user-attachments/assets/7b2601b2-19c9-4535-8315-6b2fe328731f)

### Retrieving player info
Drawing the player territory leads to unecessary and expensive data
gathering, such as the anonymous name list:

![442410324-2e7dbcc9-e7ba-4051-b38f-3ae57cb072e8](https://github.com/user-attachments/assets/67894616-ecec-4748-85f9-9f665c58aab1)

Instead, after retrieving the proper data directly:

![442410386-0eaffd72-045d-40b7-96c3-e04030de3d40](https://github.com/user-attachments/assets/ff59f988-9f80-4f52-b972-a155d6ae94dd)


## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
- [x] I understand that submitting code with bugs that could have been
caught through manual testing blocks releases and new features for all
contributors

## Please put your Discord username so you can be contacted if a bug or
regression is found:

IngloriousTom
This commit is contained in:
DevelopingTom
2025-05-28 06:43:33 +02:00
committed by GitHub
parent 3a481d3d16
commit b6596c88ee
4 changed files with 39 additions and 21 deletions
+2 -2
View File
@@ -182,12 +182,12 @@ export class PlayerView {
return this.data.flag;
}
name(): string {
return userSettings.anonymousNames() && this.anonymousName !== null
return this.anonymousName !== null && userSettings.anonymousNames()
? this.anonymousName
: this.data.name;
}
displayName(): string {
return userSettings.anonymousNames() && this.anonymousName !== null
return this.anonymousName !== null && userSettings.anonymousNames()
? this.anonymousName
: this.data.name;
}