Player data synchronisation

Hi guys.

I’ve got an algorithm problem (means no code, just ideas and methodology)

In my game, players are able to create their ships from scratch using a minecraftlike method (placing blocks in a chunk) offline.
When playing online, player must sync their ship data (sending block array) to other players to be sure his ship will be displayed correctly on all machines.

I’m using lidgren, and a custom library to move standard server code into a separate dll (and enable me to build a dedicated server)

Actually, the netcode (in the dll) maintain a Dictionnary of playerData for each player sync across server and clients.
When a player select his ship, I transfert the chunk data by setting his player data, which get replicated on other clients (like an netview.RPC)
When a ShipChunk is spawned (like an unity Network.Instantiate call), the Start() method will request data from netcode by using his netview’s playerID, then create itself using the gathered data.

My main concern is about ChunkData size, which can be quite high and take time to transfert.
I would like to send the Instantiate call without waiting the ChunkData to sync (ie: using a different channel), enabling chunk to be spawned on all clients BEFORE his information was arrived (and then update it when it comes)
I can check if PlayerData was changed in Update(), and then recreate the chunk BUT I don’t want to allow a player to change his chunk information without suicide (ie: Destroying the chunk, then reInstantiating it)

The only way to do that is to wait ChunkData to sync BEFORE sending the Instantiate call, but it can introduce a large amounts of lags.

I’ve thought about sending an autoincrementing shipID along with the instantiate call and with the ship data, enabling chunk to wait for the given ID to arrive, and don’t respond to later ship changes (because the id will be different), but it seem a bit an headache for me.

Any thoughts on that will be greatly appreciated :wink:
I hope I make myself clear enough.
Thanks all!

Let me try that here :smile:
So, IIRC you want a local player to see the shipchunk(s) of connecting clients before the data is sent, right?
If a chunk had any form of system, a predictable structure then that might be possible to let a local player guess the chunk data before it actually arrives.
I would think there is no such thing as, if you said, people can build their own ships and you will never know how those things look like.

I suggest that you try to send the chunk data separately via X amount of RPC calls.
This way ships would (probably) show up on the other clients bit by bit. It would (probably) reduce the lag greatly.

Another note, when a new player connects, it should not send the ship data to the clients itself.
I would say if the server knew about the data first, it can dispatch it to other clients more effectively.

The problem isn’t about displaying the chunk before data arrives, but more about updating chunk.

In game, the player can change his chunk data during warmup, and can’t re-change it when spawned and still alive.
The problem comes that chunk data can arrive after or before the chunk create event.
So I accept the modification only if the change chunk event has been sended before the instantiate chunk.

The problem is that I can’t check that server side because it’s a non authoritative game.

So in my actual solution, I’m using the same channel for chunkdata and chunk instantiate messages, so they arrive in the same order as they where sent (but it can implies a huge lag as the instantiating of all objects are delayed)

I am thinking about implementing that by using a Timestamp in both of these data messages, then when changing chunk data I check this timestamp, and then set it as actual chunk data or as next chunk data (which will be used after respawn).

I’m still looking for a better solution through…