Skip to content

Conversation

@bobtista
Copy link

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

  1. Place a rebelambush in the water or on impassable terrain
  2. Rebels should spawn without dying on nearby passable terrain

@bobtista bobtista self-assigned this Nov 19, 2025
@bobtista bobtista added Bug Something is not working right, typically is user facing GLA Affects GLA faction NoRetail This fix or change is not applicable with Retail game compatibility labels Nov 19, 2025
Caball009
Caball009 previously approved these changes Nov 29, 2025
{
fpOptions.flags = FPF_USE_HIGHEST_LAYER;
}
// TheSuperHackers @bugfix bobtista 18/11/2025 Fall back to center if no passable position found in spread formation

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;

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?

Copy link
Author

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.

@Caball009
Copy link

Caball009 commented Nov 29, 2025

Generals does not work the same way as Zero Hour, so this fix does not apply there.

How does Generals handle this issue?

@bobtista
Copy link
Author

Generals does not work the same way as Zero Hour, so this fix does not apply there.

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:
Tries to find a position around the adjusted center using findPositionAround. With the fix, if that fails, it falls back to the center, which is already known to be passable.

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?

@Caball009 Caball009 dismissed their stale review December 1, 2025 03:34

Generals implementation needs looking at.

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 GLA Affects GLA faction NoRetail This fix or change is not applicable with Retail game compatibility

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rebels of the Rebel Ambush die on Spawn

2 participants