mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-28 23:57:28 +01:00
multiplayer stage 8: state correction and surviving a dropped connection
Two things were still missing once a session ran for a while: a peer that had drifted apart from the authority had no way back short of restarting, and a connection that blinked cost the player their seat and handed their vehicle to the AI while the other driver was still sitting in it. - a client that disagrees with the authoritative digest for 120 steps in a row asks to be put back in line, and the server answers with a fresh snapshot. There is a cooldown between requests, so a correction that needs a moment to take hold does not turn into a stream of them - the server hands out a session token with its hello and remembers it. Present it again on the next connection and you come back as the same peer, with the same id - a lost connection no longer removes the peer from its crews: the seat is held for a minute. Come back in time and nothing changed; stay away and the seat is given up properly, handing the vehicle back to the AI only when that leaves the crew empty and the AI was driving it in the first place - after applying a snapshot a peer that finds itself on a crew walks into that cab, which is what makes a reconnect land the player back where they were - the vehicle roster is sent to a joining peer right before its snapshot, so the crew section resolves to names instead of waiting for the next broadcast
This commit is contained in:
@@ -124,6 +124,8 @@ namespace network
|
||||
void send_commands(command_queue::commands_map commands);
|
||||
// tells the server the scenario is loaded and a snapshot can be applied
|
||||
void send_ready();
|
||||
// our world has drifted too far to carry on; ask to be put back in line
|
||||
void send_resync_request(uint64_t tick, uint64_t state_hash);
|
||||
// lobby requests; the server is the one that decides
|
||||
void send_claim(NetworkEntityId entity_id);
|
||||
void send_leave(NetworkEntityId entity_id);
|
||||
|
||||
Reference in New Issue
Block a user