• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Buffer naming conventions and organization

Xer0botXer0

Senpai
good day,

I feel like I'm getting confused with the buffer_ids which get sent back and forth from client to server.

The client can send and receive, the server can send and receive.
They both have a send buffer and a receive buffer.

The issue is the first value sent is the ID for the packet and the data that follows.
Sometimes there are extra IDs, nested IDs.

What's a good way to name these and to organize them ?


I'm thinking of making a list of the IDs and what they represent, but perhaps there's more to it, like an article or so on the matter ?
 

GMWolf

aka fel666
By ID, do you mean a number that tells it what the data holds? Like packet_player_pos, packet_player_die, packet_enemy_spawn etc?
In that case I would use an enum.
Code:
enum packetID {
playerPos,
playerDie,
...
}
For nested Id, do you mean sub types?
Again, enums. Then you can say, if it was packet_update, read the next byte. If that was update_payer, do a thing, if that was update_enemy, do another thing.
 
Top