Actually fix default dimensions with multiple mods
This commit is contained in:
+2
-8
@@ -186,8 +186,6 @@ export function check_references(mods: LoadedMod[], engine_textures: Iterable<st
|
||||
"biome source": new Map(),
|
||||
dimension: new Map(),
|
||||
};
|
||||
// the dimensions that say they're the default, only one can be
|
||||
const defaults: string[] = [];
|
||||
const biome_rule_owners = new Map<string, string[]>();
|
||||
const all_noise_settings: NoiseSettingsJson[] = [];
|
||||
const feature_owners = new Map<string, string[]>();
|
||||
@@ -225,7 +223,6 @@ export function check_references(mods: LoadedMod[], engine_textures: Iterable<st
|
||||
}
|
||||
for (const { json } of mod.dimensions ?? []) {
|
||||
add(worldgen_owners.dimension, json.id, mod.id);
|
||||
if (json.default) defaults.push(`${json.id} (${mod.id})`);
|
||||
}
|
||||
for (const { json } of mod.biome_sources ?? []) {
|
||||
add(worldgen_owners["biome source"], json.id, mod.id);
|
||||
@@ -432,11 +429,8 @@ export function check_references(mods: LoadedMod[], engine_textures: Iterable<st
|
||||
[settings.terrain.cell_height, settings.caves.cell_height],
|
||||
);
|
||||
if (problem) errors.push(`${file}: can't be generated by ${json.generator}: ${problem}`);
|
||||
if (json.default && defaults.length > 1) {
|
||||
errors.push(
|
||||
`${file}: only one dimension can be the default, and these all are: ${defaults.join(", ")}`,
|
||||
);
|
||||
}
|
||||
// whether exactly one is the default is up to the server, with the mods a world plays: a folder of mods
|
||||
// can hold several games, each with its own
|
||||
}
|
||||
for (const { file, json } of mod.biome_sources ?? []) {
|
||||
const refs = new_refs();
|
||||
|
||||
@@ -335,8 +335,11 @@ torches, light it, and day and night don't change how bright it is. The sky is s
|
||||
|
||||
The world plays the dimension with `"default": true`. Exactly one dimension in the loaded mods can be the default: with
|
||||
none, or more than one, the server doesn't start, and the error names them. A mod can have dimensions that aren't the
|
||||
default, but nothing plays them yet. Since a mod can't change another mod's files yet, a mod with a default dimension of
|
||||
its own, like a flat world, can't be loaded with the base game's for now.
|
||||
default, but nothing plays them yet.
|
||||
|
||||
A mod with a default dimension of its own, like a flat world or a game that doesn't build on the base game, is played
|
||||
without the base game: a singleplayer world picks its mods, and a dedicated server loads the ones `MODS` names, like
|
||||
`MODS=my_game,recipe_viewer`. `check-mods` doesn't mind a folder holding several, since each world plays one.
|
||||
|
||||
There's one dimension per world for now, there's no travelling between them yet.
|
||||
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
"dimension": {
|
||||
"id": "dangerous_business:void",
|
||||
"generator": "dangerous_business:void",
|
||||
"default": false
|
||||
"default": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
// a dedicated server: the host from server/host.ts on a port, saving the world when it's stopped
|
||||
import { MOD_EXTENSION } from "@/common/mod.ts";
|
||||
import { type Host, start_host } from "./host.ts";
|
||||
|
||||
const PORT = Number(Deno.env.get("PORT") ?? 8000);
|
||||
@@ -11,6 +12,9 @@ try {
|
||||
host = await start_host({
|
||||
build_dir: Deno.env.get("BUILD_DIR") ?? "build",
|
||||
server_mods_dir: Deno.env.get("SERVER_MODS_DIR") ?? "server_mods",
|
||||
// which mods to play, by id, like MODS=bworld,create. each is <id>.cubi, as deno task build names them. every
|
||||
// one when left out, which only works while server_mods/ has a single game with a default dimension
|
||||
mod_files: Deno.env.get("MODS")?.split(",").map((id) => `${id.trim()}${MOD_EXTENSION}`),
|
||||
config_dir: Deno.env.get("CONFIG_DIR") ?? "config",
|
||||
dist_dir: Deno.env.get("DIST_DIR") ?? "dist",
|
||||
world_dir: Deno.env.get("WORLD_DIR") ?? "world",
|
||||
|
||||
+4
-1
@@ -42,7 +42,10 @@ let repo_mods: ServerModSource[] | undefined;
|
||||
// own copy, so a test that changes what it got can't change another test's
|
||||
export async function mod_sources(mods_dir: string): Promise<ServerModSource[]> {
|
||||
if (resolve(mods_dir) !== resolve("mods")) return await read_mod_sources(mods_dir);
|
||||
repo_mods ??= await read_mod_sources(mods_dir);
|
||||
// other games in mods/, the ones with a default dimension of their own, are left out: tests play bworld
|
||||
repo_mods ??= (await read_mod_sources(mods_dir)).filter((mod) =>
|
||||
mod.listing.id === "bworld" || !mod.data.dimensions?.some((json) => json.default)
|
||||
);
|
||||
return structuredClone(repo_mods);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user