bugfix(behavior): Fix wrong and unsafe logic in CountermeasuresBehavior::calculateCountermeasureToDivertTo()#1367
Merged
Conversation
xezon
reviewed
Jul 26, 2025
b2031d5 to
b6198c4
Compare
Author
|
Tweaked and updated, also updated comments. |
b6198c4 to
e0d6fc7
Compare
Author
|
Tweaked and pushed. |
xezon
reviewed
Jul 27, 2025
e0d6fc7 to
a1622eb
Compare
Author
|
Tweaked and pushed EDIT: pushed again since i noticed i made a small spelling mistake |
a1622eb to
59524b1
Compare
xezon
reviewed
Jul 27, 2025
xezon
reviewed
Jul 27, 2025
…vertTo to correct iterator behaviour and fix functionality
59524b1 to
301744c
Compare
xezon
approved these changes
Jul 27, 2025
fbraz3
pushed a commit
to fbraz3/GeneralsX
that referenced
this pull request
Nov 10, 2025
…or::calculateCountermeasureToDivertTo() (TheSuperHackers#1367) Co-authored-by: Stubbjax <stubbjax02@hotmail.com>
fbraz3
pushed a commit
to fbraz3/GeneralsX
that referenced
this pull request
Feb 23, 2026
…or::calculateCountermeasureToDivertTo() (TheSuperHackers#1367) Co-authored-by: Stubbjax <stubbjax02@hotmail.com>
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.
This PR is an alternative implementation to an earlier PR that refactors and fixes iterator and function behaviour.
The original code did not work as intended and could lead to the iterator becoming invalidated by going past the end of the container.
The intention of the original code was to work from the end of the container to get the most recently launched flare. It would then check if the current flare ID was for a valid object and then check the distance of the flare to the incoming weapon.
The code was meant to count that a valid flare had been seen and also check that we were only counting up to the number of flares within a volley. This was meant to break the loop if more available flares were still within the container.
Instead the code, once it had received a valid object, would simply spin it's wheels while sat on the same object before returning from the while loop. This meant that only the first valid flare in the container was checked against instead of finding the closest flare to the weapon in the volley.
To maintain retail compatibility, we have to break the loop after finding the first flare, the corrected behaviour counts up flares and correctly sets the closest flare that the weapon should be diverted towards.