Skip to content

Commit

Permalink
use u64 instead of usize in checksums
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksa2808 committed Feb 14, 2024
1 parent 5d3e2ff commit 75295f8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/rollback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ impl<'w, 's, 'a> AddRollbackCommandExtension for EntityCommands<'w, 's, 'a> {
/// A [`Resource`] which provides methods for stable ordering of [`Rollback`] flags.
#[derive(Resource, Default, Clone)]
pub struct RollbackOrdered {
order: HashMap<Rollback, usize>,
order: HashMap<Rollback, u64>,
sorted: Vec<Rollback>,
}

impl RollbackOrdered {
/// Register a new [`Rollback`] for explicit ordering.
fn push(&mut self, rollback: Rollback) -> &mut Self {
self.sorted.push(rollback);
self.order.insert(rollback, self.sorted.len() - 1);
self.order.insert(rollback, self.sorted.len() as u64 - 1);

self
}
Expand All @@ -75,7 +75,7 @@ impl RollbackOrdered {
}

/// Returns a unique and order stable index for the provided [`Rollback`].
pub fn order(&self, rollback: Rollback) -> usize {
pub fn order(&self, rollback: Rollback) -> u64 {
self.order
.get(&rollback)
.copied()
Expand Down
4 changes: 2 additions & 2 deletions src/snapshot/entity_checksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ impl EntityChecksumPlugin {
let mut hasher = checksum_hasher();

// The quantity of active rollback entities must be synced.
active_entities.iter().len().hash(&mut hasher);
(active_entities.iter().len() as u64).hash(&mut hasher);

// The quantity of total spawned rollback entities must be synced.
rollback_ordered.len().hash(&mut hasher);
(rollback_ordered.len() as u64).hash(&mut hasher);

let result = ChecksumPart(hasher.finish() as u128);

Expand Down

0 comments on commit 75295f8

Please sign in to comment.