Game synchronization ...

Everything related to the code /
Tout ce qui touche au code
Post Reply
User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Game synchronization ...

Post by zuzuf » Mon Apr 28, 2008 11:16 pm

I ran a few tests for UDP sync packets. For now they are very simple, but it works :) . Those packets use UDP, so we shouldn't rely on them. For now there is no packet to synchronize events such as unit creation/destruction or weapon data.

Currently there is no full game synchronization but I am glad to see two human controlled commanders from 2 different player walking in the same game :D . Movements aren't synchronized so it's a bit ugly ... even if it starts the walking animation (but I don't know why ...)
=>;-D Penguin Powered

User avatar
Balthazar
Moderator
Posts: 2055
Joined: Wed Nov 01, 2006 4:31 pm
Location: Russian Federation
Contact:

Post by Balthazar » Tue Apr 29, 2008 5:49 am

Well, there are always many "features" in every field of coding. Multyplayer part have it`s on "secrets", so there are still much to learn and test :)

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Post by zuzuf » Tue Apr 29, 2008 10:19 am

yes, and networking is hard to debug/test. Yesterday I found a bug which is only visible if there are at least 3 computers (1 server and 2 clients) ...
=>;-D Penguin Powered

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Post by zuzuf » Wed Apr 30, 2008 6:27 pm

Here is what is currently synchronized:
  • * unit creation & death
    * unit scripts calls (so unit animation is synchronized :) )
    * unit position, speed, health, build_percent_left, and angle_y (other angles should be computed by the engine)
at that point, if you destroy a unit that belongs to a remote player game will be out of sync because unit synchronization works only if a player is the only one that can make changes to his units. It'll require to add some damage events ...

Orders aren't synchronized at all !!! which means all remote units have a very basic mission : wait and do nothing !! It prevents the engine from doing useless calculation.

Also speed can be set very easily since the game will run at the speed of the slowest client ... so if server sets speed to 3x and client to 2x it'll run at 2x but if server sets speed to 1x it'll run at 1x. And if someone set pause ... it pauses for everyone :)

I have run no test about required bandwidth, but it may be high (might be difficult using a DSL connection) because nothing is compressed or optimized ... for example unit types are identified using their names, not their ID since their ID can change on a client which loaded some extra units ... And packet sizes are fixed ... so sometimes it sends useless data. It uses UDP to sync positon, speed, angles, HP, ... and TCP to send events (unit creation, death, ...)[/list]
=>;-D Penguin Powered

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Post by zuzuf » Wed Apr 30, 2008 8:51 pm

weapons are synchronized ... :)

I experimented some lag, so things will need some speed/size optimization
=>;-D Penguin Powered

User avatar
Balthazar
Moderator
Posts: 2055
Joined: Wed Nov 01, 2006 4:31 pm
Location: Russian Federation
Contact:

Post by Balthazar » Thu May 01, 2008 6:40 am

Well, how much bandwidth is it using now?

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Post by zuzuf » Thu May 01, 2008 12:31 pm

I don't know exactly, I have to debug statistics first :cry:

Currently all units are synced even if it"s not needed, so I'll implement 2 lacking mechanisms:
_only send sync events when required (dirty flag)
_a critical sync system that is used when UDP packets loss is too high and some unit needs to be synced

Also packets need to be endianness independent and we can only send what is really required. Then we'll talk about compression :D

But first let's sync map features, for now you end with the same game on several computers but not with the same wreckages :?
=>;-D Penguin Powered

Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests