From 7b3cdd925eaf67f8bea44cb52c5356572500cafa Mon Sep 17 00:00:00 2001 From: Paula Date: Fri, 2 Oct 2026 13:26:00 -0300 Subject: [PATCH] Fix skins not loading on connection --- server/game/game_server.ts | 9 +++++++++ tests/skin_test.ts | 8 +++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/server/game/game_server.ts b/server/game/game_server.ts index af98a1a..54a6295 100644 --- a/server/game/game_server.ts +++ b/server/game/game_server.ts @@ -733,6 +733,15 @@ export class GameServer { if (player.worn_sent !== "[]") { this.#send(player, { type: "player_worn", id: player.id, worn: player.worn_list() }); } + // and their own skin, from when they last played + if (player.skin) { + this.#send(player, { + type: "player_skin", + id: player.id, + skin: player.skin, + slim: player.slim || undefined, + }); + } // the chunks come with the next ticks this.#update_view(player); this.#sync(player); diff --git a/tests/skin_test.ts b/tests/skin_test.ts index d1f7662..f6d7029 100644 --- a/tests/skin_test.ts +++ b/tests/skin_test.ts @@ -1,5 +1,6 @@ import { assertEquals } from "@std/assert"; import { encode_skin } from "$/server/game/skins.ts"; +import { PROTOCOL_VERSION } from "$/common/protocol.ts"; import { test_game } from "./helpers.ts"; const SKIN = Deno.readFileSync("assets/sprites/skin_template.png"); @@ -29,7 +30,12 @@ Deno.test("/skin downloads a png, tells everyone and is saved with the player", // players joining later get it with the rest of alice's info, and it's still there after a restart const loaded = await test_game("mods", t.game.save()); - loaded.join(1, "alice"); + // alice gets it too, for her own hand + loaded.game.on_connect(1); + loaded.send(1, { type: "hello", name: "alice", protocol: PROTOCOL_VERSION }); + loaded.send(1, { type: "ready" }); + const own = loaded.take(1).find((m) => m.type === "player_skin"); + assertEquals([own?.id, own?.skin], [loaded.game.players()[0].id, skin]); const join = loaded.join(2, "bob"); assertEquals(join.players.find((p: { name: string }) => p.name === "alice").skin, skin); });