[PR #6202] [MERGED] Collision scans: a movement's budget covers its sweep (#6124) #6712

Closed
opened 2026-11-03 06:25:21 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6202
Author: @JustKarkat
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: fix/collision-scan-budget


📝 Commits (1)

  • 835f2b5 Collision scans: a movement's budget covers its sweep

📊 Changes

3 files changed (+196 additions, -31 deletions)

View changed files

📝 crates/horizon-world/src/block_collision_scan.rs (+46 -23)
📝 crates/horizon-world/src/world_movement.rs (+19 -8)
➕ crates/horizon-world/tests/world_movement.rs (+131 -0)

📄 Description

🤖 Opened by JustKarkat's AI agent (ZCode, deepseek-v4.1-flash), not by JustKarkat personally.

Fixes #6124.

The crash. A movement scan walks every cell of the box the movement expands to (try_resolve_step_movement → aabb.expand_towards(movement)), so a diagonal move covers about N×N cells. The client passes candidate_budget: 1_000_000, and a legal movement_speed of 400 passes that within a second of running: the scan ended in VisitBudget and Motion::collide turned it into the crash "collision scan candidate budget exhausted".

The fix. Vanilla walks the same box with no candidate counter, so the same movement is slow there, never fatal. resolve_world_movement now raises the budget to the cells its own queries can visit — the sweep, and the step's own box raised by max_step — and leaves the caller's budget as the floor for everything else. Nothing changes below the budget (ordinary movement keeps the exact same scan), and a movement past it stalls like vanilla instead of exiting the game.

scan_cells shares the cursor arithmetic with BlockCollisionScan::new instead of repeating it, and the new crates/horizon-world/tests/world_movement.rs covers:

  • a 40×40 diagonal sweep under a budget of 10 is walked in full and resolves (the crash case);
  • scan_cells is an upper bound on what a scan visits, short by at most the eight skipped corners;
  • ordinary movements resolve identically under a tiny and a huge budget.

Checks: cargo test -p horizon-world --test world_movement --test block_collision_scan (8 tests, green), cargo clippy -p horizon-world --all-targets (clean), python3 tools/parity.py world_movement block_collision_scan (2 passed, 0 failed).

Not covered: I could not drive the speed-400 run through horizon-ctl (the scripted move ignores the attribute and held keys do not reach the offscreen window), so this fixes the abort at the code level and the harness levels above; the in-game confirmation still needs a real client session.


🔄 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/6202 **Author:** [@JustKarkat](https://github.com/JustKarkat) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/collision-scan-budget` --- ### 📝 Commits (1) - [`835f2b5`](https://github.com/horizon-rust/horizon/commit/835f2b5222e9a082182a10bd3ef84b89ba9914b3) Collision scans: a movement's budget covers its sweep ### 📊 Changes **3 files changed** (+196 additions, -31 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-world/src/block_collision_scan.rs` (+46 -23) 📝 `crates/horizon-world/src/world_movement.rs` (+19 -8) ➕ `crates/horizon-world/tests/world_movement.rs` (+131 -0) </details> ### 📄 Description > 🤖 Opened by JustKarkat's AI agent (ZCode, deepseek-v4.1-flash), not by JustKarkat personally. Fixes #6124. **The crash.** A movement scan walks every cell of the box the movement expands to (`try_resolve_step_movement` → `aabb.expand_towards(movement)`), so a diagonal move covers about N×N cells. The client passes `candidate_budget: 1_000_000`, and a legal `movement_speed` of 400 passes that within a second of running: the scan ended in `VisitBudget` and `Motion::collide` turned it into the crash "collision scan candidate budget exhausted". **The fix.** Vanilla walks the same box with no candidate counter, so the same movement is slow there, never fatal. `resolve_world_movement` now raises the budget to the cells its own queries can visit — the sweep, and the step's own box raised by `max_step` — and leaves the caller's budget as the floor for everything else. Nothing changes below the budget (ordinary movement keeps the exact same scan), and a movement past it stalls like vanilla instead of exiting the game. `scan_cells` shares the cursor arithmetic with `BlockCollisionScan::new` instead of repeating it, and the new `crates/horizon-world/tests/world_movement.rs` covers: - a 40×40 diagonal sweep under a budget of 10 is walked in full and resolves (the crash case); - `scan_cells` is an upper bound on what a scan visits, short by at most the eight skipped corners; - ordinary movements resolve identically under a tiny and a huge budget. **Checks:** `cargo test -p horizon-world --test world_movement --test block_collision_scan` (8 tests, green), `cargo clippy -p horizon-world --all-targets` (clean), `python3 tools/parity.py world_movement block_collision_scan` (2 passed, 0 failed). **Not covered:** I could not drive the speed-400 run through `horizon-ctl` (the scripted `move` ignores the attribute and held keys do not reach the offscreen window), so this fixes the abort at the code level and the harness levels above; the in-game confirmation still needs a real client session. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:25:21 +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#6712
No description provided.