How To Sync 2d Platformer Level Data?

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

TheSilverMonkey
Posts: 7
Joined: 19 Apr 2021, 15:30

How To Sync 2d Platformer Level Data?

Postby TheSilverMonkey » 19 Apr 2021, 15:40

I'm working on a 2d platformer where players can edit the game live with other players. Currently when a player updates the level I serialize what the changes were, update a room variable with that changeset, and then receive that on other players games. This mostly works, except when multiple updates are made quickly in succession. I've noticed a few of the changesets will be missing.

Is there a better way to handle this? It seems like room variable isn't built for this kind of functionality. I need something that can sequentially send and receive all items given to it.
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How To Sync 2d Platformer Level Data?

Postby Lapo » 20 Apr 2021, 08:07

Hi,
Room Variables should work just fine. If the change-set is a lot of data you may want to switch to Extensions (server side custom code) but essentially you're always sending data to and from the server.

What is not very clear is why you're getting those inconsistencies when there are multiple changes in quick succession. It sounds like a bug in the implementation, but I'd need to understand more about how your game works.

If multiple users submit changes almost at the same time the other players will receive those updates in quick succession but the data is transported via TCP so if you get the packet it will be 100% complete. There can't be missing data, because TCP guarantees the delivery.

I would recommend to check the content of these updates by dumping to the console the raw content of these Room Variable updates. Also you can view such content by activating the DEBUG mode of the API. (See the ConfigData object)
This will output the content of every packet received.

Unless something very odd is going on in your network you should find all of your updates perfectly intact. If that's the case I'd investigate more the rest of the update code. Maybe you've a bug in the logic that handles these updates.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
TheSilverMonkey
Posts: 7
Joined: 19 Apr 2021, 15:30

Re: How To Sync 2d Platformer Level Data?

Postby TheSilverMonkey » 21 Apr 2021, 03:57

Ok, good to know that with room variables it would receive all updates.

It must have been in my implementation, I ended up changing the level editor slightly and the issue was resolved.

Thanks for the reply!

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Google [Bot] and 42 guests