shubla wrote:Ysh wrote:shubla wrote:Player moves. It's O(n) being done every server-tick for every player that is in cave, because the state of being in light or not may change as the player or light sources move. I am also pretty sure that the server currently does not iterate through every object that is near the player every server tick.
I do not consider this point. Do you know when or how does server evaluate when to send object? It seem to me that object changed/removed messages are sent at consistent positions, which I think will imply that it is not checking my position on timer, but rather every time I move. If this is the case, then I think my point still stands. I admit that I do not study this game that closely though.
It will probably check characters position. But it will not iterate through objects that often.
When characters position moves, so that it will unload/load new areas with objects, it will tell the client to remove objects from areas that client should see no more, and load objects from areas that client will now see.
Each object will only be iterated once when the server sends them. And once when the server tells client to unload them. Of course, sometimes objects positions or other data about them may change, then server will send that to the client, but only for that 1 object that changed.
So then your guess is server have world subdivided into some low resolution ''visibility grid.'' Each visibility grid tile will know which object is within it. When player moves, server checks if player position changes visibility grid and then removes objects within grid that have left range and add new objects for grid that have entered range. This seem to be reasonable system to me, and if this is the case then I do agree it seem this problem of light source is not so trivial.