Skip to content

Commit

Permalink
Fix wrong names in lobby
Browse files Browse the repository at this point in the history
  • Loading branch information
NouCake committed Jan 15, 2024
1 parent d02c7f0 commit 7ea3b79
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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));
}

Expand Down
1 change: 1 addition & 0 deletions src/types/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export interface RoomNamePacket extends PlayerPacket {
type: PacketType.ROOM_NAME;
data: {
name: string,
uuid: string,
};

}
Expand Down

0 comments on commit 7ea3b79

Please sign in to comment.