Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Multiplayer via network - "Master server"?  (Read 2170 times)

0 Members and 2 Guests are viewing this topic.

P@u1

  • Jr. Member
  • **
  • Posts: 83
    • View Profile
Multiplayer via network - "Master server"?
« on: April 22, 2011, 08:27:53 pm »
Hi everyone,

I was thinking about how to implement a multiplayer mode via network.
Unfortunately I almost know anything about network.
If any1 knows where to find a tutorial about creating a multiplayer mode via network, please let me know.

So I had the following idea:
All logic is calculated at some "master server". Between each (logic?) frame all clients send to him information about which keys are pressed, the master server (can be a client too) then evaluates the inputs and calculates the next frame and sends the positions of each visible object to the clients which then can render the scene using this information.
Is this approach suitable? (For example I don't know, if the network connection is so fast and responsive that beween each frame data can be exchanged...)
Or are there better approaches?
The reason I thought about this approach is that if we do the logics at the clients and not centralized, it could easily happen that things run out of sync.
For example if some random values are used for the logic, then it must be ensured that for all clients the same random value is used.
If there is only a slight non-deterministic behaviour then synchronisation is needed, so I got the idea described above.

Please comment on my thoughts.
Thank you in advance!

s3rius

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Multiplayer via network - "Master server"?
« Reply #1 on: April 23, 2011, 01:34:48 am »
Quote from: "P@u1"

The reason I thought about this approach is that if we do the logics at the clients and not centralized, it could easily happen that things run out of sync.
For example if some random values are used for the logic, then it must be ensured that for all clients the same random value is used.
If there is only a slight non-deterministic behaviour then synchronisation is needed, so I got the idea described above.


Luckily pseudo random number generators are deterministic! :P

Generally it is indeed done like this. The logic is run seperately by every client.
Each client sents the user input (or the resulting changes) to the server, which tells every other client about it.

Often times the server also corrects certain values if they're wrong.
E.g. in an ego shooter a lagging player might not be able to transmit his movement constantly. Thus he becomes out of synch with the other players.
He transmits his information to the server, the server notices the difference between where he thinks the player should be and the data he just got.
So the server tells the player to correct his position accordingly (the server is generally authoritative, so his data is regarded as the real data).