Markers - Fix issues with custom channels (#9383)

This commit is contained in:
Grim 2023-09-12 23:05:42 -04:00 committed by GitHub
parent 7a3e5dd3e0
commit f7b520b56b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 33 deletions

View File

@ -1,6 +1,6 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
/* /*
* Author: commy2, Timi007 * Author: commy2, Timi007, LinkIsGrim
* Return enabled channels. * Return enabled channels.
* *
* Arguments: * Arguments:
@ -17,33 +17,19 @@
params [["_localize", false, [false]]]; params [["_localize", false, [false]]];
private _currentChannel = currentChannel;
private _enabledChannels = []; private _enabledChannels = [];
private _currentChannel = currentChannel;
// Micro-optimization so we don't rebuild the array and localize in each iteration
private _engineChannels = CHANNEL_NAMES;
for "_channelId" from 0 to 15 do {
if (_channelId == 5) then {continue}; // Direct channel, ignore
if (setCurrentChannel _channelId) then {
if (_localize) then { if (_localize) then {
if (setCurrentChannel 0) then { _enabledChannels pushBack (_engineChannels param [_channelId, (radioChannelInfo (_channelId - 5)) select 1]); // radioChannelInfo works off custom IDs only, offset engine channels
_enabledChannels pushBack localize "str_channel_global";
};
if (setCurrentChannel 1) then {
_enabledChannels pushBack localize "str_channel_side";
};
if (setCurrentChannel 2) then {
_enabledChannels pushBack localize "str_channel_command";
};
if (setCurrentChannel 3) then {
_enabledChannels pushBack localize "str_channel_group";
};
if (setCurrentChannel 4) then {
_enabledChannels pushBack localize "str_channel_vehicle";
};
} else { } else {
for "_i" from 0 to 4 do { _enabledChannels pushBack _channelId;
if (setCurrentChannel _i) then {
_enabledChannels pushBack _i;
}; };
}; };
}; };

View File

@ -223,8 +223,7 @@
while {_i < lbSize _channel} do { while {_i < lbSize _channel} do {
private _channelName = _channel lbText _i; private _channelName = _channel lbText _i;
// _enabledChannels can not include custom channels names. Therefore also check if it's a custom one. Blame BI if the unit should not access the channel. if (_channelName in _enabledChannels) then {
if (_channelName in _enabledChannels || {!(_channelName in CHANNEL_NAMES)}) then {
_i = _i + 1; _i = _i + 1;
} else { } else {
_channel lbDelete _i; _channel lbDelete _i;
@ -238,13 +237,14 @@
currentChannel currentChannel
}; };
private _currentChannelName = CHANNEL_NAMES param [_selectChannel, localize "str_channel_group"]; // engine channels (0-4) can use names directly, custom channels need an offset for radioChannelInfo
private _selectChannelName = CHANNEL_NAMES param [_selectChannel, radioChannelInfo (_selectChannel - 5) select 1];
// select current channel in list box, must be done after lbDelete // select current channel in list box, must be done after lbDelete
for "_j" from 0 to (lbSize _channel - 1) do { for "_j" from 0 to (lbSize _channel - 1) do {
if (_channel lbText _j == _currentChannelName) then { if (_channel lbText _j == _selectChannelName) then {
_channel lbSetCurSel _j; _channel lbSetCurSel _j;
setCurrentChannel (CHANNEL_NAMES find _currentChannelName); setCurrentChannel _selectChannel;
}; };
}; };

View File

@ -1,6 +1,6 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
/* /*
* Author: commy2 * Author: commy2, LinkIsGrim
* When the channel list box is changed. * When the channel list box is changed.
* *
* Arguments: * Arguments:
@ -19,6 +19,6 @@
params ["_ctrl", "_index"]; params ["_ctrl", "_index"];
TRACE_2("params",_ctrl,_index); TRACE_2("params",_ctrl,_index);
private _channelName = _ctrl lbText _index; private _enabledChannels = false call FUNC(getEnabledChannels);
setCurrentChannel (CHANNEL_NAMES find _channelName); setCurrentChannel (_enabledChannels select _index);