Scope lighthouse quest variables to NPC, not global #73097
Merged
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
Bugfixes "Lighthouse clear quest can be completed again"
Purpose of change
Describe the solution
Variables were accidentally migrated to global(?!) in #71027 by prefixing
npc_
. The correct prefix isn_
.npc_has_var
was correctly checking the NPC for the variable, but the variable was held in global scope.I changed the existing instances of the global
npc_count_cleaning_lighthouse_man
ton_count_cleaning_lighthouse_man
, which makes npctalkvars local to the beta talker (the NPC in question).Describe alternatives you've considered
Making everything global /shrug
Testing
Confirmed that the quest was completable on the provided save, even though the quest NPC did not already have the npctalkvar initialized. Confirmed that newly received quests properly set the var on the NPC and it can be completed as normal with that new NPC.
Additional context
It looks like John Bailey's training dialogue was also accidentally migrated to global. https://github.com/CleverRaven/Cataclysm-DDA/pull/71027/files#diff-3ce8cc7bacf285a65d92aa9f8d6b8b777d192d993c061a0f4fc4efdfde8c9f04R530-R531
However because of the way the condition is set up, it still checks against the now global variable.
This PR does not migrate or handle the global var in existing saves. It will remain as unused data, but that should not have any impact besides a few extra characters in the save file.