Skip to content

AIGroup::groupMoveToPosition() The size of the group rectangle for the tighten operation is considered invalid #2462

@diqezit

Description

@diqezit

Prerequisites

  • I have searched for similar issues and confirmed this is not a duplicate

Game Version

  • Command & Conquer Generals
  • Command & Conquer Generals: Zero Hour
  • Other (please specify below)

Bug Description

File GeneralsGameCode\GeneralsMD\Code\GameEngine\Source\GameLogic\AI\AIGroup.cpp

In AIGroup::groupMoveToPosition(), the tightenGroup size check incorrectly reuses the X span for both axes:
dy is computed from max.x - min.x instead of max.y - min.y.
This causes cells to be calculated as width² rather than width * height, so groupTightenToPosition() can be triggered or skipped based on group orientation instead of actual group size.


if (tightenGroup)
{
isFormation = false;
if (!addWaypoint) {
Int dx = (max.x-min.x)/PATHFIND_CELL_SIZE_F;
Int dy = (max.x-min.x)/PATHFIND_CELL_SIZE_F;
Int cells = (dx*dy);
if (cells<2000) {
groupTightenToPosition(pos, false, cmdSource);
return;
}
}
}

Maybbe instead ?

Int dx = (max.x - min.x) / PATHFIND_CELL_SIZE_F;
Int dy = (max.y - min.y) / PATHFIND_CELL_SIZE_F;
Int cells = dx * dy;

I'll leave it up to

#218 Relation to

Reproduction Steps

I have not yet been able to visually reproduce this in a player-visible way gameplay scenario.
So this bug is confirmed at the code level and logging shows that the tightenGroup logic is active for normal player movement commands.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    AIIs AI relatedBugSomething is not working right, typically is user facingGenRelates to GeneralsMinorSeverity: Minor < Major < Critical < BlockerZHRelates to Zero Hour

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions