fix: surface speed effect removal, type correctness, and code cleanup#226
Merged
Merged
Conversation
- Fix effect removal stripping unrelated MovementSpeedIncrease effects (e.g. Expeditious Retreat) by using RemoveEffectByTag with ID-based removal instead of deferred AIMaster RemoveEffect with raw pointers - Use MovementSpeedDecrease for negative speed modifiers (mud, water, snow, sand) instead of MovementSpeedIncrease with negative values - Use find() on m_SurfaceMaterialSpeeds to avoid unbounded map growth from operator[] inserting defaults for unknown surface materials - Fix vector(128) pre-filling 128 zeros in RemoveEffectByTag; use reserve(128) instead - Extract ParseRuneTag helper with bounds checking to eliminate 4x duplicated tag parsing across ApplyRune, CombineRunes, GetRuneDescription, and prevent server crash on malformed tags - Extract GetRaceVFXOffset helper to eliminate 3x duplicated race-to-VFX-offset mapping - Fix NextColor/PreviousColor OOB vector access at boundaries - Allow weapon color 0 in SetItemAppearance and NextColor wrap-around - Remove unused m_GetItemInSlotHook member, duplicate include, fix LOG_INFO format specifier for size_t Fixes nwnxee#374
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.
Summary
RemoveEffectByTagwith ID-based removal instead of deferredAIMasterEvent::RemoveEffectwith rawCGameEffect*pointers, which could match and remove unrelatedMovementSpeedIncreaseeffectsMovementSpeedDecreasewithstd::abs(effectChange)for negative speed modifiers (mud, water, snow, sand) instead ofMovementSpeedIncreasewith negative valuesfind()onm_SurfaceMaterialSpeedsinstead ofoperator[]which silently inserted default entries for every unknown surface materialRemoveEffectByTagcallingRemoveEffectById(0)128 times:vector(128)pre-filled 128 zeros before real IDs; changed toreserve(128)ParseRuneTaghelper with bounds checking; callers guard against sentinel returnv[index]at vector boundariesSetItemAppearancenow acceptsval >= 0andNextColorwrap-around searches from 0GetRaceVFXOffsethelper (3x dedup), removed deadm_GetItemInSlotHookmember, removed duplicate#include, fixed%d→%zuforsize_tFixes nwnxee#374
Test plan