diff --git a/addons/frag/functions/fnc_dev_debugAmmo.sqf b/addons/frag/functions/fnc_dev_debugAmmo.sqf index db093f66c9..fd7b0b30d3 100644 --- a/addons/frag/functions/fnc_dev_debugAmmo.sqf +++ b/addons/frag/functions/fnc_dev_debugAmmo.sqf @@ -39,9 +39,10 @@ if (_onlyShotAmmoTypes) then { ]; if (_ammo isEqualTo "" || {_ammo in _allAmmoConfigs}) exitWith {}; _allAmmoConfigs pushBack _ammo; - private _subMunit = toLowerANSI getText (configFile >> "cfgAmmo" >> _ammo >> "submunitionAmmo"); + private _ammoConfig = configFile >> "cfgAmmo" >> _ammo; + private _subMunit = toLowerANSI getText (_ammoConfig >> "submunitionAmmo"); if (_subMunit isNotEqualTo "") then { - _subMunit = getArray (configFile >> "cfgAmmo" >> _ammo >> "submunitionAmmo"); + _subMunit = getArray (_ammoConfig >> "submunitionAmmo"); for "_i" from 0 to count _subMunit - 1 do { if (_i mod 2 == 0) then { [toLowerANSI (_subMunit#_i)] call _configSearchFunc; @@ -57,7 +58,7 @@ if (_onlyShotAmmoTypes) then { [toLowerANSI getText (_x >> "ammo")] call _configSearchFunc; } forEach _allMagazineConfigs; } else { - _allAmmoConfigs = configProperties [configFile >> "cfgAmmo", "isClass _x && !('ace_frag' in configName _x)", true] apply {configName _x}; + _allAmmoConfigs = configProperties [configFile >> "CfgAmmo", "isClass _x && !('ace_frag' in configName _x)", true] apply {configName _x}; }; private _processedCfgAmmos = []; @@ -67,7 +68,7 @@ private _printCount = 0; if (_ammo != "" && {!(_ammo in _processedCfgAmmos)}) then { _processedCfgAmmos pushBack _ammo; - private _ammoConfig = (configFile >> "cfgAmmo" >> _ammo); + private _ammoConfig = (configFile >> "CfgAmmo" >> _ammo); private _shoulFrag = [_ammo] call FUNC(shouldFrag); if (_shoulFrag || _logAll) then { diff --git a/addons/frag/functions/fnc_getFragInfo.sqf b/addons/frag/functions/fnc_getFragInfo.sqf index 47d724da34..f5a0fce58b 100644 --- a/addons/frag/functions/fnc_getFragInfo.sqf +++ b/addons/frag/functions/fnc_getFragInfo.sqf @@ -27,10 +27,11 @@ private _ammoInfo = GVAR(fragInfoCache) get _ammo; if (!isNil "_ammoInfo") exitWith {_ammoInfo}; +private _ammoConfig = configFile >> "CfgAmmo" >> _ammo; private _fragTypes = []; private _warn = false; -if (isArray (configFile >> "cfgAmmo" >> _ammo >> QGVAR(CLASSES))) then { - _fragTypes = getArray (configFile >> "cfgAmmo" >> _ammo >> QGVAR(CLASSES)); +if (isArray (_ammoConfig >> QGVAR(CLASSES))) then { + _fragTypes = getArray (_ammoConfig >> QGVAR(CLASSES)); } else { _warn = true; }; @@ -55,16 +56,35 @@ if (isArray (configFile >> "cfgAmmo" >> _ammo >> QGVAR(CLASSES))) then { * or 0.8 * _gurneyConstant * sqrt (_chargeMass /(_metalMass + _chargeMass * _geometryCoefficient)); (slightly faster to compute) */ -private _chargeMass = getNumber (configFile >> "cfgAmmo" >> _ammo >> QGVAR(CHARGE)); -if (_chargeMass == 0) then {_chargeMass = 1; _warn = true;}; -private _metalMass = getNumber (configFile >> "cfgAmmo" >> _ammo >> QGVAR(METAL)); -if (_metalMass == 0) then {_metalMass = 2; _warn = true;}; -private _geometryCoefficient = getNumber (configFile >> "cfgAmmo" >> _ammo >> QGVAR(GURNEY_K)); -if (_geometryCoefficient == 0) then {_geometryCoefficient = 0.8; _warn = true;}; -private _gurneyConstant = getNumber (configFile >> "cfgAmmo" >> _ammo >> QGVAR(GURNEY_C)); -if (_gurneyConstant == 0) then {_gurneyConstant = 2440; _warn = true;}; -private _fragCount = getNumber (configFile >> "cfgAmmo" >> _ammo >> QGVAR(fragCount)); -if (_fragCount == 0) then {_fragCount = 400; _warn = true;}; +private _chargeMass = getNumber (_ammoConfig >> QGVAR(CHARGE)); +if (_chargeMass == 0) then { + _chargeMass = 1; + _warn = true; +}; + +private _metalMass = getNumber (_ammoConfig >> QGVAR(METAL)); +if (_metalMass == 0) then { + _metalMass = 2; + _warn = true; +}; + +private _geometryCoefficient = getNumber (_ammoConfig >> QGVAR(GURNEY_K)); +if (_geometryCoefficient == 0) then { + _geometryCoefficient = 0.8; + _warn = true; +}; + +private _gurneyConstant = getNumber (_ammoConfig >> QGVAR(GURNEY_C)); +if (_gurneyConstant == 0) then { + _gurneyConstant = 2440; + _warn = true; +}; + +private _fragCount = getNumber (_ammoConfig >> QGVAR(fragCount)); +if (_fragCount == 0) then { + _fragCount = 400; + _warn = true; +}; if (_warn) then { INFO_1("Ammo class %1 lacks proper explosive properties definitions for frag!",_ammo); diff --git a/addons/frag/functions/fnc_getMaterialInfo.sqf b/addons/frag/functions/fnc_getMaterialInfo.sqf index 54d01cc103..2ca46ac8d8 100644 --- a/addons/frag/functions/fnc_getMaterialInfo.sqf +++ b/addons/frag/functions/fnc_getMaterialInfo.sqf @@ -28,10 +28,11 @@ if (!isNil "_material") exitWith { _material }; // Use 'soundEnviron' or 'soundHit' to extract approx material -if (isClass (configFile >> "CfgSurfaces" >> _surfType)) then { - _material = getText (configFile >> "CfgSurfaces" >> _surfType >> "soundEnviron"); +private _surfaceConfig = configFile >> "CfgSurfaces" >> _surfType; +if (isClass _surfaceConfig) then { + _material = getText (_surfaceConfig >> "soundEnviron"); if (_material isEqualTo "" || {_material isEqualTo "empty"}) then { - _material = getText (configFile >> "CfgSurfaces" >> _surfType >> "soundhit"); + _material = getText (_surfaceConfig >> "soundhit"); }; } else { // Messy way when a surface isn't added to cfgSurfaces private _surfFileText = toLowerANSI preprocessFile _surfType; diff --git a/addons/frag/functions/fnc_getSpallInfo.sqf b/addons/frag/functions/fnc_getSpallInfo.sqf index 7126803933..a8751351fe 100644 --- a/addons/frag/functions/fnc_getSpallInfo.sqf +++ b/addons/frag/functions/fnc_getSpallInfo.sqf @@ -25,9 +25,10 @@ private _ammoInfo = GVAR(spallInfoCache) get _ammo; if (!isNil "_ammoInfo") exitWith {_ammoInfo}; -private _caliber = getNumber (configFile >> "CfgAmmo" >> _ammo >> "caliber"); -private _explosive = 1 min getNumber (configFile >> "CfgAmmo" >> _ammo >> "explosive"); -private _indirectHit = getNumber (configFile >> "CfgAmmo" >> _ammo >> "indirectHitRange"); +private _ammoConfig = (configFile >> "CfgAmmo" >> _ammo); +private _caliber = getNumber (_ammoConfig >> "caliber"); +private _explosive = 1 min getNumber (_ammoConfig >> "explosive"); +private _indirectHit = getNumber (_ammoConfig >> "indirectHitRange"); private _ammoInfo = [_caliber, _explosive, _indirectHit]; GVAR(spallInfoCache) set [_ammo, _ammoInfo]; diff --git a/addons/frag/functions/fnc_initBlackList.sqf b/addons/frag/functions/fnc_initBlackList.sqf index 78b8ecb19a..3802130de1 100644 --- a/addons/frag/functions/fnc_initBlackList.sqf +++ b/addons/frag/functions/fnc_initBlackList.sqf @@ -24,7 +24,7 @@ if (!ADDON) then { // could improve text parsing of CBA setting string private _convArray = parseSimpleArray GVAR(blackList); -if (count _convArray == 0 ) exitWith { +if (_convArray isEqualTo []) exitWith { TRACE_1("Empty blacklist", _convArray); }; diff --git a/addons/frag/functions/fnc_shouldFrag.sqf b/addons/frag/functions/fnc_shouldFrag.sqf index d957781f10..f9e032d301 100644 --- a/addons/frag/functions/fnc_shouldFrag.sqf +++ b/addons/frag/functions/fnc_shouldFrag.sqf @@ -24,11 +24,12 @@ if (!isNil "_shouldFrag") exitWith {_shouldFrag}; _shouldFrag = true; -private _skip = getNumber (configFile >> "cfgAmmo" >> _ammo >> QGVAR(skip)); -private _force = getNumber (configFile >> "cfgAmmo" >> _ammo >> QGVAR(force)); -private _explosive = getNumber (configFile >> "cfgAmmo" >> _ammo >> "explosive"); -private _indirectHit = getNumber (configFile >> "cfgAmmo" >> _ammo >> "indirectHit"); -private _indirectRange = getNumber (configFile >> "cfgAmmo" >> _ammo >> "indirectHitRange"); +private _ammoConfig = configFile >> "CfgAmmo" >> _ammo; +private _skip = getNumber (_ammoConfig >> QGVAR(skip)); +private _force = getNumber (_ammoConfig >> QGVAR(force)); +private _explosive = getNumber (_ammoConfig >> "explosive"); +private _indirectHit = getNumber (_ammoConfig >> "indirectHit"); +private _indirectRange = getNumber (_ammoConfig >> "indirectHitRange"); if (_skip == 1 || (_force == 0 && {_explosive < 0.5 || {_indirectHit < 3 || {_indirectRange < 5 && _indirectHit < _indirectRange}}})) then { diff --git a/addons/frag/functions/fnc_shouldSpall.sqf b/addons/frag/functions/fnc_shouldSpall.sqf index 1ece3ba0c8..0265aa305a 100644 --- a/addons/frag/functions/fnc_shouldSpall.sqf +++ b/addons/frag/functions/fnc_shouldSpall.sqf @@ -22,9 +22,10 @@ private _shouldSpall = GVAR(shouldSpallCache) get _ammo; if (!isNil "_shouldSpall") exitWith {_shouldSpall}; -private _caliber = getNumber (configFile >> "CfgAmmo" >> _ammo >> "caliber"); -private _explosive = getNumber (configFile >> "CfgAmmo" >> _ammo >> "explosive"); -private _indirectHit = getNumber (configFile >> "CfgAmmo" >> _ammo >> "indirectHitRange"); +private _ammoConfig = configFile >> "CfgAmmo" >> _ammo; +private _caliber = getNumber (_ammoConfig >> "caliber"); +private _explosive = getNumber (_ammoConfig >> "explosive"); +private _indirectHit = getNumber (_ammoConfig >> "indirectHitRange"); _shouldSpall = _caliber * GVAR(spallIntensity) >= 2.5 || (_explosive >= 0.5 && _explosive * _indirectHit * GVAR(spallIntensity) >= 4);