Race: Suppress and Reactive for temp disabling nwnx_race effects#1784
Merged
Daztek merged 2 commits intonwnxee:masterfrom Oct 22, 2024
Merged
Race: Suppress and Reactive for temp disabling nwnx_race effects#1784Daztek merged 2 commits intonwnxee:masterfrom
Daztek merged 2 commits intonwnxee:masterfrom
Conversation
Daztek
reviewed
Oct 13, 2024
Comment on lines
+187
to
+194
| for (int i = pCreature->m_appliedEffects.num; i >= 0; --i) | ||
| { | ||
| auto eff = (CGameEffect*)pCreature->m_appliedEffects.element[i]; | ||
| if (eff->m_sCustomTag == "NWNX_Race_RacialMod") | ||
| { | ||
| pCreature->RemoveEffectById(eff->m_nID); | ||
| } | ||
| } |
Member
There was a problem hiding this comment.
Deleting an effect can remove multiple linked ones so this would have a big chance for out of bound array access, you can't trust the effect list after a removal. The previous method of adding IDs to be removed to a list is better
Contributor
Author
There was a problem hiding this comment.
Ah of course. I had reasoned that, under the old method, RemoveEffectById would try and remove invalid effects anyway, so it /must/ be fine to attempt to do so. Didn't think through the array access. New commit reverts this section to the previous method.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
By request of Noler on discord.
Splits out the removal of the effects into its own function, and then adds nwscript calls to the Apply/Removal of them.
Compiled locally but untested. Only substantive c++ change was effect countdown remove rather than count-up creating a list to then count-through and remove from.