From bcec28e4b5247211b309b45b44f63157c106ab43 Mon Sep 17 00:00:00 2001 From: jokoho48 Date: Sat, 15 Aug 2015 23:53:04 +0200 Subject: [PATCH] Code Cleanup laser Self Designate Module. --- .../functions/fnc_findLaserSource.sqf | 29 +++++------- .../functions/fnc_initDesignatorActions.sqf | 10 +++-- .../functions/fnc_laserHudDesignateOff.sqf | 11 +++-- .../functions/fnc_laserHudDesignateOn.sqf | 45 +++++++++---------- .../functions/fnc_unitTurretHasDesignator.sqf | 8 ++-- 5 files changed, 49 insertions(+), 54 deletions(-) diff --git a/addons/laser_selfdesignate/functions/fnc_findLaserSource.sqf b/addons/laser_selfdesignate/functions/fnc_findLaserSource.sqf index 27beed3c6a..b948f0b70e 100644 --- a/addons/laser_selfdesignate/functions/fnc_findLaserSource.sqf +++ b/addons/laser_selfdesignate/functions/fnc_findLaserSource.sqf @@ -3,28 +3,21 @@ * Handler function for laser network code. * * Argument: - * 0: Emitter - * 1: Owner - * - * Return value: - * [position, direction] + * 0: Emitter + * + * Return Value: + * 0: position + * 1: direction + * + * Public: No */ - //findLaserSource.sqf -//#define DEBUG_MODE_FULL #include "script_component.hpp" -private["_emmiter", "_owner", "_gunnerInfo", "_turretInfo", "_povPos", "_povDir"]; - -_emmiter = _this select 0; -_owner = _this select 1; +private["_gunnerInfo", "_turretInfo"]; +params ["_emmiter"]; _gunnerInfo = [_emmiter, (currentWeapon _emmiter)] call CBA_fnc_getFirer; _turretInfo = [_emmiter, _gunnerInfo select 1] call EFUNC(common,getTurretDirection); -_povPos = _turretInfo select 0; -_povDir = _turretInfo select 1; +_turretInfo params [["_povPos", -1], ["_povDir", -1]]; -if(!isNil "_povPos" && !isNil "_povDir") exitWith { - [_povPos, _povDir] -}; - -[-1,-1] \ No newline at end of file +[_povPos, _povDir] diff --git a/addons/laser_selfdesignate/functions/fnc_initDesignatorActions.sqf b/addons/laser_selfdesignate/functions/fnc_initDesignatorActions.sqf index a75e58f533..5afc581619 100644 --- a/addons/laser_selfdesignate/functions/fnc_initDesignatorActions.sqf +++ b/addons/laser_selfdesignate/functions/fnc_initDesignatorActions.sqf @@ -2,15 +2,17 @@ * Author: esteldunedain * Initializes the actions for turning on/off the laser for vehicles that have them * - * Argument: + * Arguments: * 0: Vehicle * - * Return value: - * NONE. + * Return Value: + * None + * + * Public: No */ #include "script_component.hpp" -EXPLODE_1_PVT(_this,_vehicle); +params ["_vehicle"]; // Add action to class if it is not already done private ["_type", "_initializedClasses"]; diff --git a/addons/laser_selfdesignate/functions/fnc_laserHudDesignateOff.sqf b/addons/laser_selfdesignate/functions/fnc_laserHudDesignateOff.sqf index aa46c383bd..300811cba2 100644 --- a/addons/laser_selfdesignate/functions/fnc_laserHudDesignateOff.sqf +++ b/addons/laser_selfdesignate/functions/fnc_laserHudDesignateOff.sqf @@ -6,15 +6,14 @@ * 0: Shooter, player shooting the laser * 1: LaserUUID, the UUID of the laser returned by EFUNC(laser,laserOn) * 2: Local laser target, unused. - * - * Return value: - * true + * + * Return Value: + * True */ #include "script_component.hpp" if( (count _this) > 2) then { - EXPLODE_3_PVT(_this,_shooter,_laserUuid,_localLaserTarget); - + params ["", "_laserUuid"]; [_laserUuid] call EFUNC(laser,laserOff); // @TODO: Nou gets to field all tickets about missing lasers. //deleteVehicle _localLaserTarget; @@ -27,4 +26,4 @@ if(!isNil QGVAR(selfDesignateHandle)) then { GVAR(selfDesignateHandle) = nil; }; -true \ No newline at end of file +true diff --git a/addons/laser_selfdesignate/functions/fnc_laserHudDesignateOn.sqf b/addons/laser_selfdesignate/functions/fnc_laserHudDesignateOn.sqf index a07b197236..e585a409ff 100644 --- a/addons/laser_selfdesignate/functions/fnc_laserHudDesignateOn.sqf +++ b/addons/laser_selfdesignate/functions/fnc_laserHudDesignateOn.sqf @@ -3,12 +3,14 @@ * Turns on laser self designation from this vehicle based on the turret. * There are no arguments, because it is all strictly based on the users vehicle. * - * Argument: + * Arguments: + * None * - * Return value: - * N/A + * Return Value: + * None + * + * Public: No */ - //#define DEBUG_MODE_FULL #include "script_component.hpp" TRACE_1("enter", _this); @@ -17,20 +19,18 @@ TRACE_1("enter", _this); FUNC(laserHudDesignatePFH) = { private["_strongestResultPos", "_args", "_localLaserTarget", "_laserResultPosition", "_laserResult", "_shooter", "_vehicle", "_weapon", "_gunnerInfo", "_turretInfo", "_pov", "_gunBeg", "_gunEnd", "_povPos", "_povDir", "_result", "_resultPositions", "_firstResult", "_forceUpdateTime"]; - _args = _this select 0; - - _shooter = _args select 0; - _localLaserTarget = _args select 2; + params ["_args"]; + _args params ["_shooter", "_localLaserTarget"]; _vehicle = vehicle _shooter; TRACE_1("", _args); - - if((vehicle _shooter) == _shooter || {!alive _shooter} || {isNull _vehicle} || {!GVAR(active)} ) exitWith { + + if((vehicle _shooter) == _shooter || {!alive _shooter} || {isNull _vehicle} || {!GVAR(active)} ) exitWith { _args call FUNC(laserHudDesignateOff); }; if(!([_shooter] call FUNC(unitTurretHasDesignator)) ) exitWith { _args call FUNC(laserHudDesignateOff); }; - + if( (count _args) < 4) then { _args set[3, ACE_diagTime + FCS_UPDATE_DELAY]; }; @@ -38,15 +38,15 @@ FUNC(laserHudDesignatePFH) = { // @TODO: We don't have anything here we need to do the calculations for right now /* - + _gunnerInfo = [_vehicle, (currentWeapon _vehicle)] call CBA_fnc_getFirer; _turretInfo = [_vehicle, _gunnerInfo select 1] call EFUNC(common,getTurretDirection); _povPos = _turretInfo select 0; - + _laserCode = (vehicle ACE_player) getVariable["ace_laser_code", ACE_DEFAULT_LASER_CODE]; _waveLength = (vehicle ACE_player) getVariable["ace_laser_waveLength", ACE_DEFAULT_LASER_WAVELENGTH]; - - + + _laserResult = [_povPos, [_waveLength,_waveLength], _laserCode] call EFUNC(laser,seekerFindLaserSpot); _laserResultPosition = _laserResult select 0; TRACE_1("Search", _laserResult); @@ -56,12 +56,12 @@ FUNC(laserHudDesignatePFH) = { //_localLaserTarget setPosASL _laserResultPosition; }; */ - + if(ACE_diagTime > _forceUpdateTime) then { ["ace_fcs_forceUpdate", []] call ace_common_fnc_localEvent; _args set[3, ACE_diagTime + FCS_UPDATE_DELAY]; }; - + _this set[0, _args]; }; @@ -69,23 +69,22 @@ private ["_laserTarget", "_handle", "_vehicle", "_laserUuid", "_waveLength", "_b if(!GVAR(active)) then { GVAR(active) = true; - + TRACE_1("Activating laser", ""); - + // Get the self-designation variables, or use defaults _laserCode = (vehicle ACE_player) getVariable["ace_laser_code", ACE_DEFAULT_LASER_CODE]; _waveLength = (vehicle ACE_player) getVariable["ace_laser_waveLength", ACE_DEFAULT_LASER_WAVELENGTH]; _beamSpread = (vehicle ACE_player) getVariable["ace_laser_beamSpread", ACE_DEFAULT_LASER_BEAMSPREAD]; - + _laserUuid = [(vehicle ACE_player), ACE_player, QFUNC(findLaserSource), _waveLength, _laserCode, _beamSpread] call EFUNC(laser,laserOn); - + // @TODO: Create the local target for the players side // @TODO: Nou gets to field all tickets about missing lasers. //_localLaserTarget = "LaserTargetW" createVehicleLocal (getpos ACE_player); - + GVAR(selfDesignateHandle) = [FUNC(laserHudDesignatePFH), 0.1, [ACE_player, _laserUuid, nil]] call CBA_fnc_addPerFrameHandler; } else { [] call FUNC(laserHudDesignateOff); [] call FUNC(laserHudDesignateOn); }; - diff --git a/addons/laser_selfdesignate/functions/fnc_unitTurretHasDesignator.sqf b/addons/laser_selfdesignate/functions/fnc_unitTurretHasDesignator.sqf index 291deb5015..caa1a0e39c 100644 --- a/addons/laser_selfdesignate/functions/fnc_unitTurretHasDesignator.sqf +++ b/addons/laser_selfdesignate/functions/fnc_unitTurretHasDesignator.sqf @@ -2,15 +2,17 @@ * Author: esteldunedain * Checks if the turret occupied by the given unit has a laser designator * - * Argument: + * Arguments: * 0: Unit * - * Return value: + * Return Value: * Has designator? + * + * Public: No */ #include "script_component.hpp" -EXPLODE_1_PVT(_this,_unit); +params ["_unit"]; // Get the player turret path private ["_turret","_config","_turretConfig"];