From b12c89650ed0d7d0f02c7e2bf2a475c3b962e9a3 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Mon, 26 Oct 2026 11:46:27 +0100 Subject: [PATCH] Mod API levels: server mods' players functions are level 1; the registry's lockfile Main gained players.online, tell and broadcast (#1833) after 0.2.69, so they take level 1 with render.set-minimap. horizon-mod-registry's own Cargo.lock picks up wasmparser. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-mod-registry/Cargo.lock | 24 ++++++++++++++++++++++++ crates/horizon-mods/src/api_level.rs | 7 +++++-- docs/api/stability.md | 2 +- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/crates/horizon-mod-registry/Cargo.lock b/crates/horizon-mod-registry/Cargo.lock index e93f5b3b5..f80068fcc 100644 --- a/crates/horizon-mod-registry/Cargo.lock +++ b/crates/horizon-mod-registry/Cargo.lock @@ -401,6 +401,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" dependencies = [ "foldhash", + "serde", + "serde_core", ] [[package]] @@ -442,6 +444,7 @@ dependencies = [ "serde_json", "sha2", "toml", + "wasmparser", "zip", ] @@ -649,6 +652,8 @@ checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" dependencies = [ "equivalent", "hashbrown", + "serde", + "serde_core", ] [[package]] @@ -921,6 +926,12 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" + [[package]] name = "serde" version = "1.0.229" @@ -1326,6 +1337,19 @@ dependencies = [ "wit-bindgen", ] +[[package]] +name = "wasmparser" +version = "0.254.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5ff8685b587722894b6f25958fc608d315b93b8d23647bfb567664e7006d757" +dependencies = [ + "bitflags", + "hashbrown", + "indexmap", + "semver", + "serde", +] + [[package]] name = "webpki-roots" version = "0.26.11" diff --git a/crates/horizon-mods/src/api_level.rs b/crates/horizon-mods/src/api_level.rs index a81cf27bc..e7b72c20b 100644 --- a/crates/horizon-mods/src/api_level.rs +++ b/crates/horizon-mods/src/api_level.rs @@ -10,10 +10,10 @@ pub const LEVEL: u32 = 1; /// Every function the game offers mods, as `interface.function`, with its -/// level. Level 0 is the contract of Horizon 0.2.67 and 0.2.68. A new +/// level. Level 0 is the contract of Horizon 0.2.67 to 0.2.69. A new /// function takes the next level and raises [`LEVEL`] (the `api_reference` /// test fails until it is listed here). -pub const FUNCTIONS: [(&str, u32); 29] = [ +pub const FUNCTIONS: [(&str, u32); 32] = [ ("log.write", 0), ("game.get-player", 0), ("game.get-clock", 0), @@ -43,6 +43,9 @@ pub const FUNCTIONS: [(&str, u32); 29] = [ ("render.frame-stats", 0), ("render.set-zoom", 0), ("render.set-minimap", 1), + ("players.online", 1), + ("players.tell", 1), + ("players.broadcast", 1), ]; /// A function's level; None for one this Horizon doesn't have. diff --git a/docs/api/stability.md b/docs/api/stability.md index cea3415d7..65cfc0c13 100644 --- a/docs/api/stability.md +++ b/docs/api/stability.md @@ -38,7 +38,7 @@ don't import it); faster, or fixing behaviour to what the reference already says A new WIT function doesn't break older mods, but a mod that calls it can't run on a Horizon from before it. So every function the game offers mods has an **API level**, the one it arrived at (`crates/horizon-mods/src/api_level.rs`): -level 0 is the contract of Horizon 0.2.67 and 0.2.68, level 1 adds `render.set-minimap`. A mod needs the level of +level 0 is the contract of Horizon 0.2.67 to 0.2.69, level 1 adds `render.set-minimap` and server mods' `players`. A mod needs the level of the newest function it imports (a component imports only the functions it calls). The level is read from the file, never declared: