From cfc1541be9e92f1f59b21f4a81f96fc88f4d9f7e Mon Sep 17 00:00:00 2001 From: NewSoupVi <57900059+NewSoupVi@users.noreply.github.com> Date: Thu, 28 Mar 2024 15:19:32 +0100 Subject: [PATCH] Docs: Mention the "last received item index" paradigm in the network protocol docs (#2989) Co-authored-by: Exempt-Medic <60412657+Exempt-Medic@users.noreply.github.com> --- docs/network protocol.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/network protocol.md b/docs/network protocol.md index 9f2c07883b9d..604ff6708fca 100644 --- a/docs/network protocol.md +++ b/docs/network protocol.md @@ -31,6 +31,9 @@ There are also a number of community-supported libraries available that implemen | GameMaker: Studio 2.x+ | [see Discord](https://discord.com/channels/731205301247803413/1166418532519653396) | | ## Synchronizing Items +After a client connects, it will receive all previously collected items for its associated slot in a [ReceivedItems](#ReceivedItems) packet. This will include items the client may have already processed in a previous play session. +To ensure the client is able to reject those items if it needs to, each item in the packet has an associated `index` argument. You will need to find a way to save the "last processed item index" to the player's local savegame, a local file, or something to that effect. Before connecting, you should load that "last processed item index" value and compare against it in your received items handling. + When the client receives a [ReceivedItems](#ReceivedItems) packet, if the `index` argument does not match the next index that the client expects then it is expected that the client will re-sync items with the server. This can be accomplished by sending the server a [Sync](#Sync) packet and then a [LocationChecks](#LocationChecks) packet. Even if the client detects a desync, it can still accept the items provided in this packet to prevent gameplay interruption.