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

Fix companions ceasing activities when PC enter Z level #72883

Merged
merged 2 commits into from Apr 9, 2024

Conversation

PatrikLundell
Copy link
Contributor

@PatrikLundell PatrikLundell commented Apr 7, 2024

Summary

None

Purpose of change

Fix #72792, i.e. Companion crafting aborted whe PC enters the companion's Z level.

Describe the solution

Add a call to rebuild map caches when the PC changes Z level.

Describe alternatives you've considered

Testing

Using a save suffering from the bug report issue and verify it still happens when going down the stairs and then up again.
Modify the code and verify there is no visible effect on the crafting companion (still active) after having returned to the same Z level.
Waiting and verifying that the progress of a pair of heavy survivor boots in progress craft increases from 49% to 50% after waiting.

Additional context

The changes to the tests requires some explanations:

  • The reason the test failed is that the implicit recalculation of the light map due to the change of Z levels was performed BEFORE the time was changed, so it was still daytime.
  • The test probably didn't test anything useful, as it updated the light map for Z level 0, while 'dummy' was shifted up to Z level 1, whose light map remained unchanged (despite the claim that all Z levels are affected, only the specified Z level light map is updated, which presumably is why there is a Z level parameter to the call).
  • I have no idea why the code wants to change the Z level of 'dummy'. I retained that since there might be some reason for it. However, as far as I can tell, you can remove the Z level juggling and restore the call to build_map_cache (as it's no longer called implicitly), keeping it a Z level 0. Testing that caused the test to pass.

This is presumably caused by the solution not to keep lighting information up to date on all Z levels for performance reasons, coupled with a delay in the update of the lighting conditions of the Z level the PC reaches to after the companions have evaluated their light levels for the turn. Companions are kept unaffected by the light level while the PC is on a different Z level by code that explicitly ignores it due to the performance issues involved in keeping it up to date.

@github-actions github-actions bot added [C++] Changes (can be) made in C++. Previously named `Code` <Bugfix> This is a fix for a bug (or closes open issue) astyled astyled PR, label is assigned by github actions json-styled JSON lint passed, label assigned by github actions labels Apr 7, 2024
@PatrikLundell PatrikLundell marked this pull request as draft April 7, 2024 13:12
@github-actions github-actions bot added the Code: Tests Measurement, self-control, statistics, balancing. label Apr 7, 2024
@PatrikLundell PatrikLundell marked this pull request as ready for review April 7, 2024 14:33
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Apr 7, 2024
@ashGlaw
Copy link
Contributor

ashGlaw commented Apr 7, 2024

Thank you for this. Very annoying bug

@PatrikLundell
Copy link
Contributor Author

Completely agree!

It was @pwalsh0 who put me on the right track, though.

@dseguin dseguin merged commit f78bf49 into CleverRaven:master Apr 9, 2024
29 of 40 checks passed
@PatrikLundell PatrikLundell deleted the fix_companion_crafting branch April 10, 2024 06:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Code: Tests Measurement, self-control, statistics, balancing. json-styled JSON lint passed, label assigned by github actions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Companion crafting aborted when PC enters the companion's Z level.
3 participants