Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make light source detection more consistent #4541

Merged

Conversation

kwvanderlinde
Copy link
Collaborator

@kwvanderlinde kwvanderlinde commented Dec 7, 2023

Identify the Bug or Feature request

Addresses #4298

Description of the Change

This change addresses the inconsistent states that can be seen when modifying tokens and the use of player view. There are a few main aspects to it:

  1. Have only one routine responsible for updating light sources, whether at creation time or afterwards. This avoids discrepancies in the filtering logic.
  2. Cache auras depending on the view. This make the GM's "player view" more like a real player in terms of not showing GM-only auras.
  3. Make the lightSourceMap have distinct entries for player and GM roles, since they disagree on which lights even exist. This also affects the illuminations, so IlluminationKey also includes the role now so we don't use a GM illumination when in player view.

Possible Drawbacks

Should be none.

Documentation Notes

N/A

Release Notes

  • Fixed a bug where lights would not always show up for GMs when "Visible to players" is not set.
  • Fixed a bug where auras and lights would not respect the "Show As Player" toggle.

This change is Reviewable

Since players and GMs disagree on which light sources exist, and since GMs can enable "player view", we need to be able
to track light sources based on the current role. This has implications for illumination as well, so we now key the
light source map and illuminations cache by player role in addition to the existing keys. Doing so allows
`lightSourceMap` to always be `ZoneView`'s source of truth when it comes to light sources, and it works even in the
presence of view changes.

On a related note, auras are now only filtered in `getDrawableAuras()`, but that method is now dependent on the current
view. This makes it so that, e.g., GM-only auras are not returned  when the GM is in player view.

There is now one place (`updateLightSourcesFromTokens()`) that checks whether or not a token should be added to the
light source map. This avoids inconsistencies in how tokens are handled at campaign load vs being added or modified
later. The event handlers that need to use it have also been updated to avoid any repeated logic.

With the other changes, `MapTool.getPlayer().isEffectiveGM()` is no longer needed since we always work off the provided
view rather than trying to determine it ourselves. The same logic, if needed again, can be attained by checking
`getEffectiveRole()` instead.
@kwvanderlinde kwvanderlinde force-pushed the bugfix/4298-inconsistent-light-display branch from 4774031 to b9cf002 Compare December 9, 2023 22:38
@cwisniew cwisniew added this pull request to the merge queue Dec 15, 2023
@cwisniew cwisniew added the bug label Dec 15, 2023
Merged via the queue into RPTools:develop with commit 47d9899 Dec 15, 2023
4 checks passed
@kwvanderlinde kwvanderlinde deleted the bugfix/4298-inconsistent-light-display branch December 15, 2023 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants