CBA_A3 icon indicating copy to clipboard operation
CBA_A3 copied to clipboard

Have CBA_fnc_players return player logic entities

Open Freddo3000 opened this issue 3 years ago • 4 comments

When merged this pull request will:

  • Make CBA_fnc_players return player logic entities

Strange that there's a check for headless clients even though there was seemingly no way for the function to list logic entities previously. This allows the function to list player spectator/Zeus logic entities and similar.

Freddo3000 avatar Jul 30 '21 18:07 Freddo3000

I'm worried about side effects from including virtual units in this list

e.g. acre_sys_rack uses _player = ([] call CBA_fnc_players) select 0; as a backup default value I'm not sure what will happen if it now uses spectator or virtual-zeus for that (but I haven't tested it)

perhaps we should add an optional arg to include virtual entities?

PabstMirror avatar Jul 30 '21 18:07 PabstMirror

I'm worried about side effects from including virtual units in this list

e.g. acre_sys_rack uses _player = ([] call CBA_fnc_players) select 0; as a backup default value I'm not sure what will happen if it now uses spectator or virtual-zeus for that (but I haven't tested it)

perhaps we should add an optional arg to include virtual entities?

I've got similar thoughts, but right now the description of the function seems to imply that logic entities should be included (but currently aren't).

Freddo3000 avatar Jul 30 '21 19:07 Freddo3000

Reports all (human) player objects

I don't think a spectator is human

PabstMirror avatar Jul 30 '21 19:07 PabstMirror

Reports all (human) player objects

I don't think a spectator is human

Fair enough, was more looking at the Headless Client part.

Freddo3000 avatar Jul 30 '21 19:07 Freddo3000

I am not sure about this, seems like a very very edge case. And are you sure allUnits doesn't include headless clients? When a headless client entity is marked as "playable" it should be included.

jonpas avatar Aug 17 '23 12:08 jonpas

I am not sure about this, seems like a very very edge case. And are you sure allUnits doesn't include headless clients? When a headless client entity is marked as "playable" it should be included.

I can't say off the top of my head, I don't have a workable Arma install at the moment to check and this PR is two years old. Feel free to commit your suggestions, as I'm getting an github error trying to commit them via the web.

Freddo3000 avatar Sep 10 '23 19:09 Freddo3000

Fair. I think best way to go about this is to remove the !(_x isKindOf "HeadlessClient_F") check from the function. @Mike-MF has confirmed for us that allUnits never returns Headless Clients entities, be it playable, player etc.

I believe this condition originally came from the deprecation of this function in favour of allPlayers, but that was quickly changed as allPlayers returns virtual entities. This condition was probably left in by mistake of first writing it using allPlayers, but was changed to allUnits + allDead(Men) - this is a guess as commit history only confirms the first part of this theory.

Anyways, as for this function returning logics, one should just use allPlayers command for that, I see no reason for additional argument. Wiki has some nice examples of filtering that too.

Alternatively, we just don't change the function at all, as there might have been a forgotten case of allUnits or allDead(Men) returning Headless Clients... Now that I think about it allDead(Men) wiki says it includes agents, so there might be a case of dead Headless Client entities?

I will close this and if someone wants to do more research and provide proof, I would be happy to change it.

jonpas avatar Sep 10 '23 22:09 jonpas