Jump to content

Image of the Day

#animation 2/14

Sweet piggy, isn't it?

#gamedev #indiedev #indiegame #GamersUnite #screenshotsaturday #unity3d https://t.co/lscyvCxrPR
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net's newsletters to receive the latest updates and exclusive content.


Sign up now

data structure for client list

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
1 reply to this topic

#1 rogerdv   Members   

399
Like
0Likes
Like

Posted 27 February 2014 - 11:51 AM

I have started an educational project to learn about networking. I built a small server using enet that receives UDP packets and replies to clients, next step is to actually have multiple connected clients. I dont plan to create my own WoW killer mmorpg, but I would like to learn the right way to do things. I was plannnig to use an std::map to eep the list of clients indexed by their ip address, but then I thought that it wouldnt be optimal when the server needs to find client neighbors to propagate changes (I think that kdtrees are the right data structure to optimize that). Then I thought that I should have an  std::map indexed by IP and a kdtree with "visible" entities. And finally, I realized that using IPs mnaybe is not a wise way to index clients, because it would limit connections  to one per IP. What is the correct approach to this problem?

 



#2 hplus0603   Moderators   

10811
Like
3Likes
Like

Posted 27 February 2014 - 01:13 PM

Typically, you keep several data structures with "clients" or "client entities" in them.
You'll want a hash table (typically unordered_map, not regular map) from source IP:port to client.
You'll also want a spatial index, as you say a kd tree or perhaps easier a loose quadtree.
You may also want various queues for notifications, periodic tasks, database checkpoints, etc.
enum Bool { True, False, FileNotFound };




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.