[PR #4947] [MERGED] Far terrain on servers (3/3): Horizon clients get their LOD from the server #5963

Closed
opened 2026-11-03 05:16:15 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4947
Author: @ludovic111
Created: 10/31/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: server-asks/lod-client


📝 Commits (7)

  • 55ed606 Far terrain on servers: Horizon clients ask the server for it
  • f9030e2 Far terrain client: requests leave from the game thread, failed tiles are asked again
  • cf7b5ce Merge #4946 (main merged) into #4947
  • 85c781e Far terrain client: a reconfiguration frees the old server's slots and rate
  • a9e7b49 Merge #4946 (main merged) into #4947
  • 2439930 Far terrain docs: dedicated servers only for now (an open-to-LAN world has no distance setting yet)
  • a6d37d7 Merge main into #4947: failed tiles still wait out their retry in main's wanted_tiles queue

📊 Changes

11 files changed (+575 additions, -14 deletions)

View changed files

📝 crates/horizon-client-render/src/lod.rs (+39 -4)
📝 crates/horizon-client-render/src/streaming.rs (+2 -0)
📝 crates/horizon-client/src/game.rs (+34 -6)
📝 crates/horizon-client/src/game/control.rs (+1 -1)
📝 crates/horizon-client/src/game/remote.rs (+21 -0)
📝 crates/horizon-client/src/lod_net.rs (+7 -3)
➕ crates/horizon-client/src/lod_net/client.rs (+285 -0)
📝 crates/horizon-client/src/net.rs (+56 -0)
📝 docs/graphics.md (+2 -0)
📝 docs/hosting.md (+9 -0)
➕ tools/server_lod_e2e.py (+119 -0)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

What and why

Part 3 of 3: far terrain (LOD) on dedicated servers, on top of #4946 and #4945. A Horizon client of another machine's server now draws far terrain when the server offers it. Before, LOD was off for every remote client. A server owner turns it on with horizon-lod-distance (off by default; see docs/hosting.md).

  • lod_net/client.rs: RemoteSource is the far terrain's LodSource. Each sampling thread queues one tile request and waits for its reply; there are no more samplers than the server lets requests wait. Inbox is per connection: the game thread sends the queued requests each tick with its other packets (Session::send_far_terrain), so samplers never take the connection's writer, and the network thread hands each reply straight to its sampler. It keeps to the server's offer (requests waiting, tiles a second), so a well-behaved client is never refused.
  • A tile refused, unreadable, or not answered within 30 s comes back as no columns: Lod keeps nothing for it and asks again 2 s later (lod.rs, retry), instead of keeping an empty tile for good. Requests still queued when the far terrain ends are dropped with their slots.
  • net.rs: the offer in configuration (Event::FarTerrain), the replies in play, and Session::far_terrain / send_far_terrain / cancel_far_terrain.
  • game.rs: prepare_lod uses the server's source for a remote client that isn't the window's own server thread, which keeps handing its generator over directly. LOD Distance stops at the server's distance. clear_lod cancels the waiting samplers first: dropping the far terrain joins them, which would otherwise wait for replies that may never come. A reconfiguration forgets the offer (a proxy's next server may not have one).
  • status reports lod.source "server".
  • Docs: hosting.md (the key, the limits), graphics.md.

Not in this stack, possible follow-ups:

  • an open-to-LAN world offering far terrain: a LAN host has no horizon-lod-distance setting yet, so it offers none (docs say dedicated servers only);
  • the decoration refinement of nearby tiles (single player's "Far decoration" chunks); over the network, tiles come from the generator's sampling only;
  • skipping tiles the client already holds as chunks;
  • a client tile cache, keyed by a world identity the offer would carry (a new protocol VERSION), so a rejoin doesn't download everything again.

Checked

tools/server_lod_e2e.py runs a real dedicated server and a real client (horizon-ctl, offscreen, scratch folders) with LOD Distance 32:

  • with horizon-lod-distance=16: source "server", effective distance 16, far tiles drawn (51 active, 128 cached);
  • with no horizon-lod-distance (off by default): no far terrain.
on: {'active_tiles': 39, 'cached_tiles': 116, 'distance': 32, 'effective_distance': 16, ..., 'source': 'server', ...}
on: the server samples far terrain, capped at its 16 chunks
off: {'active_tiles': 0, ..., 'source': 'none', ...}
off: no far terrain

Unit tests: cancelling the inbox frees its waiting samplers at once and drops unsent requests, and a late reply still frees its slot; a refused tile comes back as no columns, so Lod asks again.

pr_ready (tools/pr_ready.py on ludovics-mac-mini, against origin/main at c3905131b, 41 min 14 s)

Check Result
Scope ⚠️ 19 files, +1577 −9; 1575 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 495 passed (1 min 31 s)
rustfmt ✅ (6 s)
clippy ✅ (30 s)
tests: horizon-client, horizon-client-render ✅ 2055 passed (4 min 39 s)
doc tests ✅ 0 passed (1 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ✅ 117 affected, 116 passed (34 min 15 s)
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

The Scope row counts the whole stack against main; this PR alone is +523 −9 on #4946. The dedicated_server and secure_chat failures from the first round pass now that main is fixed.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/4947 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `server-asks/lod-client` --- ### 📝 Commits (7) - [`55ed606`](https://github.com/horizon-rust/horizon/commit/55ed606b373b61d3988c7c24ab4ef48f0b4ea484) Far terrain on servers: Horizon clients ask the server for it - [`f9030e2`](https://github.com/horizon-rust/horizon/commit/f9030e2da981f05628b57fa08a3e22f497dd5f11) Far terrain client: requests leave from the game thread, failed tiles are asked again - [`cf7b5ce`](https://github.com/horizon-rust/horizon/commit/cf7b5ce636c66378563d53d4f5a4b2b062389918) Merge #4946 (main merged) into #4947 - [`85c781e`](https://github.com/horizon-rust/horizon/commit/85c781e56e27584dd79b4405a546e0982b8543ac) Far terrain client: a reconfiguration frees the old server's slots and rate - [`a9e7b49`](https://github.com/horizon-rust/horizon/commit/a9e7b49f043ee4c2858bb0de01c9c233157a2d10) Merge #4946 (main merged) into #4947 - [`2439930`](https://github.com/horizon-rust/horizon/commit/24399301baa6c9c2af5368ac2739097b612b87d5) Far terrain docs: dedicated servers only for now (an open-to-LAN world has no distance setting yet) - [`a6d37d7`](https://github.com/horizon-rust/horizon/commit/a6d37d7f68557e58c0f807662b4ab0353cbe35ab) Merge main into #4947: failed tiles still wait out their retry in main's wanted_tiles queue ### 📊 Changes **11 files changed** (+575 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/lod.rs` (+39 -4) 📝 `crates/horizon-client-render/src/streaming.rs` (+2 -0) 📝 `crates/horizon-client/src/game.rs` (+34 -6) 📝 `crates/horizon-client/src/game/control.rs` (+1 -1) 📝 `crates/horizon-client/src/game/remote.rs` (+21 -0) 📝 `crates/horizon-client/src/lod_net.rs` (+7 -3) ➕ `crates/horizon-client/src/lod_net/client.rs` (+285 -0) 📝 `crates/horizon-client/src/net.rs` (+56 -0) 📝 `docs/graphics.md` (+2 -0) 📝 `docs/hosting.md` (+9 -0) ➕ `tools/server_lod_e2e.py` (+119 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What and why Part 3 of 3: **far terrain (LOD) on dedicated servers**, on top of #4946 and #4945. A Horizon client of another machine's server now draws far terrain when the server offers it. Before, LOD was off for every remote client. A server owner turns it on with `horizon-lod-distance` (off by default; see docs/hosting.md). - `lod_net/client.rs`: `RemoteSource` is the far terrain's `LodSource`. Each sampling thread queues one tile request and waits for its reply; there are no more samplers than the server lets requests wait. `Inbox` is per connection: the game thread sends the queued requests each tick with its other packets (`Session::send_far_terrain`), so samplers never take the connection's writer, and the network thread hands each reply straight to its sampler. It keeps to the server's offer (requests waiting, tiles a second), so a well-behaved client is never refused. - A tile refused, unreadable, or not answered within 30 s comes back as no columns: `Lod` keeps nothing for it and asks again 2 s later (`lod.rs`, `retry`), instead of keeping an empty tile for good. Requests still queued when the far terrain ends are dropped with their slots. - `net.rs`: the offer in configuration (`Event::FarTerrain`), the replies in play, and `Session::far_terrain` / `send_far_terrain` / `cancel_far_terrain`. - `game.rs`: `prepare_lod` uses the server's source for a remote client that isn't the window's own server thread, which keeps handing its generator over directly. LOD Distance stops at the server's distance. `clear_lod` cancels the waiting samplers first: dropping the far terrain joins them, which would otherwise wait for replies that may never come. A reconfiguration forgets the offer (a proxy's next server may not have one). - `status` reports `lod.source` "server". - Docs: hosting.md (the key, the limits), graphics.md. Not in this stack, possible follow-ups: - an open-to-LAN world offering far terrain: a LAN host has no `horizon-lod-distance` setting yet, so it offers none (docs say dedicated servers only); - the decoration refinement of nearby tiles (single player's "Far decoration" chunks); over the network, tiles come from the generator's sampling only; - skipping tiles the client already holds as chunks; - a client tile cache, keyed by a world identity the offer would carry (a new protocol `VERSION`), so a rejoin doesn't download everything again. ## Checked `tools/server_lod_e2e.py` runs a real dedicated server and a real client (horizon-ctl, offscreen, scratch folders) with LOD Distance 32: - with `horizon-lod-distance=16`: source "server", effective distance 16, far tiles drawn (51 active, 128 cached); - with no `horizon-lod-distance` (off by default): no far terrain. ``` on: {'active_tiles': 39, 'cached_tiles': 116, 'distance': 32, 'effective_distance': 16, ..., 'source': 'server', ...} on: the server samples far terrain, capped at its 16 chunks off: {'active_tiles': 0, ..., 'source': 'none', ...} off: no far terrain ``` Unit tests: cancelling the inbox frees its waiting samplers at once and drops unsent requests, and a late reply still frees its slot; a refused tile comes back as no columns, so `Lod` asks again. **pr_ready** (`tools/pr_ready.py` on ludovics-mac-mini, against origin/main at c3905131b, 41 min 14 s) | Check | Result | | --- | --- | | Scope | ⚠️ 19 files, +1577 −9; 1575 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 495 passed (1 min 31 s) | | rustfmt | ✅ (6 s) | | clippy | ✅ (30 s) | | tests: horizon-client, horizon-client-render | ✅ 2055 passed (4 min 39 s) | | doc tests | ✅ 0 passed (1 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ✅ 117 affected, 116 passed (34 min 15 s) | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | The Scope row counts the whole stack against main; this PR alone is +523 −9 on #4946. The `dedicated_server` and `secure_chat` failures from the first round pass now that main is fixed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:16:15 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#5963
No description provided.