From cfb4518a53a2e4f4a34f40add1ea9dab479b0ff5 Mon Sep 17 00:00:00 2001 From: Chris Mounce Date: Fri, 20 Mar 2026 23:04:56 -0700 Subject: [PATCH] Rename x/y step fields to `step_x`, `step_y` This makes things more consistent with Board's `enter_x` and `enter_y`, and it prevents autocomplete prefix collisions with Stat's `x` and `y`. --- .../zztff__world__tests__decode_snapshot.snap | 69 +++++++++---------- src/world.rs | 18 ++--- 2 files changed, 43 insertions(+), 44 deletions(-) diff --git a/src/snapshots/zztff__world__tests__decode_snapshot.snap b/src/snapshots/zztff__world__tests__decode_snapshot.snap index 305430b..d4ff163 100644 --- a/src/snapshots/zztff__world__tests__decode_snapshot.snap +++ b/src/snapshots/zztff__world__tests__decode_snapshot.snap @@ -1,6 +1,5 @@ --- source: src/world.rs -assertion_line: 589 expression: world --- World { @@ -56,8 +55,8 @@ World { Stat { x: 1, y: 1, - x_step: 0, - y_step: 0, + step_x: 0, + step_y: 0, cycle: 1, p1: 0, p2: 0, @@ -97,8 +96,8 @@ World { Stat { x: 1, y: 1, - x_step: 0, - y_step: 0, + step_x: 0, + step_y: 0, cycle: 1, p1: 0, p2: 0, @@ -138,8 +137,8 @@ World { Stat { x: 1, y: 1, - x_step: 0, - y_step: 0, + step_x: 0, + step_y: 0, cycle: 1, p1: 0, p2: 0, @@ -179,8 +178,8 @@ World { Stat { x: 1, y: 1, - x_step: 0, - y_step: 0, + step_x: 0, + step_y: 0, cycle: 1, p1: 0, p2: 0, @@ -199,8 +198,8 @@ World { Stat { x: 3, y: 2, - x_step: 0, - y_step: 0, + step_x: 0, + step_y: 0, cycle: 3, p1: 51, p2: 0, @@ -219,8 +218,8 @@ World { Stat { x: 20, y: 4, - x_step: 0, - y_step: 0, + step_x: 0, + step_y: 0, cycle: 0, p1: 0, p2: 0, @@ -239,8 +238,8 @@ World { Stat { x: 5, y: 2, - x_step: 0, - y_step: 0, + step_x: 0, + step_y: 0, cycle: 1, p1: 49, p2: 1, @@ -259,8 +258,8 @@ World { Stat { x: 7, y: 2, - x_step: 0, - y_step: 0, + step_x: 0, + step_y: 0, cycle: 3, p1: 64, p2: 0, @@ -279,8 +278,8 @@ World { Stat { x: 10, y: 2, - x_step: 0, - y_step: 0, + step_x: 0, + step_y: 0, cycle: 3, p1: 9, p2: 0, @@ -320,8 +319,8 @@ World { Stat { x: 1, y: 1, - x_step: 0, - y_step: 0, + step_x: 0, + step_y: 0, cycle: 1, p1: 0, p2: 0, @@ -340,8 +339,8 @@ World { Stat { x: 3, y: 2, - x_step: 0, - y_step: -1, + step_x: 0, + step_y: -1, cycle: 4, p1: 0, p2: 0, @@ -360,8 +359,8 @@ World { Stat { x: 5, y: 2, - x_step: 0, - y_step: 1, + step_x: 0, + step_y: 1, cycle: 4, p1: 0, p2: 0, @@ -380,8 +379,8 @@ World { Stat { x: 7, y: 2, - x_step: 1, - y_step: 0, + step_x: 1, + step_y: 0, cycle: 4, p1: 0, p2: 0, @@ -400,8 +399,8 @@ World { Stat { x: 9, y: 2, - x_step: -1, - y_step: 0, + step_x: -1, + step_y: 0, cycle: 4, p1: 0, p2: 0, @@ -420,8 +419,8 @@ World { Stat { x: 3, y: 4, - x_step: 0, - y_step: 0, + step_x: 0, + step_y: 0, cycle: 2, p1: 4, p2: 4, @@ -440,8 +439,8 @@ World { Stat { x: 4, y: 4, - x_step: 0, - y_step: 0, + step_x: 0, + step_y: 0, cycle: 2, p1: 0, p2: 0, @@ -460,8 +459,8 @@ World { Stat { x: 5, y: 4, - x_step: 0, - y_step: 0, + step_x: 0, + step_y: 0, cycle: 2, p1: 0, p2: 0, diff --git a/src/world.rs b/src/world.rs index 9c51f0e..a38d3f2 100644 --- a/src/world.rs +++ b/src/world.rs @@ -267,9 +267,9 @@ pub struct Stat { /// are possible and are useful for advanced techniques, but care must be taken to ensure that /// they are safe; ZZT's bounds checking code assumes step distances will never exceed 1, so /// steps larger than that may go off-board and cause memory corruption. - pub x_step: i16, + pub step_x: i16, /// Vertical step delta. - pub y_step: i16, + pub step_y: i16, /// How often this stat is updated, in game ticks. /// /// Roughly speaking, stats update every 1/cycle game ticks. A cycle 1 object will run its code @@ -330,8 +330,8 @@ impl Default for Stat { Stat { x: 0, y: 0, - x_step: 0, - y_step: 0, + step_x: 0, + step_y: 0, cycle: 0, p1: 0, p2: 0, @@ -625,7 +625,7 @@ impl Board { impl Stat { fn parse(input: &[u8]) -> IResult<&[u8], Self, DecodeError> { - let (input, (x, y, x_step, y_step)) = (le_u8, le_u8, le_i16, le_i16).parse(input)?; + let (input, (x, y, step_x, step_y)) = (le_u8, le_u8, le_i16, le_i16).parse(input)?; let (input, (cycle, p1, p2, p3)) = (le_i16, le_u8, le_u8, le_u8).parse(input)?; let (input, (follower, leader)) = (le_i16, le_i16).parse(input)?; let (input, (under_element, under_color)) = (le_u8, le_u8).parse(input)?; @@ -650,8 +650,8 @@ impl Stat { Stat { x, y, - x_step, - y_step, + step_x, + step_y, follower, leader, cycle, @@ -672,8 +672,8 @@ impl Stat { let mut result = vec![]; result.push(self.x); result.push(self.y); - result.push_i16(self.x_step); - result.push_i16(self.y_step); + result.push_i16(self.step_x); + result.push_i16(self.step_y); result.push_i16(self.cycle); result.push(self.p1); result.push(self.p2);