This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use ggrs::{Config, GGRSError, P2PSession, PlayerType, SessionBuilder, UdpNonBlockingSocket, GameStateCell}; | |
use godot::prelude::*; | |
use std::{ | |
collections::{HashMap, VecDeque}, | |
net::SocketAddr, | |
}; | |
pub struct GGRSConfig; | |
impl Config for GGRSConfig { | |
type Input = i32; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static List<byte> RLEEncode(List<byte> toEncode) | |
{ | |
var bytes = new List<byte>(); | |
byte count = 1; | |
byte current = toEncode[0]; | |
for (int i = 0; i < toEncode.Count; i++) | |
{ | |
if (current == toEncode[i] && count != byte.MaxValue) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Text; | |
public class FletcherChecksum | |
{ | |
/// <summary> | |
/// Transforms byte array into an enumeration of blocks of 'blockSize' bytes | |
/// </summary> | |
/// <param name="inputAsBytes"></param> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Readme: In the following pseudo code, [] indicates a subroutine. | |
Sometimes I choose to write the subroutine inline under the [] in order to maintain context. | |
One important fact about the way rollbacks are handled here is that we are storing state for every frame. | |
In any real implementation you only need to store one game state at a time. Storing a game | |
state for every frame allows us to only rollback to the first frame where the predicted inputs don't match the true ones. | |
==Constants== | |
MAX_ROLLBACK_FRAMES := Any Positive Integer # Specifies the maximum number of frames that can be resimulated | |
FRAME_ADVANTAGE_LIMIT := Any Positive Integer # Specifies the number of frames the local client can progress ahead of the remote client before time synchronizing. |