Skip to content

Commit

Permalink
please CI
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewgazelka committed Sep 21, 2024
1 parent 533f307 commit c3b02ec
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 28 deletions.
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/hyperion/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ base64.workspace = true
bitfield-struct = "0.8.0"
bitvec.workspace = true
bvh-region.workspace = true
compact_str.workspace = true
derive_more.workspace = true
dirs-next.workspace = true
fastrand.workspace = true
Expand Down
48 changes: 24 additions & 24 deletions crates/hyperion/src/simulation/blocks/loader/parse/section.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl Section {
self.changed.insert(idx as u32);
}

new
before
}

pub fn reset_tick_deltas(&mut self) {
Expand All @@ -50,8 +50,8 @@ mod tests {
biomes: BiomeContainer::new(),
block_light: [0; 2048],
sky_light: [0; 2048],
original: HashMap::with_hasher(FxBuildHasher::default()),
changed_since_last_tick: FxHashSet::default(),
changed: RoaringBitmap::default(),
changed_since_last_tick: RoaringBitmap::default(),
}
}

Expand All @@ -60,34 +60,34 @@ mod tests {
let mut section = create_test_section();
let new_state = BlockState::STONE;

let result = section.set(0, new_state);
let result = section.set_delta(0, new_state);
assert_eq!(result, BlockState::AIR);
assert_eq!(section.block_states.get(0), new_state);
assert_eq!(section.original.len(), 1);
assert!(section.changed_since_last_tick.contains(&0));
assert_eq!(section.changed.len(), 1);
assert!(section.changed_since_last_tick.contains(0));
}

#[test]
fn test_section_set_same_block() {
let mut section = create_test_section();
let state = BlockState::STONE;

section.set(0, state);
let result = section.set(0, state);
section.set_delta(0, state);
let result = section.set_delta(0, state);
assert_eq!(result, state);
assert_eq!(section.original.len(), 1);
assert_eq!(section.changed.len(), 1);
}

#[test]
fn test_section_set_revert_block() {
let mut section = create_test_section();
let new_state = BlockState::STONE;

section.set(0, new_state);
let result = section.set(0, BlockState::AIR);
section.set_delta(0, new_state);
let result = section.set_delta(0, BlockState::AIR);
assert_eq!(result, new_state);
assert!(section.original.is_empty());
assert!(section.changed_since_last_tick.contains(&0));
assert!(section.changed.contains(0));
assert!(section.changed_since_last_tick.contains(0));
}

#[test]
Expand All @@ -96,10 +96,10 @@ mod tests {
let states = [BlockState::STONE, BlockState::DIRT, BlockState::GRASS_BLOCK];

for (i, &state) in states.iter().enumerate() {
section.set(i as u16, state);
section.set_delta(i as u16, state);
}

assert_eq!(section.original.len(), 3);
assert_eq!(section.changed.len(), 3);
assert_eq!(section.changed_since_last_tick.len(), 3);

for (i, &state) in states.iter().enumerate() {
Expand All @@ -113,36 +113,36 @@ mod tests {
let state = BlockState::STONE;

// Test setting the first block
section.set(0, state);
section.set_delta(0, state);
assert_eq!(section.block_states.get(0), state);

// Test setting the last block (assuming 4096 blocks per section)
section.set(4095, state);
section.set_delta(4095, state);
assert_eq!(section.block_states.get(4095), state);
}

#[test]
fn test_reset_tick_deltas() {
let mut section = create_test_section();

section.set(0, BlockState::STONE);
section.set(1, BlockState::DIRT);
section.set_delta(0, BlockState::STONE);
section.set_delta(1, BlockState::DIRT);
assert_eq!(section.changed_since_last_tick.len(), 2);

section.reset_tick_deltas();
assert!(section.changed_since_last_tick.is_empty());
assert_eq!(section.original.len(), 2);
assert_eq!(section.changed.len(), 2);
}

#[test]
fn test_section_set_multiple_changes() {
let mut section = create_test_section();

section.set(0, BlockState::STONE);
section.set(0, BlockState::DIRT);
section.set(0, BlockState::GRASS_BLOCK);
section.set_delta(0, BlockState::STONE);
section.set_delta(0, BlockState::DIRT);
section.set_delta(0, BlockState::GRASS_BLOCK);

assert_eq!(section.original.len(), 1);
assert_eq!(section.changed.len(), 1);
assert_eq!(section.block_states.get(0), BlockState::GRASS_BLOCK);
}
}
1 change: 0 additions & 1 deletion events/infection/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ dotenvy = "0.15.7"
nom = "7.1.3"
serde_json = "1.0.128"
ndarray = "0.16.1"
rand = "0.8.5"

[dev-dependencies]
tokio = { workspace = true, features = ["full"] }
Expand Down

0 comments on commit c3b02ec

Please sign in to comment.