# Its been months, but I am back to my MMO!

This topic is 3164 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

##### Share on other sites
Also, mind you, as stated they are lists. So, if anyone else has a way to limit around the lists that would be great. What if I limit to 200 then alternate set 1, 2, 3, 4 each time so im only spending time updating 200 max each loop.

Mind you, these conditions are very very rare. I highly doubt there will ever be this many online at all, but I like to know im coding right.

##### Share on other sites
Is the game 3D or 2D? What's the sight range for each client? What spatial partitioning are you using? A grid with a 2D rectangle for the camera and cull outside the client's view?

Everything past this sentence you already know, but I just want to make sure. If your map is say 100000x100000 units and you use a grid of 500x500 cells and 4K players are evenly distributed throughout the map that's 0.1 players per cell. Basically you'll define a viewing rectangle or circle and grab all of the entities in the cells that overlap the rectangle/circle. Since you inserted all the entities into their corresponding cells that means you'll be able to get a list of adjacent entities very quickly. (All of this can be implement with O(1) algorithms if you're clever with a linked list + observer pattern). Also look into hashed grids.

I also use full state updates and delta state updates. Store the known entities and objects for a client. Obviously if you go to insert something into that known entity list and it's not in there the player doesn't know about it and a full state update is required. If the client gets really out of sync? Remove all of the entities in the container and it does a full state update to them. These algorithms can also be implemented extremely cheaply. You can even run the checks for updating this list every 100 ticks or something if you want to and cut the cost down so low that it becomes almost free. >_>

Is that basically what you have?

About the problem at hand limiting the packets updates is a good idea. You can even drop the field of view if that's possible especially for populated areas. 800 players in an area is going to be insane. I'd be more worried trying to stop such traffic in one area. I mean it's not like players can do anything meaningful in such a dense region.

##### Share on other sites
Some of what you mention have to do with the client.

This is just server side. Simple.

Its the MMO server. Players just need to know about other players near it.

Some what you have mentioned I will look into, I have heard Trees is where I need to be, just never really worked with them.

Ken

##### Share on other sites
Quote:
 These algorithms can also be implemented extremely cheaply. You can even run the checks for updating this list every 100 ticks or something if you want to and cut the cost down so low that it becomes almost free. >_>

This is probably what I am looking for. How can I run checks quickly? From my knowledge, I would have the cycle the entire List<> and check if a player has run to far from another player.

Another problem could come into play is .Broadcasting() packets. For each person that knows of this person, broadcast. If the list is 400, that could be a large broadcast.

Ken

##### Share on other sites
Dont worry!
I got time vehicle, and i already know, your mmo will be release in future!
and will be better than WoW, and everything else, you will be pionier of MMO's. :)

then dont forget about me. I know your in future earns alot of money from mmo, then you should give me some. :D

##### Share on other sites
(You can edit a post by the way. No need to double post).

When you register a player to a cell in the grid you register the cell with the player. Removing the player from the cell is then instant since you have the cells the entity is in and can just call entity.RemoveFromSpatialPartitioning() or something. So you have a region around the player where you check for adjacent cells. Something like:
int minX = (int)((entity.Position.X - Player.SightRadius) / CellSize);int minY = (int)((entity.Position.Y - Player.SightRadius) / CellSize);int maxX = (int)((entity.Position.X + Player.SightRadius) / CellSize);int maxY = (int)((entity.Position.Y + Player.SightRadius) / CellSize); for (int x = minX; x <= maxX; ++x){	for (int y = minY; y <= maxY; ++y)	{		// try to add the grid[x][y].entities to a HashSet of known entities if possible. If the entity isn't already known then a full state is needed 	}}

So you have the known entities and a fullStateEntities hashset. You don't have to run the above code every frame. You just need to run it enough so that the known entity list is reasonably up to date. You mentioned how do you know if an entity is moving far away? There's a trick. When building delta packets for the known entities for any entity that is X distance away remove them from the hashset and skip them. If they come back within range they will automatically be picked up for a full state update by the above code. :)

##### Share on other sites
Sir,

Sorry I didn't mention before, it is a 3D game. Basically, those grids I have are not just 1 set away. Since its a 3D game, I think your formula wouldn't work. The grids I stated could be as big as town. (I wouldn't say that big but they are not blocks). Its not like chess.

So, when people get into the game, they go into a cell. That cell then is used when the update process goes through. When people move, if they are within range, they are added into the KnownList of the entity.

Ken

##### Share on other sites
Use smaller cell sizes then? Is there a reason you made them so large? This method applies to both 2D and 3D games though. You could be use a 3D grid if needed, but then the hash grid idea becomes much more important due to the memory needed.

##### Share on other sites
The lines are followed by the client. And I dont have the source to that anymore.

As you speak of HashTables, I currently have all known entities in a List<> The problem is cycling through that list. I need to find the quickest way to either A) Go through the entire list, B) If the list is large, only do X amount. Problem with this is I have to ensure that the next time around, we do the rest. Personally, I think A is the way. But in what order is best.

1. 1
2. 2
3. 3
4. 4
frob
15
5. 5

• 16
• 12
• 20
• 12
• 19
• ### Forum Statistics

• Total Topics
632163
• Total Posts
3004514

×