Jump to content

net code sugestions


Guest uvinrg

Recommended Posts

I have some sugestions to improve the net code. First, the net code being sent by a player could be a simple struct like this:

struct sentnetcode

{

byte movetype; // 0=standing still 1=normal run 2=sprint 3=in car

unsigned short int dirx,diry,dirz; //the direction vector on wich you're goin'

byte health; //health level

byte armor; //armor level

byte weapon; //weapon in hand

bool shooting; // false=not shooting true=shooting

byte car; //if (movetype==3) car=the car you are in

}

Now this is roughly 12 bytes! And it has all you need to send. Each user sends this code updated with what his doing at the moment of sending for 24 times/second to the server. He receives from the server a struct like this for each player( ex: 4 players, 4 structs per package (48 bytes received and 12 sent)*24=1152 Bps received and 288 Bps sent). Until he receives the next struct the game assumes the other players continue moving in that direction and doing the same stuff and updates their position each frame acordingly to the player.

I think it isn't hard to implement and it will spare a LOT of bandwidth this way and the multi player experience will aproach the single player one more in respect to realism and actual players moving(not just teleporting from place to place like you do it now)...

Hope you take it into consideration. Tell me what you guys think!

Link to comment

We do only send what has changed, and to fully understand the size of the packets you need to see what data we are also dealing with on our end, which is not something I can show.

There is a lot more data that needs to be synced then just what you have pasted here. If it were only that easy, then we would be set for life :)

Link to comment
  • 2 weeks later...

i got a question about this netcode.

does 24 packets a second mean, 24 frames per second allowable? what happens between one packet and the next that makes the game go dead; like the cars stopping and stuff. can you guys make some sort of thing inbetwen to let everything in the game still keep going? like pedestrian like, when they haul out of a car, it keeps giong in the ocean like when u shoot them.

Link to comment

no, the ammount of packets sent per second just "defines" how "smooth" the motion looks depending on how the server works (sending only to signal change, sending to update status ect)

Link to comment
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...