Fix: anonymized name isn't used in chat message (#1265)

## Description:

Bugfix:
- Anonymized name isn't used in Event Panel message, instead actual
player name is displayed even if "Hidden names" is enabled. Neither for
the 'P1' name in the chat message, nor for the name in "From name:
message" and "Sent name: message". Fix: in QuickChatExecution, instead
of sender.name() and recipient.name(), send their id(). In
EventsDisplay, from that PlayerID get their displayName.

- There was more in this PR to try to improve readibility and remove
some unused/uncommented code. This was moved later to #1275, which may
be re-opened and brought up-to-date after this PR is merged.

Example screenshot of the bug before the fix, send chat to anonymized
name 'Norwegian Sisterhood' but in Event Panel real name 'Mister Goo'
was displayed:
![Sent Mister Goo instead of anonymous Norwegian
Brotherhood](https://github.com/user-attachments/assets/197e2808-aa85-4271-9c96-c53fe10f6546)

## 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
- [ ] 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
- [x] I understand that submitting code with bugs that could have been
caught through manual testing blocks releases and new features for all
contributors
This commit is contained in:
VariableVince
2025-07-16 01:43:31 +02:00
committed by GitHub
parent 5dd7826192
commit af3dcb77bd
2 changed files with 12 additions and 5 deletions
+9 -2
View File
@@ -375,7 +375,7 @@ export class EventsDisplay extends LitElement implements Layer {
if (event.target) {
try {
const targetPlayer = this.game.player(event.target);
const targetName = targetPlayer?.name() ?? event.target;
const targetName = targetPlayer?.displayName() ?? event.target;
translatedMessage = baseMessage.replace("[P1]", targetName);
} catch (e) {
console.warn(
@@ -386,9 +386,16 @@ export class EventsDisplay extends LitElement implements Layer {
}
}
let otherPlayerDiplayName: string = "";
if (event.recipient !== null) {
//'recipient' parameter contains sender ID or recipient ID
const player = this.game.player(event.recipient);
otherPlayerDiplayName = player ? player.displayName() : "";
}
this.addEvent({
description: translateText(event.isFrom ? "chat.from" : "chat.to", {
user: event.recipient,
user: otherPlayerDiplayName,
msg: translatedMessage,
}),
createdAt: this.game.ticks(),
+3 -3
View File
@@ -35,7 +35,7 @@ export class QuickChatExecution implements Execution {
this.target,
this.recipient.id(),
true,
this.sender.name(),
this.sender.id(),
);
this.mg.displayChat(
@@ -44,11 +44,11 @@ export class QuickChatExecution implements Execution {
this.target,
this.sender.id(),
false,
this.recipient.name(),
this.recipient.id(),
);
console.log(
`[QuickChat] ${this.sender.name}${this.recipient.name}: ${message}`,
`[QuickChat] ${this.sender.name}${this.recipient.displayName}: ${message}`,
);
this.active = false;