Skip to content

[GEN][ZH] Fix using uninitialized memory 'mask' in getHumanPlayerMask() #1114

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

xezon
Copy link

@xezon xezon commented Jun 19, 2025

This change fixes using uninitialized memory 'mask' in getHumanPlayerMask()

GeneralsMD\Code\GameEngine\Source\GameLogic\ScriptEngine\ScriptActions.cpp(3005): warning C6001: Using uninitialized memory 'mask'.

This can never have worked. This code is reachable through ScriptActions::doRevealMapAtWaypoint and ScriptActions::doShroudMapAtWaypoint, which are accessible in the Map scripts. It perhaps is not possible to setup the scripts without specifying a player, in which case this code is unreachable. If it was reachable, the behaviour would be undefined.

I looked at WorldBuilder and it the script action asks for a player to select. But it is possible to add the script without a player. I do not know if the script works then. It shows a question mark, indicating that something is misconfigured in it.

image

@xezon xezon added Minor Severity: Minor < Major < Critical < Blocker Fix Is fixing something, but is not user facing labels Jun 19, 2025
@ViTeXFTW
Copy link

ViTeXFTW commented Jun 19, 2025

Copied from Discord.

Retail Game

In the circle I have a waypoint that should clear the fog but no player is specified. Both of the cases the script runs in the debug window, but nothing happens
image
image

PR #1114

There is no difference between the result in game, don't know how to get the debugger to run without using the WB
image

@xezon
Copy link
Author

xezon commented Jun 20, 2025

This code can be called in test map:

!FogTest.zip

The player mask works correctly now, but the shroud reveal still is bugged.

image

@xezon
Copy link
Author

xezon commented Jun 20, 2025

I have now put the fix behind !RETAIL_COMPATIBLE_CRC to play this safe.

@xezon xezon added the Bug Something is not working right, typically is user facing label Jun 20, 2025
@ViTeXFTW
Copy link

ViTeXFTW commented Jun 20, 2025

So what does the script do now if a player is not selected in the script slot?

I am unsure as to what the expected behavior should be in this case other than tell the mapper/player that the script is misconfigured?

@xezon xezon force-pushed the xezon/staticanalysis2/027 branch from 061bd82 to 24eb628 Compare June 20, 2025 07:35
@xezon
Copy link
Author

xezon commented Jun 20, 2025

The expected behaviour is, according to code, all human players should see shroud or reveal at the waypoint with the given radius.

@ViTeXFTW
Copy link

The expected behaviour is, according to code, all human players should see shroud or reveal at the waypoint with the given radius.

It feels wrong that when no player is selected in the script, ALL players are selected? Then I feel like there should be an option for "All Players"

@xezon
Copy link
Author

xezon commented Jun 20, 2025

Yes it is strange. But that it is a different conversation for another time.

@xezon xezon removed the Fix Is fixing something, but is not user facing label Jun 22, 2025
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 Minor Severity: Minor < Major < Critical < Blocker
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants