diff --git a/README.md b/README.md index deee366..dd49363 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,21 @@ alone: the flag only surfaces a per-install opt-in, off by default, next to that warning. Set it when the plugin genuinely does not function otherwise, not when it merely has a nicer HUD if you do. +### Plugins that need Metamod + +A native Metamod:Source plugin (a `.vdf` in `addons/metamod` and its own +`addons//bin`) loads on either 5Stack image, but SwiftlyS2 servers only +start Metamod for a plugin that asks: + +```json +"requires_metamod": true +``` + +Every server that loads the plugin then starts Metamod ahead of SwiftlyS2, which +keeps working underneath it; servers that load no such plugin are unchanged. A +Metamod plugin usually ships one archive for both runtimes, so list it under +both `variants`. + ### Plugins that ship workshop addons CS2 cannot send files from a server to a player, so a plugin's custom models, diff --git a/schema/plugin.schema.json b/schema/plugin.schema.json index a8cdc0b..d64d0ef 100644 --- a/schema/plugin.schema.json +++ b/schema/plugin.schema.json @@ -69,6 +69,11 @@ "default": false, "description": "Needs FollowCS2ServerGuidelines set to false to work at all. The panel hides the plugin's functionality behind a per-install opt-in and warns that Valve can ban every GSLT on the operator's account." }, + "requires_metamod": { + "type": "boolean", + "default": false, + "description": "Needs Metamod:Source: a native Metamod plugin, or one built on it. A server loading the plugin starts Metamod, ahead of SwiftlyS2 on the SwiftlyS2 image; servers that load no such plugin never start it." + }, "workshop_addons": { "type": "array", "uniqueItems": true, diff --git a/scripts/build.test.mjs b/scripts/build.test.mjs index 400505b..65c7650 100644 --- a/scripts/build.test.mjs +++ b/scripts/build.test.mjs @@ -8,6 +8,7 @@ import { sameIndex } from "./changed.mjs"; import { validateConfig, validateMapRotation, + validateRequiresMetamod, validateWorkshopAddons, } from "./validate.mjs"; @@ -248,6 +249,24 @@ const addonsEntry = (fields) => ({ ...fields, }); +test("accepts requires_metamod on a game plugin", () => { + assert.deepEqual( + validateRequiresMetamod(addonsEntry({ requires_metamod: true }), "x.json"), + [], + ); +}); + +test("rejects requires_metamod that is not a boolean, or on a panel plugin", () => { + assert.equal( + validateRequiresMetamod(addonsEntry({ requires_metamod: "true" }), "x.json").length, + 1, + ); + assert.equal( + validateRequiresMetamod({ kind: "panel", requires_metamod: true }, "x.json").length, + 1, + ); +}); + test("accepts workshop addons on a SwiftlyS2 plugin", () => { const problems = validateWorkshopAddons( addonsEntry({ workshop_addons: ["3791548068", "3070212801"] }), diff --git a/scripts/validate.mjs b/scripts/validate.mjs index d475383..3c3860a 100644 --- a/scripts/validate.mjs +++ b/scripts/validate.mjs @@ -135,6 +135,7 @@ export function validateEntry({ entry, filePath, directory, fileName }) { problems.push(...validateConfig(entry, filePath)); problems.push(...validateWorkshopAddons(entry, filePath)); + problems.push(...validateRequiresMetamod(entry, filePath)); if (entry.wiring) { if (entry.kind === "game") { @@ -356,6 +357,24 @@ export function validateWorkshopAddons(entry, filePath) { // The subset of JSON Schema the panel's form understands. A default the form // cannot render is a broken editor, so it is held to the same rules. +// A string "true" reads as truthy everywhere but the panel's boolean column, +// where the sync would fail the whole entry. +export function validateRequiresMetamod(entry, filePath) { + if (entry.requires_metamod === undefined) { + return []; + } + + if (typeof entry.requires_metamod !== "boolean") { + return [`${filePath}: "requires_metamod" must be true or false`]; + } + + if (entry.requires_metamod && entry.kind === "panel") { + return [`${filePath}: "requires_metamod" only belongs on a game or bundle entry`]; + } + + return []; +} + export function schemaProblems(schema, value, at) { const problems = []; const type = schema?.type;