Skip to content

Commit

Permalink
Remove unit from laser pointer list if laser removed (#5190)
Browse files Browse the repository at this point in the history
  • Loading branch information
PabstMirror authored May 31, 2017
1 parent afe8623 commit e6a291b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
29 changes: 16 additions & 13 deletions addons/laserpointer/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,33 @@ GVAR(greenLaserUnits) = [];
params ["_unit"];

private _weapon = currentWeapon _unit;
if (!(_unit isFlashlightOn _weapon)) exitWith {
GVAR(redLaserUnits) deleteAt (GVAR(redLaserUnits) find _unit);
GVAR(greenLaserUnits) deleteAt (GVAR(greenLaserUnits) find _unit);
};

private _laser = [(_unit weaponAccessories _weapon) select 1] param [0, ""];

if (_laser isEqualTo "") exitWith {};
if (_laser isEqualTo "") exitWith {
GVAR(redLaserUnits) deleteAt (GVAR(redLaserUnits) find _unit);
GVAR(greenLaserUnits) deleteAt (GVAR(greenLaserUnits) find _unit);
};

private _laserID = GVAR(laserClassesCache) getVariable _laser;

if (isNil "_laserID") then {
_laserID = getNumber (configFile >> "CfgWeapons" >> _laser >> "ACE_laserpointer");
GVAR(laserClassesCache) setVariable [_laser, _laserID];
};
TRACE_3("",_weapon,_laser,_laserID);

if (_unit isFlashlightOn _weapon) then {
if (_laserID isEqualTo 1) exitWith {
GVAR(redLaserUnits) pushBackUnique _unit;
GVAR(greenLaserUnits) deleteAt (GVAR(greenLaserUnits) find _unit);
};
if (_laserID isEqualTo 1) exitWith {
GVAR(redLaserUnits) pushBackUnique _unit;
GVAR(greenLaserUnits) deleteAt (GVAR(greenLaserUnits) find _unit);
};

if (_laserID isEqualTo 2) exitWith {
GVAR(greenLaserUnits) pushBackUnique _unit;
GVAR(redLaserUnits) deleteAt (GVAR(redLaserUnits) find _unit);
};
} else {
if (_laserID isEqualTo 2) exitWith {
GVAR(greenLaserUnits) pushBackUnique _unit;
GVAR(redLaserUnits) deleteAt (GVAR(redLaserUnits) find _unit);
GVAR(greenLaserUnits) deleteAt (GVAR(greenLaserUnits) find _unit);
};
};

Expand Down
4 changes: 2 additions & 2 deletions addons/laserpointer/functions/fnc_getNearUnits.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* None
*
* Return Value:
* None
* Near Units <ARRAY>
*
* Public: No
*/
Expand All @@ -15,7 +15,7 @@
private _camPosAGL = positionCameraToWorld [0, 0, 0];

// handle RHS / bugged vehicle slots
if !((_camPosAGL select 0) isEqualType 0) exitWith {};
if !((_camPosAGL select 0) isEqualType 0) exitWith { [] };

private _nearUnits = [];

Expand Down

0 comments on commit e6a291b

Please sign in to comment.