Fix skins not loading on connection
This commit is contained in:
@@ -733,6 +733,15 @@ export class GameServer {
|
|||||||
if (player.worn_sent !== "[]") {
|
if (player.worn_sent !== "[]") {
|
||||||
this.#send(player, { type: "player_worn", id: player.id, worn: player.worn_list() });
|
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
|
// the chunks come with the next ticks
|
||||||
this.#update_view(player);
|
this.#update_view(player);
|
||||||
this.#sync(player);
|
this.#sync(player);
|
||||||
|
|||||||
+7
-1
@@ -1,5 +1,6 @@
|
|||||||
import { assertEquals } from "@std/assert";
|
import { assertEquals } from "@std/assert";
|
||||||
import { encode_skin } from "$/server/game/skins.ts";
|
import { encode_skin } from "$/server/game/skins.ts";
|
||||||
|
import { PROTOCOL_VERSION } from "$/common/protocol.ts";
|
||||||
import { test_game } from "./helpers.ts";
|
import { test_game } from "./helpers.ts";
|
||||||
|
|
||||||
const SKIN = Deno.readFileSync("assets/sprites/skin_template.png");
|
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
|
// 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());
|
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");
|
const join = loaded.join(2, "bob");
|
||||||
assertEquals(join.players.find((p: { name: string }) => p.name === "alice").skin, skin);
|
assertEquals(join.players.find((p: { name: string }) => p.name === "alice").skin, skin);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user