Struct ggrs::SyncTestSession [−][src]
pub struct SyncTestSession { /* fields omitted */ }
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. If you provide checksums
in your save_game_state()
function, the SyncTestSession
will compare the resimulated checksums with the original checksums and report if there was a mismatch.
Implementations
pub fn add_player(
&mut self,
player_type: PlayerType,
player_handle: PlayerHandle
) -> Result<(), GGRSError>
pub fn add_player(
&mut self,
player_type: PlayerType,
player_handle: PlayerHandle
) -> Result<(), GGRSError>
Must be called for each player in the session (e.g. in a 3 player session, must be called 3 times).
Errors
Will return InvalidHandle
when the provided player handle is too big for the number of players.
Will return InvalidRequest
if a player with that handle has been added before.
Will return InvalidRequest
for any player type other than Local
. SyncTestSession
does not support remote players.
After you are done defining and adding all players, you should start the session. In a sync test, starting the session saves the initial game state and sets running to true.
Errors
Return a InvalidRequestError
, if the session is already running.
pub fn advance_frame(
&mut self,
player_handle: PlayerHandle,
input: &[u8]
) -> Result<Vec<GGRSRequest>, GGRSError>
pub fn advance_frame(
&mut self,
player_handle: PlayerHandle,
input: &[u8]
) -> Result<Vec<GGRSRequest>, 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
- Returns
InvalidHandle
if the provided player handle is higher than the number of players. - Returns
MismatchedChecksumError
if checksums don’t match after resimulation. - Returns
NotSynchronized
if the session has not been started yet.
pub fn set_frame_delay(
&mut self,
frame_delay: u32,
player_handle: PlayerHandle
) -> Result<(), GGRSError>
pub fn set_frame_delay(
&mut self,
frame_delay: u32,
player_handle: PlayerHandle
) -> Result<(), GGRSError>
Change the amount of frames GGRS will delay the inputs for a player.
Errors
Returns InvalidHandle
if the provided player handle is higher than the number of players.
Returns InvalidRequest
if the provided player handle refers to a remote player.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for SyncTestSession
impl Send for SyncTestSession
impl Sync for SyncTestSession
impl Unpin for SyncTestSession
impl !UnwindSafe for SyncTestSession