Fix skins not loading on connection

This commit is contained in:
2026-10-02 13:26:00 -03:00
parent cd07d441b2
commit 7b3cdd925e
2 changed files with 16 additions and 1 deletions
+9
View File
@@ -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);
+7 -1
View File
@@ -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);
});