Sign in to follow this  
xsirxx

Theory, What should the server send back? (client-server)

Recommended Posts

Ok so say in a FPS client-server game, your clients send key strokes by bit flipping to the server. The server translates and calculates all the physics that act upon the object and changes the PlayerInfo. Now how should the other clients know? 1st: Should the server just tell the other clients that the person has hit this key? Thus just forwarding the information of small bits, and then gamestate updating every 1/10th of a second? 2nd: After server has recieve the keystrokes, calculate all info of the Player and query a SendAttitude of the player including position and new rotations and velocity? Then send out query to all clients? And still update gamestate? or drop gamestate updates? 3rd: Other ideas? --Brad

Share this post


Link to post
Share on other sites
Yea essentially thats right. They both do the work load of physics but the server is always right when updating info. This is what I have implemented right now, but I didnt not test the other way...

Is this generally what people use when doing a fps, flight sim, action game?
-------Typo


--Brad

Share this post


Link to post
Share on other sites
thats basicaly how the HL engine does it, and others follow the same pattern.
Basicaly the client is given enuff infomation that it can work out a few frames if data gets lost on route, so you dont get laggyness of other players, however the server is always right and the clients arent trusted, so server does all hit scanning, performs its own physics based on input etc and the client just runs its own sim when needed.

Things like reload, weapon changes and firing animations ARE done on the client, again to reduce apprent lag (earlier CS netcode used to send the fire confirmation to the server and not play animations etc until it got a message back) but ofcourse the server has to be told of these.

So, basicaly from the server pov its

- read all game data from clients
- update game states
- send new data back to clients

From a clients pov its

- send data to server
- if we have new data then update game state to sync with server
- else carry on sim based on last known infomation

Ofcourse, the sim will drift out if lots of packet loss accure, but thats unavoidable.

Share this post


Link to post
Share on other sites
You could send enough data per n/seconds so that the client will be able to predict the actions until the next update.

If its 30/sec, and the server receieves input that a client just changed direction, is that client going to move so far it'll be noticable when the server updates everyone else 1/30th of a second later?

Share this post


Link to post
Share on other sites
This all is very good, but when the server sends back the information what happens? Say for instane it is a time based game, should the server send time stamped information? Then subtract the time from the physics routines?
(I have it so I update the angle, velocity, and pos so it is never that far off when I run my physics.)

Also, there is talk about interpolation? and cubic splines... Are these things to consider on a FPS? How much will they effect the game?

--Brad

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this