Closed LocalInsomniac closed 1 month ago
Create a tick queueing system. Clients will be using this to tick the game with input relays from the host. Currently, only the host should be able to control their character. Client input will be handled later.
TICK
packet containing the input data of every player in the game.Allow each client to send input data to the host. The host should then queue those inputs in the Networking Async Event and apply it to the next tick.
Some other ideas to consider:
Implement game stalling by checking if any client hasn't ACKed tick packets for more than a certain amount of ticks (should be around half of TICKRATE
). This should help laggy clients catch up with other players, otherwise they would be stuck on a frozen game that occasionally skips forward.
A naive implementation would be as follows:
Netgame
gets two new variables: ack_count
for tracking how many clients have ACKed any tick packet, and stall_time
for increasing the timer before stalling the game.
NetPlayer
) also gets a boolean variable named tick_acked
in order to increment the counter properly.At the start of the host's tick loop, check if ack_count >= player_count
.
ack_count
and stall_time
and set every client's tick_acked
to false
.stall_time
. If stall_time
reaches the limit, the game is paused until all clients have ACKed.If a client has ACKed a tick packet during a Network Async Event while their tick_acked
is false, it is set to true
and ack_count
is incremented.
Reimplement netgames using lockstep which is more suitable towards PNEngine's structure.
Reference
Desyncs could be detected by comparing game/level information periodically, for example.