Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/<name>/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,
Expand Down
5 changes: 5 additions & 0 deletions schema/plugin.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
19 changes: 19 additions & 0 deletions scripts/build.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { sameIndex } from "./changed.mjs";
import {
validateConfig,
validateMapRotation,
validateRequiresMetamod,
validateWorkshopAddons,
} from "./validate.mjs";

Expand Down Expand Up @@ -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"] }),
Expand Down
19 changes: 19 additions & 0 deletions scripts/validate.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down Expand Up @@ -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;
Expand Down