-
-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Remove requirement of Hashing from GameState #17
Comments
(Copying this from a discord conversation) FYI, as a temporary workaround, I'm manually serializing vec2s into Is the backroll-rs/backroll/src/command.rs Lines 65 to 69 in 3c6bdc0
But there's already the ability to save the state without a hash and with an explicit hash: backroll-rs/backroll/src/command.rs Lines 71 to 85 in 3c6bdc0
To remove the For example, something like this seems to compile. struct A<T>(std::marker::PhantomData<T>);
impl<T> A<T> {
pub fn save(state: T) where T: std::hash::Hash {
let mut hasher = std::collections::hash_map::DefaultHasher::new();
state.hash(&mut hasher);
todo!();
}
pub fn save_without_hash(_state: T) {
todo!();
}
pub fn save_with_hash(_state: T) {
todo!();
}
} |
Thought this would be harder given that Rust does not allow constraining on associated types, but turns out we just needed to restructure the generic type parameters a bit, and it does indeed work. This should be fixed as of 014fd15; however, this has led to a silent failure case show in #20. This should be fixed in some user visible way before releasing the next public version of backroll and the bevy plugin. |
Currently in Backroll, gamestates that get saved and loaded HAVE to be able to be hashed. This leads to a lot of issues, since important gamestate stuff like floats and vectors aren't able to be hashed. This should be replaced with something more universal.
Note: as far as I know I think this issue is with bevy_backroll but it could extend to the original backroll library as well
The text was updated successfully, but these errors were encountered: