• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

 How to send large amounts of data over network at start of connection?

A

Arthrax

Guest
I'm developing a multiplayer game in which the map changes frequently during the course of the match.

To be more specific, I have a ds_list server-side that contains all the values of map objects that need to be destroyed.

Everything so far is working, as the objects can be transferred to other connected clients easily. However I have yet to find a way to be able to load the initial conditions of the map (aka the server side ds_list) when a client connects.

I tried sending it through a single buffer but the amount of data is simply too large for it, and causes a memory dump when the list of objects gets a certain size.

I know it has something to do involving a loading bar / sequence or sending the data in bursts, the functions ds_list_read(); and ds_list_write(); and potentially using .ini files, but I'm not sure how to go about doing this and I would love to learn.

And by the way, the list can end up being a LOT of objects so I'd need to be able to scale for potentially vast quantities of data. I don't mind if the client upon joining has to wait for it to load.

Any help is appreciated, and if you need me to be more specific I can.
 

Yal

šŸ§ *penguin noises*
GMC Elder
"sending lots of data" sounds like a bad idea in the first place, generally netcode is all about minimizing the amount of data you need to send (because it's slow and unreliable). I'd recommend having the lists of objects be local to every client (e.g. all maps always are the same and are known to the game), and only letting people join at the start of a match.

Other approaches worth considering:
  • If more than half of objects are destroyed, send a "only these objects are left" message that contains the objects that AREN'T destroyed; anything not in this list is not created.
  • Have objects respawn once you're reaching the critical number of objects, so that only X objects can be broken at once. (Respawn the oldest object from the list first, then remove it from the list)
  • Send bursts of objects based on the distance to where the new client would spawn, so that objects close to them get the correct status but anything further away will load in over time.
  • If there's no major gameplay effects if an object that's actually broken shows up as existing for a player (e.g. they're just cool effects), don't worry too much about ensuring correctness.
 
A

Arthrax

Guest
All set, it actually was much easier than I initially thought.

I just set a state client side to "Loading" which activates upon joining the lobby. When the player joins, the server will create a ds_queue that is essentially a copy of the ds_list that the server has of the destroyed instances. The server will then send 10 values of the instances every frame, making sure that the client has recieved the data (meaning the next frame is not called unless the client gives a message that the data has been recieved) until there is no more values left in the ds_queue, in which case it will send a message that the transfer of map data is over, and the client-side will end the loading state.

Additionally this is unnoticeable by all users and loading happens extremely quickly even with this large amount of data.
 
Top