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

Invalidate seen cache properly in many-z-level mode #30940

Merged
merged 1 commit into from
May 29, 2019

Conversation

kevingranade
Copy link
Member

Summary

SUMMARY: Bugfixes "Prevents occasional inappropriate vision across z-levels."

Purpose of change

Fixes #29175
When walking on a roof, a shocker on a lower floor could sometimes fire it's shockstorm attack at the player.
This would only occur if both z-levels and 3D vision options were enabled.
The reason shockstorm came up is that it's a ranged attack that does not double-check for a path to the target, treating vision as sufficient.

It turns out the cause of this issue is that the "seen" cache calculated for the player was not fully cleared after map shift, meaning the tile occupied by the shocker could remain labeled "seen" after a shift, which transitively meant that the shocker was also considered able to see the player in order to fire.

A consistent reproduction case for the issue is to find a relatively small building whose center point is no more than 11 tiles from any edge, spawn a shocker on the lower floor, move the player to the upper floor, and then cross the midline of the building, which triggers the map shift and resultant cache error. The shocker will very consistently be in a position to fire on the player since they track the player by sound.

Describe the solution

Couldn't be simpler, when clearing the seen cache before regenerating it, clear every level of the cache instead of just the current one.

Describe alternatives you've considered

A more sophisticated caching system may be possible in the future, but we don't have the infrastructure for it right now.

@KorGgenT KorGgenT added [C++] Changes (can be) made in C++. Previously named `Code` Z-levels Levels below and above ground. labels May 29, 2019
@ZhilkinSerg ZhilkinSerg merged commit beb9e23 into CleverRaven:master May 29, 2019
@kevingranade kevingranade deleted the reset-seen-cache-fully branch June 12, 2019 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Z-levels Levels below and above ground.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Attacks from under ceiling with 3D FOV on.
3 participants