Skip to content

Commit

Permalink
Log player names
Browse files Browse the repository at this point in the history
  • Loading branch information
SheepTester committed Jun 21, 2024
1 parent 9282d3b commit c473272
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions server/Game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,7 @@ export class Game implements ServerHandlers<ClientMessage, ServerMessage> {
if (player.entity) {
player.entity.displayName = data.name;
}
log(`Player ${conn.id.slice(0, 6)} renamed to "${data.name}"`);
break;
}
case "change-role": {
Expand Down
4 changes: 2 additions & 2 deletions server/net/WsServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export class WsServer implements Server<ClientMessage, ServerMessage> {
// New player (or they reconnected with an invalid ID; we treat them like a new player)
// Generate a new ID
id = [...getRandomValues(new Uint8Array(64))].map((x) => x.toString(16)).join("");
log(`New player ${id.slice(0, 6)}`);
log(`New player ${id.slice(0, 6)} "${data.name}"`);
}

// Create mapping from the new ID to the WebSocket that is currently alive that belongs to that ID
Expand All @@ -194,7 +194,7 @@ export class WsServer implements Server<ClientMessage, ServerMessage> {
// Tell the game that they joined
this.#game.handlePlayerJoin(connection, data.name);

console.log(`Player ${id} joined!`);
console.log(`Player ${id} "${data.name}" joined!`);
// Ok we believe u 🥰 you are the client you say you are
connection.send({
type: "join-response",
Expand Down

0 comments on commit c473272

Please sign in to comment.