Hearing - Removed remoteExec & added microoptimisations (#9853)

* Removed remoteExec. added microoptimisations

* Update addons/hearing/XEH_preInit.sqf

Co-authored-by: PabstMirror <pabstmirror@gmail.com>

* move EH to after !hasInterface

---------

Co-authored-by: PabstMirror <pabstmirror@gmail.com>
This commit is contained in:
johnb432 2024-03-21 20:26:46 +01:00 committed by GitHub
parent b4eaa1e270
commit 50978efa46
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 12 deletions

View File

@ -23,6 +23,8 @@ GVAR(lastPlayerVehicle) = objNull;
// Spawn volume updating process
[LINKFUNC(updateVolume), 1, [false]] call CBA_fnc_addPerFrameHandler;
[QGVAR(updateVolume), LINKFUNC(updateVolume)] call CBA_fnc_addEventHandler;
// Update veh attunation when player veh changes
["vehicle", {
params ["_player", "_vehicle"];

View File

@ -12,7 +12,8 @@ PREP_RECOMPILE_END;
params ["_unit", "_loadout", "_extendedInfo"];
if (_extendedInfo getOrDefault ["ace_earplugs", false]) then {
_unit setVariable ["ACE_hasEarPlugsIn", true, true];
[[true]] remoteExec [QFUNC(updateVolume), _unit];
[QGVAR(updateVolume), [[true]], _unit] call CBA_fnc_targetEvent;
};
}] call CBA_fnc_addEventHandler;

View File

@ -15,14 +15,14 @@
* Public: No
*/
params ["_unit"];
TRACE_2("params",_unit,typeOf _unit);
// only run this after the settings are initialized
if !(EGVAR(common,settingsInitFinished)) exitWith {
EGVAR(common,runAtSettingsInitialized) pushBack [FUNC(addEarPlugs), _this];
};
params ["_unit"];
TRACE_2("params",_unit,typeOf _unit);
// Exit if hearing is disabled OR autoAdd is disabled OR soldier has earplugs already in (persistence scenarios)
if (!GVAR(enableCombatDeafness) || {!GVAR(autoAddEarplugsToUnits)} || {[_unit] call FUNC(hasEarPlugsIn)}) exitWith {};
@ -38,16 +38,20 @@ if ((primaryWeapon _unit) == "") exitWith {};
(primaryWeaponMagazine _unit) params [["_magazine", ""]];
if (_magazine == "") exitWith {};
private _initSpeed = getNumber (configFile >> "CfgMagazines" >> _magazine >> "initSpeed");
private _ammo = getText (configFile >> "CfgMagazines" >> _magazine >> "ammo");
private _count = getNumber (configFile >> "CfgMagazines" >> _magazine >> "count");
private _cfgMagazine = configFile >> "CfgMagazines" >> _magazine;
private _caliber = getNumber (configFile >> "CfgAmmo" >> _ammo >> "ACE_caliber");
private _initSpeed = getNumber (_cfgMagazine >> "initSpeed");
private _ammo = getText (_cfgMagazine >> "ammo");
private _count = getNumber (_cfgMagazine >> "count");
private _cfgAmmo = configFile >> "CfgAmmo";
private _caliber = getNumber (_cfgAmmo >> _ammo >> "ACE_caliber");
_caliber = call {
if (_ammo isKindOf ["ShellBase", (configFile >> "CfgAmmo")]) exitWith { 80 };
if (_ammo isKindOf ["RocketBase", (configFile >> "CfgAmmo")]) exitWith { 200 };
if (_ammo isKindOf ["MissileBase", (configFile >> "CfgAmmo")]) exitWith { 600 };
if (_ammo isKindOf ["SubmunitionBase", (configFile >> "CfgAmmo")]) exitWith { 80 };
if (_ammo isKindOf ["ShellBase", _cfgAmmo]) exitWith { 80 };
if (_ammo isKindOf ["RocketBase", _cfgAmmo]) exitWith { 200 };
if (_ammo isKindOf ["MissileBase", _cfgAmmo]) exitWith { 600 };
if (_ammo isKindOf ["SubmunitionBase", _cfgAmmo]) exitWith { 80 };
[_caliber, 6.5] select (_caliber <= 0);
};
private _loudness = (_caliber ^ 1.25 / 10) * (_initspeed / 1000) / 5;