Description
When the server transmits an entity state to a client, it is always delta encoded against some base entity state. This base entity state is one of the following, in order of priority:
- The entity's state in the client's most recently acknowledged snapshot
- The entity's state in the "entity baseline"
- An all-zeroes entity state
I think (1) should be used the majority of the time under normal conditions. But when an entity first enters the client's PVS, (1) won't be available. Assuming entities stay in roughly the same position from frame to frame, and the network is not too flaky, (1) will start being available after a delay roughly equal to the client's ping. I assume (2) is intended to make things more efficient during that window.
This issue is about (2). So what is the entity baseline? I always imagined that entity baselines and delta compression work like keyframes in a video: periodically you get a new baseline/keyframe, and then for the next few seconds each frame is encoded via the diff from that base. (1) is kind of like that, but (2) is stupider: a baseline is taken only once, when the map is first loaded. It's never updated, not even on a map_restart
(the cause of the inconsistent behavior in Unvanquished/Unvanquished#2124). It's like if the entire video were encoded based on diffs from the first frame. This was probably good for Quake, since most entities that existed at the start could never be destroyed. But we have buildables that can be destroyed and moved, and beacons for those buildables. Entity numbers are recycled, so it's likely that the baseline entity with a given number isn't even the same type as the currently existing entity. It's likely that using the entity baseline results in more bandwidth consumption in such cases.
What should we do about this? The easiest thing would be to NUKE or disable baselines. Maybe they can be considered an unnecessary micro-optimization from today's standpoint. If not, we could try some of the following ideas:
- Remove an entity from the baseline once it dies. If we do this (and never add any new entities), we could keep the advantages of the baseline just for permanent stuff like doors.
- When a new entity spawns, update its baseline entity.
- Transmit baselines lazily instead of all at once.
- Remember states of entities received by the client even after they leave the PVS. This would be more an extension of (1) that would replace the baseline concept.