Repository navigation
Fix brush restore, border digs, and cached sword damage - #343
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
4c6ba64 to
50b92a1
Compare
A checkpoint now stores the demolition command log and replays it before the next dig. apply_brush_now loads every chunk in the brush radius. The greybox runs run_aravath_slice once at startup and reuses that sword remainder. The greybox golden and the destruction replay case stay put. Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
The greybox golden stays b6a9d5a2c5da28a6. local_sim remains a required replay case. Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
50b92a1 to
c929b78
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c929b78872
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let count = self.log.len(); | ||
| for index in 0..count { | ||
| if let CommandKind::Brush(brush) = self.log[index].kind { | ||
| self.load_brush_chunks(brush); |
There was a problem hiding this comment.
Preserve recent chunk histories while reloading brushes
When a save contains brushes in more than four distinct chunks, restore replay initially leaves the four most recent histories in Terrain's fixed slot array, but this oldest-to-newest loop then loads evicted older chunks and slot_mut overwrites slot zero. When the loop reaches the displaced recent chunk, load rebuilds an empty slot because it does not replay that chunk's commands. Consequently, loading a save and digging again in a recently edited chunk produces a different depth than uninterrupted play; reconstruct the loaded slots while replaying their brush commands rather than loading every logged span afterward.
Useful? React with 👍 / 👎.
| pub fn apply_brush_now(&mut self, brush: crate::command::Brush) -> Result<(), CommandError> { | ||
| let chunk = ( | ||
| brush.origin[0].div_euclid(crate::octree::CHUNK_EXTENT), | ||
| brush.origin[2].div_euclid(crate::octree::CHUNK_EXTENT), | ||
| ); | ||
| self.terrain.load(chunk); | ||
| self.load_brush_chunks(brush); | ||
| self.enqueue(DestructionCommand { |
There was a problem hiding this comment.
Validate brushes before traversing their chunk span
For a brush that enqueue will reject, this call still traverses and rebuilds its entire claimed span first. For example, a sphere with radius = u16::MAX is invalid under MAX_BRUSH_CELLS but causes roughly 16 million terrain.load calls before returning BrushTooLarge; LogFull similarly returns only after mutating the loaded-slot set. Validate the brush and command-log capacity before loading any chunks so rejected input cannot stall or alter the world.
Useful? React with 👍 / 👎.
| fn load_brush_chunks(&mut self, brush: crate::command::Brush) { | ||
| let extent = crate::octree::CHUNK_EXTENT; | ||
| let radius = i32::from(brush.radius); | ||
| let x0 = brush.origin[0].saturating_sub(radius).div_euclid(extent); | ||
| let x1 = brush.origin[0].saturating_add(radius).div_euclid(extent); | ||
| let z0 = brush.origin[2].saturating_sub(radius).div_euclid(extent); | ||
| let z1 = brush.origin[2].saturating_add(radius).div_euclid(extent); |
There was a problem hiding this comment.
Compute loaded bounds from the brush shape
Valid box brushes are bounded by half_extents, not radius, but this helper always derives both horizontal bounds from radius. For example, a box centered at x=29 with radius 1 and x half-extent 4 edits across x=32, while only chunk 0 is loaded; the brush is recorded in chunk 1 but surface_y ignores it because that slot remains unloaded. Use the relevant x/z half-extents for boxes and include them for the box portion of capsules.
Useful? React with 👍 / 👎.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Status pages said every connecting hit calls run_aravath_slice. Greybox startup runs it once, and each hit reuses that sword_hp. A checkpoint stores the demolition command log, and the brush loads every chunk its radius touches. The golden and the sixteen required cases are unchanged. Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
Description
Review fixes from merged #329 and #275, rebased onto
main10757c81(#330).restore_editsrebuilt voxels and leftDestructionWorldon the live log. A dig after load used that stale history. Checkpoints now storepersist_bytesunderdemolition.restore_dugreplays that log, rebindsColumnFns, and loads the brushed chunks before the next dig. An empty or pre-log save starts a fresh column world.dig_after_load_matches_the_continuous_rundigs, saves, loads, digs, and matches the no-loadstate_hash.apply_brush_nowloaded only the centre chunk, sosurface_ypast the border ignored the brush. It now loads every chunk in(origin ± radius).div_euclid(CHUNK_EXTENT)beforetick.brush_across_a_chunk_border_lowers_both_columnsdigs at x=31 with radius 3 and checks column 32.run_aravath_slicebuilt an ECS app, parsed the table, and ticked a destruction world on every connecting hit to read a constantsword_hp.Greybox::newandGreybox::openrun it once. Each hit applies that remainder (40 - sword_hp, still 25) and the cached cover result.The greybox golden stays
b6a9d5a2c5da28a6from #330.replay_matches_golden_hashpassed on this rebase. Required replay cases are unchanged, includinglocal_sim. Thedestructionreplay case is unchanged:apply_brush_nowis not on that path, andFlatColumnBasestays the unbound terrain. No new assets. No GPU sim.Do not merge.
Type of change
Security Considerations
Checklist