by mh » Sun Aug 05, 2012 1:51 am
sv_novis 1 really just started life as a hack to allow entities to be seen through translucent water. It doesn't pretend to be robust, and really does need protocol and other limit extensions. If SV_WriteEntitiesToClient and client-side visedict addition are coded to fail gracefully (rather than crash or overflow buffers) - which is the case with ID Quake - then the worst that can happen is some entities don't get added or drawn.
A few things can firm it up. In SV_WriteEntitiesToClient you could do a first pass through the entities writing those that are visible, then do a second pass writing those that are not. That would mean that if an entity fails to send it's probably not that big a deal as it likely would not have been visible anyway. Sorting entities by distance to the client and sending from nearest to farthest would also help some, at a (small) performance cost (this only need be done for the entities that are not visible). There are also some entities that you probably must send (monsters, doors, plats, other players) and some you could get away with not bothering to send if need be (gibs, heads, dead bodies, bubble sprites) so there's another sort key. Basically, it amounts to being a bit more clever about how you manage sending entities to the client. I haven't bothered doing any of this in my own code, as I've never extended use of sv_novis 1 beyond it's initial purpose as a hack (plus my limits are already stupidly high anyway so I don't really need to).
Client-side it's quite trivial to just extend the visedicts array. Extending cl_entities is a bit more work (if you want to avoid reserving too much memory for this array), but since this is defined at size MAX_EDICTS which is the same size used for server-side, it's probably not necessary (unless you've been mucking around with the size of the server-side array, in which case you're in "might crash" country even without sv_novis 1 support - another of the nice little traps Quake lays for you).
There's one more place server-side that PVS is used and that should probably be addressed, and that's in PF_checkclient where it's used to check if enemies can see you for accelerating aim tests. Sending all entities to the client is also something that should probably be done if the viewpoint is inside a solid leaf (i.e. we're noclipping).