Apply suggestions from code review

Small formatting changes and small errors

Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
This commit is contained in:
lambdatiger 2024-02-14 16:50:09 -06:00 committed by GitHub
parent 665707bbda
commit 1da1c68803
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 39 additions and 38 deletions

View File

@ -13,7 +13,7 @@
* true results in blue traces, false in red. <BOOL> * true results in blue traces, false in red. <BOOL>
* *
* Return Value: * Return Value:
* None * Nothing Useful
* *
* Example: * Example:
* [_projectile, false, false] call ace_frag_dev_addRound; * [_projectile, false, false] call ace_frag_dev_addRound;
@ -28,9 +28,9 @@ params [
]; ];
if (_isSidePlayer) then { if (_isSidePlayer) then {
GVAR(dev_trackLines) set [getObjectID _projectile, [[getposATL _projectile], [0, 0, 1, 1]]]; GVAR(dev_trackLines) set [getObjectID _projectile, [[getPosATL _projectile], [0, 0, 1, 1]]];
} else { } else {
GVAR(dev_trackLines) set [getObjectID _projectile, [[getposATL _projectile], [1, 0, 0, 1]]]; GVAR(dev_trackLines) set [getObjectID _projectile, [[getPosATL _projectile], [1, 0, 0, 1]]];
}; };
// event handler to track round and cleanup when round is "dead" // event handler to track round and cleanup when round is "dead"

View File

@ -81,20 +81,20 @@ private _printCount = 0;
private _warn = false; private _warn = false;
private _skip = getNumber (_ammoConfig >> QGVAR(skip)); private _skip = getNumber (_ammoConfig >> QGVAR(skip));
private _fragTypes = getArray (_ammoConfig >> QGVAR(CLASSES)); private _fragTypes = getArray (_ammoConfig >> QGVAR(classes));
if (_fragTypes isEqualTo []) then {_warn = true;}; if (_fragTypes isEqualTo []) then {_warn = true;};
private _c = getNumber(_ammoConfig >> QGVAR(CHARGE)); private _c = getNumber (_ammoConfig >> QGVAR(charge));
if (_c == 0) then {_warn = true;}; if (_c == 0) then {_warn = true;};
private _m = getNumber(_ammoConfig >> QGVAR(METAL)); private _m = getNumber (_ammoConfig >> QGVAR(metal));
if (_m == 0) then {_warn = true;}; if (_m == 0) then {_warn = true;};
private _k = getNumber(_ammoConfig >> QGVAR(GURNEY_K)); private _k = getNumber (_ammoConfig >> QGVAR(gurney_k));
if (_k == 0) then {_warn = true;}; if (_k == 0) then {_warn = true;};
private _gC = getNumber(_ammoConfig >> QGVAR(GURNEY_C)); private _gC = getNumber (_ammoConfig >> QGVAR(gurney_c));
if (_gC == 0) then {_warn = true;}; if (_gC == 0) then {_warn = true;};
private _fragCount = getNumber (_ammoConfig >> QGVAR(fragCount)); private _fragCount = getNumber (_ammoConfig >> QGVAR(fragCount));
if (_fragCount == 0) then {_fragCount = 200; _warn = true;}; if (_fragCount == 0) then {_fragCount = 200; _warn = true;};
if (!_printOnlyIncomplete || {_warn && _skip isNotEqualTo 0}) then { if (!_printOnlyIncomplete || {_warn && _skip != 0}) then {
INC(_printCount); INC(_printCount);
if (_csvFormat) then { if (_csvFormat) then {
diag_log text format ["%7,%1,%2,%3,%4,%5,%6,%8", _c, _m, _k, _gC, _skip, _fragCount, _ammo, [_ammoConfig, true] call BIS_fnc_returnParents]; diag_log text format ["%7,%1,%2,%3,%4,%5,%6,%8", _c, _m, _k, _gC, _skip, _fragCount, _ammo, [_ammoConfig, true] call BIS_fnc_returnParents];

View File

@ -7,7 +7,7 @@
* Parameters inherited from EFUNC(common,firedEH) * Parameters inherited from EFUNC(common,firedEH)
* *
* Return Value: * Return Value:
* None * Nothing Useful
* *
* Example: * Example:
* [clientFiredBIS-XEH] call ace_frag_fnc_fired * [clientFiredBIS-XEH] call ace_frag_fnc_fired

View File

@ -12,7 +12,7 @@
* None * None
* *
* Example: * Example:
* [false, 10] call ace_frag_fnc_fragoCalcDump * false call ace_frag_fnc_dev_fragCalcDump
* *
* Public: No * Public: No
*/ */
@ -28,15 +28,15 @@ diag_log text "//****************** fragCalcDump Beg ******************//";
{ // Begin _allAmmoConfigs forEach { // Begin _allAmmoConfigs forEach
private _ammo = configName _x; private _ammo = configName _x;
if (_ammo isEqualTo "" || {_ammo in _processedCfgAmmos} ) then { if (_ammo isEqualTo "" || {_ammo in _processedCfgAmmos}) then {
continue continue
}; };
private _shouldFrag = [_ammo] call FUNC(shouldFrag); private _shouldFrag = [_ammo] call FUNC(shouldFrag);
if (_nSkip || _logAll) then { if (_shouldFrag || _logAll) then {
private _fragInfo = [_ammo] call FUNC(getFragInfo); private _fragInfo = [_ammo] call FUNC(getFragInfo);
_fragInfo params ["_fragRange", "_fragMaxVelocity", "", "_modifiedFragCount"]; _fragInfo params ["_fragRange", "_fragMaxVelocity", "", "_modifiedFragCount"];
private _fragCount = 4 * pi* _modifiedFragCount; private _fragCount = 4 * pi * _modifiedFragCount;
private _ammoConfig = configFile >> "CfgAmmo" >> _ammo; private _ammoConfig = configFile >> "CfgAmmo" >> _ammo;
private _indirectHitRange = getNumber (_ammoConfig >> "indirectHitRange"); private _indirectHitRange = getNumber (_ammoConfig >> "indirectHitRange");
private _indirectHit = getNumber (_ammoConfig >> "indirectHit"); private _indirectHit = getNumber (_ammoConfig >> "indirectHit");

View File

@ -11,7 +11,7 @@
* None * None
* *
* Example: * Example:
* [unit0, player] call ace_frag_fnc_dev_switchUnitHandle; * [getPosASL player, "blue"] call ace_frag_fnc_dev_sphereDraw;
* *
* Public: No * Public: No
*/ */

View File

@ -48,7 +48,7 @@ private _centerPoint = ASLToAGL getPosASL _object;
if (GVAR(dbgSphere) && {_addSphere && {isNull objectParent _object}}) then { if (GVAR(dbgSphere) && {_addSphere && {isNull objectParent _object}}) then {
private _centerSphere = [getPosASL _object, "yellow"] call FUNC(dev_sphereDraw); private _centerSphere = [getPosASL _object, "yellow"] call FUNC(dev_sphereDraw);
_centerSphere disableCollisionWith vehicle _object; _centerSphere disableCollisionWith _object;
_centerSphere attachTo [_object, _object worldToModel _centerPoint]; _centerSphere attachTo [_object, _object worldToModel _centerPoint];
}; };
@ -66,7 +66,7 @@ private _points = [
[_p7#0, _p1#1, _p7#2] [_p7#0, _p1#1, _p7#2]
]; ];
_color = switch (side _object) do { private _color = switch (side _object) do {
case east: {[1, 0, 0, 1]}; case east: {[1, 0, 0, 1]};
case resistance: {[0, 1, 0, 1]}; case resistance: {[0, 1, 0, 1]};
default {[0, 0, 1, 1]}; default {[0, 0, 1, 1]};

View File

@ -1,7 +1,7 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
/* /*
* Author: Lambda.Tiger * Author: Lambda.Tiger
* This function adds an object to have it's course tracked (every frame). * This function adds an object to have its course tracked (every frame).
* *
* Arguments: * Arguments:
* 0: Object to draw track OBJECT> * 0: Object to draw track OBJECT>
@ -42,21 +42,22 @@ GVAR(dev_trackLines) set [getObjectID _object, [[getPosATL _object], _colorArray
[ [
{ {
if (isGamePaused) exitWith {}; if (isGamePaused) exitWith {};
params ["_params", "_handle"]; params ["_object", "_handle"];
_params params ["_object"];
if (!alive _object) exitWith { if (!alive _object) exitWith {
[_handle] call CBA_fnc_removePerFrameHandler; [_handle] call CBA_fnc_removePerFrameHandler;
}; };
private _arr = GVAR(dev_trackLines) getOrDefault [(getObjectID _object), -1];
private objectArray = GVAR(dev_trackLines) get (getObjectID _object);
if (_arr isEqualType 0) exitWith { if (isNil "_objectArray") exitWith {
[_handle] call CBA_fnc_removePerFrameHandler; [_handle] call CBA_fnc_removePerFrameHandler;
}; };
(_arr#0) pushBack getPosATL _object; (objectArray#0) pushBack getPosATL _object;
}, },
0, 0,
[_object] _object
] call CBA_fnc_addPerFrameHandler; ] call CBA_fnc_addPerFrameHandler;
// Projectile event handlers that add spheres and points for more accurate round tracking // Projectile event handlers that add spheres and points for more accurate round tracking

View File

@ -14,7 +14,7 @@
* None * None
* *
* Example: * Example:
* [_projectile, getPosASL _projectile, velocity _projectile, typeOf _projectile, getShotParents _projectile] call ace_frag_fnc_doFrag; * [getPosASL _projectile, velocity _projectile, typeOf _projectile, getShotParents _projectile] call ace_frag_fnc_doFrag;
* *
* Public: No * Public: No
*/ */

View File

@ -49,7 +49,7 @@ if (_fragTypes isEqualTo []) then {
private _objects = (ASLToATL _posASL) nearEntities [["Car", "Motorcycle", "Tank", "StaticWeapon", "CAManBase", "Air", "Ship"], _fragRange]; private _objects = (ASLToATL _posASL) nearEntities [["Car", "Motorcycle", "Tank", "StaticWeapon", "CAManBase", "Air", "Ship"], _fragRange];
if (_objects isEqualTo []) exitWith { if (_objects isEqualTo []) exitWith {
TRACE_2("No nearby targets",_posASL,_fragRange); TRACE_2("No nearby targets",_posASL,_fragRange);
0; 0
}; };
// grab crews and add them in so that targets stay approx. sorted by distance // grab crews and add them in so that targets stay approx. sorted by distance
@ -126,12 +126,12 @@ private _totalFragCount = 0;
// target pos for fragment to hit // target pos for fragment to hit
private _targetPos = (velocity _target vectorMultiply _timeOfFlight) vectorAdd [0, 0, ACE_FRAG_HALF_GRAVITY_APPROX * _timeOfFlight ^ 2]; private _targetPos = (velocity _target vectorMultiply _timeOfFlight) vectorAdd [0, 0, ACE_FRAG_HALF_GRAVITY_APPROX * _timeOfFlight ^ 2];
if _isPerson then { _targetPos = if (_isPerson) then {
private _hitPoint = selectRandom ACE_FRAG_HITPOINTS; private _hitPoint = selectRandom ACE_FRAG_HITPOINTS;
private _hitPointPos = _target selectionPosition [_hitPoint, "HitPoints", "AveragePoint"]; private _hitPointPos = _target selectionPosition [_hitPoint, "HitPoints", "AveragePoint"];
_targetPos = _target modelToWorldWorld _hitPointPos vectorAdd _targetPos; _target modelToWorldWorld _hitPointPos vectorAdd _targetPos;
} else { } else {
_targetPos = _targetPos vectorAdd getPosASL _target vectorAdd [ _targetPos vectorAdd getPosASL _target vectorAdd [
-0.5 + random 1, -0.5 + random 1,
-0.5 + random 1, -0.5 + random 1,
(0.1 + random 0.4) * _height (0.1 + random 0.4) * _height

View File

@ -33,11 +33,11 @@ if (CBA_missionTime < GVAR(nextSpallAllowTime)||
_lastPosASL isEqualTo [0,0,0] || _lastPosASL isEqualTo [0,0,0] ||
{_ammo isEqualTo "" || {!isNull _objectHit && {_ammo isEqualTo "" || {!isNull _objectHit &&
{objectHit isKindOf "CAManBase"}}}) exitWith { {objectHit isKindOf "CAManBase"}}}) exitWith {
TRACE_4("time/invldHit",CBA_missionTime,GVAR(nextSpallAllowTime),_objectHit,_lastPosASL); TRACE_4("time/invalidHit",CBA_missionTime,GVAR(nextSpallAllowTime),_objectHit,_lastPosASL);
}; };
private _material = [_surfaceType] call FUNC(getMaterialInfo); private _material = [_surfaceType] call FUNC(getMaterialInfo);
if (_material isEqualTo "ground") then { if (_material == "ground") then {
#ifdef DEBUG_MODE_FULL #ifdef DEBUG_MODE_FULL
systemChat "ground spall"; systemChat "ground spall";
#endif #endif
@ -49,7 +49,7 @@ private _vel = if (alive _projectile) then {
_explosive = 0; // didn't explode since it's alive a frame later _explosive = 0; // didn't explode since it's alive a frame later
velocity _projectile velocity _projectile
} else { } else {
[0, 0, 0]; [0, 0, 0]
}; };
private _velocityChange = 0 max (vectorMagnitude _lastVelocity - vectorMagnitude _vel); private _velocityChange = 0 max (vectorMagnitude _lastVelocity - vectorMagnitude _vel);
@ -85,7 +85,7 @@ if GVAR(dbgSphere) then {
* impacts. 120 degrees due to 90 degree offset with _lastVelocityUnit into object. * impacts. 120 degrees due to 90 degree offset with _lastVelocityUnit into object.
*/ */
private _spallPosASL = _lastPosASL vectorAdd _deltaStep; private _spallPosASL = _lastPosASL vectorAdd _deltaStep;
if (120 > acos ( _lastVelocityUnit vectorDotProduct _surfaceNorm)) then { if (120 > acos (_lastVelocityUnit vectorDotProduct _surfaceNorm)) then {
_spallPosASL = _spallPosASL vectorAdd (_deltaStep vectorMultiply 5); _spallPosASL = _spallPosASL vectorAdd (_deltaStep vectorMultiply 5);
}; };
private _insideObject = true; private _insideObject = true;

View File

@ -29,8 +29,8 @@ if (!isNil "_ammoInfo") exitWith {_ammoInfo};
private _ammoConfig = configFile >> "CfgAmmo" >> _ammo; private _ammoConfig = configFile >> "CfgAmmo" >> _ammo;
private _fragTypes = []; private _fragTypes = [];
private _warn = false; private _warn = false;
if (isArray (_ammoConfig >> QGVAR(CLASSES))) then { if (isArray (_ammoConfig >> QGVAR(classes))) then {
_fragTypes = getArray (_ammoConfig >> QGVAR(CLASSES)); _fragTypes = getArray (_ammoConfig >> QGVAR(classes));
} else { } else {
_warn = true; _warn = true;
}; };

View File

@ -31,7 +31,7 @@ if (!isNil "_material") exitWith {
private _surfaceConfig = configFile >> "CfgSurfaces" >> _surfType; private _surfaceConfig = configFile >> "CfgSurfaces" >> _surfType;
if (isClass _surfaceConfig) then { if (isClass _surfaceConfig) then {
_material = getText (_surfaceConfig >> "soundEnviron"); _material = getText (_surfaceConfig >> "soundEnviron");
if (_material isEqualTo "" || {_material isEqualTo "empty"}) then { if (_material == "" || {_material == "empty"}) then {
_material = getText (_surfaceConfig >> "soundhit"); _material = getText (_surfaceConfig >> "soundhit");
}; };
} else { // Messy way when a surface isn't added to CfgSurfaces } else { // Messy way when a surface isn't added to CfgSurfaces

View File

@ -68,7 +68,7 @@ if (GVAR(spallEnabled) && {_ammo call FUNC(shouldSpall)}) then {
]; ];
}; };
#ifdef DEBUG_MODE_DRAW #ifdef DEBUG_MODE_DRAW
if (GVAR(debugOptions) && (_shouldFrag || _shouldSpall)) then { if (GVAR(debugOptions) && {_ammo call FUNC(shouldFrag) || {_ammo call FUNC(shouldSpall)}}) then {
[_projectile, "red", true] call FUNC(dev_trackObj); [_projectile, "red", true] call FUNC(dev_trackObj);
}; };
#endif #endif

View File

@ -3,7 +3,7 @@
#include "\z\ace\addons\main\script_mod.hpp" #include "\z\ace\addons\main\script_mod.hpp"
// #define LOG_FRAG_INFO // #define LOG_FRAG_INFO
#define DEBUG_MODE_FULL // #define DEBUG_MODE_FULL
// #define DEBUG_MODE_DRAW // #define DEBUG_MODE_DRAW
// #define DISABLE_COMPILE_CACHE // #define DISABLE_COMPILE_CACHE
// #define ENABLE_PERFORMANCE_COUNTERS // #define ENABLE_PERFORMANCE_COUNTERS