-
Notifications
You must be signed in to change notification settings - Fork 121
bugfix(ocl): Fix GLA Rebel Ambush units spawning in water/cliffs and dying immediately #1882
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
base: main
Are you sure you want to change the base?
bugfix(ocl): Fix GLA Rebel Ambush units spawning in water/cliffs and dying immediately #1882
Conversation
| { | ||
| fpOptions.flags = FPF_USE_HIGHEST_LAYER; | ||
| } | ||
| // TheSuperHackers @bugfix bobtista 18/11/2025 Fall back to center if no passable position found in spread formation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it'd be better to combine both comments given their proximity.
Could be something like:
// TheSuperHackers @bugfix bobtista 18/11/2025 Spawn the object on passable terrain if it would be destroyed on impassable terrain (water / cliffs).
// Use the original spawn position if no passable terrain was found in spread formation.
| // TheSuperHackers @bugfix bobtista 18/11/2025 Fall back to center if no passable position found in spread formation | ||
| if (!ThePartitionManager->findPositionAround(pos, &fpOptions, &resultPos)) | ||
| { | ||
| resultPos = *pos; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this branch ever taken in your testing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't set a breaktpoint to check, I just played a game against an easy computer with water and mountains and eventually did rebel ambushes on the water and mountains to see if anyone died.
How does Generals handle this issue? |
Ok so if I understand correctly, Zero Hour uses OCLAdjustPositionToPassable, it takes the clicked location (loc) and adjusts it to a passable position within MAX_ADJUST_RADIUS (500 units), Updates targetCoord to that passable position (if found), ObjectCreationList::create is called with that adjusted position, This becomes the pos parameter used as the center for spawning. For each unit, spread formation: In Generals, there isn't a OCLAdjustPositionToPassable, so the initial click is used as is. For each unit in the spread, findPositionAround tries to find a spot. If it finds passable ground nearby: sets resultPos to that position, returns TRUE. If it doesn't find passable ground: returns FALSE, but the return value doesn't seem to be used, and the code calls doStuffToObj with resultPos (which I'm not sure if it's even set). I think that units will still spawn and die immediately, possibly at garbage places. For what we can do from here - If we do check the return value of findPositionAround and find that there's no valid position, we could either destroy it or let it die immediately - neither of these are ideal though, as we're not getting the expected amount of units. Maybe we could just try to add OCLAdjustPositionToPassable and make Generals do it like Zero Hour does? |
Generals implementation needs looking at.
Spread formation uses FPF_USE_HIGHEST_LAYER which allows spawning on bridges/elevated terrain but doesn't guarantee passable ground.
Now spread formation uses FPF_CLEAR_CELLS_ONLY to only spawn units on passable terrain. If no passable position is found within the spread radius, units fall back to the center position which is guaranteed passable due to OCLAdjustPositionToPassable. It still uses FPF_USE_HIGHEST_LAYER, so they'll still spawn on a bridge.
Generals does not work the same way as Zero Hour, so this fix does not apply there.
Testing