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: remove wield value frequency, fix cache invalidation #3296

Merged
merged 1 commit into from
Sep 28, 2023

Conversation

OrenAudeles
Copy link
Collaborator

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.

@github-actions github-actions bot added the src changes related to source code. label Sep 28, 2023
@chaosvolt chaosvolt added this pull request to the merge queue Sep 28, 2023
Merged via the queue into cataclysmbnteam:upload with commit a1dae37 Sep 28, 2023
@OrenAudeles OrenAudeles deleted the de-frequency branch September 29, 2023 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
src changes related to source code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants