Open Zbizu opened 4 years ago
You could do a bitmap (0/1) that updates when the player changes his position and using that map look for the status (1) in the range with a small loop and thus know if a player is in field of vision, completely eliminating the use of the function getSpectators, I don't know if this consumes more time, although in theory it shouldn't, since it only handles a map of zeros and ones
What if we moved refreshing monster aggro from spawns to players and summons?
In case the question wasn't clear enough, I'm speaking of spawn.cpp loop that calls onCreatureAppear.
current problem
if there are 10000+ monsters, every single spawn calls getSpectators. RL maps and custom rpg maps tend to have that much, even high exp servers do, though they have less spawns. Tracked maps have one monster per spawn which can also get laggy.
potential solution
biggest servers have around 2000 players (though we don't know how much of that is spoofed). If we moved aggro checks (onCreatureAppear) to player and his summons, then label monsters that they were just checked (to avoid duplicate checks), we could reduce amount of getSpectators calls (though the calls would return more data because players are usually together in cities).
I don't know which one would be faster, but this solution should definitely be explored.
difficulty
high (too high for me) - it needs to be completely rewritten and needs a lot of testing and performance checks