Skip to content

Commit

Permalink
Update to new bounds on ggrs input types
Browse files Browse the repository at this point in the history
Default, Serialize and Deserialize instead of bytemuck traits.
  • Loading branch information
johanhelsing committed Dec 15, 2024
1 parent f70a56d commit b36149b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ log = "0.4"
ggrs = { git = "https://github.com/gschup/ggrs", features = ["sync-send"] }
seahash = "4.1"
disqualified = "1.0.0"
serde = { version = "1", default-features = false }

[dev-dependencies]
bevy = { version = "0.15", default-features = true }
Expand Down
4 changes: 2 additions & 2 deletions examples/box_game/box_game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use bevy_ggrs::{
AddRollbackCommandExtension, GgrsConfig, LocalInputs, LocalPlayers, PlayerInputs, Rollback,
Session,
};
use bytemuck::{Pod, Zeroable};
use serde::{Deserialize, Serialize};
use std::hash::Hash;

const BLUE: Color = Color::srgb(0.8, 0.6, 0.2);
Expand All @@ -28,7 +28,7 @@ const CUBE_SIZE: f32 = 0.2;
pub type BoxConfig = GgrsConfig<BoxInput>;

#[repr(C)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Pod, Zeroable)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct BoxInput(u8);

#[derive(Default, Component)]
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use bevy::{
utils::{Duration, HashMap},
};
use ggrs::{Config, InputStatus, P2PSession, PlayerHandle, SpectatorSession, SyncTestSession};
use serde::{Deserialize, Serialize};
use std::{fmt::Debug, hash::Hash, marker::PhantomData, net::SocketAddr};

pub use ggrs;
Expand Down Expand Up @@ -47,7 +48,7 @@ pub struct GgrsConfig<Input, Address = SocketAddr, State = u8> {
impl<Input, Address, State> Config for GgrsConfig<Input, Address, State>
where
Self: 'static,
Input: Send + Sync + PartialEq + bytemuck::Pod,
Input: Send + Sync + PartialEq + Serialize + for<'a> Deserialize<'a> + Default + Copy,
Address: Send + Sync + Debug + Hash + Eq + Clone,
State: Send + Sync + Clone,
{
Expand Down
4 changes: 2 additions & 2 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use bevy_ggrs::{
AddRollbackCommandExtension, GgrsConfig, GgrsPlugin, GgrsSchedule, LocalInputs, LocalPlayers,
PlayerInputs, ReadInputs, Rollback, Session,
};
use bytemuck::{Pod, Zeroable};
use ggrs::{Config, P2PSession, PlayerHandle, PlayerType, SessionBuilder, UdpNonBlockingSocket};
use serde::{Deserialize, Serialize};
use serial_test::serial;
use std::net::{IpAddr, Ipv4Addr, SocketAddr};

Expand Down Expand Up @@ -91,7 +91,7 @@ fn create_app<T: Config>(session: P2PSession<T>) -> App {
type TestConfig = GgrsConfig<BoxInput>;

#[repr(C)]
#[derive(Copy, Clone, PartialEq, Eq, Pod, Zeroable)]
#[derive(Copy, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct BoxInput {
pub inp: u8,
}
Expand Down

0 comments on commit b36149b

Please sign in to comment.