Skip to content

bugfix(behavior): Fix wrong and unsafe logic in CountermeasuresBehavior::calculateCountermeasureToDivertTo()#1367

Merged
xezon merged 1 commit into
TheSuperHackers:mainfrom
Mauller:fix-countermeasures
Jul 28, 2025
Merged

bugfix(behavior): Fix wrong and unsafe logic in CountermeasuresBehavior::calculateCountermeasureToDivertTo()#1367
xezon merged 1 commit into
TheSuperHackers:mainfrom
Mauller:fix-countermeasures

Conversation

@Mauller

@Mauller Mauller commented Jul 26, 2025

Copy link
Copy Markdown

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.

@Mauller Mauller self-assigned this Jul 26, 2025
@Mauller Mauller added Bug Something is not working right, typically is user facing ZH Relates to Zero Hour Refactor Edits the code with insignificant behavior changes, is never user facing labels Jul 26, 2025
@Mauller Mauller added this to the Stability fixes milestone Jul 26, 2025
@xezon xezon changed the title Bugfix(CountermeasuresBehavior): refactor calculateCountermeasureToDivertTo() to correct iterator behaviour and fix functionality bugfix(behavior): Fix wrong and unsafe logic in CountermeasuresBehavior::calculateCountermeasureToDivertTo() Jul 26, 2025
@Mauller Mauller force-pushed the fix-countermeasures branch from b2031d5 to b6198c4 Compare July 26, 2025 16:50
@Mauller

Mauller commented Jul 26, 2025

Copy link
Copy Markdown
Author

Tweaked and updated, also updated comments.

@Mauller Mauller force-pushed the fix-countermeasures branch from b6198c4 to e0d6fc7 Compare July 26, 2025 22:01
@Mauller

Mauller commented Jul 26, 2025

Copy link
Copy Markdown
Author

Tweaked and pushed.

@Mauller Mauller force-pushed the fix-countermeasures branch from e0d6fc7 to a1622eb Compare July 27, 2025 09:08
@Mauller

Mauller commented Jul 27, 2025

Copy link
Copy Markdown
Author

Tweaked and pushed

EDIT: pushed again since i noticed i made a small spelling mistake

@Mauller Mauller force-pushed the fix-countermeasures branch from a1622eb to 59524b1 Compare July 27, 2025 09:13
…vertTo to correct iterator behaviour and fix functionality
@Mauller Mauller force-pushed the fix-countermeasures branch from 59524b1 to 301744c Compare July 27, 2025 10:48
@xezon xezon added Major Severity: Minor < Major < Critical < Blocker Minor Severity: Minor < Major < Critical < Blocker Stability Concerns stability of the runtime and removed Refactor Edits the code with insignificant behavior changes, is never user facing Minor Severity: Minor < Major < Critical < Blocker labels Jul 27, 2025
@xezon xezon merged commit 0dd58aa into TheSuperHackers:main Jul 28, 2025
9 checks passed
@xezon xezon deleted the fix-countermeasures branch July 28, 2025 16:34
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something is not working right, typically is user facing Major Severity: Minor < Major < Critical < Blocker Stability Concerns stability of the runtime ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants