Struct ggrs::SyncTestSession

source ·
pub struct SyncTestSession<T>
where T: Config,
{ /* private fields */ }
Expand description

During a SyncTestSession, GGRS will simulate a rollback every frame and resimulate the last n states, where n is the given check distance. The resimulated checksums will be compared with the original checksums and report if there was a mismatch.

Implementations§

source§

impl<T: Config> SyncTestSession<T>

source

pub fn add_local_input( &mut self, player_handle: PlayerHandle, input: T::Input ) -> Result<(), GgrsError>

Registers local input for a player for the current frame. This should be successfully called for every local player before calling advance_frame(). If this is called multiple times for the same player before advancing the frame, older given inputs will be overwritten. In a sync test, all players are considered to be local, so you need to add input for all of them.

§Errors
  • Returns InvalidRequest when the given handle is not valid (i.e. not between 0 and num_players).
source

pub fn advance_frame(&mut self) -> Result<Vec<GgrsRequest<T>>, GgrsError>

In a sync test, this will advance the state by a single frame and afterwards rollback check_distance amount of frames, resimulate and compare checksums with the original states. Returns an order-sensitive Vec<GgrsRequest>. You should fulfill all requests in the exact order they are provided. Failure to do so will cause panics later.

§Errors
source

pub fn num_players(&self) -> usize

Returns the number of players this session was constructed with.

source

pub fn max_prediction(&self) -> usize

Returns the maximum prediction window of a session.

source

pub fn check_distance(&self) -> usize

Returns the check distance set on creation, i.e. the length of the simulated rollbacks

Auto Trait Implementations§

§

impl<T> Freeze for SyncTestSession<T>

§

impl<T> !RefUnwindSafe for SyncTestSession<T>

§

impl<T> Send for SyncTestSession<T>
where <T as Config>::Input: Send, <T as Config>::State: Send,

§

impl<T> Sync for SyncTestSession<T>
where <T as Config>::Input: Sync, <T as Config>::State: Send,

§

impl<T> Unpin for SyncTestSession<T>
where <T as Config>::Input: Unpin,

§

impl<T> !UnwindSafe for SyncTestSession<T>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V