Skip to content

Commit

Permalink
fix(GameplayManager): Add FrameBias
Browse files Browse the repository at this point in the history
  • Loading branch information
Sup3rFire committed Sep 13, 2021
1 parent a6df486 commit 41ca6f0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/gameplay/GameplayManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default class GameplayManager extends EventEmitter {
// Variables

private options;
private previousFramesSent?: number;

/**
* The Client Class
Expand Down Expand Up @@ -251,23 +252,29 @@ export default class GameplayManager extends EventEmitter {

const sendFrames: GameplayEvents = [];

let frameBias = 0;

this.nextFrames = this.nextFrames.reduce<GameplayEvents>((acc, current) => {
if (current.frame < currentFrame) {
if (current.frame <= (this.previousFramesSent || 0))
frameBias = (this.previousFramesSent || 0) - current.frame + 1;
current.frame = current.frame + frameBias;
sendFrames.push(current);
} else {
acc.push(current);
}
return acc;
}, []);

this.previousFramesSent = currentFrame;
// console.log(sendFrames);
this.client.ws?.send_packet({
id: this.client.ws.clientId,
command: "replay",
data: {
listenID: this.id,
frames: sendFrames,
provisioned: currentFrame,
provisioned: currentFrame + frameBias,
},
});
}
Expand Down

0 comments on commit 41ca6f0

Please sign in to comment.