Improve SCUM map playback and vehicle markers

This commit is contained in:
npc0-hue
2026-09-18 15:53:32 +08:00
parent 4009b7260e
commit 156392df1e
7 changed files with 432 additions and 55 deletions
+17 -1
View File
@@ -3,7 +3,7 @@ import { existsSync, readFileSync } from "node:fs";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { scumCatalogEntries, scumCatalogIconUrl } from "../examples/scum-server-plugin/features/scum-catalog.js";
import { scumCatalogEntries, scumCatalogIconUrl, scumVehicleEntry, scumVehicleFallbackIconUrl, scumVehicleIconUrl } from "../examples/scum-server-plugin/features/scum-catalog.js";
const pluginRoot = resolve(dirname(fileURLToPath(import.meta.url)), "../examples/scum-server-plugin");
const catalogSource = readFileSync(join(pluginRoot, "features/scum-catalog.ts"), "utf8");
@@ -19,4 +19,20 @@ describe("scum catalog icons", () => {
const missing = scumCatalogEntries.filter((entry) => entry.icon && !existsSync(join(pluginRoot, "assets/scum-catalog", entry.icon)));
expect(missing.map((entry) => entry.icon)).toEqual([]);
});
it("matches the live server's <name>_ES vehicle classes to bundled icons", () => {
const liveClasses = ["Rager_ES", "Laika_ES", "RIS_ES", "WolfsWagen_ES", "WheelBarrow_Metal_ES", "Barba_ES", "Tractor_ES", "Dinghy_ES", "Cruiser_ES", "SidecarBike_ES", "Dirtbike_ES", "CityBike_ES", "SUP_ES", "MountainBike_ES", "Kinglet_Duster_ES", "WheelBarrow_Improvised_ES"];
for (const code of liveClasses) expect(scumVehicleIconUrl(code)).toContain("scum-catalog");
expect(scumVehicleEntry("Rager_ES")?.name).toBe("Rager");
expect(scumVehicleEntry("BPC_Rager_C")?.name).toBe("Rager");
expect(scumVehicleEntry("Laika_ES")?.name).toBe("Laika");
expect(scumVehicleEntry("WheelBarrow_Metal_ES")?.name).toBe("Metal Wheelbarrow");
});
it("draws an inline glyph for models whose class ships no icon", () => {
expect(scumVehicleIconUrl("Pickup_01_A_ES")).toBe("");
expect(scumVehicleFallbackIconUrl("Pickup_01_A_ES")).toContain("data:image/svg+xml");
expect(scumVehicleFallbackIconUrl("Quad_01_D_ES")).toContain("data:image/svg+xml");
expect(decodeURIComponent(scumVehicleFallbackIconUrl("Dinghy_ES"))).toContain("<svg");
});
});