ServUO Version
Publish Unknown
Ultima Expansion
None
I've been looking into the file Movement.cs (RunUO 2.6 but the changes to ServUO are superficial it seems) with the aim of making CheckMovement() faster and I suspect that the number of items per sector plays a role. I found out that there is a variable "SectorSize" which is hardcoded to "16" in Map.cs which may or may not control this (it is not obvious that it is used anywhere).

So I was wondering: Is there a straight-forward way of changing the sector size? And, has anyone ever experimented with this value?

My guess is that a smaller value can become beneficial when the density of items on the server becomes large.

On a side-note: CheckMovement() is possibly the toughest piece of code I have ever looked at. o_O:p
 
The important value apparently is "SectorShift" not "SectorSize". It is set to 4 by default, which leads to a divisor of 16 for each of the grid dimensions. For Trammel and Felluca, this leads to pretty large sectors. Raising "SectorShift" to 5 (divisor = 32) might reduce item search times.

This could work for each map, except Tokuno, which has dimensions not divisible by 32.
 
The larger the sectors, the more AI will be activated.
Increasing the sector size wouldn't reduce object search times because the sector list will hold more entries that need to be filtered.
Smaller sectors does mean more memory usage, but it performs better because the sectors are pre-filtered by the bounds you're searching in;
If your search happens to cross sector boundaries, you could be filtering through twice as many items as necessary than you would with a smaller sector size.

An example, Outlands uses 8:3, which actually matches the block size of the land tile matrix.
I will likely configure ServUO P58 to use 8:3 too.
 
How would you go about changing the sector size?

Yes, I was intending to make sectors smaller to boost performance. I should have expressed it more clearly above. "SectorShift" encodes a divisor, so making this value larger means making the sectors smaller.
 
How would you go about changing the sector size?

Yes, I was intending to make sectors smaller to boost performance. I should have expressed it more clearly above. "SectorShift" encodes a divisor, so making this value larger means making the sectors smaller.
I guess this is wrong :p Sorry for being clueless...
 
That's right.

In the context of Map implementation, it is used to shift the top-left and bottom-right locations of the sector bounds during iteration of the map enumerators, in order to keep them in bounds or effectively reset them.

The sector shift value is equivalent to floor( log( SectorSize, 2 ) ) so it can be configured as such;
C#:
public const int SectorSize = 8;

public static readonly int SectorShift = (int)Math.Log(SectorSize, 2);
The SectorSize must always be multiples of 8, so configuring it this way can be potentially unsafe.

Conversely, you can configure it in a safe manner;
C#:
public const int SectorShift = 3;
public const int SectorSize = 1 << SectorShift;
With 0-12 being the valid range for the SectorShift value, as anything higher will typically cover the entire map.

This way you only need to be concerned with changing one value.
 
Back