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

Race: Suppress and Reactive for temp disabling nwnx_race effects #1784

Merged
merged 2 commits into from
Oct 22, 2024

Conversation

WilliamDraco
Copy link
Contributor

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.

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);
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Daztek Daztek merged commit 8c56c4e into nwnxee:master Oct 22, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants