Mod config
This commit is contained in:
+17
-3
@@ -8,6 +8,7 @@ import { mod_data } from "$/common/mod_check.ts";
|
||||
import type { ServerModSource } from "$/server/game/load_mods.ts";
|
||||
import { GameServer } from "$/server/game/game_server.ts";
|
||||
import { start_game } from "$/server/game/load_mods.ts";
|
||||
import { apply_config } from "$/server/load_bmods.ts";
|
||||
import { PROTOCOL_VERSION } from "$/common/protocol.ts";
|
||||
import { decode_level_chunk } from "$/common/chunk_streaming.ts";
|
||||
import { CHUNK_AREA, CHUNK_SIZE, ID_MASK } from "$/common/constants.ts";
|
||||
@@ -68,9 +69,22 @@ class MemoryChunks implements SavedChunks {
|
||||
}
|
||||
|
||||
// a game with an in memory host that remembers what it sent to each connection. the seed has low, dry land around
|
||||
// 0, 0, where players spawn and where tests build things
|
||||
export async function test_game(mods_dir: string, save?: WorldSave, seed = "test-seed-90") {
|
||||
// 0, 0, where players spawn and where tests build things. config changes mods' settings, by mod id, like a server's
|
||||
// config/<mod id>.json files
|
||||
export async function test_game(
|
||||
mods_dir: string,
|
||||
save?: WorldSave,
|
||||
seed = "test-seed-90",
|
||||
config: Record<string, Record<string, unknown>> = {},
|
||||
) {
|
||||
EverythingRegistry.clear();
|
||||
const mods = mod_sources(mods_dir);
|
||||
for (const mod of mods) {
|
||||
if (!config[mod.listing.id]) continue;
|
||||
const changed = apply_config(mod.data.config ?? {}, config[mod.listing.id]);
|
||||
if (changed.problems.length) throw new Error(`${mod.listing.id}: ${changed.problems.join("; ")}`);
|
||||
mod.data.config = changed.config;
|
||||
}
|
||||
const outbox = new Map<number, unknown[]>();
|
||||
const closed = new Set<number>();
|
||||
// what host.download gives back, by url. other urls fail
|
||||
@@ -97,7 +111,7 @@ export async function test_game(mods_dir: string, save?: WorldSave, seed = "test
|
||||
host,
|
||||
{ level: save?.level, chunks },
|
||||
seed,
|
||||
mod_sources(mods_dir),
|
||||
mods,
|
||||
);
|
||||
// what it saves is read back from memory, like a host's region files
|
||||
const save_game = game.save.bind(game);
|
||||
|
||||
Reference in New Issue
Block a user