Skip to content

Conversation

@Mauller
Copy link

@Mauller Mauller commented Jun 30, 2025

This fixes a crash due to the nuke launcher not having its special power module loaded till it is fully constructed.
This was possibly intentional due to reasons described further on. The hack could have been avoided in other ways if the returns from quite a few functions were used and checked properly, but the hack i put in place is the only way to keep retail compatibility for now while preventing the crash.

The crash occurs within MissileLauncherBuildingUpdate::initiateIntentToDoSpecialPower() when attempting to retrieve the special power template from the special power module.

The issue occurs due to special power timers being initialised to zero instead of max uint. This is relevant as special power timers are set into the future for when the special power is ready based on the current frame.

The game then counts down to the future m_availableOnFrame value, where it then considers the special power available. By it being set to zero it can allow activation before it is meant to be usable.

The full fix for this is setting the special power ready frame to be initialised to max uint, this prevents the messages activating the special power from being sent long before the point of the crash.
But m_availableOnFrame is part of the CRC check, so i had to instead catch the crash point and set the ready frame into the future and then add some code to escape the activation of the power.

In this instance the full escape is required as fixing the crash introduced an exploit where the power will immediately activate.

I won't post the reproduction steps here due to the nature of this bug.
Talk to me outside of this PR to learn the reproduction steps.

EDIT:

This PR also adds the special power timers exploit fix to generals behind a retail compatible CRC conditional.

TODO

  • Check and replicate in generals if necessary

@Mauller Mauller self-assigned this Jun 30, 2025
@Mauller Mauller added Major Severity: Minor < Major < Critical < Blocker ZH Relates to Zero Hour Crash This is a crash, very bad labels Jun 30, 2025
@Mauller Mauller added this to the Major bug fixes milestone Jun 30, 2025
Copy link

@xezon xezon left a comment

Choose a reason for hiding this comment

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

Zero Hour version looks ok.

@Mauller
Copy link
Author

Mauller commented Jul 1, 2025

Zero Hour version looks ok.

I still need to check on the generals side, the code is quite different so might not have the same issues.

@Mauller Mauller force-pushed the fix-nuke-missile-crash branch from a8e4f98 to c791c49 Compare July 1, 2025 20:19
@Mauller
Copy link
Author

Mauller commented Jul 1, 2025

Updated to add debug assert crash if we end up in the escape path and valid is set true.

@Mauller
Copy link
Author

Mauller commented Jul 6, 2025

So i checked generals and it appears that the crash does not occur there but the exploit is there.

I tested by just copying across the changes from the zero hour code and it allowed preventing the exploit, but it would also end up causing a mismatch.

What are thoughts on this? i would say let the game mismatch if someone took advantage of this exploit since it's equivalent to the scud bug in a way.

@xezon
Copy link

xezon commented Jul 6, 2025

I suggest no mismatch. Can put fix behind !RETAIL_COMPATIBLE_CRC

@Mauller
Copy link
Author

Mauller commented Jul 6, 2025

I suggest no mismatch. Can put fix behind !RETAIL_COMPATIBLE_CRC

Then i will put the fix behind the retail compatible CRC and leave the exploit in place.

@Mauller Mauller force-pushed the fix-nuke-missile-crash branch from c791c49 to c823dde Compare July 6, 2025 10:32
@Mauller
Copy link
Author

Mauller commented Jul 6, 2025

Updated and added the exploit fix behind the retail compatible crc for generals. So this should be good to go now.

@xezon
Copy link

xezon commented Jul 6, 2025

Maybe we put the Generals change in a separate Pull Request then? Because it will then get the "NoRetail" label. Whereas Zero Hour fix is retail compatible.

Edit: On second look, seems fine. Just need to be careful then when writing change log.

@xezon xezon added the NoRetail This fix or change is not applicable with Retail game compatibility label Jul 6, 2025
@Mauller
Copy link
Author

Mauller commented Jul 6, 2025

Maybe we put the Generals change in a separate Pull Request then? Because it will then get the "NoRetail" label. Whereas Zero Hour fix is retail compatible.

Edit: On second look, seems fine. Just need to be careful then when writing change log.

Just as i was making the seperate PR too lol. i will hold back on that then.

@Mauller Mauller added the Gen Relates to Generals label Jul 6, 2025
@xezon xezon modified the milestones: Major bug fixes, Stability fixes Jul 6, 2025
@xezon xezon added Critical Severity: Minor < Major < Critical < Blocker and removed Major Severity: Minor < Major < Critical < Blocker labels Jul 6, 2025
@xezon xezon changed the title [ZH] Fix crash in MissileLauncherBuildingUpdate::initiateIntentToDoSpecialPower() [ZH] Fix game crash in MissileLauncherBuildingUpdate::initiateIntentToDoSpecialPower() Jul 6, 2025
@xezon xezon merged commit 477be26 into TheSuperHackers:main Jul 6, 2025
16 checks passed
@xezon xezon deleted the fix-nuke-missile-crash branch July 6, 2025 13:08
fbraz3 pushed a commit to fbraz3/GeneralsX that referenced this pull request Nov 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Crash This is a crash, very bad Critical Severity: Minor < Major < Critical < Blocker Gen Relates to Generals NoRetail This fix or change is not applicable with Retail game compatibility ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants