Skip to content

Commit

Permalink
make size of inputs sent configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
Giesch committed Nov 11, 2024
1 parent 616a98d commit 8c8c295
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions examples/rollback/Config.roc
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ rollback = {
millisPerTick: 1000 // 120,
maxRollbackTicks: 16,
tickAdvantageLimit: 10,
sendMostRecent: 20,
}
8 changes: 5 additions & 3 deletions examples/rollback/Rollback.roc
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ currentState : Recording -> World
currentState = \@Recording recording ->
recording.state

recentMessages : Recording, U64 -> List FrameMessage
recentMessages = \@Recording recording, n ->
recentMessages : Recording -> List FrameMessage
recentMessages = \@Recording recording ->
recording.outgoingMessages
|> List.keepOks \res -> res
|> List.takeLast n
|> List.takeLast recording.config.sendMostRecent

desyncStatus : Recording -> [Synced, Desynced DesyncBugReport]
desyncStatus = \@Recording recording ->
Expand All @@ -49,6 +49,8 @@ Config : {
## the configured frame advantage limit;
## a client further ahead of their opponent than this will block
tickAdvantageLimit : I64,
## how many recent frames of inputs to send each frame
sendMostRecent : U64,
}

## a World with rollback and fixed timestep related bookkeeping
Expand Down
2 changes: 1 addition & 1 deletion examples/rollback/main.roc
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ renderConnected! = \oldModel, state ->
model = { oldModel & world, timestampMillis }
messages = Rollback.recentMessages world 10
messages = Rollback.recentMessages world
sendFrameMessages! messages network
drawConnected! model state
Expand Down

0 comments on commit 8c8c295

Please sign in to comment.