broadcasting player's position through the network question

Developer discussion of experimental fixes, changes, and improvements.

Moderators: Nexuiz Moderators, Moderators

broadcasting player's position through the network question

Postby mickey » Thu Feb 26, 2009 4:25 pm

Hi

From the back of my head on what I understood how this is done on most FPS game is each client broadcast their positions to the server every 30 - 50 ms and the server sends those new positions to all the clients. Clients then interpolate the new position from the old position.

So I was looking at the source code finding out how it was done on Nexius and if it was the same as what I understood, if someone could tell me which file / function I can find those that would be great.

Thanks!
David Ang
mickey
Newbie
 
Posts: 5
Joined: Thu Feb 26, 2009 4:20 pm

Postby esteel » Thu Feb 26, 2009 5:02 pm

Actually its the other way round.. the server knows the exact position of the players and transmit it to the clients.. the clients in turn only send the direction and speed they want to go to the server. Other wise one could hack a client to teleport around..
The engine itself has no idea about players.. just entities with certain properites like a position, a model and animation state, a direction, speed and such (health armor, weapon count..).. Those entities are filtered or 'culled' and only the remaining ones (which can possible be seen by a given client) are transmitted to that client.
So much for the theory.. i'm not sure about the source files though :)
esteel
Site admin and forum addon
 
Posts: 3924
Joined: Wed Mar 01, 2006 8:27 am

Postby mickey » Thu Feb 26, 2009 6:58 pm

Hi esteel

thanks for your reply. You said, the direction and speed is transmitted? I assume this is transmitted every 30 - 50 ms only if the player is holding down the "W" or forward key?

So while the player is holding down the forward key, it actually does not move the player but waits for the authorization from the server that the client can actually move forward?

I'm actually confuse. So lets my character is running at 30 units per frame - so lets say my forward key is hold down. The next 30 ms i told the server im moving N at 30 units. Server said OK and returns my next movement coordinate? And then I'll call on PlayerCharacter::setNewPosition(...) that I got from the server?

Or should I interpolate from my current position to the next position that was reported from the server?
David Ang
mickey
Newbie
 
Posts: 5
Joined: Thu Feb 26, 2009 4:20 pm

Postby esteel » Thu Feb 26, 2009 7:50 pm

Well first a little warning, i'm not too familiar with the code so i hope everything i tell is correct.. I hope some of those that have a real clue about the code will jump in when i'm wrong.

Clients usually send info to the server when they change something.. buttons pressed and such. There are settings for the available network so they do not try to send too much info that might saturate the line.

From what i understand the client tries to predict were it will end up from the last known position and its desired speed/direction. Thats the cl_movement stuff in this case. For this the client gets several info from the server via 'stats' including the floor and air friction. However the client can not predict everything.. like enemy fire or an other player colliding. In this case the client just sets the new position and tries the interpolate the movement between the two positions. For other players it also does such a interpolation.
esteel
Site admin and forum addon
 
Posts: 3924
Joined: Wed Mar 01, 2006 8:27 am

Postby mickey » Thu Feb 26, 2009 8:29 pm

Okay so client sends button press "forward" to the server and the server authorizes the client and client now interpolates from its last position to the "target position" sent by the server ?

But seems strange players usually hold down the forward button does that means every frame it sends or i assume each client only sends their data every xx ms?

Also, is everything package when a client sends their data? Or movement data is in another packet, weapon fire data is in another packet and so on?
David Ang
mickey
Newbie
 
Posts: 5
Joined: Thu Feb 26, 2009 4:20 pm

Postby esteel » Thu Feb 26, 2009 8:49 pm

No, i think the client extrapolates its OWN position from the last known pos received from the server and were 'you ' want to go. All the other client positions are interpolated from the last to the new received position.

There is a setting cl_netfps (iirc) thats how often data is send from the client to the server. All that info is collected within 'one tic' for cl_netfps and then send to the server.
esteel
Site admin and forum addon
 
Posts: 3924
Joined: Wed Mar 01, 2006 8:27 am


Return to Nexuiz - Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron