[PR #4954] [MERGED] PlayerMotion: Clone, for the movement prediction's replays #5968

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

📋 Pull Request Information

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

Base: main ← Head: feat/player-motion-clone


📝 Commits (1)

  • c58859a PlayerMotion: Clone, for the movement prediction's replays

📊 Changes

8 files changed (+97 additions, -5 deletions)

View changed files

📝 crates/horizon-client/src/attribute_updates.rs (+1 -1)
📝 crates/horizon-client/src/health.rs (+2 -1)
📝 crates/horizon-client/src/motion.rs (+37 -3)
📝 crates/horizon-client/src/motion/fluids.rs (+1 -0)
📝 crates/horizon-world/src/attribute_map.rs (+1 -0)
📝 crates/horizon-world/src/attributes/live.rs (+18 -0)
📝 crates/horizon-world/src/object_open_map.rs (+36 -0)
📝 crates/horizon-world/src/object_open_set.rs (+1 -0)

📄 Description

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

Prediction (b0): a prerequisite for the movement prediction's replay (#4919 records each client tick; the plan is on #4735). The replay plays each client tick again on a copy of the player, one copy per input the server can't know. So PlayerMotion must be Clone, and a copy must never change the original.

  • Every field already derives Clone except the attributes, whose identity allocator was a Box<dyn FnMut() -> i32>. It is now a Box<dyn Identities> (horizon-world attributes::live): any FnMut() -> i32 that is also Clone. Both closures that build one (PlayerMotion::new's counter, and scene_motion_probe's replayed identities) already were.
  • LiveAttributes, AttributeMap, ObjectOpenSet, PlayerHealth and PlayerFluids derive Clone.
  • ObjectOpenMap keeps its table in an Rc<RefCell<…>>. A derived Clone would share that table, so its Clone copies the table instead.

Nothing calls clone yet. Behaviour and cost are unchanged.

Tests

  • object_open_map::tests::a_copy_has_its_own_table: writes to the copy never reach the original.
  • motion::tests::a_copied_player_moves_on_its_own: sprinting on the copy (a speed modifier) and its velocity stay in the copy, and both copies keep editing their own attributes afterwards.
  • Harnesses: attribute, attribute_health, attribute_updates, live_attribute_updates, live_attributes, attribute_map_queries pass.

pr_ready

Check Result
Scope ✅ 8 files, +97 −5
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 486 passed (1 min 3 s)
rustfmt ✅ (4 s)
clippy ✅ (51 s)
tests: horizon-client, horizon-world ❌ 910 passed, 1 failed (3 min 25 s)
doc tests ✅ 0 passed (2 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 ➖ 72 affected, to run in CI (--quick): arrow, attribute_health, attribute_map_queries, attribute_updates, auto_jump, block_removal, command_exec, composter, container_title, crafter, cursor_death, dedicated_server and 60 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

The failing test, motion::tests::a_swimming_passenger_sits_up_even_when_standing_does_not_fit, comes from #4662 and fails on main whenever .local data is present. Reported on #4662; not touched here.

🤖 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/4954 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/player-motion-clone` --- ### 📝 Commits (1) - [`c58859a`](https://github.com/horizon-rust/horizon/commit/c58859aedf9243efe99ac0e1fb7ee7addb1529be) PlayerMotion: Clone, for the movement prediction's replays ### 📊 Changes **8 files changed** (+97 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/attribute_updates.rs` (+1 -1) 📝 `crates/horizon-client/src/health.rs` (+2 -1) 📝 `crates/horizon-client/src/motion.rs` (+37 -3) 📝 `crates/horizon-client/src/motion/fluids.rs` (+1 -0) 📝 `crates/horizon-world/src/attribute_map.rs` (+1 -0) 📝 `crates/horizon-world/src/attributes/live.rs` (+18 -0) 📝 `crates/horizon-world/src/object_open_map.rs` (+36 -0) 📝 `crates/horizon-world/src/object_open_set.rs` (+1 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Prediction (b0): a prerequisite for the movement prediction's replay (#4919 records each client tick; the plan is on #4735). The replay plays each client tick again on a copy of the player, one copy per input the server can't know. So `PlayerMotion` must be `Clone`, and a copy must never change the original. - Every field already derives `Clone` except the attributes, whose identity allocator was a `Box<dyn FnMut() -> i32>`. It is now a `Box<dyn Identities>` (horizon-world `attributes::live`): any `FnMut() -> i32` that is also `Clone`. Both closures that build one (`PlayerMotion::new`'s counter, and `scene_motion_probe`'s replayed identities) already were. - `LiveAttributes`, `AttributeMap`, `ObjectOpenSet`, `PlayerHealth` and `PlayerFluids` derive `Clone`. - `ObjectOpenMap` keeps its table in an `Rc<RefCell<…>>`. A derived `Clone` would share that table, so its `Clone` copies the table instead. Nothing calls `clone` yet. Behaviour and cost are unchanged. ## Tests - `object_open_map::tests::a_copy_has_its_own_table`: writes to the copy never reach the original. - `motion::tests::a_copied_player_moves_on_its_own`: sprinting on the copy (a speed modifier) and its velocity stay in the copy, and both copies keep editing their own attributes afterwards. - Harnesses: `attribute`, `attribute_health`, `attribute_updates`, `live_attribute_updates`, `live_attributes`, `attribute_map_queries` pass. ## pr_ready | Check | Result | | --- | --- | | Scope | ✅ 8 files, +97 −5 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 486 passed (1 min 3 s) | | rustfmt | ✅ (4 s) | | clippy | ✅ (51 s) | | tests: horizon-client, horizon-world | ❌ 910 passed, 1 failed (3 min 25 s) | | doc tests | ✅ 0 passed (2 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 | ➖ 72 affected, to run in CI (--quick): arrow, attribute_health, attribute_map_queries, attribute_updates, auto_jump, block_removal, command_exec, composter, container_title, crafter, cursor_death, dedicated_server and 60 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | The failing test, `motion::tests::a_swimming_passenger_sits_up_even_when_standing_does_not_fit`, comes from #4662 and fails on main whenever `.local` data is present. Reported on #4662; not touched here. 🤖 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:16 +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#5968
No description provided.