Skip to content
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

SearchNearby Endless Loop #1544

Closed
mrzachhigginsofficial opened this issue Apr 26, 2022 · 3 comments
Closed

SearchNearby Endless Loop #1544

mrzachhigginsofficial opened this issue Apr 26, 2022 · 3 comments
Labels
Milestone

Comments

@mrzachhigginsofficial
Copy link
Contributor

Mods (complete and add to the following information):

  • Arma 3: x.xx [e.g. 1.00 stable, rc, dev]
  • CBA: fe3eba0
    Make sure to reproduce the issue with only CBA on a newly created mission!

Description:
CBA_fnc_SearchNearby is susceptible to an endless loop when pathing issues occur. In the excerpt below, you can see that the position is not removed until the unit is ready. If the unit does not reach its destination, it will never be ready. Therefore one unit in a group can cause this thread to stay open forever.
https://github.com/CBATeam/CBA_A3/blob/release/addons/ai/fnc_searchNearby.sqf

 while {_positions isNotEqualTo []} do {
        // Update units in case of death
        private _units = (units _group) - [_leader];

        // Abort search if the group has no units left
        if (_units isEqualTo []) exitWith {};

        // Send all available units to the next available position
        {
            if (_positions isEqualTo []) exitWith {};
            if (unitReady _x) then {
                private _pos = _positions deleteAt 0;
                _x commandMove _pos;
                sleep 2;
            };
        } forEach _units;
    };

In my opinion, there should be a failsafe in this loop (maybe a timeout).

private _starttime = time;
private _timeout = 240; //???

... stuff

while {_positions isNotEqualTo [] && __starttime + _timeout > time} do {
        // Update units in case of death
        private _units = (units _group) - [_leader];

        // Abort search if the group has no units left
        if (_units isEqualTo []) exitWith {};

        // Send all available units to the next available position
        {
            if (_positions isEqualTo []) exitWith {};
            if (unitReady _x) then {
                private _pos = _positions deleteAt 0;
                _x commandMove _pos;
                sleep 2;
            };
        } forEach _units;
    };

Not sure, just need some way to break this loop if there are pathing issues.

Steps to reproduce:

  • Assign this task to group of 5 or more units. Eventually, they will get stuck.

Expected behavior:

  • Units don't get stuck... forever.

Where did the issue occur?

  • Self Hosted Multiplayer (probably everywhere)

Log Files:

  • Not applicable. No error reported.

Additional context:
I will make a PR after work with my suggestion.

@mrzachhigginsofficial
Copy link
Contributor Author

Please review the PR. I found it was better to track each units time start and add a timeout evaluation with unitready.

@mrzachhigginsofficial
Copy link
Contributor Author

mrzachhigginsofficial commented May 16, 2022

image

In the provided screenshot, all 4 units in group1 are not moving. Since the loop depends on them being ready before the waypoint lock is removed, this will never be complete.

@jonpas
Copy link
Member

jonpas commented Sep 7, 2023

Addressed in #1547.

@jonpas jonpas closed this as completed Sep 7, 2023
@jonpas jonpas modified the milestones: 3.16.0, 3.15.7 Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants