From 59da3e1c35ee12c1439df9c9c396fb0264ff8153 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sat, 3 Oct 2015 23:05:46 -0500 Subject: [PATCH] Optimize PFEH Funcs --- .../common/functions/fnc_getTurretIndex.sqf | 24 +++++++------------ addons/common/functions/fnc_timePFH.sqf | 20 +++++++++------- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/addons/common/functions/fnc_getTurretIndex.sqf b/addons/common/functions/fnc_getTurretIndex.sqf index b2f28c5f90..050f3e1c4f 100644 --- a/addons/common/functions/fnc_getTurretIndex.sqf +++ b/addons/common/functions/fnc_getTurretIndex.sqf @@ -8,29 +8,23 @@ * Return Value: * Turret Index * + * Example: + * [ace_player] call ace_common_fnc_getTurretIndex + * * Public: Yes */ #include "script_component.hpp" params ["_unit"]; -private ["_vehicle", "_turrets", "_units", "_index"]; - -_vehicle = vehicle _unit; - +local _vehicle = vehicle _unit; if (_unit == _vehicle) exitWith {[]}; -_turrets = allTurrets [_vehicle, true]; - -_units = []; +scopeName "main"; { - _units pushBack (_vehicle turretUnit _x); - false -} count _turrets; + if (_unit == (_vehicle turretUnit _x)) then {_x breakOut "main"}; + nil +} count allTurrets [_vehicle, true]; -_index = _units find _unit; - -if (_index == -1) exitWith {[]}; - -_turrets select _index; +[] diff --git a/addons/common/functions/fnc_timePFH.sqf b/addons/common/functions/fnc_timePFH.sqf index 4f099ea68c..152eceee3f 100644 --- a/addons/common/functions/fnc_timePFH.sqf +++ b/addons/common/functions/fnc_timePFH.sqf @@ -1,26 +1,26 @@ /* - * Author: ? - * ? + * Author: jaynus + * PFEH to set all Ace Time Variables * * Arguments: - * ? + * None * * Return Value: - * ? + * None * - * Public: ? + * Public: No */ #include "script_component.hpp" -private ["_lastTickTime", "_lastGameTime", "_delta"]; +BEGIN_COUNTER(timePFH); -_lastTickTime = ACE_diagTime; -_lastGameTime = ACE_gameTime; +local _lastTickTime = ACE_diagTime; +local _lastGameTime = ACE_gameTime; ACE_gameTime = time; ACE_diagTime = diag_tickTime; -_delta = ACE_diagTime - _lastTickTime; +local _delta = ACE_diagTime - _lastTickTime; if (ACE_gameTime <= _lastGameTime) then { TRACE_1("paused",_delta); @@ -36,3 +36,5 @@ if (ACE_gameTime <= _lastGameTime) then { ACE_virtualTime = ACE_virtualTime + (_delta * accTime); ACE_time = ACE_virtualTime; }; + +END_COUNTER(timePFH);