Skip to content

Commit

Permalink
use seahash instead of bevy's AHash
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksa2808 committed Feb 14, 2024
1 parent 75295f8 commit 70a2f8b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ wasm-bindgen = ["instant/wasm-bindgen", "ggrs/wasm-bindgen"]

[dependencies]
bevy = { version = "0.12", default-features = false }
bytemuck = { version = "1.7", features=["derive"]}
bytemuck = { version = "1.7", features = ["derive"] }
instant = { version = "0.1", optional = true }
log = "0.4"
#ggrs = { version= "0.10.0", features=["sync-send"]}
ggrs = { git = "https://github.com/gschup/ggrs", features=["sync-send"]}
ggrs = { git = "https://github.com/gschup/ggrs", features = ["sync-send"] }
seahash = "4.1"

[dev-dependencies]
bevy = { version = "0.12", default-features = true }
Expand Down
2 changes: 1 addition & 1 deletion src/snapshot/component_checksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ where
let mut result = 0;

for (&rollback, component) in components.iter() {
let mut hasher = hasher.clone();
let mut hasher = hasher;

// Hashing the rollback index ensures this hash is unique and stable
rollback_ordered.order(rollback).hash(&mut hasher);
Expand Down
14 changes: 6 additions & 8 deletions src/snapshot/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use crate::{ConfirmedFrameCount, Rollback, DEFAULT_FPS};
use bevy::{
prelude::*,
utils::{AHasher, FixedState, HashMap},
};
use std::{collections::VecDeque, hash::BuildHasher, marker::PhantomData};
use bevy::{prelude::*, utils::HashMap};
use seahash::SeaHasher;
use std::{collections::VecDeque, marker::PhantomData};

mod checksum;
mod component_checksum;
Expand Down Expand Up @@ -242,7 +240,7 @@ impl<For, As> GgrsComponentSnapshot<For, As> {
}
}

/// Returns a hasher built using Bevy's [FixedState] appropriate for creating checksums
pub fn checksum_hasher() -> AHasher {
FixedState.build_hasher()
/// Returns a hasher built using the `seahash` library appropriate for creating portable checksums.
pub fn checksum_hasher() -> SeaHasher {
SeaHasher::new()
}

0 comments on commit 70a2f8b

Please sign in to comment.