From 7ea3b79c513dfb11c2645c42e56eac69cd91c5af Mon Sep 17 00:00:00 2001 From: Kevin Fischer Date: Mon, 15 Jan 2024 21:37:05 +0100 Subject: [PATCH] Fix wrong names in lobby --- src/room.ts | 15 ++++++--------- src/types/client.ts | 1 + 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/room.ts b/src/room.ts index 4a8ba17..656d399 100644 --- a/src/room.ts +++ b/src/room.ts @@ -50,22 +50,19 @@ export default class Room extends EventTarget { this._connectedIds.add(client); }); - this._playerNames.set(this.aznopoly.player.uuid, this.aznopoly.player.name); - this.broadcastName(this.aznopoly.player.uuid, this.aznopoly.player.name); + this._playerNames.set(this.aznopoly.client.id, this.aznopoly.player.name); + this.broadcastName(this.aznopoly.client.id, this.aznopoly.player.name); this.dispatchEvent(new Event(RoomEvent.READY)); } private broadcastName(id: string, name: string) { - // if (this.client.debugMode) { - // console.log("Broadcasting name", id, name) - // } - const namePacket: RoomNamePacket = { type: PacketType.ROOM_NAME, - sender: id, + sender: this.client.id, data: { - name + name, + uuid: id, } } this.client.sendPacket(namePacket) @@ -102,7 +99,7 @@ export default class Room extends EventTarget { console.warn("Player " + packet.sender + " tried to change their name, but the room is locked!"); } - this._playerNames.set(packet.sender, packet.data.name); + this._playerNames.set(packet.data.uuid, packet.data.name); this.dispatchEvent(new Event(RoomEvent.UPDATE)); } diff --git a/src/types/client.ts b/src/types/client.ts index 46aed46..c64011b 100644 --- a/src/types/client.ts +++ b/src/types/client.ts @@ -52,6 +52,7 @@ export interface RoomNamePacket extends PlayerPacket { type: PacketType.ROOM_NAME; data: { name: string, + uuid: string, }; }