fix: remove wield value frequency, fix cache invalidation #3296
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.
Summary
SUMMARY: Bugfixes "Revert one per minute frequency addition to npc::regen_ai_cache and fix cache invalidation"
Purpose of change
Having wielded value to be calculated and cached only once per minute is a clunky solution caused by the bug in
deactivate_weapon_cbm
. The bug was forcing the cache to become invalid every turn so the following turn it was recalculated instead of actually being used.Describe the solution
Removed the
once_every
wrapping condition introduced in #3283 and move the cache invalidator from outside the loop to inside so the cached value is invalidated only when the NPC is actually turning off weapon cbms. Now, instead of possibly calculating other values using up-to 1 minute old data the NPC will use the most accurate data it can. More accuracy, fewer calls to the expensive function.Testing
Waited several hours in both pre-change and post-change configurations. Performance is approximately the same between the two. In profiling the NPCs calculate the cached value once then properly refer to that cached value every turn after.