fix(spectator): rebuild the overview instead of showing an empty grid - #232
Open
TheMeinerLP wants to merge 1 commit into
Open
fix(spectator): rebuild the overview instead of showing an empty grid#232TheMeinerLP wants to merge 1 commit into
TheMeinerLP wants to merge 1 commit into
Conversation
The overview listed no survivors at all. Its inventory is built once, at server start, when the survivor team is still empty, and the head list was never rebuilt afterwards: invalidating the data layout only clears a flag while nobody has the inventory open, and the following getInventory skips the rebuild because it retrieves a data layout only while it applies the design layout as well. Invalidating both layouts on open and on every roster change fixes that and also clears the inventory, which a data layout cannot do on its own - the head of a player who left the round would otherwise stay in place and stay clickable.
Contributor
Test results 336 files 336 suites 2m 6s ⏱️ Results for commit 49704f8. |
theEvilReaper
requested changes
Sep 6, 2026
Comment on lines
+145
to
+148
| public void refresh() { | ||
| this.invalidateLayout(); | ||
| this.invalidateDataLayout(); | ||
| } |
Contributor
There was a problem hiding this comment.
This is just a hotfix for the inventory update and does not address the underlying issues.
With this approach, every time a player opens the inventory, all items aligned with the background and data layers are recalculated. A proper fix would be to identify the specific positions where the data layout needs to be invalidated and only recalculate those positions when necessary, rather than triggering a full recalculation on every inventory open.
| */ | ||
| public void updateInventory() { | ||
| this.spectatorInventory.invalidateDataLayout(); | ||
| this.spectatorInventory.refresh(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
The spectate overview showed no survivors at all, even while survivors were still alive.
Root cause:
SpectatorInventoryis constructed in theCygnusconstructor at server start, and itsregister()call builds the inventory and computes the data layout right there, at a point where the survivor team is still empty. The head list was never rebuilt afterwards. Aves'InventoryBuilder#invalidateDataLayoutonly clears the valid flag while nobody has the inventory open, and the followingGlobalInventoryBuilder#getInventoryskips the rebuild: it computesapplyLayoutfrom the design layout flag, andupdateInventory(inventory, locale, false)returns before it ever reaches theretrieveDataLayoutbranch. So the empty list from server start stayed for the whole round.Fix: a
SpectatorInventory#refreshthat invalidates both layouts, called fromopenand fromSpectatorService#updateInventory(which the death and quit listeners already drive). Invalidating the design layout as well is also what clears the inventory. A data layout can only write items:applyDataLayoutskips null and air stacks, so a blanked slot is never written back and the head of a player who left the round would otherwise stay in place and stay clickable.Types of changes
What types of changes does your code introduce to this project?
Put an
xin the boxes that applyChecklist
Put an
xin the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any ofthem, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before
merging your code.
Further comments
Two tests come with the fix, both failing on main:
SpectatorInventoryTest#testOpenPicksUpSurvivorsThatJoinedAfterTheInventoryWasBuiltreproduces the production order, meaning the inventory is built while the team is still empty and survivors join later.SpectatorInventoryTest#testOpenDropsHeadsOfPlayersThatLeftTheSurvivorTeamcovers the stale head.The fix stays inside this repo and uses only Aves' public API, so no Aves release is needed. Worth noting that the same limitation would bite any other Aves inventory whose data layout changes while it is closed.
The companion PR on branch
fix/spectator-flight-cooldownfixes the spectator flight and stamina bugs. The two touchSpectatorServicein different places and merge onto main without a conflict, and both were verified merged together with a green./gradlew build.