From 15374de6979999b8e21fb3759d31e80b85caf262 Mon Sep 17 00:00:00 2001 From: Julien Date: Tue, 28 Feb 2023 07:56:27 +0100 Subject: [PATCH 1/7] Acoustic gunshot detector core logic --- @cTab/addons/acousticdetector/$PBOPREFIX$ | 1 + .../acousticdetector/CfgEventHandlers.hpp | 15 ++++ @cTab/addons/acousticdetector/XEH_PREP.hpp | 5 ++ .../acousticdetector/XEH_postInitClient.sqf | 15 ++++ @cTab/addons/acousticdetector/XEH_preInit.sqf | 8 ++ .../addons/acousticdetector/XEH_preStart.sqf | 2 + @cTab/addons/acousticdetector/config.cpp | 15 ++++ .../functions/fnc_applySettings.sqf | 18 ++++ .../functions/fnc_computeAmmoCaliberType.sqf | 65 ++++++++++++++ .../functions/fnc_firedManEH.sqf | 27 ++++++ .../functions/fnc_simulatePFH.sqf | 90 +++++++++++++++++++ .../functions/fnc_updateActiveState.sqf | 34 +++++++ .../functions/script_component.hpp | 1 + .../acousticdetector/script_component.hpp | 24 +++++ @cTab/addons/acousticdetector/stringtable.xml | 27 ++++++ 15 files changed, 347 insertions(+) create mode 100644 @cTab/addons/acousticdetector/$PBOPREFIX$ create mode 100644 @cTab/addons/acousticdetector/CfgEventHandlers.hpp create mode 100644 @cTab/addons/acousticdetector/XEH_PREP.hpp create mode 100644 @cTab/addons/acousticdetector/XEH_postInitClient.sqf create mode 100644 @cTab/addons/acousticdetector/XEH_preInit.sqf create mode 100644 @cTab/addons/acousticdetector/XEH_preStart.sqf create mode 100644 @cTab/addons/acousticdetector/config.cpp create mode 100644 @cTab/addons/acousticdetector/functions/fnc_applySettings.sqf create mode 100644 @cTab/addons/acousticdetector/functions/fnc_computeAmmoCaliberType.sqf create mode 100644 @cTab/addons/acousticdetector/functions/fnc_firedManEH.sqf create mode 100644 @cTab/addons/acousticdetector/functions/fnc_simulatePFH.sqf create mode 100644 @cTab/addons/acousticdetector/functions/fnc_updateActiveState.sqf create mode 100644 @cTab/addons/acousticdetector/functions/script_component.hpp create mode 100644 @cTab/addons/acousticdetector/script_component.hpp create mode 100644 @cTab/addons/acousticdetector/stringtable.xml diff --git a/@cTab/addons/acousticdetector/$PBOPREFIX$ b/@cTab/addons/acousticdetector/$PBOPREFIX$ new file mode 100644 index 00000000..c811f548 --- /dev/null +++ b/@cTab/addons/acousticdetector/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ctab\addons\acousticdetector diff --git a/@cTab/addons/acousticdetector/CfgEventHandlers.hpp b/@cTab/addons/acousticdetector/CfgEventHandlers.hpp new file mode 100644 index 00000000..d3d0d195 --- /dev/null +++ b/@cTab/addons/acousticdetector/CfgEventHandlers.hpp @@ -0,0 +1,15 @@ +class Extended_PreStart_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preStart)); + }; +}; +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; +class Extended_PostInit_EventHandlers { + class ADDON { + clientInit = QUOTE(call COMPILE_FILE(XEH_postInitClient)); + }; +}; diff --git a/@cTab/addons/acousticdetector/XEH_PREP.hpp b/@cTab/addons/acousticdetector/XEH_PREP.hpp new file mode 100644 index 00000000..224b5bcd --- /dev/null +++ b/@cTab/addons/acousticdetector/XEH_PREP.hpp @@ -0,0 +1,5 @@ +PREP(computeAmmoCaliberType); +PREP(firedManEH); +PREP(simulatePFH); +PREP(updateActiveState); +PREP(applySettings); diff --git a/@cTab/addons/acousticdetector/XEH_postInitClient.sqf b/@cTab/addons/acousticdetector/XEH_postInitClient.sqf new file mode 100644 index 00000000..3a669c00 --- /dev/null +++ b/@cTab/addons/acousticdetector/XEH_postInitClient.sqf @@ -0,0 +1,15 @@ +#include "script_component.hpp" + +if (!hasInterface) exitWith {}; + +GVAR(caliberTypeCache) = createHashMap; +GVAR(shotsToProcess) = []; +GVAR(detectedShots) = []; +GVAR(distanceLimitPerCaliber) = [250, 750, 350, 550, 1000, 1350, 1650, 2400]; +GVAR(caliberLabel) = ["Rocket", "Missile", "5.56mm", "7.62mm", "12.7mm", "14.5mm", "20-40mm", "90mm+"]; +GVAR(nextShotId) = 1; +GVAR(isActive) = false; +GVAR(pfhHandle) = -1; +GVAR(isInitialized) = false; + +["CBA_settingsInitialized", FUNC(applySettings)] call CBA_fnc_addEventHandler; diff --git a/@cTab/addons/acousticdetector/XEH_preInit.sqf b/@cTab/addons/acousticdetector/XEH_preInit.sqf new file mode 100644 index 00000000..0079ae0c --- /dev/null +++ b/@cTab/addons/acousticdetector/XEH_preInit.sqf @@ -0,0 +1,8 @@ +#include "script_component.hpp" +ADDON = false; +#include "XEH_PREP.hpp" +ADDON = true; + +[QGVAR(enable), "CHECKBOX", [LLSTRING(enable), LLSTRING(enableDetails)], ["cTab", LLSTRING(acousticdetector)], false, 0, FUNC(applySettings)] call CBA_fnc_addSetting; +[QGVAR(shotsTrackTimeLimit), "TIME", [LLSTRING(timeLimit), LLSTRING(timeLimitDetails)], ["cTab", LLSTRING(acousticdetector)], [10, 120, 30]] call CBA_fnc_addSetting; + diff --git a/@cTab/addons/acousticdetector/XEH_preStart.sqf b/@cTab/addons/acousticdetector/XEH_preStart.sqf new file mode 100644 index 00000000..a51262a3 --- /dev/null +++ b/@cTab/addons/acousticdetector/XEH_preStart.sqf @@ -0,0 +1,2 @@ +#include "script_component.hpp" +#include "XEH_PREP.hpp" diff --git a/@cTab/addons/acousticdetector/config.cpp b/@cTab/addons/acousticdetector/config.cpp new file mode 100644 index 00000000..9e8ebcd4 --- /dev/null +++ b/@cTab/addons/acousticdetector/config.cpp @@ -0,0 +1,15 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + name = QUOTE(COMPONENT); + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ctab_main","ctab_core"}; + author = "GrueArbre"; + VERSION_CONFIG; + }; +}; + +#include "CfgEventHandlers.hpp" diff --git a/@cTab/addons/acousticdetector/functions/fnc_applySettings.sqf b/@cTab/addons/acousticdetector/functions/fnc_applySettings.sqf new file mode 100644 index 00000000..98244a73 --- /dev/null +++ b/@cTab/addons/acousticdetector/functions/fnc_applySettings.sqf @@ -0,0 +1,18 @@ +#include "script_component.hpp" + +if ( !hasInterface ) exitWith {}; + +TRACE_2("applySettings", GVAR(enable), GVAR(isInitialized)); + +if ( GVAR(enable) ) then { + if ( !GVAR(isInitialized) ) then { + LOG("Initialize events for Acoustic gunshot detector"); + ["CAManBase", "firedMan", FUNC(firedManEH)] call CBA_fnc_addClassEventHandler; + ["unit", FUNC(updateActiveState)] call CBA_fnc_addPlayerEventHandler; + ["turret", FUNC(updateActiveState)] call CBA_fnc_addPlayerEventHandler; + ["vehicle", FUNC(updateActiveState)] call CBA_fnc_addPlayerEventHandler; + GVAR(isInitialized) = true; + }; +}; + +call FUNC(updateActiveState); diff --git a/@cTab/addons/acousticdetector/functions/fnc_computeAmmoCaliberType.sqf b/@cTab/addons/acousticdetector/functions/fnc_computeAmmoCaliberType.sqf new file mode 100644 index 00000000..3db98b8c --- /dev/null +++ b/@cTab/addons/acousticdetector/functions/fnc_computeAmmoCaliberType.sqf @@ -0,0 +1,65 @@ +#include "script_component.hpp" +params ['_ammo']; +private _cfgAmmo = configFile >> "CfgAmmo"; +if (_ammo isKindOf ["BulletBase", _cfgAmmo]) exitWith { + private _ace_caliber = getNumber (_cfgAmmo >> _ammo >> "ace_caliber"); + if (_ace_caliber == 0) then { + _ace_caliber = getNumber (_cfgAmmo >> _ammo >> "ace_rearm_caliber"); + }; + if (_ace_caliber == 0) exitWith { + private _caliber = getNumber (_cfgAmmo >> _ammo >> "caliber"); + if ( _caliber <= 1 ) exitWith { + CALIBER_556 + }; + if ( _caliber <= 2 ) exitWith { + CALIBER_762 + }; + if ( _caliber <= 3 ) exitWith { + CALIBER_1270 + }; + private _hit = getNumber (_cfgAmmo >> _ammo >> "hit"); + if ( _hit > 20 ) exitWith { + CALIBER_2000 + }; + CALIBER_1450 + }; + if ( _ace_caliber < 6 ) exitWith { + CALIBER_556 + }; + if ( _ace_caliber < 8 ) exitWith { + CALIBER_762 + }; + if ( _ace_caliber < 13 ) exitWith { + CALIBER_1270 + }; + if ( _ace_caliber >= 20 ) exitWith { + CALIBER_2000 + }; + CALIBER_1450 +}; +if (_ammo isKindOf ["ShellBase", _cfgAmmo]) exitWith { + if (_ammo isKindOf ["ace_explosion_reflection_base", _cfgAmmo]) exitWith { + INFO_1("Ammo %1 is IGNORED", _ammo); + CALIBER_UNSUPPORTED + }; + private _ace_caliber = getNumber (_cfgAmmo >> _ammo >> "ace_rearm_caliber"); + if (_ace_caliber == 0) exitWith { + private _caliber = getNumber (_cfgAmmo >> _ammo >> "caliber"); + if ( _caliber < 10 ) exitWith { + CALIBER_2000 + }; + CALIBER_9000 + }; + if (_ace_caliber < 90) exitWith { + CALIBER_2000 + }; + CALIBER_9000 +}; +if (_ammo isKindOf ["RocketBase", _cfgAmmo]) exitWith { + CALIBER_ROCKET +}; +if (_ammo isKindOf ["MissileBase", _cfgAmmo]) exitWith { + CALIBER_MISSILE +}; +INFO_1("Ammo %1 is IGNORED", _ammo); +CALIBER_UNSUPPORTED \ No newline at end of file diff --git a/@cTab/addons/acousticdetector/functions/fnc_firedManEH.sqf b/@cTab/addons/acousticdetector/functions/fnc_firedManEH.sqf new file mode 100644 index 00000000..02cad311 --- /dev/null +++ b/@cTab/addons/acousticdetector/functions/fnc_firedManEH.sqf @@ -0,0 +1,27 @@ +#include "script_component.hpp" + +if ( !GVAR(isActive) ) exitWith { }; + +params ["_unit", "", "", "", "_ammo", "", "_projectile", "_vehicle"]; + +if ( _unit == player || { _vehicle == vehicle player } ) exitWith {}; // system is able to ignore shots from vehicle + +private _pos1 = if ( isNull _vehicle ) then { getPosASL _unit } else { getPosASL _vehicle }; +private _pos2 = getPosASL _projectile; + +// TODO: Arma 2.12 => private _caliber = GVAR(caliberTypeCache) getOrDefaultCall [_ammo, {[_ammo] call FUNC(computeAmmoCaliberType)}, true]; + +private _caliber = GVAR(caliberTypeCache) getOrDefault [_ammo,-2]; +if (_caliber == -2) then { + _caliber = [_ammo] call FUNC(computeAmmoCaliberType); + GVAR(caliberTypeCache) set [_ammo, _caliber]; +}; + +if ( _caliber != -1 ) then { + // Register shot for PFH + #ifdef DEBUG_MODE_FULL + private _caliberLabel = GVAR(caliberLabel) select _caliber; + TRACE_4("FiredMan", _pos1, _pos2, _ammo, _caliberLabel); + #endif + GVAR(shotsToProcess) pushBack [diag_tickTime, _pos1, _caliber]; +}; diff --git a/@cTab/addons/acousticdetector/functions/fnc_simulatePFH.sqf b/@cTab/addons/acousticdetector/functions/fnc_simulatePFH.sqf new file mode 100644 index 00000000..719035e9 --- /dev/null +++ b/@cTab/addons/acousticdetector/functions/fnc_simulatePFH.sqf @@ -0,0 +1,90 @@ +#include "script_component.hpp" + +if ( !GVAR(isActive) ) exitWith { }; + +private _now = diag_tickTime; + +// Remove outdated detected shots +private _count = count GVAR(detectedShots); +GVAR(detectedShots) = GVAR(detectedShots) select { _now - (_x select 0) < GVAR(shotsTrackTimeLimit) }; +private _changed = _count != count GVAR(detectedShots); + +// Process any pending shots +if ( count GVAR(shotsToProcess) > 0 ) then { + + private _shots = GVAR(shotsToProcess); + GVAR(shotsToProcess) = []; + + private _position = getPosASL vehicle player; + private _soundSpeed = 340; // meter per seconds + + if (!isNil "ace_weather_currentTemperature") then { + // ACE if present, can give temperature + // temperature have an effect on sound speed + // Approximated to 331.5 + (0.607 * tempInCelcius) + // better approximation to consider : 20.05 * sqrt(tempInCelcius+273.15) + _soundSpeed = 331.5 + (0.607 * (ace_weather_currentTemperature - 0.0065 * (_position select 2))); + }; + + { + _x params ['_time', '_source', '_caliber']; + private _distance = _position vectorDistance _source; + private _limit = GVAR(distanceLimitPerCaliber) select _caliber; + if ( (_now - _time) > (_distance / _soundSpeed) ) then { + // sound had time to travel to our position + + if ( _distance < _limit ) then { + + // gunshot is at a detectable distance, let's detect him + private _detectedDir = (_position getDir _source) + (random [-2, 0, +2]); // +/- 2° + private _detectedDistance = _distance * (random [0.9, 1, 1.1]); // +/- 10% + private _point = _position getPos [_detectedDistance, _detectedDir]; + private _pointA = _position getPos [_detectedDistance + (_distance * 0.1), _detectedDir - 2]; + private _pointB = _position getPos [_detectedDistance - (_distance * 0.1), _detectedDir - 2]; + private _pointC = _position getPos [_detectedDistance - (_distance * 0.1), _detectedDir + 2]; + private _pointD = _position getPos [_detectedDistance + (_distance * 0.1), _detectedDir + 2]; + private _radius = _point vectorDistance _pointA; + private _shotId = GVAR(nextShotId); + private _data = [ _now, _shotId, _point, _radius, [_pointA, _pointB, _pointC, _pointD], _caliber]; + GVAR(detectedShots) pushBack _data; + TRACE_1("DetectedShot", _data); + _changed = true; + GVAR(nextShotId) = GVAR(nextShotId) + 1; + +#ifdef DEBUG_MODE_FULL + private _marker = createMarker [ format ['_USER_DEFINED #0/shot%1A/0', _shotId], _pointA]; + _marker setMarkerShape 'polyline'; + _marker setMarkerPolyline ((_pointA select [0,2]) + (_pointB select [0,2]) + (_pointC select [0,2]) +(_pointD select [0,2]) +(_pointA select [0,2])); + _marker setMarkerColor "ColorRed"; + + _marker = createMarker [format ['_USER_DEFINED #0/shot%1C/0', _shotId], _point]; + _marker setMarkerShape "ELLIPSE"; + _marker setMarkerColor "ColorRed"; + _marker setMarkerSize [_radius, _radius]; + + _marker = createMarker [format ['_USER_DEFINED #0/shot%1R/0', _shotId], _source]; + _marker setMarkerType "mil_dot"; + _marker setMarkerColor "ColorBlack"; +#endif + }; + + } else { + // sound did not have time to get to our position + if ( _distance < _limit * 1.2 ) then { + // A ground vehicle speed will always be slower than sound + // Lets consider vehicle max speed 216km/h => 60m/s (really fast for a ground vehicle) + // Slowest sound condition, will be be 300m/s (extremely cold weather => -50°C) + // Even if we drive in the direction of the gunshot, we will never detect him + // if distance is larger than 20% the kimit (=60/300) + GVAR(shotsToProcess) pushBack _x; + }; + }; + } forEach _shots; + + +}; + +if ( _changed ) then { + TRACE_1("Update", GVAR(detectedShots)); + [QGVAR(update)] call CBA_fnc_localEvent; +}; diff --git a/@cTab/addons/acousticdetector/functions/fnc_updateActiveState.sqf b/@cTab/addons/acousticdetector/functions/fnc_updateActiveState.sqf new file mode 100644 index 00000000..5566b012 --- /dev/null +++ b/@cTab/addons/acousticdetector/functions/fnc_updateActiveState.sqf @@ -0,0 +1,34 @@ +#include "script_component.hpp" + +private _isActive = false; + +if ( GVAR(enable) ) then { + + private _vehicle = vehicle ctab_player; + if ( _vehicle != ctab_player) then { + private _cargoIndex = _vehicle getCargoIndex ctab_player; + if (_cargoIndex == -1) then { + _isActive = true; // TODO : check vehicle has acoustic detector + }; + }; + +}; + +TRACE_3("updateActiveState", GVAR(enable), _isActive, GVAR(isActive)); + +if ( _isActive != GVAR(isActive) ) then { + if ( _isActive ) then { + if ( GVAR(pfhHandle) == -1 ) then { + LOG("Acoustic gunshot detector is started"); + GVAR(pfhHandle) = [FUNC(simulatePFH)] call CBA_fnc_addPerFrameHandler; + }; + } + else + { + if ( GVAR(pfhHandle) != -1 ) then { + LOG("Acoustic gunshot detector is stopped"); + [GVAR(pfhHandle)] call CBA_fnc_removePerFrameHandler; + GVAR(pfhHandle) = -1; + }; + }; +}; diff --git a/@cTab/addons/acousticdetector/functions/script_component.hpp b/@cTab/addons/acousticdetector/functions/script_component.hpp new file mode 100644 index 00000000..593284a6 --- /dev/null +++ b/@cTab/addons/acousticdetector/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\ctab\addons\acousticdetector\script_component.hpp" diff --git a/@cTab/addons/acousticdetector/script_component.hpp b/@cTab/addons/acousticdetector/script_component.hpp new file mode 100644 index 00000000..da42d70b --- /dev/null +++ b/@cTab/addons/acousticdetector/script_component.hpp @@ -0,0 +1,24 @@ +#define COMPONENT acousticdetector +#include "\z\ctab\addons\main\script_mod.hpp" + + #define DEBUG_MODE_FULL + #define DISABLE_COMPILE_CACHE + +#ifdef DEBUG_ENABLED_CORE + #define DEBUG_MODE_FULL +#endif + #ifdef DEBUG_SETTINGS_OTHER + #define DEBUG_SETTINGS DEBUG_SETTINGS_CORE +#endif + +#include "\z\ctab\addons\main\script_macros.hpp" + +#define CALIBER_UNSUPPORTED -1 +#define CALIBER_ROCKET 0 +#define CALIBER_MISSILE 1 +#define CALIBER_556 2 +#define CALIBER_762 3 +#define CALIBER_1270 4 +#define CALIBER_1450 5 +#define CALIBER_2000 6 +#define CALIBER_9000 7 diff --git a/@cTab/addons/acousticdetector/stringtable.xml b/@cTab/addons/acousticdetector/stringtable.xml new file mode 100644 index 00000000..a0b102f2 --- /dev/null +++ b/@cTab/addons/acousticdetector/stringtable.xml @@ -0,0 +1,27 @@ + + + + + Acoustic gunshot detector + Détecteur acoustique de coup de feu + + + Enable gunshot detector + Activer le détecteur de coup de feu + + + Track gunshots using acoustic dector if embarked in an equipped vehicle, display them on map and on the horizontal compass of vehicle. + Suit les coups de feu à l'aide d'un détecteur acoustique lorsque le véhicule est équipé, les affiche sur la carte, et sur la boussole horizontale du véhicule. + + + + Tracking time limit + Durée limite de suivi + + + Time during which detected shots are kept and displayed. + Durée pendant laquelle les tirs détectés sont conservés et affichés. + + + + \ No newline at end of file From 05aa4550a0b4db3da9313d4a4315c643b0193184 Mon Sep 17 00:00:00 2001 From: Julien Date: Thu, 2 Mar 2023 19:55:14 +0100 Subject: [PATCH 2/7] Arma 2.12 --- .../addons/acousticdetector/functions/fnc_firedManEH.sqf | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/@cTab/addons/acousticdetector/functions/fnc_firedManEH.sqf b/@cTab/addons/acousticdetector/functions/fnc_firedManEH.sqf index 02cad311..1e81d7cd 100644 --- a/@cTab/addons/acousticdetector/functions/fnc_firedManEH.sqf +++ b/@cTab/addons/acousticdetector/functions/fnc_firedManEH.sqf @@ -9,13 +9,7 @@ if ( _unit == player || { _vehicle == vehicle player } ) exitWith {}; // system private _pos1 = if ( isNull _vehicle ) then { getPosASL _unit } else { getPosASL _vehicle }; private _pos2 = getPosASL _projectile; -// TODO: Arma 2.12 => private _caliber = GVAR(caliberTypeCache) getOrDefaultCall [_ammo, {[_ammo] call FUNC(computeAmmoCaliberType)}, true]; - -private _caliber = GVAR(caliberTypeCache) getOrDefault [_ammo,-2]; -if (_caliber == -2) then { - _caliber = [_ammo] call FUNC(computeAmmoCaliberType); - GVAR(caliberTypeCache) set [_ammo, _caliber]; -}; +private _caliber = GVAR(caliberTypeCache) getOrDefaultCall [_ammo, {[_ammo] call FUNC(computeAmmoCaliberType)}, true]; if ( _caliber != -1 ) then { // Register shot for PFH From c1a2e5a8b9fd513eb1c0b651459cfe24f728af6f Mon Sep 17 00:00:00 2001 From: Julien Date: Sat, 4 Mar 2023 11:46:07 +0100 Subject: [PATCH 3/7] Ingame acoustic detector display + basic script performance profiler --- @cTab/addons/acousticdetector/XEH_PREP.hpp | 10 +-- .../acousticdetector/XEH_postInitClient.sqf | 47 +++++++++++ @cTab/addons/acousticdetector/XEH_preInit.sqf | 5 +- .../functions/fnc_applySettings.sqf | 14 ++++ .../functions/fnc_firedManEH.sqf | 4 - .../functions/fnc_simulatePFH.sqf | 71 ++++++++-------- .../functions/fnc_updateActiveState.sqf | 1 + .../acousticdetector/script_component.hpp | 3 +- @cTab/addons/acousticdetector/stringtable.xml | 22 ++++- @cTab/addons/compass/HorizontalCompass.hpp | 80 +++++++++++++++++++ @cTab/addons/compass/XEH_PREP.hpp | 12 +-- @cTab/addons/compass/XEH_postInitClient.sqf | 1 + @cTab/addons/compass/config.cpp | 2 +- .../compass/functions/fnc_initCompass.sqf | 8 ++ .../compass/functions/fnc_updateCompass.sqf | 31 ++++++- @cTab/addons/compass/script_component.hpp | 1 + @cTab/addons/core/XEH_postInitClient.sqf | 2 + @cTab/addons/core/functions/fnc_onDrawbft.sqf | 6 +- .../core/functions/fnc_onDrawbftVeh.sqf | 1 + @cTab/addons/core/script_component.hpp | 2 +- @cTab/addons/main/script_macros.hpp | 20 +++++ @cTab/addons/simpleprofiler/$PBOPREFIX$ | 1 + .../simpleprofiler/CfgEventHandlers.hpp | 5 ++ @cTab/addons/simpleprofiler/CfgFunctions.hpp | 11 +++ @cTab/addons/simpleprofiler/XEH_postInit.sqf | 1 + @cTab/addons/simpleprofiler/config.cpp | 16 ++++ .../simpleprofiler/fnc_compileFunction.sqf | 5 ++ .../simpleprofiler/fnc_highFreqReport.sqf | 12 +++ .../fnc_instrumentAddPerFrameHandler.sqf | 7 ++ .../simpleprofiler/fnc_instrumentFunction.sqf | 23 ++++++ @cTab/addons/simpleprofiler/fnc_report.sqf | 11 +++ .../simpleprofiler/script_component.hpp | 15 ++++ 32 files changed, 386 insertions(+), 64 deletions(-) create mode 100644 @cTab/addons/simpleprofiler/$PBOPREFIX$ create mode 100644 @cTab/addons/simpleprofiler/CfgEventHandlers.hpp create mode 100644 @cTab/addons/simpleprofiler/CfgFunctions.hpp create mode 100644 @cTab/addons/simpleprofiler/XEH_postInit.sqf create mode 100644 @cTab/addons/simpleprofiler/config.cpp create mode 100644 @cTab/addons/simpleprofiler/fnc_compileFunction.sqf create mode 100644 @cTab/addons/simpleprofiler/fnc_highFreqReport.sqf create mode 100644 @cTab/addons/simpleprofiler/fnc_instrumentAddPerFrameHandler.sqf create mode 100644 @cTab/addons/simpleprofiler/fnc_instrumentFunction.sqf create mode 100644 @cTab/addons/simpleprofiler/fnc_report.sqf create mode 100644 @cTab/addons/simpleprofiler/script_component.hpp diff --git a/@cTab/addons/acousticdetector/XEH_PREP.hpp b/@cTab/addons/acousticdetector/XEH_PREP.hpp index 224b5bcd..606c27ad 100644 --- a/@cTab/addons/acousticdetector/XEH_PREP.hpp +++ b/@cTab/addons/acousticdetector/XEH_PREP.hpp @@ -1,5 +1,5 @@ -PREP(computeAmmoCaliberType); -PREP(firedManEH); -PREP(simulatePFH); -PREP(updateActiveState); -PREP(applySettings); +PREP_RET(computeAmmoCaliberType); +PREP_VOID_HF(firedManEH); +PREP_VOID_HF(simulatePFH); +PREP_VOID(updateActiveState); +PREP_VOID(applySettings); diff --git a/@cTab/addons/acousticdetector/XEH_postInitClient.sqf b/@cTab/addons/acousticdetector/XEH_postInitClient.sqf index 3a669c00..5613d8df 100644 --- a/@cTab/addons/acousticdetector/XEH_postInitClient.sqf +++ b/@cTab/addons/acousticdetector/XEH_postInitClient.sqf @@ -13,3 +13,50 @@ GVAR(pfhHandle) = -1; GVAR(isInitialized) = false; ["CBA_settingsInitialized", FUNC(applySettings)] call CBA_fnc_addEventHandler; + +#ifdef DEBUG_MODE_FULL + +// GVAR(drawn) = []; + +// [QGVAR(update), { +// private _toKeep = []; +// { +// _x params ['','_shotId','_point','_radius']; +// if ( !(_shotId in GVAR(drawn)) ) then { +// GVAR(drawn) pushBack _shotId; +// private _marker = createMarker [format ['_USER_DEFINED #0/shot%1C/0', _shotId], _point]; +// _marker setMarkerShape "ELLIPSE"; +// _marker setMarkerColor "ColorRed"; +// _marker setMarkerSize [_radius, _radius]; +// }; +// _toKeep pushBack _shotId; +// } forEach GVAR(detectedShots); + +// { +// deleteMarker format ['_USER_DEFINED #0/shot%1C/0', _x]; +// } forEach (GVAR(drawn) - _toKeep); + +// /* +// private _marker1 = createMarker [ format ['_USER_DEFINED #0/shot%1A/0', _shotId], _pointA]; +// _marker1 setMarkerShape 'polyline'; +// _marker1 setMarkerPolyline ((_pointA select [0,2]) + (_pointB select [0,2]) + (_pointC select [0,2]) +(_pointD select [0,2]) +(_pointA select [0,2])); +// _marker1 setMarkerColor "ColorRed"; + +// private _marker2 = createMarker [format ['_USER_DEFINED #0/shot%1C/0', _shotId], _point]; +// _marker2 setMarkerShape "ELLIPSE"; +// _marker2 setMarkerColor "ColorRed"; +// _marker2 setMarkerSize [_radius, _radius]; + +// private _marker3 = createMarker [format ['_USER_DEFINED #0/shot%1R/0', _shotId], _source]; +// _marker3 setMarkerType "mil_dot"; +// _marker3 setMarkerColor "ColorBlack"; +// */ + +// }] call CBA_fnc_addEventHandler; + + + + + + +#endif \ No newline at end of file diff --git a/@cTab/addons/acousticdetector/XEH_preInit.sqf b/@cTab/addons/acousticdetector/XEH_preInit.sqf index 0079ae0c..139ce7a8 100644 --- a/@cTab/addons/acousticdetector/XEH_preInit.sqf +++ b/@cTab/addons/acousticdetector/XEH_preInit.sqf @@ -4,5 +4,6 @@ ADDON = false; ADDON = true; [QGVAR(enable), "CHECKBOX", [LLSTRING(enable), LLSTRING(enableDetails)], ["cTab", LLSTRING(acousticdetector)], false, 0, FUNC(applySettings)] call CBA_fnc_addSetting; -[QGVAR(shotsTrackTimeLimit), "TIME", [LLSTRING(timeLimit), LLSTRING(timeLimitDetails)], ["cTab", LLSTRING(acousticdetector)], [10, 120, 30]] call CBA_fnc_addSetting; - +[QGVAR(shotsTrackTimeLimit), "TIME", [LLSTRING(timeLimit), LLSTRING(timeLimitDetails)], ["cTab", LLSTRING(acousticdetector)], [10, 60, 20]] call CBA_fnc_addSetting; +[QGVAR(shotsCountLimit), "SLIDER", [LLSTRING(countLimit), LLSTRING(countLimitDetails)], ["cTab", LLSTRING(acousticdetector)], [10, 510, 150, 0]] call CBA_fnc_addSetting; +[QGVAR(filterDistance), "SLIDER", [LLSTRING(filterDistance), LLSTRING(filterDistanceDetails)], ["cTab", LLSTRING(acousticdetector)], [0, 100, 50, 0]] call CBA_fnc_addSetting; \ No newline at end of file diff --git a/@cTab/addons/acousticdetector/functions/fnc_applySettings.sqf b/@cTab/addons/acousticdetector/functions/fnc_applySettings.sqf index 98244a73..32f0f06a 100644 --- a/@cTab/addons/acousticdetector/functions/fnc_applySettings.sqf +++ b/@cTab/addons/acousticdetector/functions/fnc_applySettings.sqf @@ -11,6 +11,20 @@ if ( GVAR(enable) ) then { ["unit", FUNC(updateActiveState)] call CBA_fnc_addPlayerEventHandler; ["turret", FUNC(updateActiveState)] call CBA_fnc_addPlayerEventHandler; ["vehicle", FUNC(updateActiveState)] call CBA_fnc_addPlayerEventHandler; + + GVAR(red1) = +cTabColorRed; + GVAR(red2) = +cTabColorRed; + GVAR(red2) set [3,(GVAR(red2)#3)/2]; + + EGVAR(core,bftDrawHandlers) pushBack { + if ( !GVAR(isActive) ) exitWith { }; + params ['_ctrl']; + { + _x params ['_time','','_point','_radius']; + _ctrl drawEllipse [_point, _radius, _radius, 0, if ((diag_tickTime-_time)<2.5) then {GVAR(red1)} else {GVAR(red2)}, "#(argb,8,8,3)color(1,1,1,0.5)"]; + } forEach GVAR(detectedShots); + }; + GVAR(isInitialized) = true; }; }; diff --git a/@cTab/addons/acousticdetector/functions/fnc_firedManEH.sqf b/@cTab/addons/acousticdetector/functions/fnc_firedManEH.sqf index 1e81d7cd..d891383c 100644 --- a/@cTab/addons/acousticdetector/functions/fnc_firedManEH.sqf +++ b/@cTab/addons/acousticdetector/functions/fnc_firedManEH.sqf @@ -13,9 +13,5 @@ private _caliber = GVAR(caliberTypeCache) getOrDefaultCall [_ammo, {[_ammo] call if ( _caliber != -1 ) then { // Register shot for PFH - #ifdef DEBUG_MODE_FULL - private _caliberLabel = GVAR(caliberLabel) select _caliber; - TRACE_4("FiredMan", _pos1, _pos2, _ammo, _caliberLabel); - #endif GVAR(shotsToProcess) pushBack [diag_tickTime, _pos1, _caliber]; }; diff --git a/@cTab/addons/acousticdetector/functions/fnc_simulatePFH.sqf b/@cTab/addons/acousticdetector/functions/fnc_simulatePFH.sqf index 719035e9..8567ab8d 100644 --- a/@cTab/addons/acousticdetector/functions/fnc_simulatePFH.sqf +++ b/@cTab/addons/acousticdetector/functions/fnc_simulatePFH.sqf @@ -4,8 +4,12 @@ if ( !GVAR(isActive) ) exitWith { }; private _now = diag_tickTime; -// Remove outdated detected shots private _count = count GVAR(detectedShots); +if ( _count > GVAR(shotsCountLimit) ) then { + // Prevent having too much shots stored + GVAR(detectedShots) = GVAR(detectedShots) select [_count - GVAR(shotsCountLimit), GVAR(shotsCountLimit)]; +}; +// Remove outdated detected shots GVAR(detectedShots) = GVAR(detectedShots) select { _now - (_x select 0) < GVAR(shotsTrackTimeLimit) }; private _changed = _count != count GVAR(detectedShots); @@ -33,41 +37,33 @@ if ( count GVAR(shotsToProcess) > 0 ) then { if ( (_now - _time) > (_distance / _soundSpeed) ) then { // sound had time to travel to our position - if ( _distance < _limit ) then { - - // gunshot is at a detectable distance, let's detect him - private _detectedDir = (_position getDir _source) + (random [-2, 0, +2]); // +/- 2° - private _detectedDistance = _distance * (random [0.9, 1, 1.1]); // +/- 10% - private _point = _position getPos [_detectedDistance, _detectedDir]; - private _pointA = _position getPos [_detectedDistance + (_distance * 0.1), _detectedDir - 2]; - private _pointB = _position getPos [_detectedDistance - (_distance * 0.1), _detectedDir - 2]; - private _pointC = _position getPos [_detectedDistance - (_distance * 0.1), _detectedDir + 2]; - private _pointD = _position getPos [_detectedDistance + (_distance * 0.1), _detectedDir + 2]; - private _radius = _point vectorDistance _pointA; - private _shotId = GVAR(nextShotId); - private _data = [ _now, _shotId, _point, _radius, [_pointA, _pointB, _pointC, _pointD], _caliber]; - GVAR(detectedShots) pushBack _data; - TRACE_1("DetectedShot", _data); - _changed = true; - GVAR(nextShotId) = GVAR(nextShotId) + 1; - -#ifdef DEBUG_MODE_FULL - private _marker = createMarker [ format ['_USER_DEFINED #0/shot%1A/0', _shotId], _pointA]; - _marker setMarkerShape 'polyline'; - _marker setMarkerPolyline ((_pointA select [0,2]) + (_pointB select [0,2]) + (_pointC select [0,2]) +(_pointD select [0,2]) +(_pointA select [0,2])); - _marker setMarkerColor "ColorRed"; - - _marker = createMarker [format ['_USER_DEFINED #0/shot%1C/0', _shotId], _point]; - _marker setMarkerShape "ELLIPSE"; - _marker setMarkerColor "ColorRed"; - _marker setMarkerSize [_radius, _radius]; - - _marker = createMarker [format ['_USER_DEFINED #0/shot%1R/0', _shotId], _source]; - _marker setMarkerType "mil_dot"; - _marker setMarkerColor "ColorBlack"; -#endif + if ( _distance < _limit ) then { // gunshot is at a detectable distance, let's detect him + + if ( _distance > GVAR(filterDistance) ) then { // if shot is too close, ignore him + private _detectedDir = (_position getDir _source) + (random [-2, 0, +2]); // +/- 2° + private _detectedDistance = _distance * (random [0.9, 1, 1.1]); // +/- 10% + private _point = _position getPos [_detectedDistance, _detectedDir]; + + // check if an existing shot might have the same source (close distance, to avoid flooding with too much data) + private _existing = GVAR(detectedShots) findIf { (_x select 4) == _caliber && { (_x select 2) vectorDistance _point < ((_x select 3) * 0.3) } }; + if ( _existing == -1 ) then { + private _pointA = _position getPos [_detectedDistance + (_distance * 0.1), _detectedDir - 2]; + private _pointB = _position getPos [_detectedDistance - (_distance * 0.1), _detectedDir - 2]; + private _pointC = _position getPos [_detectedDistance - (_distance * 0.1), _detectedDir + 2]; + private _pointD = _position getPos [_detectedDistance + (_distance * 0.1), _detectedDir + 2]; + private _radius = _point vectorDistance _pointA; + private _shotId = GVAR(nextShotId); + GVAR(detectedShots) pushBack [ _now, _shotId, _point, _radius, _caliber, [_pointA, _pointB, _pointC, _pointD], _source]; + _changed = true; + GVAR(nextShotId) = GVAR(nextShotId) + 1; + } else { + // Assume same source + (GVAR(detectedShots) select _existing) set [0, _now]; + // _changed = true; Should we notify this one ? + }; + + }; }; - } else { // sound did not have time to get to our position if ( _distance < _limit * 1.2 ) then { @@ -80,11 +76,10 @@ if ( count GVAR(shotsToProcess) > 0 ) then { }; }; } forEach _shots; - - }; if ( _changed ) then { - TRACE_1("Update", GVAR(detectedShots)); + TRACE_1("Update", count GVAR(detectedShots)); [QGVAR(update)] call CBA_fnc_localEvent; }; + diff --git a/@cTab/addons/acousticdetector/functions/fnc_updateActiveState.sqf b/@cTab/addons/acousticdetector/functions/fnc_updateActiveState.sqf index 5566b012..56572c80 100644 --- a/@cTab/addons/acousticdetector/functions/fnc_updateActiveState.sqf +++ b/@cTab/addons/acousticdetector/functions/fnc_updateActiveState.sqf @@ -17,6 +17,7 @@ if ( GVAR(enable) ) then { TRACE_3("updateActiveState", GVAR(enable), _isActive, GVAR(isActive)); if ( _isActive != GVAR(isActive) ) then { + GVAR(isActive) = _isActive; if ( _isActive ) then { if ( GVAR(pfhHandle) == -1 ) then { LOG("Acoustic gunshot detector is started"); diff --git a/@cTab/addons/acousticdetector/script_component.hpp b/@cTab/addons/acousticdetector/script_component.hpp index da42d70b..dda3eff5 100644 --- a/@cTab/addons/acousticdetector/script_component.hpp +++ b/@cTab/addons/acousticdetector/script_component.hpp @@ -1,8 +1,9 @@ #define COMPONENT acousticdetector #include "\z\ctab\addons\main\script_mod.hpp" - #define DEBUG_MODE_FULL +// #define DEBUG_MODE_FULL #define DISABLE_COMPILE_CACHE +#define PROFILER #ifdef DEBUG_ENABLED_CORE #define DEBUG_MODE_FULL diff --git a/@cTab/addons/acousticdetector/stringtable.xml b/@cTab/addons/acousticdetector/stringtable.xml index a0b102f2..66ee5a3a 100644 --- a/@cTab/addons/acousticdetector/stringtable.xml +++ b/@cTab/addons/acousticdetector/stringtable.xml @@ -15,13 +15,31 @@ - Tracking time limit - Durée limite de suivi + Shot display duration + Durée d'affichage des tirs Time during which detected shots are kept and displayed. Durée pendant laquelle les tirs détectés sont conservés et affichés. + + Limit number of shots displayed + Nombre limite de tirs affichés + + + Maximum number of detected shots that are kept and displayed. + Nombre maximal de tirs détecté conservés et affiché. + + + + Minimum distance (meters) + Distance minimale (mètres) + + + Shots that are below this distance are ignored. + Les tirs qui sont en dessous de cette distance sont ignorés. + + \ No newline at end of file diff --git a/@cTab/addons/compass/HorizontalCompass.hpp b/@cTab/addons/compass/HorizontalCompass.hpp index 6ad3c444..8e06fc13 100644 --- a/@cTab/addons/compass/HorizontalCompass.hpp +++ b/@cTab/addons/compass/HorizontalCompass.hpp @@ -4,6 +4,7 @@ class RscControlsGroupNoScrollbars; class RscMapControlEmpty; class RscPicture; +class RscText; class GVARMAIN(HorizontalCompass) : RscControlsGroupNoScrollbars { @@ -47,6 +48,49 @@ class GVARMAIN(HorizontalCompass) : RscControlsGroupNoScrollbars h = BAR_HEIGHT; text=QPATHTOF(data\ns_ca.paa); // North > East > South }; + class B00 : RscText + { + idc=9200; + w = BAR_WIDTH/18; + h = BAR_HEIGHT/4; + y = BAR_HEIGHT*3/4; + colorBackground[] = { 1, 0, 0, 0.8 }; + }; + class B01 : B00 { idc=9201; x = BAR_WIDTH*01/18; }; + class B02 : B00 { idc=9202; x = BAR_WIDTH*02/18; }; + class B03 : B00 { idc=9203; x = BAR_WIDTH*03/18; }; + class B04 : B00 { idc=9204; x = BAR_WIDTH*04/18; }; + class B05 : B00 { idc=9205; x = BAR_WIDTH*05/18; }; + class B06 : B00 { idc=9206; x = BAR_WIDTH*06/18; }; + class B07 : B00 { idc=9207; x = BAR_WIDTH*07/18; }; + class B08 : B00 { idc=9208; x = BAR_WIDTH*08/18; }; + class B09 : B00 { idc=9209; x = BAR_WIDTH*09/18; }; + class B10 : B00 { idc=9210; x = BAR_WIDTH*10/18; }; + class B11 : B00 { idc=9211; x = BAR_WIDTH*11/18; }; + class B12 : B00 { idc=9212; x = BAR_WIDTH*12/18; }; + class B13 : B00 { idc=9213; x = BAR_WIDTH*13/18; }; + class B14 : B00 { idc=9214; x = BAR_WIDTH*14/18; }; + class B15 : B00 { idc=9215; x = BAR_WIDTH*15/18; }; + class B16 : B00 { idc=9216; x = BAR_WIDTH*16/18; }; + class B17 : B00 { idc=9217; x = BAR_WIDTH*17/18; }; + class B18 : B00 { idc=9218; x = BAR_WIDTH*18/18; }; + class B19 : B00 { idc=9219; x = BAR_WIDTH*19/18; }; + class B20 : B00 { idc=9220; x = BAR_WIDTH*20/18; }; + class B21 : B00 { idc=9221; x = BAR_WIDTH*21/18; }; + class B22 : B00 { idc=9222; x = BAR_WIDTH*22/18; }; + class B23 : B00 { idc=9223; x = BAR_WIDTH*23/18; }; + class B24 : B00 { idc=9224; x = BAR_WIDTH*24/18; }; + class B25 : B00 { idc=9225; x = BAR_WIDTH*25/18; }; + class B26 : B00 { idc=9226; x = BAR_WIDTH*26/18; }; + class B27 : B00 { idc=9227; x = BAR_WIDTH*27/18; }; + class B28 : B00 { idc=9228; x = BAR_WIDTH*28/18; }; + class B29 : B00 { idc=9229; x = BAR_WIDTH*29/18; }; + class B30 : B00 { idc=9230; x = BAR_WIDTH*30/18; }; + class B31 : B00 { idc=9231; x = BAR_WIDTH*31/18; }; + class B32 : B00 { idc=9232; x = BAR_WIDTH*32/18; }; + class B33 : B00 { idc=9233; x = BAR_WIDTH*33/18; }; + class B34 : B00 { idc=9234; x = BAR_WIDTH*34/18; }; + class B35 : B00 { idc=9235; x = BAR_WIDTH*35/18; }; }; }; class Bar2 : Bar1 @@ -59,6 +103,42 @@ class GVARMAIN(HorizontalCompass) : RscControlsGroupNoScrollbars { text=QPATHTOF(data\sn_ca.paa); // South > West > North }; + class B00 : B00 {idc=9236;}; + class B01 : B01 {idc=9237;}; + class B02 : B02 {idc=9238;}; + class B03 : B03 {idc=9239;}; + class B04 : B04 {idc=9240;}; + class B05 : B05 {idc=9241;}; + class B06 : B06 {idc=9242;}; + class B07 : B07 {idc=9243;}; + class B08 : B08 {idc=9244;}; + class B09 : B09 {idc=9245;}; + class B10 : B10 {idc=9246;}; + class B11 : B11 {idc=9247;}; + class B12 : B12 {idc=9248;}; + class B13 : B13 {idc=9249;}; + class B14 : B14 {idc=9250;}; + class B15 : B15 {idc=9251;}; + class B16 : B16 {idc=9252;}; + class B17 : B17 {idc=9253;}; + class B18 : B18 {idc=9254;}; + class B19 : B19 {idc=9255;}; + class B20 : B20 {idc=9256;}; + class B21 : B21 {idc=9257;}; + class B22 : B22 {idc=9258;}; + class B23 : B23 {idc=9259;}; + class B24 : B24 {idc=9260;}; + class B25 : B25 {idc=9261;}; + class B26 : B26 {idc=9262;}; + class B27 : B27 {idc=9263;}; + class B28 : B28 {idc=9264;}; + class B29 : B29 {idc=9265;}; + class B30 : B30 {idc=9266;}; + class B31 : B31 {idc=9267;}; + class B32 : B32 {idc=9268;}; + class B33 : B33 {idc=9269;}; + class B34 : B34 {idc=9270;}; + class B35 : B35 {idc=9271;}; }; }; class Center : RscPicture diff --git a/@cTab/addons/compass/XEH_PREP.hpp b/@cTab/addons/compass/XEH_PREP.hpp index d0f646b7..c83afdae 100644 --- a/@cTab/addons/compass/XEH_PREP.hpp +++ b/@cTab/addons/compass/XEH_PREP.hpp @@ -1,6 +1,6 @@ -PREP(initCompass); -PREP(updateCompass); -PREP(disposeCompass); -PREP(addMarkerBar); -PREP(updateMarkerBar); -PREP(deleteMarkerBar); +PREP_VOID(initCompass); +PREP_VOID_HF(updateCompass); +PREP_VOID(disposeCompass); +PREP_VOID(addMarkerBar); +PREP_VOID(updateMarkerBar); +PREP_VOID(deleteMarkerBar); diff --git a/@cTab/addons/compass/XEH_postInitClient.sqf b/@cTab/addons/compass/XEH_postInitClient.sqf index 8ef4ef49..a0d95be5 100644 --- a/@cTab/addons/compass/XEH_postInitClient.sqf +++ b/@cTab/addons/compass/XEH_postInitClient.sqf @@ -3,3 +3,4 @@ if (!hasInterface) exitWith {}; ["ctab_userMarkerListUpdated", { GVAR(markersHaveChanged) = true; }] call CBA_fnc_addEventHandler; +[QEGVAR(acousticdetector,update), { GVAR(acousticChanged) = true; }] call CBA_fnc_addEventHandler; diff --git a/@cTab/addons/compass/config.cpp b/@cTab/addons/compass/config.cpp index 38347556..8164d9ca 100644 --- a/@cTab/addons/compass/config.cpp +++ b/@cTab/addons/compass/config.cpp @@ -6,7 +6,7 @@ class CfgPatches { units[] = {}; weapons[] = {}; requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"ctab_main","ctab_core"}; + requiredAddons[] = {"ctab_main","ctab_core","ctab_acousticdetector"}; author = "GrueArbre"; VERSION_CONFIG; }; diff --git a/@cTab/addons/compass/functions/fnc_initCompass.sqf b/@cTab/addons/compass/functions/fnc_initCompass.sqf index 3b0ea419..2b5f5c4e 100644 --- a/@cTab/addons/compass/functions/fnc_initCompass.sqf +++ b/@cTab/addons/compass/functions/fnc_initCompass.sqf @@ -7,6 +7,7 @@ INFO('INIT'); GVAR(nextIdc) = 10000; GVAR(markerToIdc) = createHashMap; GVAR(markersHaveChanged) = true; +GVAR(acousticChanged) = EGVAR(acousticdetector,isActive); GVAR(previousPosition) = [0,0,0]; private _bg1 = (_control controlsgroupctrl 9001) controlsGroupCtrl 9101; @@ -15,3 +16,10 @@ _bg1 ctrlSetText ([QPATHTOF(data\ns_deg_ca.paa),QPATHTOF(data\ns_ca.paa)] select _bg2 ctrlSetText ([QPATHTOF(data\sn_deg_ca.paa),QPATHTOF(data\sn_ca.paa)] select ctab_core_useMils); _bg1 ctrlcommit 0; _bg2 ctrlcommit 0; + +private _blocs = []; +private _bloc = controlNull; +for "_idc" from 9200 to 9271 do { + _blocs pushBack (_control controlsGroupCtrl _idc); +}; +uiNamespace setVariable [QGVAR(blocs), _blocs]; diff --git a/@cTab/addons/compass/functions/fnc_updateCompass.sqf b/@cTab/addons/compass/functions/fnc_updateCompass.sqf index 75f5ad38..b326b7c8 100644 --- a/@cTab/addons/compass/functions/fnc_updateCompass.sqf +++ b/@cTab/addons/compass/functions/fnc_updateCompass.sqf @@ -7,6 +7,11 @@ private _ctrlBloc = _control controlsgroupctrl 9000; private _shouldDisplay = (cameraView in ["GUNNER", "GROUP"]) && GVAR(enable); if ( ctrlShown _ctrlBloc != _shouldDisplay ) then { _ctrlBloc ctrlShow _shouldDisplay; + if ( _shouldDisplay && !EGVAR(acousticdetector,isActive) ) then { + { + _x ctrlShow false; + } forEach (uiNamespace getVariable [QGVAR(blocs), []]); + }; }; if ( !_shouldDisplay ) exitWith { }; @@ -100,4 +105,28 @@ if ( GVAR(markersHaveChanged) || { (GVAR(previousPosition) vectorDistanceSqr _pl //private _elapsed = diag_tickTime-_start; //INFO_1('Markers updated in %1 msec', _elapsed); -}; \ No newline at end of file + + GVAR(acousticChanged) = EGVAR(acousticdetector,isActive); +}; + +if ( GVAR(acousticChanged) ) then { + GVAR(acousticChanged) = false; + private _blocs = uiNamespace getVariable [QGVAR(blocs), []]; + if ( count _blocs == 0 ) exitWith {}; + // 72 values for 5° blocs + private _vector=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]; + { + _x params ['','','_point']; + private _distance = _playerPosition vectorDistanceSqr _point; + if ( _distance > 625 ) then { // 25m strict minimum + private _direction = floor ((_playerPosition getDir _point) / 5); + //_vector set [(_direction+71) % 72, 1]; + _vector set [_direction % 72, 1]; + //_vector set [(_direction+1) % 72, 1]; + }; + } forEach EGVAR(acousticdetector,detectedShots); + { + (_blocs select _forEachIndex) ctrlShow (_x > 0); + } forEach _vector; +}; + diff --git a/@cTab/addons/compass/script_component.hpp b/@cTab/addons/compass/script_component.hpp index 3ec9db51..a705713f 100644 --- a/@cTab/addons/compass/script_component.hpp +++ b/@cTab/addons/compass/script_component.hpp @@ -3,6 +3,7 @@ // #define DEBUG_MODE_FULL // #define DISABLE_COMPILE_CACHE +#define PROFILER #ifdef DEBUG_ENABLED_CORE #define DEBUG_MODE_FULL diff --git a/@cTab/addons/core/XEH_postInitClient.sqf b/@cTab/addons/core/XEH_postInitClient.sqf index 0bbc0767..3c9056d5 100644 --- a/@cTab/addons/core/XEH_postInitClient.sqf +++ b/@cTab/addons/core/XEH_postInitClient.sqf @@ -82,6 +82,8 @@ INFO_4("Devices detected in %1 sec : %2, %3, %4",(diag_tickTime - _start),GVAR(t GVAR(leaderDevices) = GVAR(tabDevices) + GVAR(androidDevices); GVAR(personnelDevices) = GVAR(leaderDevices) + GVAR(dagrDevices); +GVAR(bftDrawHandlers) = []; + /* Figure out the scaling factor based on the current map (island) being played Requires the scale of the map control to be at 0.001 diff --git a/@cTab/addons/core/functions/fnc_onDrawbft.sqf b/@cTab/addons/core/functions/fnc_onDrawbft.sqf index 83b56db4..38cecd9e 100644 --- a/@cTab/addons/core/functions/fnc_onDrawbft.sqf +++ b/@cTab/addons/core/functions/fnc_onDrawbft.sqf @@ -5,11 +5,11 @@ (previously in player_init.sqf) */ _cntrlScreen = _this select 0; -_display = ctrlParent _cntrlScreen; cTabMapWorldPos = [_cntrlScreen] call cTab_fnc_ctrlMapCenter; cTabMapScale = ctrlMapScale _cntrlScreen; +{_this call _x;} forEach GVAR(bftDrawHandlers); [_cntrlScreen,true] call cTab_fnc_drawUserMarkers; private _drawPlayer = [_cntrlScreen,0] call cTab_fnc_drawBftMarkers; @@ -17,14 +17,14 @@ _veh = vehicle cTab_player; _playerPos = getPosASL _veh; // draw directional arrow at own location -if (_playerDrawn) then { +if (_drawPlayer) then { _heading = direction _veh; _cntrlScreen drawIcon ["\A3\ui_f\data\map\VehicleIcons\iconmanvirtual_ca.paa",cTabMicroDAGRfontColour,_playerPos,cTabTADownIconBaseSize,cTabTADownIconBaseSize,_heading,"", 1,cTabTxtSize,"TahomaB","right"]; }; // update hook information if (cTabDrawMapTools) then { - [_display,_cntrlScreen,_playerPos,cTabMapCursorPos,0,false] call cTab_fnc_drawHook; + [ctrlParent _cntrlScreen,_cntrlScreen,_playerPos,cTabMapCursorPos,0,false] call cTab_fnc_drawHook; }; true \ No newline at end of file diff --git a/@cTab/addons/core/functions/fnc_onDrawbftVeh.sqf b/@cTab/addons/core/functions/fnc_onDrawbftVeh.sqf index ea20c1cd..a73f705c 100644 --- a/@cTab/addons/core/functions/fnc_onDrawbftVeh.sqf +++ b/@cTab/addons/core/functions/fnc_onDrawbftVeh.sqf @@ -10,6 +10,7 @@ _display = ctrlParent _cntrlScreen; cTabMapWorldPos = [_cntrlScreen] call cTab_fnc_ctrlMapCenter; cTabMapScale = ctrlMapScale _cntrlScreen; +{_this call _x;} forEach GVAR(bftDrawHandlers); [_cntrlScreen,true] call cTab_fnc_drawUserMarkers; private _drawPlayer = [_cntrlScreen,0] call cTab_fnc_drawBftMarkers; diff --git a/@cTab/addons/core/script_component.hpp b/@cTab/addons/core/script_component.hpp index 6f0bfb09..680b4b82 100644 --- a/@cTab/addons/core/script_component.hpp +++ b/@cTab/addons/core/script_component.hpp @@ -2,7 +2,7 @@ #include "\z\ctab\addons\main\script_mod.hpp" // #define DEBUG_MODE_FULL -// #define DISABLE_COMPILE_CACHE + #define DISABLE_COMPILE_CACHE #ifdef DEBUG_ENABLED_CORE #define DEBUG_MODE_FULL diff --git a/@cTab/addons/main/script_macros.hpp b/@cTab/addons/main/script_macros.hpp index 7bf3469b..8310b71c 100644 --- a/@cTab/addons/main/script_macros.hpp +++ b/@cTab/addons/main/script_macros.hpp @@ -14,3 +14,23 @@ #undef PREPMAIN #define PREPMAIN(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf), QFUNCMAIN(fncName)] call CBA_fnc_compileFunction #endif + +#ifdef PROFILER + #define PREP_RET(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNC(fncName),true,false] call ctab_fnc_compileFunction + #define PREP_VOID(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNC(fncName),false,false] call ctab_fnc_compileFunction + #define PREP_RET_HF(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNC(fncName),true,true] call ctab_fnc_compileFunction + #define PREP_VOID_HF(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNC(fncName),false,true] call ctab_fnc_compileFunction + #define PREPMAIN_RET(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNCMAIN(fncName),true,false] call ctab_fnc_compileFunction + #define PREPMAIN_VOID(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNCMAIN(fncName),false,false] call ctab_fnc_compileFunction + #define PREPMAIN_RET_HF(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNCMAIN(fncName),true,true] call ctab_fnc_compileFunction + #define PREPMAIN_VOID_HF(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNCMAIN(fncName),false,true] call ctab_fnc_compileFunction +#else + #define PREP_RET(fncName) PREP(fncName) + #define PREP_VOID(fncName) PREP(fncName) + #define PREP_RET_HF(fncName) PREP(fncName) + #define PREP_VOID_HF(fncName) PREP(fncName) + #define PREPMAIN_RET(fncName) PREPMAIN(fncName) + #define PREPMAIN_VOID(fncName) PREPMAIN(fncName) + #define PREPMAIN_RET_HF(fncName) PREPMAIN(fncName) + #define PREPMAIN_VOID_HF(fncName) PREPMAIN(fncName) +#endif diff --git a/@cTab/addons/simpleprofiler/$PBOPREFIX$ b/@cTab/addons/simpleprofiler/$PBOPREFIX$ new file mode 100644 index 00000000..9e67709b --- /dev/null +++ b/@cTab/addons/simpleprofiler/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ctab\addons\simpleprofiler diff --git a/@cTab/addons/simpleprofiler/CfgEventHandlers.hpp b/@cTab/addons/simpleprofiler/CfgEventHandlers.hpp new file mode 100644 index 00000000..b0cc92b5 --- /dev/null +++ b/@cTab/addons/simpleprofiler/CfgEventHandlers.hpp @@ -0,0 +1,5 @@ +class Extended_PostInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_postInit)); + }; +}; diff --git a/@cTab/addons/simpleprofiler/CfgFunctions.hpp b/@cTab/addons/simpleprofiler/CfgFunctions.hpp new file mode 100644 index 00000000..35b709c9 --- /dev/null +++ b/@cTab/addons/simpleprofiler/CfgFunctions.hpp @@ -0,0 +1,11 @@ +class CfgFunctions { + class PREFIX { + class COMPONENT { + PATHTO_FNC(compileFunction); + PATHTO_FNC(instrumentFunction); + PATHTO_FNC(instrumentAddPerFrameHandler); + PATHTO_FNC(report); + PATHTO_FNC(highFreqReport); + }; + }; +}; \ No newline at end of file diff --git a/@cTab/addons/simpleprofiler/XEH_postInit.sqf b/@cTab/addons/simpleprofiler/XEH_postInit.sqf new file mode 100644 index 00000000..32e9af20 --- /dev/null +++ b/@cTab/addons/simpleprofiler/XEH_postInit.sqf @@ -0,0 +1 @@ +[ctab_fnc_highFreqReport, 30] call CBA_fnc_addPerFrameHandler; // High freq report every 30 seconds \ No newline at end of file diff --git a/@cTab/addons/simpleprofiler/config.cpp b/@cTab/addons/simpleprofiler/config.cpp new file mode 100644 index 00000000..9192a973 --- /dev/null +++ b/@cTab/addons/simpleprofiler/config.cpp @@ -0,0 +1,16 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + name = QUOTE(COMPONENT); + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {}; + author = "GrueArbre"; + VERSION_CONFIG; + }; +}; + +#include "CfgEventHandlers.hpp" +#include "CfgFunctions.hpp" diff --git a/@cTab/addons/simpleprofiler/fnc_compileFunction.sqf b/@cTab/addons/simpleprofiler/fnc_compileFunction.sqf new file mode 100644 index 00000000..0c546d5a --- /dev/null +++ b/@cTab/addons/simpleprofiler/fnc_compileFunction.sqf @@ -0,0 +1,5 @@ +#include "script_component.hpp" +params ["_sqfFile","_name","_isReturning","_isHighFreq"]; +private _fnc = [compileFinal preprocessFileLineNumbers _sqfFile, _name, _isReturning, _isHighFreq] call FUNCMAIN(instrumentFunction); +missionNamespace setVariable [_name, _fnc]; +_fnc \ No newline at end of file diff --git a/@cTab/addons/simpleprofiler/fnc_highFreqReport.sqf b/@cTab/addons/simpleprofiler/fnc_highFreqReport.sqf new file mode 100644 index 00000000..0d508334 --- /dev/null +++ b/@cTab/addons/simpleprofiler/fnc_highFreqReport.sqf @@ -0,0 +1,12 @@ +#include "script_component.hpp" +if (isNil QGVAR(highFreq)) exitWith {}; +INFO("Performance HF"); +{ + _x params ['_name','_counterFnc','_elapsedFnc', '_resetFnc']; + private _counter = call _counterFnc; + private _elapsed = (call _elapsedFnc) * 1000; + if ( _counter > 0) then { + INFO_4("%1;%2;%3;%4",_name, _counter, _elapsed, _elapsed / _counter); + }; + call _resetFnc; +} forEach GVAR(highFreq); diff --git a/@cTab/addons/simpleprofiler/fnc_instrumentAddPerFrameHandler.sqf b/@cTab/addons/simpleprofiler/fnc_instrumentAddPerFrameHandler.sqf new file mode 100644 index 00000000..3721fa01 --- /dev/null +++ b/@cTab/addons/simpleprofiler/fnc_instrumentAddPerFrameHandler.sqf @@ -0,0 +1,7 @@ +#include "script_component.hpp" +params [["_function", {}, [{}]], ["_name", "", [""]], ["_delay", 0, [0]], ["_args", []]]; +if (_delay<2) then { + [[_function,_name,false,true] call FUNCMAIN(instrumentFunction),_delay,_args] call CBA_fnc_addPerFrameHandler +} else { + [[_function,_name,false,false] call FUNCMAIN(instrumentFunction),_delay,_args] call CBA_fnc_addPerFrameHandler +} \ No newline at end of file diff --git a/@cTab/addons/simpleprofiler/fnc_instrumentFunction.sqf b/@cTab/addons/simpleprofiler/fnc_instrumentFunction.sqf new file mode 100644 index 00000000..33f28648 --- /dev/null +++ b/@cTab/addons/simpleprofiler/fnc_instrumentFunction.sqf @@ -0,0 +1,23 @@ +#include "script_component.hpp" +params ["_code","_name","_isReturning",["_isHighFreq",false]]; +if (isNil QGVAR(nextUid)) then { + GVAR(nextUid) = 1; + GVAR(data) = []; + GVAR(highFreq) = []; +}; +private _uid = GVAR(nextUid); +GVAR(nextUid) = GVAR(nextUid) + 1; +private _entry = [_name, compileFinal(format ["bsp_counter_%1", _uid]), compileFinal(format ["bsp_elapsed_%1", _uid]), compileFinal(format ["bsp_elapsed_%1=0;bsp_counter_%1=0;", _uid])]; +if (_isHighFreq) then { + GVAR(highFreq) pushBack _entry; +} else { + GVAR(data) pushBack _entry; +}; +missionNamespace setVariable [format ["bsp_fnc_%1", _uid], _code]; +missionNamespace setVariable [format ["bsp_counter_%1", _uid], 0]; +missionNamespace setVariable [format ["bsp_elapsed_%1", _uid], 0]; +if ( _isReturning ) then { + compileFinal (format ["bsp_counter_%1=bsp_counter_%1 + 1;private _s = diag_tickTime;private _r=_this call bsp_fnc_%1;bsp_elapsed_%1 = bsp_elapsed_%1 + diag_tickTime - _s;_r", _uid]) +} else { + compileFinal (format ["bsp_counter_%1=bsp_counter_%1 + 1;private _s = diag_tickTime;_this call bsp_fnc_%1;bsp_elapsed_%1 = bsp_elapsed_%1 + diag_tickTime - _s;", _uid]) +} \ No newline at end of file diff --git a/@cTab/addons/simpleprofiler/fnc_report.sqf b/@cTab/addons/simpleprofiler/fnc_report.sqf new file mode 100644 index 00000000..bce137ac --- /dev/null +++ b/@cTab/addons/simpleprofiler/fnc_report.sqf @@ -0,0 +1,11 @@ +#include "script_component.hpp" +if (isNil QGVAR(data)) exitWith {}; +INFO("Performance STD"); +{ + _x params ['_name','_counterFnc','_elapsedFnc']; + private _counter = call _counterFnc; + private _elapsed = (call _elapsedFnc) * 1000; + if ( _counter > 0) then { + INFO_4("%1;%2;%3;%4",_name, _counter, _elapsed, _elapsed / _counter); + }; +} forEach GVAR(data); diff --git a/@cTab/addons/simpleprofiler/script_component.hpp b/@cTab/addons/simpleprofiler/script_component.hpp new file mode 100644 index 00000000..00383094 --- /dev/null +++ b/@cTab/addons/simpleprofiler/script_component.hpp @@ -0,0 +1,15 @@ +#define MAINPREFIX z +#define PREFIX ctab +#define COMPONENT simpleprofiler +#define MAJOR 2 +#define MINOR 8 +#define PATCH 0 +#define BUILD 0 + +#define VERSION MAJOR.MINOR.PATCH.BUILD +#define VERSION_AR MAJOR,MINOR,PATCH,BUILD +#define REQUIRED_VERSION 1.88 + +#define RECOMPILE + +#include "\x\cba\addons\main\script_macros_common.hpp" From 70c79fa1f05488a19dea044f5bf8e110df542586 Mon Sep 17 00:00:00 2001 From: Julien Date: Sat, 4 Mar 2023 15:00:40 +0100 Subject: [PATCH 4/7] IRL support --- .../functions/fnc_applySettings.sqf | 8 +-- .../functions/fnc_updateActiveState.sqf | 3 ++ .../compass/functions/fnc_updateCompass.sqf | 3 +- cTabIRL/@cTabIRL/addons/connect/XEH_PREP.hpp | 14 ++--- .../@cTabIRL/addons/connect/XEH_postInit.sqf | 8 +-- .../@cTabIRL/addons/connect/XEH_preInit.sqf | 4 +- .../connect/functions/fnc_updateAcoustic.sqf | 6 +++ .../functions/fnc_updateMapMarkers.sqf | 2 + .../connect/functions/fnc_updatePosition.sqf | 7 ++- .../addons/connect/script_component.hpp | 3 +- .../@cTabIRL/addons/main/script_macros.hpp | 12 +++++ cTabIRL/cTabWebApp/Hub/CTabHub.cs | 53 ++++++++++++++++++- cTabIRL/cTabWebApp/Hub/DetectedShot.cs | 12 +++++ .../cTabWebApp/Hub/UpdateAcousticMessage.cs | 12 +++++ cTabIRL/cTabWebApp/Services/PlayerState.cs | 1 + cTabIRL/cTabWebApp/wwwroot/js/map.js | 32 +++++++++++ 16 files changed, 158 insertions(+), 22 deletions(-) create mode 100644 cTabIRL/@cTabIRL/addons/connect/functions/fnc_updateAcoustic.sqf create mode 100644 cTabIRL/cTabWebApp/Hub/DetectedShot.cs create mode 100644 cTabIRL/cTabWebApp/Hub/UpdateAcousticMessage.cs diff --git a/@cTab/addons/acousticdetector/functions/fnc_applySettings.sqf b/@cTab/addons/acousticdetector/functions/fnc_applySettings.sqf index 32f0f06a..0a9728b4 100644 --- a/@cTab/addons/acousticdetector/functions/fnc_applySettings.sqf +++ b/@cTab/addons/acousticdetector/functions/fnc_applySettings.sqf @@ -12,16 +12,12 @@ if ( GVAR(enable) ) then { ["turret", FUNC(updateActiveState)] call CBA_fnc_addPlayerEventHandler; ["vehicle", FUNC(updateActiveState)] call CBA_fnc_addPlayerEventHandler; - GVAR(red1) = +cTabColorRed; - GVAR(red2) = +cTabColorRed; - GVAR(red2) set [3,(GVAR(red2)#3)/2]; - EGVAR(core,bftDrawHandlers) pushBack { if ( !GVAR(isActive) ) exitWith { }; params ['_ctrl']; { - _x params ['_time','','_point','_radius']; - _ctrl drawEllipse [_point, _radius, _radius, 0, if ((diag_tickTime-_time)<2.5) then {GVAR(red1)} else {GVAR(red2)}, "#(argb,8,8,3)color(1,1,1,0.5)"]; + _x params ['','','_point','_radius']; + _ctrl drawEllipse [_point, _radius, _radius, 0, cTabColorRed, "#(argb,8,8,3)color(1,1,1,0.5)"]; } forEach GVAR(detectedShots); }; diff --git a/@cTab/addons/acousticdetector/functions/fnc_updateActiveState.sqf b/@cTab/addons/acousticdetector/functions/fnc_updateActiveState.sqf index 56572c80..7eb70454 100644 --- a/@cTab/addons/acousticdetector/functions/fnc_updateActiveState.sqf +++ b/@cTab/addons/acousticdetector/functions/fnc_updateActiveState.sqf @@ -18,6 +18,9 @@ TRACE_3("updateActiveState", GVAR(enable), _isActive, GVAR(isActive)); if ( _isActive != GVAR(isActive) ) then { GVAR(isActive) = _isActive; + GVAR(shotsToProcess) = []; + GVAR(detectedShots) = []; + [QGVAR(update)] call CBA_fnc_localEvent; if ( _isActive ) then { if ( GVAR(pfhHandle) == -1 ) then { LOG("Acoustic gunshot detector is started"); diff --git a/@cTab/addons/compass/functions/fnc_updateCompass.sqf b/@cTab/addons/compass/functions/fnc_updateCompass.sqf index b326b7c8..51c73f85 100644 --- a/@cTab/addons/compass/functions/fnc_updateCompass.sqf +++ b/@cTab/addons/compass/functions/fnc_updateCompass.sqf @@ -7,10 +7,11 @@ private _ctrlBloc = _control controlsgroupctrl 9000; private _shouldDisplay = (cameraView in ["GUNNER", "GROUP"]) && GVAR(enable); if ( ctrlShown _ctrlBloc != _shouldDisplay ) then { _ctrlBloc ctrlShow _shouldDisplay; - if ( _shouldDisplay && !EGVAR(acousticdetector,isActive) ) then { + if ( _shouldDisplay ) then { { _x ctrlShow false; } forEach (uiNamespace getVariable [QGVAR(blocs), []]); + GVAR(acousticChanged) = EGVAR(acousticdetector,isActive); }; }; if ( !_shouldDisplay ) exitWith { }; diff --git a/cTabIRL/@cTabIRL/addons/connect/XEH_PREP.hpp b/cTabIRL/@cTabIRL/addons/connect/XEH_PREP.hpp index ba2964c1..c9dbfea6 100644 --- a/cTabIRL/@cTabIRL/addons/connect/XEH_PREP.hpp +++ b/cTabIRL/@cTabIRL/addons/connect/XEH_PREP.hpp @@ -1,12 +1,14 @@ PREP(getId); -PREP(updateMarkers); -PREP(updateMarkersPosition); -PREP(updateDevices); -PREP(updatePosition); +PREP_VOID(updateMarkers); +PREP_VOID(updateMarkersPosition); +PREP_VOID(updateDevices); +PREP_VOID_HF(updatePosition); PREP(onConnected); PREP(connect); -PREP(updateMessages); +PREP_VOID(updateMessages); PREP(markMessageRead); PREP(sendMessage); PREP(deleteMessage); -PREP(updateMapMarkers); +PREP_VOID(updateMapMarkers); +PREP_VOID(updateAcoustic); + diff --git a/cTabIRL/@cTabIRL/addons/connect/XEH_postInit.sqf b/cTabIRL/@cTabIRL/addons/connect/XEH_postInit.sqf index 99f1db9c..ca1ce67f 100644 --- a/cTabIRL/@cTabIRL/addons/connect/XEH_postInit.sqf +++ b/cTabIRL/@cTabIRL/addons/connect/XEH_postInit.sqf @@ -37,6 +37,7 @@ if (!hasInterface) exitWith { }; ["loadout", FUNC(updateDevices)] call CBA_fnc_addPlayerEventHandler; ["unit", FUNC(updateDevices)] call CBA_fnc_addPlayerEventHandler; ["vehicle", FUNC(updateDevices)] call CBA_fnc_addPlayerEventHandler; + ["turret", FUNC(updateDevices)] call CBA_fnc_addPlayerEventHandler; // Update position 4 times per second GVAR(updatePFH) = [FUNC(updatePosition), 0.25] call CBA_fnc_addPerFrameHandler; @@ -45,22 +46,23 @@ if (!hasInterface) exitWith { }; ["ctab_listsUpdated", FUNC(updateMarkers)] call CBA_fnc_addEventHandler; ["ctab_userMarkerListUpdated", FUNC(updateMarkers)] call CBA_fnc_addEventHandler; ["ctab_messagesUpdated", FUNC(updateMessages)] call CBA_fnc_addEventHandler; + ["ctab_acousticdetector_update",{ GVAR(acousticNeedsUpdate) = true;}] call CBA_fnc_addEventHandler; addMissionEventHandler ["MarkerCreated", { params ['_name']; - if ( [_name] call FUNC(markerFilter) ) then { + if ( GVAR(syncMap) && {[_name] call FUNC(markerFilter)} ) then { GVAR(mapMarkersNeedsUpdate) = true; }; }]; addMissionEventHandler ["MarkerUpdated", { params ['_name']; - if ( [_name] call FUNC(markerFilter) ) then { + if ( GVAR(syncMap) && {[_name] call FUNC(markerFilter)} ) then { GVAR(mapMarkersNeedsUpdate) = true; }; }]; addMissionEventHandler ["MarkerDeleted", { params ['_name']; - if ( [_name] call FUNC(markerFilter) ) then { + if ( GVAR(syncMap) && {[_name] call FUNC(markerFilter)} ) then { GVAR(mapMarkersNeedsUpdate) = true; }; }]; diff --git a/cTabIRL/@cTabIRL/addons/connect/XEH_preInit.sqf b/cTabIRL/@cTabIRL/addons/connect/XEH_preInit.sqf index f0974ae9..6d09c806 100644 --- a/cTabIRL/@cTabIRL/addons/connect/XEH_preInit.sqf +++ b/cTabIRL/@cTabIRL/addons/connect/XEH_preInit.sqf @@ -72,7 +72,7 @@ GVAR(nextId) = 1; GVAR(nextMessageId) = 1; GVAR(deviceLevel) = 0; GVAR(vehicleMode) = 0; -GVAR(mapMarkersNeedsUpdate) = true; +GVAR(mapMarkersNeedsUpdate) = false; GVAR(trackDevices) = ["ItemcTab", "ItemAndroid"]; [QGVAR(enabled), "CHECKBOX", [LLSTRING(enabled), LLSTRING(enabledDetails)], ["cTab",LLSTRING(modName)], true, 0, {}, true] call CBA_fnc_addSetting; @@ -83,4 +83,4 @@ GVAR(trackDevices) = ["ItemcTab", "ItemAndroid"]; #endif [QGVAR(key), "EDITBOX", [LLSTRING(key), LLSTRING(keyDetails)], ["cTab",LLSTRING(modName)], "", 0, {}, true] call CBA_fnc_addSetting; -[QGVAR(syncMap), "CHECKBOX", [LLSTRING(syncMap), LLSTRING(syncMapDetails)], ["cTab",LLSTRING(modName)], true] call CBA_fnc_addSetting; +[QGVAR(syncMap), "CHECKBOX", [LLSTRING(syncMap), LLSTRING(syncMapDetails)], ["cTab",LLSTRING(modName)], true, 0, {GVAR(mapMarkersNeedsUpdate) = GVAR(syncMap);}] call CBA_fnc_addSetting; diff --git a/cTabIRL/@cTabIRL/addons/connect/functions/fnc_updateAcoustic.sqf b/cTabIRL/@cTabIRL/addons/connect/functions/fnc_updateAcoustic.sqf new file mode 100644 index 00000000..b3fbe435 --- /dev/null +++ b/cTabIRL/@cTabIRL/addons/connect/functions/fnc_updateAcoustic.sqf @@ -0,0 +1,6 @@ +#include "script_component.hpp" + +GVAR(acousticNeedsUpdate) = false; +toFixed 1; // 0.1 meters, 0.1 sec is far enough +"cTabExtension" callExtension ["UpdateAcoustic", [diag_tickTime, ctab_acousticdetector_detectedShots apply { _x select [0,5] }]]; +toFixed -1; diff --git a/cTabIRL/@cTabIRL/addons/connect/functions/fnc_updateMapMarkers.sqf b/cTabIRL/@cTabIRL/addons/connect/functions/fnc_updateMapMarkers.sqf index e37678f7..41396dd2 100644 --- a/cTabIRL/@cTabIRL/addons/connect/functions/fnc_updateMapMarkers.sqf +++ b/cTabIRL/@cTabIRL/addons/connect/functions/fnc_updateMapMarkers.sqf @@ -1,5 +1,7 @@ #include "script_component.hpp" +GVAR(mapMarkersNeedsUpdate) = false; + private _simple = []; private _poly = []; diff --git a/cTabIRL/@cTabIRL/addons/connect/functions/fnc_updatePosition.sqf b/cTabIRL/@cTabIRL/addons/connect/functions/fnc_updatePosition.sqf index 3e826dea..541fc16c 100644 --- a/cTabIRL/@cTabIRL/addons/connect/functions/fnc_updatePosition.sqf +++ b/cTabIRL/@cTabIRL/addons/connect/functions/fnc_updatePosition.sqf @@ -26,7 +26,10 @@ if ( ctab_core_bft_mode == 1 && { diag_tickTime > GVAR(nextMPU) } ) then { [true] call FUNC(updateMarkersPosition); }; -if ( GVAR(mapMarkersNeedsUpdate) && GVAR(syncMap) ) then { - GVAR(mapMarkersNeedsUpdate) = false; +if ( GVAR(mapMarkersNeedsUpdate) ) then { [] call FUNC(updateMapMarkers); }; + +if ( GVAR(acousticNeedsUpdate) ) then { + [] call FUNC(updateAcoustic); +}; diff --git a/cTabIRL/@cTabIRL/addons/connect/script_component.hpp b/cTabIRL/@cTabIRL/addons/connect/script_component.hpp index b766aff7..32bfe688 100644 --- a/cTabIRL/@cTabIRL/addons/connect/script_component.hpp +++ b/cTabIRL/@cTabIRL/addons/connect/script_component.hpp @@ -2,9 +2,10 @@ #include "\z\ctab_irl\addons\main\script_mod.hpp" // #define DEBUG_MODE_FULL -// #define DISABLE_COMPILE_CACHE + #define DISABLE_COMPILE_CACHE // #define DEBUG_SYNCHRONOUS // #define DEBUG_BACKEND +#define PROFILER #ifdef DEBUG_ENABLED_CONNECT #define DEBUG_MODE_FULL diff --git a/cTabIRL/@cTabIRL/addons/main/script_macros.hpp b/cTabIRL/@cTabIRL/addons/main/script_macros.hpp index 5363614e..e31ea1af 100644 --- a/cTabIRL/@cTabIRL/addons/main/script_macros.hpp +++ b/cTabIRL/@cTabIRL/addons/main/script_macros.hpp @@ -9,3 +9,15 @@ #undef PREP #define PREP(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf), QFUNC(fncName)] call CBA_fnc_compileFunction #endif + +#ifdef PROFILER + #define PREP_RET(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNC(fncName),true,false] call ctab_fnc_compileFunction + #define PREP_VOID(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNC(fncName),false,false] call ctab_fnc_compileFunction + #define PREP_RET_HF(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNC(fncName),true,true] call ctab_fnc_compileFunction + #define PREP_VOID_HF(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNC(fncName),false,true] call ctab_fnc_compileFunction +#else + #define PREP_RET(fncName) PREP(fncName) + #define PREP_VOID(fncName) PREP(fncName) + #define PREP_RET_HF(fncName) PREP(fncName) + #define PREP_VOID_HF(fncName) PREP(fncName) +#endif diff --git a/cTabIRL/cTabWebApp/Hub/CTabHub.cs b/cTabIRL/cTabWebApp/Hub/CTabHub.cs index 73f050ba..2a23a850 100644 --- a/cTabIRL/cTabWebApp/Hub/CTabHub.cs +++ b/cTabIRL/cTabWebApp/Hub/CTabHub.cs @@ -6,7 +6,6 @@ using System.Threading.Tasks; using Arma3TacMapLibrary.Arma3; using Arma3TacMapLibrary.Maps; -using Arma3TacMapLibrary.TacMaps; using cTabWebApp.Services; using cTabWebApp.TacMaps; using Microsoft.AspNetCore.Http.Extensions; @@ -85,6 +84,10 @@ private async Task WebJoin(PlayerState state) { await Clients.Caller.SendAsync("UpdateMapMarkers", state.LastUpdateMapMarkers); } + if (state.LastUpdateAcoustic != null) + { + await Clients.Caller.SendAsync("UpdateAcoustic", state.LastUpdateAcoustic); + } if (state.SyncedTacMapId != null) { await Clients.Caller.SendAsync("SyncTacMap", new SyncTacMapMessage() { MapId = state.SyncedTacMapId }); @@ -444,6 +447,54 @@ public async Task ArmaUpdateMarkers(ArmaMessage message) } } + public async Task ArmaUpdateAcoustic(ArmaMessage message) + { + //Console.WriteLine("ArmaUpdateMarkers " + string.Join(", ", message.Args)); + + var state = GetState(ConnectionKind.Arma); + if (state == null) + { + _logger.LogWarning($"No state for ArmaUpdateAcoustic"); + return; + } + + var gameTime = ArmaSerializer.ParseDouble(message.Args[0]); + var shots = ArmaSerializer.ParseMixedArray(message.Args[1]); + + var msg = new UpdateAcousticMessage() + { + Timestamp = message.Timestamp, + GameTime = gameTime ?? 0, + Shots = new List(shots.Length) + }; + + foreach (object[] data in shots) + { + var time = (double)data[0]; + var shotid = (int)((double)data[1]); + var pos = ((object[])data[2]).Cast().ToArray(); + var radius = (double)data[3]; + var caliber = (double)data[4]; + msg.Shots.Add(new DetectedShot() + { + Time = time, + Id = shotid, + X = pos[0] ?? 0, + Y = pos[1] ?? 0, + Radius = radius, + Caliber = caliber + }); + } + state.LastUpdateAcoustic = msg; + try + { + await Clients.Group(state.WebChannelName).SendAsync("UpdateAcoustic", state.LastUpdateAcoustic); + } + catch (Exception e) + { + _logger.LogWarning(e, "UpdateAcoustic failed"); + } + } public async Task ArmaUpdateMarkersPosition(ArmaMessage message) { diff --git a/cTabIRL/cTabWebApp/Hub/DetectedShot.cs b/cTabIRL/cTabWebApp/Hub/DetectedShot.cs new file mode 100644 index 00000000..2bee2612 --- /dev/null +++ b/cTabIRL/cTabWebApp/Hub/DetectedShot.cs @@ -0,0 +1,12 @@ +namespace cTabWebApp +{ + public class DetectedShot + { + public double Time { get; set; } + public int Id { get; set; } + public double X { get; set; } + public double Y { get; set; } + public double Radius { get; set; } + public double Caliber { get; set; } + } +} \ No newline at end of file diff --git a/cTabIRL/cTabWebApp/Hub/UpdateAcousticMessage.cs b/cTabIRL/cTabWebApp/Hub/UpdateAcousticMessage.cs new file mode 100644 index 00000000..7e918127 --- /dev/null +++ b/cTabIRL/cTabWebApp/Hub/UpdateAcousticMessage.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; + +namespace cTabWebApp +{ + public class UpdateAcousticMessage + { + public DateTime Timestamp { get; set; } + public List Shots { get; set; } + public double GameTime { get; set; } + } +} \ No newline at end of file diff --git a/cTabIRL/cTabWebApp/Services/PlayerState.cs b/cTabIRL/cTabWebApp/Services/PlayerState.cs index f52cd901..aada1117 100644 --- a/cTabIRL/cTabWebApp/Services/PlayerState.cs +++ b/cTabIRL/cTabWebApp/Services/PlayerState.cs @@ -36,5 +36,6 @@ public int ActiveConnections public bool IsAuthenticated { get; internal set; } public string SpectatorToken { get; internal set; } public UpdateMapMarkersMessage LastUpdateMapMarkers { get; internal set; } + public UpdateAcousticMessage LastUpdateAcoustic { get; set; } } } diff --git a/cTabIRL/cTabWebApp/wwwroot/js/map.js b/cTabIRL/cTabWebApp/wwwroot/js/map.js index 9a674c23..2b7c801a 100644 --- a/cTabIRL/cTabWebApp/wwwroot/js/map.js +++ b/cTabIRL/cTabWebApp/wwwroot/js/map.js @@ -64,6 +64,7 @@ var currentTacMapSynced = null; var currentMapInfos = null; var selfMarker = null; var existingMarkers = {}; +var existingShots = {}; var existingMapMarkers = {}; var centerOnPosition = true; var centerOnPositionButton = null; @@ -520,6 +521,27 @@ function updateMarkers(makers) { updateIsInContact(); } + +function updateAcoustic(data) { + + var shotsToKeep = []; + + data.shots.forEach(function (shot) { + var sid = ''+shot.id; + if (!existingShots[sid]) { + existingShots[sid] = L.circle([shot.y, shot.x], {radius: shot.radius, stroke: false, fill: true, fillColor:'red', fillOpacity: 0.2}).addTo(currentMap); + } + shotsToKeep.push(sid); + }); + + Object.getOwnPropertyNames(existingShots).forEach(function (id) { + if (shotsToKeep.indexOf(id) == -1) { + existingShots[id].remove(); + delete existingShots[id]; + } + }); +} + function updateIsInContact() { var isInContact = groupsInContact.indexOf(selfGroupId) != -1; if (selfIsInContact != isInContact) { @@ -959,6 +981,16 @@ $(function () { console.error(e); } }); + + connection.on("UpdateAcoustic", function (data) { + try { + console.log(data); + updateAcoustic(data); + } + catch (e) { + console.error(e); + } + }); connection.on("UpdateMapMarkers", function (data) { try { From ca408f9c945ae9a2b4eec53c8e42367aa2eeb4d5 Mon Sep 17 00:00:00 2001 From: Julien Date: Tue, 7 Mar 2023 05:05:21 +0100 Subject: [PATCH 5/7] Move profiler to a dedicated repo --- .../acousticdetector/script_component.hpp | 4 ++-- @cTab/addons/compass/script_component.hpp | 2 +- @cTab/addons/main/script_macros.hpp | 16 ++++++------- @cTab/addons/simpleprofiler/$PBOPREFIX$ | 1 - .../simpleprofiler/CfgEventHandlers.hpp | 5 ---- @cTab/addons/simpleprofiler/CfgFunctions.hpp | 11 --------- @cTab/addons/simpleprofiler/XEH_postInit.sqf | 1 - @cTab/addons/simpleprofiler/config.cpp | 16 ------------- .../simpleprofiler/fnc_compileFunction.sqf | 5 ---- .../simpleprofiler/fnc_highFreqReport.sqf | 12 ---------- .../fnc_instrumentAddPerFrameHandler.sqf | 7 ------ .../simpleprofiler/fnc_instrumentFunction.sqf | 23 ------------------- @cTab/addons/simpleprofiler/fnc_report.sqf | 11 --------- .../simpleprofiler/script_component.hpp | 15 ------------ .../addons/connect/script_component.hpp | 4 ++-- 15 files changed, 13 insertions(+), 120 deletions(-) delete mode 100644 @cTab/addons/simpleprofiler/$PBOPREFIX$ delete mode 100644 @cTab/addons/simpleprofiler/CfgEventHandlers.hpp delete mode 100644 @cTab/addons/simpleprofiler/CfgFunctions.hpp delete mode 100644 @cTab/addons/simpleprofiler/XEH_postInit.sqf delete mode 100644 @cTab/addons/simpleprofiler/config.cpp delete mode 100644 @cTab/addons/simpleprofiler/fnc_compileFunction.sqf delete mode 100644 @cTab/addons/simpleprofiler/fnc_highFreqReport.sqf delete mode 100644 @cTab/addons/simpleprofiler/fnc_instrumentAddPerFrameHandler.sqf delete mode 100644 @cTab/addons/simpleprofiler/fnc_instrumentFunction.sqf delete mode 100644 @cTab/addons/simpleprofiler/fnc_report.sqf delete mode 100644 @cTab/addons/simpleprofiler/script_component.hpp diff --git a/@cTab/addons/acousticdetector/script_component.hpp b/@cTab/addons/acousticdetector/script_component.hpp index dda3eff5..f1450c18 100644 --- a/@cTab/addons/acousticdetector/script_component.hpp +++ b/@cTab/addons/acousticdetector/script_component.hpp @@ -2,8 +2,8 @@ #include "\z\ctab\addons\main\script_mod.hpp" // #define DEBUG_MODE_FULL - #define DISABLE_COMPILE_CACHE -#define PROFILER +// #define DISABLE_COMPILE_CACHE +// #define PROFILER #ifdef DEBUG_ENABLED_CORE #define DEBUG_MODE_FULL diff --git a/@cTab/addons/compass/script_component.hpp b/@cTab/addons/compass/script_component.hpp index a705713f..24381118 100644 --- a/@cTab/addons/compass/script_component.hpp +++ b/@cTab/addons/compass/script_component.hpp @@ -3,7 +3,7 @@ // #define DEBUG_MODE_FULL // #define DISABLE_COMPILE_CACHE -#define PROFILER +// #define PROFILER #ifdef DEBUG_ENABLED_CORE #define DEBUG_MODE_FULL diff --git a/@cTab/addons/main/script_macros.hpp b/@cTab/addons/main/script_macros.hpp index 8310b71c..a1e9989a 100644 --- a/@cTab/addons/main/script_macros.hpp +++ b/@cTab/addons/main/script_macros.hpp @@ -16,14 +16,14 @@ #endif #ifdef PROFILER - #define PREP_RET(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNC(fncName),true,false] call ctab_fnc_compileFunction - #define PREP_VOID(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNC(fncName),false,false] call ctab_fnc_compileFunction - #define PREP_RET_HF(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNC(fncName),true,true] call ctab_fnc_compileFunction - #define PREP_VOID_HF(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNC(fncName),false,true] call ctab_fnc_compileFunction - #define PREPMAIN_RET(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNCMAIN(fncName),true,false] call ctab_fnc_compileFunction - #define PREPMAIN_VOID(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNCMAIN(fncName),false,false] call ctab_fnc_compileFunction - #define PREPMAIN_RET_HF(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNCMAIN(fncName),true,true] call ctab_fnc_compileFunction - #define PREPMAIN_VOID_HF(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNCMAIN(fncName),false,true] call ctab_fnc_compileFunction + #define PREP_RET(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNC(fncName),true,false] call bsp_fnc_compileFunction + #define PREP_VOID(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNC(fncName),false,false] call bsp_fnc_compileFunction + #define PREP_RET_HF(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNC(fncName),true,true] call bsp_fnc_compileFunction + #define PREP_VOID_HF(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNC(fncName),false,true] call bsp_fnc_compileFunction + #define PREPMAIN_RET(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNCMAIN(fncName),true,false] call bsp_fnc_compileFunction + #define PREPMAIN_VOID(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNCMAIN(fncName),false,false] call bsp_fnc_compileFunction + #define PREPMAIN_RET_HF(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNCMAIN(fncName),true,true] call bsp_fnc_compileFunction + #define PREPMAIN_VOID_HF(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNCMAIN(fncName),false,true] call bsp_fnc_compileFunction #else #define PREP_RET(fncName) PREP(fncName) #define PREP_VOID(fncName) PREP(fncName) diff --git a/@cTab/addons/simpleprofiler/$PBOPREFIX$ b/@cTab/addons/simpleprofiler/$PBOPREFIX$ deleted file mode 100644 index 9e67709b..00000000 --- a/@cTab/addons/simpleprofiler/$PBOPREFIX$ +++ /dev/null @@ -1 +0,0 @@ -z\ctab\addons\simpleprofiler diff --git a/@cTab/addons/simpleprofiler/CfgEventHandlers.hpp b/@cTab/addons/simpleprofiler/CfgEventHandlers.hpp deleted file mode 100644 index b0cc92b5..00000000 --- a/@cTab/addons/simpleprofiler/CfgEventHandlers.hpp +++ /dev/null @@ -1,5 +0,0 @@ -class Extended_PostInit_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_postInit)); - }; -}; diff --git a/@cTab/addons/simpleprofiler/CfgFunctions.hpp b/@cTab/addons/simpleprofiler/CfgFunctions.hpp deleted file mode 100644 index 35b709c9..00000000 --- a/@cTab/addons/simpleprofiler/CfgFunctions.hpp +++ /dev/null @@ -1,11 +0,0 @@ -class CfgFunctions { - class PREFIX { - class COMPONENT { - PATHTO_FNC(compileFunction); - PATHTO_FNC(instrumentFunction); - PATHTO_FNC(instrumentAddPerFrameHandler); - PATHTO_FNC(report); - PATHTO_FNC(highFreqReport); - }; - }; -}; \ No newline at end of file diff --git a/@cTab/addons/simpleprofiler/XEH_postInit.sqf b/@cTab/addons/simpleprofiler/XEH_postInit.sqf deleted file mode 100644 index 32e9af20..00000000 --- a/@cTab/addons/simpleprofiler/XEH_postInit.sqf +++ /dev/null @@ -1 +0,0 @@ -[ctab_fnc_highFreqReport, 30] call CBA_fnc_addPerFrameHandler; // High freq report every 30 seconds \ No newline at end of file diff --git a/@cTab/addons/simpleprofiler/config.cpp b/@cTab/addons/simpleprofiler/config.cpp deleted file mode 100644 index 9192a973..00000000 --- a/@cTab/addons/simpleprofiler/config.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "script_component.hpp" - -class CfgPatches { - class ADDON { - name = QUOTE(COMPONENT); - units[] = {}; - weapons[] = {}; - requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {}; - author = "GrueArbre"; - VERSION_CONFIG; - }; -}; - -#include "CfgEventHandlers.hpp" -#include "CfgFunctions.hpp" diff --git a/@cTab/addons/simpleprofiler/fnc_compileFunction.sqf b/@cTab/addons/simpleprofiler/fnc_compileFunction.sqf deleted file mode 100644 index 0c546d5a..00000000 --- a/@cTab/addons/simpleprofiler/fnc_compileFunction.sqf +++ /dev/null @@ -1,5 +0,0 @@ -#include "script_component.hpp" -params ["_sqfFile","_name","_isReturning","_isHighFreq"]; -private _fnc = [compileFinal preprocessFileLineNumbers _sqfFile, _name, _isReturning, _isHighFreq] call FUNCMAIN(instrumentFunction); -missionNamespace setVariable [_name, _fnc]; -_fnc \ No newline at end of file diff --git a/@cTab/addons/simpleprofiler/fnc_highFreqReport.sqf b/@cTab/addons/simpleprofiler/fnc_highFreqReport.sqf deleted file mode 100644 index 0d508334..00000000 --- a/@cTab/addons/simpleprofiler/fnc_highFreqReport.sqf +++ /dev/null @@ -1,12 +0,0 @@ -#include "script_component.hpp" -if (isNil QGVAR(highFreq)) exitWith {}; -INFO("Performance HF"); -{ - _x params ['_name','_counterFnc','_elapsedFnc', '_resetFnc']; - private _counter = call _counterFnc; - private _elapsed = (call _elapsedFnc) * 1000; - if ( _counter > 0) then { - INFO_4("%1;%2;%3;%4",_name, _counter, _elapsed, _elapsed / _counter); - }; - call _resetFnc; -} forEach GVAR(highFreq); diff --git a/@cTab/addons/simpleprofiler/fnc_instrumentAddPerFrameHandler.sqf b/@cTab/addons/simpleprofiler/fnc_instrumentAddPerFrameHandler.sqf deleted file mode 100644 index 3721fa01..00000000 --- a/@cTab/addons/simpleprofiler/fnc_instrumentAddPerFrameHandler.sqf +++ /dev/null @@ -1,7 +0,0 @@ -#include "script_component.hpp" -params [["_function", {}, [{}]], ["_name", "", [""]], ["_delay", 0, [0]], ["_args", []]]; -if (_delay<2) then { - [[_function,_name,false,true] call FUNCMAIN(instrumentFunction),_delay,_args] call CBA_fnc_addPerFrameHandler -} else { - [[_function,_name,false,false] call FUNCMAIN(instrumentFunction),_delay,_args] call CBA_fnc_addPerFrameHandler -} \ No newline at end of file diff --git a/@cTab/addons/simpleprofiler/fnc_instrumentFunction.sqf b/@cTab/addons/simpleprofiler/fnc_instrumentFunction.sqf deleted file mode 100644 index 33f28648..00000000 --- a/@cTab/addons/simpleprofiler/fnc_instrumentFunction.sqf +++ /dev/null @@ -1,23 +0,0 @@ -#include "script_component.hpp" -params ["_code","_name","_isReturning",["_isHighFreq",false]]; -if (isNil QGVAR(nextUid)) then { - GVAR(nextUid) = 1; - GVAR(data) = []; - GVAR(highFreq) = []; -}; -private _uid = GVAR(nextUid); -GVAR(nextUid) = GVAR(nextUid) + 1; -private _entry = [_name, compileFinal(format ["bsp_counter_%1", _uid]), compileFinal(format ["bsp_elapsed_%1", _uid]), compileFinal(format ["bsp_elapsed_%1=0;bsp_counter_%1=0;", _uid])]; -if (_isHighFreq) then { - GVAR(highFreq) pushBack _entry; -} else { - GVAR(data) pushBack _entry; -}; -missionNamespace setVariable [format ["bsp_fnc_%1", _uid], _code]; -missionNamespace setVariable [format ["bsp_counter_%1", _uid], 0]; -missionNamespace setVariable [format ["bsp_elapsed_%1", _uid], 0]; -if ( _isReturning ) then { - compileFinal (format ["bsp_counter_%1=bsp_counter_%1 + 1;private _s = diag_tickTime;private _r=_this call bsp_fnc_%1;bsp_elapsed_%1 = bsp_elapsed_%1 + diag_tickTime - _s;_r", _uid]) -} else { - compileFinal (format ["bsp_counter_%1=bsp_counter_%1 + 1;private _s = diag_tickTime;_this call bsp_fnc_%1;bsp_elapsed_%1 = bsp_elapsed_%1 + diag_tickTime - _s;", _uid]) -} \ No newline at end of file diff --git a/@cTab/addons/simpleprofiler/fnc_report.sqf b/@cTab/addons/simpleprofiler/fnc_report.sqf deleted file mode 100644 index bce137ac..00000000 --- a/@cTab/addons/simpleprofiler/fnc_report.sqf +++ /dev/null @@ -1,11 +0,0 @@ -#include "script_component.hpp" -if (isNil QGVAR(data)) exitWith {}; -INFO("Performance STD"); -{ - _x params ['_name','_counterFnc','_elapsedFnc']; - private _counter = call _counterFnc; - private _elapsed = (call _elapsedFnc) * 1000; - if ( _counter > 0) then { - INFO_4("%1;%2;%3;%4",_name, _counter, _elapsed, _elapsed / _counter); - }; -} forEach GVAR(data); diff --git a/@cTab/addons/simpleprofiler/script_component.hpp b/@cTab/addons/simpleprofiler/script_component.hpp deleted file mode 100644 index 00383094..00000000 --- a/@cTab/addons/simpleprofiler/script_component.hpp +++ /dev/null @@ -1,15 +0,0 @@ -#define MAINPREFIX z -#define PREFIX ctab -#define COMPONENT simpleprofiler -#define MAJOR 2 -#define MINOR 8 -#define PATCH 0 -#define BUILD 0 - -#define VERSION MAJOR.MINOR.PATCH.BUILD -#define VERSION_AR MAJOR,MINOR,PATCH,BUILD -#define REQUIRED_VERSION 1.88 - -#define RECOMPILE - -#include "\x\cba\addons\main\script_macros_common.hpp" diff --git a/cTabIRL/@cTabIRL/addons/connect/script_component.hpp b/cTabIRL/@cTabIRL/addons/connect/script_component.hpp index 32bfe688..dab47ba7 100644 --- a/cTabIRL/@cTabIRL/addons/connect/script_component.hpp +++ b/cTabIRL/@cTabIRL/addons/connect/script_component.hpp @@ -2,10 +2,10 @@ #include "\z\ctab_irl\addons\main\script_mod.hpp" // #define DEBUG_MODE_FULL - #define DISABLE_COMPILE_CACHE +// #define DISABLE_COMPILE_CACHE // #define DEBUG_SYNCHRONOUS // #define DEBUG_BACKEND -#define PROFILER +// #define PROFILER #ifdef DEBUG_ENABLED_CONNECT #define DEBUG_MODE_FULL From 1e7f2875aec56a96c671e97d0d3c73b3b3aed8b9 Mon Sep 17 00:00:00 2001 From: Julien Date: Tue, 7 Mar 2023 06:58:21 +0100 Subject: [PATCH 6/7] Remove profiling related config --- @cTab/addons/acousticdetector/XEH_PREP.hpp | 10 +++++----- .../acousticdetector/script_component.hpp | 1 - @cTab/addons/compass/XEH_PREP.hpp | 12 +++++------ @cTab/addons/compass/script_component.hpp | 1 - @cTab/addons/main/script_macros.hpp | 20 ------------------- cTabIRL/@cTabIRL/addons/connect/XEH_PREP.hpp | 14 ++++++------- .../@cTabIRL/addons/main/script_macros.hpp | 12 ----------- 7 files changed, 18 insertions(+), 52 deletions(-) diff --git a/@cTab/addons/acousticdetector/XEH_PREP.hpp b/@cTab/addons/acousticdetector/XEH_PREP.hpp index 606c27ad..224b5bcd 100644 --- a/@cTab/addons/acousticdetector/XEH_PREP.hpp +++ b/@cTab/addons/acousticdetector/XEH_PREP.hpp @@ -1,5 +1,5 @@ -PREP_RET(computeAmmoCaliberType); -PREP_VOID_HF(firedManEH); -PREP_VOID_HF(simulatePFH); -PREP_VOID(updateActiveState); -PREP_VOID(applySettings); +PREP(computeAmmoCaliberType); +PREP(firedManEH); +PREP(simulatePFH); +PREP(updateActiveState); +PREP(applySettings); diff --git a/@cTab/addons/acousticdetector/script_component.hpp b/@cTab/addons/acousticdetector/script_component.hpp index f1450c18..1dc38737 100644 --- a/@cTab/addons/acousticdetector/script_component.hpp +++ b/@cTab/addons/acousticdetector/script_component.hpp @@ -3,7 +3,6 @@ // #define DEBUG_MODE_FULL // #define DISABLE_COMPILE_CACHE -// #define PROFILER #ifdef DEBUG_ENABLED_CORE #define DEBUG_MODE_FULL diff --git a/@cTab/addons/compass/XEH_PREP.hpp b/@cTab/addons/compass/XEH_PREP.hpp index c83afdae..d0f646b7 100644 --- a/@cTab/addons/compass/XEH_PREP.hpp +++ b/@cTab/addons/compass/XEH_PREP.hpp @@ -1,6 +1,6 @@ -PREP_VOID(initCompass); -PREP_VOID_HF(updateCompass); -PREP_VOID(disposeCompass); -PREP_VOID(addMarkerBar); -PREP_VOID(updateMarkerBar); -PREP_VOID(deleteMarkerBar); +PREP(initCompass); +PREP(updateCompass); +PREP(disposeCompass); +PREP(addMarkerBar); +PREP(updateMarkerBar); +PREP(deleteMarkerBar); diff --git a/@cTab/addons/compass/script_component.hpp b/@cTab/addons/compass/script_component.hpp index 24381118..3ec9db51 100644 --- a/@cTab/addons/compass/script_component.hpp +++ b/@cTab/addons/compass/script_component.hpp @@ -3,7 +3,6 @@ // #define DEBUG_MODE_FULL // #define DISABLE_COMPILE_CACHE -// #define PROFILER #ifdef DEBUG_ENABLED_CORE #define DEBUG_MODE_FULL diff --git a/@cTab/addons/main/script_macros.hpp b/@cTab/addons/main/script_macros.hpp index a1e9989a..7bf3469b 100644 --- a/@cTab/addons/main/script_macros.hpp +++ b/@cTab/addons/main/script_macros.hpp @@ -14,23 +14,3 @@ #undef PREPMAIN #define PREPMAIN(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf), QFUNCMAIN(fncName)] call CBA_fnc_compileFunction #endif - -#ifdef PROFILER - #define PREP_RET(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNC(fncName),true,false] call bsp_fnc_compileFunction - #define PREP_VOID(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNC(fncName),false,false] call bsp_fnc_compileFunction - #define PREP_RET_HF(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNC(fncName),true,true] call bsp_fnc_compileFunction - #define PREP_VOID_HF(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNC(fncName),false,true] call bsp_fnc_compileFunction - #define PREPMAIN_RET(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNCMAIN(fncName),true,false] call bsp_fnc_compileFunction - #define PREPMAIN_VOID(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNCMAIN(fncName),false,false] call bsp_fnc_compileFunction - #define PREPMAIN_RET_HF(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNCMAIN(fncName),true,true] call bsp_fnc_compileFunction - #define PREPMAIN_VOID_HF(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNCMAIN(fncName),false,true] call bsp_fnc_compileFunction -#else - #define PREP_RET(fncName) PREP(fncName) - #define PREP_VOID(fncName) PREP(fncName) - #define PREP_RET_HF(fncName) PREP(fncName) - #define PREP_VOID_HF(fncName) PREP(fncName) - #define PREPMAIN_RET(fncName) PREPMAIN(fncName) - #define PREPMAIN_VOID(fncName) PREPMAIN(fncName) - #define PREPMAIN_RET_HF(fncName) PREPMAIN(fncName) - #define PREPMAIN_VOID_HF(fncName) PREPMAIN(fncName) -#endif diff --git a/cTabIRL/@cTabIRL/addons/connect/XEH_PREP.hpp b/cTabIRL/@cTabIRL/addons/connect/XEH_PREP.hpp index c9dbfea6..845ee50f 100644 --- a/cTabIRL/@cTabIRL/addons/connect/XEH_PREP.hpp +++ b/cTabIRL/@cTabIRL/addons/connect/XEH_PREP.hpp @@ -1,14 +1,14 @@ PREP(getId); -PREP_VOID(updateMarkers); -PREP_VOID(updateMarkersPosition); -PREP_VOID(updateDevices); -PREP_VOID_HF(updatePosition); +PREP(updateMarkers); +PREP(updateMarkersPosition); +PREP(updateDevices); +PREP(updatePosition); PREP(onConnected); PREP(connect); -PREP_VOID(updateMessages); +PREP(updateMessages); PREP(markMessageRead); PREP(sendMessage); PREP(deleteMessage); -PREP_VOID(updateMapMarkers); -PREP_VOID(updateAcoustic); +PREP(updateMapMarkers); +PREP(updateAcoustic); diff --git a/cTabIRL/@cTabIRL/addons/main/script_macros.hpp b/cTabIRL/@cTabIRL/addons/main/script_macros.hpp index e31ea1af..5363614e 100644 --- a/cTabIRL/@cTabIRL/addons/main/script_macros.hpp +++ b/cTabIRL/@cTabIRL/addons/main/script_macros.hpp @@ -9,15 +9,3 @@ #undef PREP #define PREP(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf), QFUNC(fncName)] call CBA_fnc_compileFunction #endif - -#ifdef PROFILER - #define PREP_RET(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNC(fncName),true,false] call ctab_fnc_compileFunction - #define PREP_VOID(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNC(fncName),false,false] call ctab_fnc_compileFunction - #define PREP_RET_HF(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNC(fncName),true,true] call ctab_fnc_compileFunction - #define PREP_VOID_HF(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf),QFUNC(fncName),false,true] call ctab_fnc_compileFunction -#else - #define PREP_RET(fncName) PREP(fncName) - #define PREP_VOID(fncName) PREP(fncName) - #define PREP_RET_HF(fncName) PREP(fncName) - #define PREP_VOID_HF(fncName) PREP(fncName) -#endif From fa83f898c6a84b618f1d619335beb0927c8ab8de Mon Sep 17 00:00:00 2001 From: Julien Date: Sat, 18 Jan 2025 12:03:53 +0100 Subject: [PATCH 7/7] Fix HEMTT build --- @cTab/addons/acousticdetector/stringtable.xml | 2 +- @cTab/addons/compass/HorizontalCompass.hpp | 76 +++++++++---------- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/@cTab/addons/acousticdetector/stringtable.xml b/@cTab/addons/acousticdetector/stringtable.xml index 66ee5a3a..f5dd5bd2 100644 --- a/@cTab/addons/acousticdetector/stringtable.xml +++ b/@cTab/addons/acousticdetector/stringtable.xml @@ -1,4 +1,4 @@ - + diff --git a/@cTab/addons/compass/HorizontalCompass.hpp b/@cTab/addons/compass/HorizontalCompass.hpp index d70adeda..6af7bf7b 100644 --- a/@cTab/addons/compass/HorizontalCompass.hpp +++ b/@cTab/addons/compass/HorizontalCompass.hpp @@ -50,46 +50,46 @@ class GVARMAIN(HorizontalCompass) : RscControlsGroupNoScrollbars class B00 : RscText { idc=9200; - w = BAR_WIDTH/18; - h = BAR_HEIGHT/4; - y = BAR_HEIGHT*3/4; + w = QUOTE(BAR_WIDTH/18); + h = QUOTE(BAR_HEIGHT/4); + y = QUOTE(BAR_HEIGHT*3/4); colorBackground[] = { 1, 0, 0, 0.8 }; }; - class B01 : B00 { idc=9201; x = BAR_WIDTH*01/18; }; - class B02 : B00 { idc=9202; x = BAR_WIDTH*02/18; }; - class B03 : B00 { idc=9203; x = BAR_WIDTH*03/18; }; - class B04 : B00 { idc=9204; x = BAR_WIDTH*04/18; }; - class B05 : B00 { idc=9205; x = BAR_WIDTH*05/18; }; - class B06 : B00 { idc=9206; x = BAR_WIDTH*06/18; }; - class B07 : B00 { idc=9207; x = BAR_WIDTH*07/18; }; - class B08 : B00 { idc=9208; x = BAR_WIDTH*08/18; }; - class B09 : B00 { idc=9209; x = BAR_WIDTH*09/18; }; - class B10 : B00 { idc=9210; x = BAR_WIDTH*10/18; }; - class B11 : B00 { idc=9211; x = BAR_WIDTH*11/18; }; - class B12 : B00 { idc=9212; x = BAR_WIDTH*12/18; }; - class B13 : B00 { idc=9213; x = BAR_WIDTH*13/18; }; - class B14 : B00 { idc=9214; x = BAR_WIDTH*14/18; }; - class B15 : B00 { idc=9215; x = BAR_WIDTH*15/18; }; - class B16 : B00 { idc=9216; x = BAR_WIDTH*16/18; }; - class B17 : B00 { idc=9217; x = BAR_WIDTH*17/18; }; - class B18 : B00 { idc=9218; x = BAR_WIDTH*18/18; }; - class B19 : B00 { idc=9219; x = BAR_WIDTH*19/18; }; - class B20 : B00 { idc=9220; x = BAR_WIDTH*20/18; }; - class B21 : B00 { idc=9221; x = BAR_WIDTH*21/18; }; - class B22 : B00 { idc=9222; x = BAR_WIDTH*22/18; }; - class B23 : B00 { idc=9223; x = BAR_WIDTH*23/18; }; - class B24 : B00 { idc=9224; x = BAR_WIDTH*24/18; }; - class B25 : B00 { idc=9225; x = BAR_WIDTH*25/18; }; - class B26 : B00 { idc=9226; x = BAR_WIDTH*26/18; }; - class B27 : B00 { idc=9227; x = BAR_WIDTH*27/18; }; - class B28 : B00 { idc=9228; x = BAR_WIDTH*28/18; }; - class B29 : B00 { idc=9229; x = BAR_WIDTH*29/18; }; - class B30 : B00 { idc=9230; x = BAR_WIDTH*30/18; }; - class B31 : B00 { idc=9231; x = BAR_WIDTH*31/18; }; - class B32 : B00 { idc=9232; x = BAR_WIDTH*32/18; }; - class B33 : B00 { idc=9233; x = BAR_WIDTH*33/18; }; - class B34 : B00 { idc=9234; x = BAR_WIDTH*34/18; }; - class B35 : B00 { idc=9235; x = BAR_WIDTH*35/18; }; + class B01 : B00 { idc=9201; x = QUOTE(BAR_WIDTH*01/18); }; + class B02 : B00 { idc=9202; x = QUOTE(BAR_WIDTH*02/18); }; + class B03 : B00 { idc=9203; x = QUOTE(BAR_WIDTH*03/18); }; + class B04 : B00 { idc=9204; x = QUOTE(BAR_WIDTH*04/18); }; + class B05 : B00 { idc=9205; x = QUOTE(BAR_WIDTH*05/18); }; + class B06 : B00 { idc=9206; x = QUOTE(BAR_WIDTH*06/18); }; + class B07 : B00 { idc=9207; x = QUOTE(BAR_WIDTH*07/18); }; + class B08 : B00 { idc=9208; x = QUOTE(BAR_WIDTH*08/18); }; + class B09 : B00 { idc=9209; x = QUOTE(BAR_WIDTH*09/18); }; + class B10 : B00 { idc=9210; x = QUOTE(BAR_WIDTH*10/18); }; + class B11 : B00 { idc=9211; x = QUOTE(BAR_WIDTH*11/18); }; + class B12 : B00 { idc=9212; x = QUOTE(BAR_WIDTH*12/18); }; + class B13 : B00 { idc=9213; x = QUOTE(BAR_WIDTH*13/18); }; + class B14 : B00 { idc=9214; x = QUOTE(BAR_WIDTH*14/18); }; + class B15 : B00 { idc=9215; x = QUOTE(BAR_WIDTH*15/18); }; + class B16 : B00 { idc=9216; x = QUOTE(BAR_WIDTH*16/18); }; + class B17 : B00 { idc=9217; x = QUOTE(BAR_WIDTH*17/18); }; + class B18 : B00 { idc=9218; x = QUOTE(BAR_WIDTH*18/18); }; + class B19 : B00 { idc=9219; x = QUOTE(BAR_WIDTH*19/18); }; + class B20 : B00 { idc=9220; x = QUOTE(BAR_WIDTH*20/18); }; + class B21 : B00 { idc=9221; x = QUOTE(BAR_WIDTH*21/18); }; + class B22 : B00 { idc=9222; x = QUOTE(BAR_WIDTH*22/18); }; + class B23 : B00 { idc=9223; x = QUOTE(BAR_WIDTH*23/18); }; + class B24 : B00 { idc=9224; x = QUOTE(BAR_WIDTH*24/18); }; + class B25 : B00 { idc=9225; x = QUOTE(BAR_WIDTH*25/18); }; + class B26 : B00 { idc=9226; x = QUOTE(BAR_WIDTH*26/18); }; + class B27 : B00 { idc=9227; x = QUOTE(BAR_WIDTH*27/18); }; + class B28 : B00 { idc=9228; x = QUOTE(BAR_WIDTH*28/18); }; + class B29 : B00 { idc=9229; x = QUOTE(BAR_WIDTH*29/18); }; + class B30 : B00 { idc=9230; x = QUOTE(BAR_WIDTH*30/18); }; + class B31 : B00 { idc=9231; x = QUOTE(BAR_WIDTH*31/18); }; + class B32 : B00 { idc=9232; x = QUOTE(BAR_WIDTH*32/18); }; + class B33 : B00 { idc=9233; x = QUOTE(BAR_WIDTH*33/18); }; + class B34 : B00 { idc=9234; x = QUOTE(BAR_WIDTH*34/18); }; + class B35 : B00 { idc=9235; x = QUOTE(BAR_WIDTH*35/18); }; }; }; class Bar2 : Bar1