diff --git a/all-is-cubes/src/inv/tool.rs b/all-is-cubes/src/inv/tool.rs index d1c56a818..744bc649a 100644 --- a/all-is-cubes/src/inv/tool.rs +++ b/all-is-cubes/src/inv/tool.rs @@ -754,9 +754,11 @@ mod tests { }); let transaction = tester.equip_and_use_tool(tool.clone()).unwrap(); + let mut expected_cube_transaction = + SpaceTransaction::set_cube(Cube::ORIGIN, Some(AIR), Some(tool_block.clone())); + expected_cube_transaction.add_fluff(Cube::ORIGIN, Fluff::PlaceBlockGeneric); let expected_cube_transaction = - SpaceTransaction::set_cube([0, 0, 0], Some(AIR), Some(tool_block.clone())) - .bind(tester.space_ref.clone()); + expected_cube_transaction.bind(tester.space_ref.clone()); assert_eq!( transaction, if expect_consume { @@ -809,11 +811,15 @@ mod tests { .unwrap(); assert_eq!( transaction, - SpaceTransaction::set_cube( - [0, 0, 0], - Some(AIR), - Some(tool_block.clone().rotate(GridRotation::CLOCKWISE)) - ) + { + let mut t = SpaceTransaction::set_cube( + [0, 0, 0], + Some(AIR), + Some(tool_block.clone().rotate(GridRotation::CLOCKWISE)), + ); + t.add_fluff(Cube::ORIGIN, Fluff::PlaceBlockGeneric); + t + } .bind(tester.space_ref.clone()) ); } diff --git a/all-is-cubes/src/space/space_txn.rs b/all-is-cubes/src/space/space_txn.rs index 5face8f80..4a6785b75 100644 --- a/all-is-cubes/src/space/space_txn.rs +++ b/all-is-cubes/src/space/space_txn.rs @@ -397,12 +397,13 @@ impl Merge for SpaceTransaction { impl fmt::Debug for SpaceTransaction { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { + let Self { cubes, behaviors } = self; let mut ds = fmt.debug_struct("SpaceTransaction"); - for (cube, txn) in &self.cubes { + for (cube, txn) in cubes { ds.field(&Cube::from(*cube).refmt(&ConciseDebug).to_string(), txn); } - if !self.behaviors.is_empty() { - ds.field("behaviors", &self.behaviors); + if !behaviors.is_empty() { + ds.field("behaviors", &behaviors); } ds.finish() } @@ -444,7 +445,7 @@ impl fmt::Display for SpaceTransactionConflict { /// Data for a single cube in a [`SpaceTransaction`]. This does not function as a /// transaction on its own, though it does implement [`Merge`]. -#[derive(Clone, Debug, Default, Eq, PartialEq)] +#[derive(Clone, Default, Eq, PartialEq)] struct CubeTransaction { /// Previous block which must occupy this cube. /// If `None`, no precondition. @@ -471,6 +472,31 @@ struct CubeTransaction { fluff: Vec, } +impl fmt::Debug for CubeTransaction { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let Self { + old, + new, + conserved, + activate, + fluff, + } = self; + let mut ds = f.debug_struct("CubeTransaction"); + if old.is_some() || new.is_some() { + ds.field("old", &old); + ds.field("new", &new); + ds.field("conserved", &conserved); + } + if *activate { + ds.field("activate", &activate); + } + if !fluff.is_empty() { + ds.field("fluff", &fluff); + } + ds.finish() + } +} + impl CubeTransaction { const ACTIVATE: Self = Self { old: None, diff --git a/all-is-cubes/src/universe/universe_txn.rs b/all-is-cubes/src/universe/universe_txn.rs index f4914199c..7fb3956fa 100644 --- a/all-is-cubes/src/universe/universe_txn.rs +++ b/all-is-cubes/src/universe/universe_txn.rs @@ -743,7 +743,6 @@ mod tests { }, ), conserved: true, - activate: false, }, }, }