Server advancements: flushDirty skips players whose progress didn't change

PlayerAdvancements.flushDirty only works when it is the first packet or
progress changed. Horizon walked the whole advancement tree for every
network player every tick to find nothing new: a fifth of the server
tick with 50 players.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-17 11:07:14 +02:00
parent fa2536c120
commit c98a4f7a58
@@ -144,6 +144,13 @@ impl ServerAdvancements {
) -> Option<Vec<u8>> {
let n = self.tree.list.len();
let first = visible.len() != n;
// flushDirty does nothing unless it is the first packet or progress
// changed: visibility follows progress alone, and every grant and
// revoke is in `changed`. This skips walking the whole tree for
// every player every tick.
if !first && changed.is_empty() {
return None;
}
let now = self
.tree
.visible(&self.kids, |i| progress.done(&self.tree.list[i]));