Bug #27778

Infinite loop in crbconvoys main.sqf when no groups of expected type

Added by Jedra over 5 years ago. Updated about 5 years ago.

Status:Closed Start date:01/13/2012
Priority:Normal Due date:
Assignee:Jedra % Done:


Target version:Multi-Session Operations - MSO v4.3
Component:CORE Reproduced by another DH user:No
Close Reason: I am using some Mods:No
Affected Version:


When using a factions that do not have groups (CfgGroups>>side>>Faction>>Type) configured for types "Motorized", "Mechanized" and "Armored" crbconvoys/main.sqf gets into an infinite loop in the call to mso_core_fnc_randomGroup;

Code around line 81 of crbconvoys/main.sqf...

while{isNil "_grp"} do {
        diag_log format ["Trying to Create Group for Convoy %1", _j];
        _front = [["Motorized","Mechanized","Armored"],[4,2,1]] call mso_core_fnc_selectRandomBias;
        _facs = MSO_FACTIONS;
        _grp = [_startpos, _front, _facs] call mso_core_fnc_randomGroup;

The code in mso_core_fnc_randomGroup (fn_randomgroup.sqf) will exit if the faction exists, but no units of this type exist...

code around line 80 of /core/functions/common/fn_randomgroup.sqf...

if(!isNil "_facs") then {
        _facx = [];
                _s = switch(_x) do {
                        case resistance: {"Guerrila";};
                        case civilian: {"Civilian";};
                        default {str _x;};

                private ["_x"];
                // Confirm there are units for this faction in this type
                        _grpx = count(configFile >> "CfgGroups" >> _s >> _x >> _type);
                        for "_y" from 1 to _grpx - 1 do {
                                if (!(_x in _facx)) then {
                                        _facx set [count _facx, _x];
                } forEach _facs;
        } forEach [west,east,resistance,civilian];

        _facs = _facx;
if (count _facs == 0) exitWith{nil;};

The while loop in the first code segment keeps the loop running as the faction I tested with (IRAN) does not have ANY of these group types. This causes the second portion of code to exit with nil continually.

Maybe I am trying to do something unexpected by only using a custom faction, but I thought I would report it anyway. Even so, there are a few addons out there which do not have properly formed Groups which people may wish to use.

If there's anything else you need to assist, let me know.

I have a feeling there's a similar issue in the WICT module too, but I need to investigate that further - will raise another bug if I find something.


Updated by Jedra over 5 years ago

There is a similar issue in enemy/modules/WICT_enemypop/main.sqf

code around line 296...

_type = [["Infantry", "Motorized", "Mechanized", "Armored"],[4,3,2,1]] call mso_core_fnc_selectRandomBias;

private ["_pos","_pos2","_flag","_group","_grp2","_type","_params","_handle"];
                    _params = _this select 0;
                    _handle = _this select 1;
                    _pos = _params select 0;
                    _flag = _params select 1;
                    _type= _params select 2;
                    if(([_pos, ep_dist] call fPlayersInside)) then {
                            [_handle] call mso_core_fnc_removeLoopHandler;
                            _group = nil;
                            _pos2 = [_pos, 10, 50, 10, 0, 5, 0] call bis_fnc_findSafePos;

    while{isNil "_group"} do {
                                    _group = [_pos2, _type, MSO_FACTIONS] call mso_core_fnc_randomGroup;
                            diag_log format ["Group is : %1", _group];
                            (leader _group) setBehaviour "AWARE";
                            _group setSpeedMode "LIMITED";
                            _group setFormation "STAG COLUMN";
    [_group] call BIN_fnc_taskDefend;

The while loop will go indefinitely if any one of Infanty, Motorized, Mechanized and Armoured are selected and they do not exist as part of a group config for the faction.

Updated by wolffy.au over 5 years ago

  • Project changed from Multi-Session Operations to MSO Enemy Generation

Updated by Tupolov over 5 years ago

  • Target version set to MSO v4.3

Updated by Tupolov over 5 years ago

  • Assignee set to highhead

Updated by highhead over 5 years ago

  • Status changed from New to In progress

Updated by highhead over 5 years ago

Quickwin/workaround: add a failsafe in while-loops so at least mso isnt broken on startup
Solution: fix findrandomgroup-function to not be dependend on groupconfigs (findvehiclebytype-function)

Updated by highhead about 5 years ago

  • Status changed from In progress to Resolved
  • % Done changed from 0 to 100

made a function that creates units of certain type if no groupconfigs are defined.

Updated by Tupolov about 5 years ago

  • Status changed from Resolved to Feedback
  • Assignee changed from highhead to Jedra
  • Component set to CORE

Need feedback from Jedra once 4.3 is released to him for testing.

Updated by Tupolov about 5 years ago

  • Status changed from Feedback to Closed

Fixed in 4.3

Also available in: Atom PDF