View Single Post
  #38  
Old 10-13-2008, 12:31 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Still looking into how to trim down the bandwidth from location updates, I think I know how things need to work to trim bandwidth to a minimum without effecting how players see the world.

If a player zones in, they will be sent position updates for all NPCs in the zone, but after that they only need to know if an NPC moves, depops/dies or spawns. Zoning and spawn/depop/death updates are already set, so all we need to adjust are the regular updates that occur.

First, we would only want position updates to come in if they NPC has actually moved, so maybe a check something like this could look for NPC movement:

Code:
	float cur_x = GetX();
	float cur_y = GetY();
	float cur_z = GetZ();

	if( cur_x != last_x || cur_y != last_y || cur_z != last_z ) {
		float last_x = cur_x;
		float last_y = cur_y;
		float last_z = cur_z;
		SendAllPosition();
	}
Currently, all NPCs send regular updates whether they have moved or not, which is a major waste of bandwidth. Unless a zone is full of NPCs that move non-stop, then a simple change to only update when they do move will make a considerable difference.

Next, we would just have it use the Update Manager to set the levels and timers for updates. So that close npc updates will update often and NPCs that are further away will update slower with diminishing returns the further away they are. This code is already in place in the update manager, so my only suggestion would be to allow the levels to be able to be set in the zones table and then load those levels into memory for the zone when it boots up. We could also have an adjustable setting for the level timers in the zones table, but that isn't quite as important as the levels themselves. It is probably a good idea to have a default value for all zones if these fields are left at 0. But, it would also be nice if there was a way to disable position updates completely on a per zone basis if needed.

Last, I think we could make a big difference if we have a check to see if a player was actually moving before checking the Update Manager Levels. If a player is not moving, we could have it divide the levels by 2 so that you only get updates on nearby NPCs. Most of the time, players are not moving, so they don't need to have updates from very far away. But, if they are moving, you don't want things to warp right on top of them due to having low level settings on the update manager. This would further reduce the required bandwidth for position updates to help make it as efficient as possible.

Maybe using the client movement checks created for the MQ Detection that were added to #showstats could be used to check if a player is moving so it can decide to divide the update manager levels or not:

Code:
if (GetMovementSpeed() = 0)
Then have it divide the update manager levels by 2. If they are moving, then it just uses whatever the levels are set to for that particular zone.

With some help from other coders, I think we can get this working and make a huge impact on reducing bandwidth utilization. Since that is a big limiting factor for most emulator servers, I think this change of process would be good for the whole project. Any input from experienced coders would be much appreciated!
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!

Last edited by trevius; 10-14-2008 at 02:40 AM..
Reply With Quote