From 1f96bdfedd93d369e18a38741cd8f9e255c5146d Mon Sep 17 00:00:00 2001 From: Shinriel Date: Sat, 22 Aug 2020 16:12:31 +0200 Subject: [PATCH 1/4] Add parameter to force target debug console from mission or server --- addons/common/stringtable.xml | 4 ++++ addons/diagnostic/XEH_preInit.sqf | 4 +++- addons/diagnostic/fnc_initTargetDebugConsole.sqf | 2 +- addons/diagnostic/initSettings.sqf | 12 ++++++++++++ addons/diagnostic/stringtable.xml | 4 ++++ addons/settings/fnc_addSetting.sqf | 2 +- 6 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 addons/diagnostic/initSettings.sqf diff --git a/addons/common/stringtable.xml b/addons/common/stringtable.xml index a691cb2e8f..10d68b6a12 100644 --- a/addons/common/stringtable.xml +++ b/addons/common/stringtable.xml @@ -38,5 +38,9 @@ CBA Armes CBA Оружие + + CBA Tools + CBA Outils + diff --git a/addons/diagnostic/XEH_preInit.sqf b/addons/diagnostic/XEH_preInit.sqf index 56401bb0e6..4aaaa37dfd 100644 --- a/addons/diagnostic/XEH_preInit.sqf +++ b/addons/diagnostic/XEH_preInit.sqf @@ -5,6 +5,8 @@ LOG(MSG_INIT); ADDON = false; +#include "initSettings.sqf" + #include "XEH_PREP.sqf" [QGVAR(debug), {_this call CBA_fnc_debug}] call CBA_fnc_addEventHandler; @@ -18,7 +20,7 @@ GVAR(projectileTrackedUnits) = []; ADDON = true; -if (getMissionConfigValue ["EnableTargetDebug", 0] == 1 || {getNumber (configFile >> "EnableTargetDebug") == 1}) then { +if (getMissionConfigValue ["EnableTargetDebug", 0] == 1 || {getNumber (configFile >> "EnableTargetDebug") == 1} || {GVAR(forceTargetDebug)}) then { INFO("EnableTargetDebug is enabled."); [QGVAR(watchVariable), { diff --git a/addons/diagnostic/fnc_initTargetDebugConsole.sqf b/addons/diagnostic/fnc_initTargetDebugConsole.sqf index 7026fd1e1e..8beb03cc62 100644 --- a/addons/diagnostic/fnc_initTargetDebugConsole.sqf +++ b/addons/diagnostic/fnc_initTargetDebugConsole.sqf @@ -18,7 +18,7 @@ Author: #define EXEC_RESULT_CTRL (parsingNamespace getVariable ["BIS_RscDebugConsoleExpressionResultCtrl", controlNull]) #define EXEC_SEND_RESULT {[EXEC_RESULT, {EXEC_RESULT_CTRL ctrlSetText str _this}] remoteExec ["call", remoteExecutedOwner]} -if !(getMissionConfigValue ["EnableTargetDebug", 0] == 1 || {getNumber (configFile >> "EnableTargetDebug") == 1}) exitWith {}; +if !(getMissionConfigValue ["EnableTargetDebug", 0] == 1 || {getNumber (configFile >> "EnableTargetDebug") == 1} || {GVAR(forceTargetDebug)}) exitWith {}; params ["_display"]; TRACE_1("adding server watch debug",_display); diff --git a/addons/diagnostic/initSettings.sqf b/addons/diagnostic/initSettings.sqf new file mode 100644 index 0000000000..4a579ba6f2 --- /dev/null +++ b/addons/diagnostic/initSettings.sqf @@ -0,0 +1,12 @@ + +[ + QGVAR(forceTargetDebug), + "CHECKBOX", + LLSTRING(ForceTargetDebug), + ELSTRING(common,ToolsCategory), + false, // default value + 1, // isGlobal + nil, + true +] call CBA_fnc_addSetting; + diff --git a/addons/diagnostic/stringtable.xml b/addons/diagnostic/stringtable.xml index 0fc507f547..7c170f67f7 100644 --- a/addons/diagnostic/stringtable.xml +++ b/addons/diagnostic/stringtable.xml @@ -92,5 +92,9 @@ [CBA] Abilita il debug remoto. Richiede la console di debug. [CBA] Povoluje ladění vzdáleného cíle. Vyžaduje ladící konzoli. + + Force target debugging for all missions + Forcer le débogage de la cible pour toutes les missions + diff --git a/addons/settings/fnc_addSetting.sqf b/addons/settings/fnc_addSetting.sqf index 7ba84c3fe9..11d45398f7 100644 --- a/addons/settings/fnc_addSetting.sqf +++ b/addons/settings/fnc_addSetting.sqf @@ -11,7 +11,7 @@ Parameters: _title - Display name or display name + tooltip (optional, default: same as setting name) _category - Category for the settings menu + optional sub-category _valueInfo - Extra properties of the setting depending of _settingType. See examples below - _isGlobal - 1: all clients share the same setting, 2: setting can't be overwritten (optional, default: 0) + _isGlobal - 1: all clients share the same setting, 2: setting can't be overwritten (optional, default: 0) _script - Script to execute when setting is changed. (optional) _needRestart - Setting will be marked as needing mission restart after being changed. (optional, default false) From a7faec45a9c43bf729a9d52d535efea03b758998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Duval?= Date: Mon, 24 Aug 2020 11:48:27 +0200 Subject: [PATCH 2/4] Rename ForceTargetDebug to EnableTargetDebug, Chance Utils category to Diagnostic category --- addons/common/stringtable.xml | 4 ---- addons/diagnostic/XEH_preInit.sqf | 2 +- addons/diagnostic/fnc_initTargetDebugConsole.sqf | 2 +- addons/diagnostic/initSettings.sqf | 6 +++--- addons/diagnostic/stringtable.xml | 12 +++++++++--- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/addons/common/stringtable.xml b/addons/common/stringtable.xml index 10d68b6a12..a691cb2e8f 100644 --- a/addons/common/stringtable.xml +++ b/addons/common/stringtable.xml @@ -38,9 +38,5 @@ CBA Armes CBA Оружие - - CBA Tools - CBA Outils - diff --git a/addons/diagnostic/XEH_preInit.sqf b/addons/diagnostic/XEH_preInit.sqf index 4aaaa37dfd..557364b80a 100644 --- a/addons/diagnostic/XEH_preInit.sqf +++ b/addons/diagnostic/XEH_preInit.sqf @@ -20,7 +20,7 @@ GVAR(projectileTrackedUnits) = []; ADDON = true; -if (getMissionConfigValue ["EnableTargetDebug", 0] == 1 || {getNumber (configFile >> "EnableTargetDebug") == 1} || {GVAR(forceTargetDebug)}) then { +if (getMissionConfigValue ["EnableTargetDebug", 0] == 1 || {getNumber (configFile >> "EnableTargetDebug") == 1} || {GVAR(enableTargetDebug)}) then { INFO("EnableTargetDebug is enabled."); [QGVAR(watchVariable), { diff --git a/addons/diagnostic/fnc_initTargetDebugConsole.sqf b/addons/diagnostic/fnc_initTargetDebugConsole.sqf index 8beb03cc62..40959e2d72 100644 --- a/addons/diagnostic/fnc_initTargetDebugConsole.sqf +++ b/addons/diagnostic/fnc_initTargetDebugConsole.sqf @@ -18,7 +18,7 @@ Author: #define EXEC_RESULT_CTRL (parsingNamespace getVariable ["BIS_RscDebugConsoleExpressionResultCtrl", controlNull]) #define EXEC_SEND_RESULT {[EXEC_RESULT, {EXEC_RESULT_CTRL ctrlSetText str _this}] remoteExec ["call", remoteExecutedOwner]} -if !(getMissionConfigValue ["EnableTargetDebug", 0] == 1 || {getNumber (configFile >> "EnableTargetDebug") == 1} || {GVAR(forceTargetDebug)}) exitWith {}; +if !(getMissionConfigValue ["EnableTargetDebug", 0] == 1 || {getNumber (configFile >> "EnableTargetDebug") == 1} || {GVAR(enableTargetDebug)}) exitWith {}; params ["_display"]; TRACE_1("adding server watch debug",_display); diff --git a/addons/diagnostic/initSettings.sqf b/addons/diagnostic/initSettings.sqf index 4a579ba6f2..2aabf682e9 100644 --- a/addons/diagnostic/initSettings.sqf +++ b/addons/diagnostic/initSettings.sqf @@ -1,9 +1,9 @@ [ - QGVAR(forceTargetDebug), + QGVAR(enableTargetDebug), "CHECKBOX", - LLSTRING(ForceTargetDebug), - ELSTRING(common,ToolsCategory), + LLSTRING(EnableTargetDebug), + LLSTRING(Category), false, // default value 1, // isGlobal nil, diff --git a/addons/diagnostic/stringtable.xml b/addons/diagnostic/stringtable.xml index 7c170f67f7..cf808d37e5 100644 --- a/addons/diagnostic/stringtable.xml +++ b/addons/diagnostic/stringtable.xml @@ -92,9 +92,15 @@ [CBA] Abilita il debug remoto. Richiede la console di debug. [CBA] Povoluje ladění vzdáleného cíle. Vyžaduje ladící konzoli. - - Force target debugging for all missions - Forcer le débogage de la cible pour toutes les missions + + CBA Diagnostics + CBA Diagnose + CBA Diagnostyka + Armi Diagnostica + Diagnostika CBA + CBA Teşhis + CBA Diagnostics + CBA Диагностика From 32f22a93a66ea902a914ad376a76df79026e4146 Mon Sep 17 00:00:00 2001 From: Shinriel Date: Fri, 28 Aug 2020 01:35:40 +0200 Subject: [PATCH 3/4] EnableTargetDebug wait for server overwriting settings --- addons/diagnostic/XEH_preInit.sqf | 12 +++++++++++- addons/diagnostic/fnc_initTargetDebugConsole.sqf | 9 +++++++-- addons/diagnostic/initSettings.sqf | 4 ++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/addons/diagnostic/XEH_preInit.sqf b/addons/diagnostic/XEH_preInit.sqf index 4aaaa37dfd..f2491773c3 100644 --- a/addons/diagnostic/XEH_preInit.sqf +++ b/addons/diagnostic/XEH_preInit.sqf @@ -20,7 +20,17 @@ GVAR(projectileTrackedUnits) = []; ADDON = true; -if (getMissionConfigValue ["EnableTargetDebug", 0] == 1 || {getNumber (configFile >> "EnableTargetDebug") == 1} || {GVAR(forceTargetDebug)}) then { +// Wait initializion of settings to set global variable +["CBA_settingsInitialized", { + GVAR(settingsInitialized) = true; +}] call CBA_fnc_addEventHandler; + +waitUntil{!isNil QGVAR(settingsInitialized)}; +if ( + getMissionConfigValue ["EnableTargetDebug", 0] == 1 + || {getNumber (configFile >> "EnableTargetDebug") == 1} + || {GVAR(enableTargetDebug)} +) then { INFO("EnableTargetDebug is enabled."); [QGVAR(watchVariable), { diff --git a/addons/diagnostic/fnc_initTargetDebugConsole.sqf b/addons/diagnostic/fnc_initTargetDebugConsole.sqf index 8beb03cc62..33d5bd9c76 100644 --- a/addons/diagnostic/fnc_initTargetDebugConsole.sqf +++ b/addons/diagnostic/fnc_initTargetDebugConsole.sqf @@ -5,7 +5,7 @@ Function: CBA_diagnostic_fnc_initTargetDebugConsole Description: Adds additional watch statements that are run on a remote target and have their values returned to the client. - Requires `EnableTargetDebug = 1;` in addon root config or description.ext or 3den scenario attribute with the same name + Requires `EnableTargetDebug = 1;` in addon root config or description.ext or 3den scenario attribute with the same name or in server/mission's config Author: (based on BIS's RscDebugConsole.sqf) @@ -18,7 +18,12 @@ Author: #define EXEC_RESULT_CTRL (parsingNamespace getVariable ["BIS_RscDebugConsoleExpressionResultCtrl", controlNull]) #define EXEC_SEND_RESULT {[EXEC_RESULT, {EXEC_RESULT_CTRL ctrlSetText str _this}] remoteExec ["call", remoteExecutedOwner]} -if !(getMissionConfigValue ["EnableTargetDebug", 0] == 1 || {getNumber (configFile >> "EnableTargetDebug") == 1} || {GVAR(forceTargetDebug)}) exitWith {}; +waitUntil{!isNil QGVAR(settingsInitialized)}; +if !( + getMissionConfigValue ["EnableTargetDebug", 0] == 1 + || {getNumber (configFile >> "EnableTargetDebug") == 1} + || {GVAR(enableTargetDebug)} +) exitWith {}; params ["_display"]; TRACE_1("adding server watch debug",_display); diff --git a/addons/diagnostic/initSettings.sqf b/addons/diagnostic/initSettings.sqf index 4a579ba6f2..67104dffb6 100644 --- a/addons/diagnostic/initSettings.sqf +++ b/addons/diagnostic/initSettings.sqf @@ -1,8 +1,8 @@ [ - QGVAR(forceTargetDebug), + QGVAR(enableTargetDebug), "CHECKBOX", - LLSTRING(ForceTargetDebug), + LLSTRING(EnableTargetDebug), ELSTRING(common,ToolsCategory), false, // default value 1, // isGlobal From 72370d0d0971633bca68875d8a1fb485ba2e31b3 Mon Sep 17 00:00:00 2001 From: Shinriel Date: Sun, 30 Aug 2020 02:33:24 +0200 Subject: [PATCH 4/4] Fix scheduled and wait settingsInitialized event --- addons/diagnostic/XEH_preInit.sqf | 102 +++++++++++++++-------------- addons/diagnostic/initSettings.sqf | 2 +- 2 files changed, 53 insertions(+), 51 deletions(-) diff --git a/addons/diagnostic/XEH_preInit.sqf b/addons/diagnostic/XEH_preInit.sqf index f2491773c3..f5ffe64b9c 100644 --- a/addons/diagnostic/XEH_preInit.sqf +++ b/addons/diagnostic/XEH_preInit.sqf @@ -25,60 +25,62 @@ ADDON = true; GVAR(settingsInitialized) = true; }] call CBA_fnc_addEventHandler; -waitUntil{!isNil QGVAR(settingsInitialized)}; -if ( - getMissionConfigValue ["EnableTargetDebug", 0] == 1 - || {getNumber (configFile >> "EnableTargetDebug") == 1} - || {GVAR(enableTargetDebug)} -) then { - INFO("EnableTargetDebug is enabled."); - - [QGVAR(watchVariable), { - params ["_clientID", "_varIndex", "_statementText"]; - TRACE_3("targetWatchVariable",_clientID,_varIndex,_statementText); - - private _timeStart = diag_tickTime; - private _returnString = _statementText call { - private ["_clientID", "_statementText", "_varName", "_timeStart", "_x"]; // prevent these variables from being overwritten - _this = ([nil] apply compile _this) select 0; - if (isNil "_this") exitWith {""}; - str _this +0 spawn { + waitUntil{!(isNil QGVAR(settingsInitialized))}; + if ( + getMissionConfigValue ["EnableTargetDebug", 0] == 1 + || {getNumber (configFile >> "EnableTargetDebug") == 1} + || {GVAR(enableTargetDebug)} + ) then { + INFO("EnableTargetDebug is enabled."); + + [QGVAR(watchVariable), { + params ["_clientID", "_varIndex", "_statementText"]; + TRACE_3("targetWatchVariable",_clientID,_varIndex,_statementText); + + private _timeStart = diag_tickTime; + private _returnString = _statementText call { + private ["_clientID", "_statementText", "_varName", "_timeStart", "_x"]; // prevent these variables from being overwritten + _this = ([nil] apply compile _this) select 0; + if (isNil "_this") exitWith {""}; + str _this + }; + _returnString = _returnString select [0, 1000]; // limit string length + private _duration = diag_tickTime - _timeStart; + + private _varName = format ["CBA_targetWatchVar_%1_%2", _clientID, _varIndex]; + (missionNamespace getVariable [_varName, []]) params [["_responseStatement", "", [""]], ["_responseReturn", "", [""]], ["_lastDuration", 0, [0]]]; + + if (_responseStatement isEqualTo _statementText) then { + _duration = 0.1 * _duration + 0.9 * _lastDuration; // if statement is the same, get an average + }; + + missionNamespace setVariable [_varName, [_statementText, _returnString, _duration]]; + if (_clientID != CBA_clientID) then { + publicVariable _varName; // send back over network + }; + }] call CBA_fnc_addEventHandler; + + + if (isNil QGVAR(clientIDs)) then { + GVAR(clientIDs) = [[2, format ["[SERVER] %1", profileName]]]; }; - _returnString = _returnString select [0, 1000]; // limit string length - private _duration = diag_tickTime - _timeStart; - private _varName = format ["CBA_targetWatchVar_%1_%2", _clientID, _varIndex]; - (missionNamespace getVariable [_varName, []]) params [["_responseStatement", "", [""]], ["_responseReturn", "", [""]], ["_lastDuration", 0, [0]]]; + if (isServer) then { + addMissionEventHandler ["PlayerConnected", { + params ["", "", "_name", "", "_owner"]; - if (_responseStatement isEqualTo _statementText) then { - _duration = 0.1 * _duration + 0.9 * _lastDuration; // if statement is the same, get an average - }; - - missionNamespace setVariable [_varName, [_statementText, _returnString, _duration]]; - if (_clientID != CBA_clientID) then { - publicVariable _varName; // send back over network - }; - }] call CBA_fnc_addEventHandler; + if (_owner == 2) exitWith {}; + GVAR(clientIDs) pushBackUnique [_owner, _name]; + publicVariable QGVAR(clientIDs); + }]; + addMissionEventHandler ["PlayerDisconnected", { + params ["", "", "_name", "", "_owner"]; - if (isNil QGVAR(clientIDs)) then { - GVAR(clientIDs) = [[2, format ["[SERVER] %1", profileName]]]; - }; - - if (isServer) then { - addMissionEventHandler ["PlayerConnected", { - params ["", "", "_name", "", "_owner"]; - - if (_owner == 2) exitWith {}; - GVAR(clientIDs) pushBackUnique [_owner, _name]; - publicVariable QGVAR(clientIDs); - }]; - - addMissionEventHandler ["PlayerDisconnected", { - params ["", "", "_name", "", "_owner"]; - - GVAR(clientIDs) deleteAt (GVAR(clientIDs) find [_owner, _name]); - publicVariable QGVAR(clientIDs); - }]; + GVAR(clientIDs) deleteAt (GVAR(clientIDs) find [_owner, _name]); + publicVariable QGVAR(clientIDs); + }]; + }; }; }; diff --git a/addons/diagnostic/initSettings.sqf b/addons/diagnostic/initSettings.sqf index 67104dffb6..2aabf682e9 100644 --- a/addons/diagnostic/initSettings.sqf +++ b/addons/diagnostic/initSettings.sqf @@ -3,7 +3,7 @@ QGVAR(enableTargetDebug), "CHECKBOX", LLSTRING(EnableTargetDebug), - ELSTRING(common,ToolsCategory), + LLSTRING(Category), false, // default value 1, // isGlobal nil,