Skip to content

Uninitialised Variables in Pathfinder::classifyFence (AiPathfind.cpp) may be causing unexpected AI behaviour #489

Closed
@Mauller

Description

@Mauller

Area(s) with this issue?

No response

Describe the issue

The IRegion2D cellBounds; variable on line 4031 is only being partly initialised.

Only the lo range values of x and y are being set leaving the hi range values uninitialised.
In other functions the hi range values are simply being set to the same as the lo range values.

I am not sure if this behaviour is valid but when using my own solution and checking values, the values end up around the same.

	IRegion2D cellBounds;
	cellBounds.lo.x = REAL_TO_INT_FLOOR((pos->x + 0.5f) / PATHFIND_CELL_SIZE_F);
	cellBounds.lo.y = REAL_TO_INT_FLOOR((pos->y + 0.5f) / PATHFIND_CELL_SIZE_F);
	cellBounds.hi.x = REAL_TO_INT_CEIL((pos->x + 0.5f) / PATHFIND_CELL_SIZE_F);
	cellBounds.hi.y = REAL_TO_INT_CEIL((pos->y + 0.5f) / PATHFIND_CELL_SIZE_F);

In Fighter19's build they set the high range values to zero, which i believe is also wrong as the cell bounds should be in the area of the position passed into the function. And setting the high bounds to zero could cause unintended behavious as well.

Steps to reproduce

Bug Exists within source code for Zero Hour only.

Attachments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething is not working rightExecutableIs game code relatedZHRelates to Zero Hour

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions