From e8ebe874508672a855dcdcb84dd4e3d55df6ad31 Mon Sep 17 00:00:00 2001 From: commy2 Date: Sun, 20 Sep 2015 15:52:40 +0200 Subject: [PATCH 1/4] more common code cleanup --- addons/common/XEH_preInit.sqf | 1 + .../functions/fnc_setHearingCapability.sqf | 2 + addons/common/functions/fnc_setName.sqf | 1 - addons/common/functions/fnc_setParameter.sqf | 3 +- .../common/functions/fnc_setVariableJIP.sqf | 1 - .../functions/fnc_setVariablePublic.sqf | 1 - .../functions/fnc_sortAlphabeticallyBy.sqf | 2 +- addons/common/functions/fnc_stringCompare.sqf | 38 +++++++----- .../functions/fnc_stringRemoveWhiteSpace.sqf | 12 +--- .../functions/fnc_stringToColoredText.sqf | 1 - addons/common/functions/fnc_syncedEvent.sqf | 32 ++++------ .../common/functions/fnc_syncedEventPFH.sqf | 62 ++++++++++++------- .../functions/fnc_throttledPublicVariable.sqf | 17 +++-- addons/common/functions/fnc_timePFH.sqf | 1 + addons/common/functions/fnc_toBitmask.sqf | 7 +-- addons/common/functions/fnc_toNumber.sqf | 1 - .../functions/fnc_translateToModelSpace.sqf | 1 - .../functions/fnc_translateToWeaponSpace.sqf | 1 - addons/common/functions/fnc_unhideUnit.sqf | 1 - .../common/functions/fnc_uniqueElements.sqf | 27 ++++++++ .../functions/fnc_uniqueElementsOnly.sqf | 33 ++++------ addons/common/functions/fnc_unmuteUnit.sqf | 1 - addons/common/functions/fnc_useItem.sqf | 41 ++++++------ addons/common/functions/fnc_useMagazine.sqf | 40 ++++++------ .../common/functions/fnc_waitAndExecute.sqf | 3 +- addons/common/functions/fnc_waveHeightAt.sqf | 1 + 26 files changed, 176 insertions(+), 155 deletions(-) create mode 100644 addons/common/functions/fnc_uniqueElements.sqf diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index 9604941ab7..ee10806f39 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -179,6 +179,7 @@ PREP(toBitmask); PREP(toHex); PREP(toNumber); PREP(unhideUnit); +PREP(uniqueElements); PREP(uniqueElementsOnly); PREP(unloadPerson); PREP(unloadPersonLocal); diff --git a/addons/common/functions/fnc_setHearingCapability.sqf b/addons/common/functions/fnc_setHearingCapability.sqf index 9dea992e3e..d24f8d0d9d 100644 --- a/addons/common/functions/fnc_setHearingCapability.sqf +++ b/addons/common/functions/fnc_setHearingCapability.sqf @@ -11,6 +11,8 @@ * None * * Public: Yes + * + * Note: uses player */ #include "script_component.hpp" diff --git a/addons/common/functions/fnc_setName.sqf b/addons/common/functions/fnc_setName.sqf index 8a32dd669d..117445b561 100644 --- a/addons/common/functions/fnc_setName.sqf +++ b/addons/common/functions/fnc_setName.sqf @@ -1,6 +1,5 @@ /* * Author: commy2 - * * Sets the name variable of the object. Used to prevent issues with the name command. * * Arguments: diff --git a/addons/common/functions/fnc_setParameter.sqf b/addons/common/functions/fnc_setParameter.sqf index 6a1345479b..dd946f7bc5 100644 --- a/addons/common/functions/fnc_setParameter.sqf +++ b/addons/common/functions/fnc_setParameter.sqf @@ -1,6 +1,5 @@ /* * Author: esteldunedain - * * Sets the value of an ACE_Parameter and makes it public. * * Arguments: @@ -12,7 +11,7 @@ * * Public: Yes * - * Deprecated *@todo commy + * Deprecated */ #include "script_component.hpp" diff --git a/addons/common/functions/fnc_setVariableJIP.sqf b/addons/common/functions/fnc_setVariableJIP.sqf index 766a4d9f5b..d1bd27ea4e 100644 --- a/addons/common/functions/fnc_setVariableJIP.sqf +++ b/addons/common/functions/fnc_setVariableJIP.sqf @@ -1,6 +1,5 @@ /* * Author: commy2 - * * Sets a public object namespace variable that gets reset with the same value after respawn, so JIP clients keep the value. * * Arguments: diff --git a/addons/common/functions/fnc_setVariablePublic.sqf b/addons/common/functions/fnc_setVariablePublic.sqf index 2f6cd70f65..b6fb58b0f4 100644 --- a/addons/common/functions/fnc_setVariablePublic.sqf +++ b/addons/common/functions/fnc_setVariablePublic.sqf @@ -1,6 +1,5 @@ /* * Author: commy2 and joko // Jonas - * * Sets a public variable, but wait a certain amount of ACE_time to transfer the value over the network. Changing the value by calling this function again resets the windup timer. * * Arguments: diff --git a/addons/common/functions/fnc_sortAlphabeticallyBy.sqf b/addons/common/functions/fnc_sortAlphabeticallyBy.sqf index 3380b181c8..76082013ef 100644 --- a/addons/common/functions/fnc_sortAlphabeticallyBy.sqf +++ b/addons/common/functions/fnc_sortAlphabeticallyBy.sqf @@ -1,6 +1,6 @@ /* * Author: Glowbal - * ? deprecated + * ? * * Arguments: * ? diff --git a/addons/common/functions/fnc_stringCompare.sqf b/addons/common/functions/fnc_stringCompare.sqf index 2162f71fd0..da65c676f8 100644 --- a/addons/common/functions/fnc_stringCompare.sqf +++ b/addons/common/functions/fnc_stringCompare.sqf @@ -1,35 +1,41 @@ -/** - * fn_stringCompare.sqf - * @Descr: Determines whether one string matches another and how many characters match. Case insensitive. - * @Author: bovine3dom +/* + * Author: bovine3dom + * Determines whether one string matches another and how many characters match. Case insensitive. * - * @Arguments: [stringA STRING, stringB STRING] - * @Return: NUMBER Number of matching characters - * @PublicAPI: true + * Arguments: + * 0: stringA + * 1: stringB + * + * Return Value: + * Number of matching characters >NUMBER> + * + * Public: Yes */ - #include "script_component.hpp" -private ["_searchTerm", "_string", "_arraySearchTerm", "_arrayString", "_sizeSearchTerm", "_sizeString", "_matchingCharacters", "_searchIterator", "_targetIterator"]; -_string = toLower (_this select 0); // removes case sensitivity -_searchTerm = toLower (_this select 1); +params ["_string", "_searchTerm"]; +_string = toLower _string; // removes case sensitivity +_searchTerm = toLower _searchTerm; + +private ["_arraySearchTerm", "_arrayString", "_sizeSearchTerm", "_sizeString", "_matchingCharacters", "_searchIterator", "_targetIterator"]; _arraySearchTerm = toArray _searchTerm; // splits string into array of unicode decimals _arrayString = toArray _string; _sizeSearchTerm = count _arraySearchTerm; // We only measure the array once _sizeString = count _arrayString; - _matchingCharacters = 0; -_targetIterator = 0; _searchIterator = 0; -while {(_searchIterator < _sizeSearchTerm) && (_targetIterator < _sizeString)} do { // Prevents us from going out of bounds - if ((_arraySearchTerm select _searchIterator) == (_arrayString select _targetIterator)) then { // If we have a match, start looking for the next character in the search term +_targetIterator = 0; + +while {_searchIterator < _sizeSearchTerm && _targetIterator < _sizeString} do { // Prevents us from going out of bounds + if (_arraySearchTerm select _searchIterator == _arrayString select _targetIterator) then { // If we have a match, start looking for the next character in the search term _matchingCharacters = _matchingCharacters + 1; _searchIterator = _searchIterator + 1 }; + _targetIterator = _targetIterator + 1; // Look at the next character in the string }; -_matchingCharacters \ No newline at end of file +_matchingCharacters diff --git a/addons/common/functions/fnc_stringRemoveWhiteSpace.sqf b/addons/common/functions/fnc_stringRemoveWhiteSpace.sqf index 7caf8cdf9f..2121f69ef4 100644 --- a/addons/common/functions/fnc_stringRemoveWhiteSpace.sqf +++ b/addons/common/functions/fnc_stringRemoveWhiteSpace.sqf @@ -10,17 +10,9 @@ * copy of string * * Public: Yes - * - * Deprecated */ #include "script_component.hpp" -params ["_string", ""]; +params ["_string"]; -private ["_charArray", "_returnString"]; - -_charArray = toArray _string; -_charArray = _charArray - [((toArray " ") select 0)]; -_returnString = toString _charArray; - -_returnString +(_string splitString " ") joinString "" diff --git a/addons/common/functions/fnc_stringToColoredText.sqf b/addons/common/functions/fnc_stringToColoredText.sqf index 5cbf280320..e6e19e4869 100644 --- a/addons/common/functions/fnc_stringToColoredText.sqf +++ b/addons/common/functions/fnc_stringToColoredText.sqf @@ -1,6 +1,5 @@ /* * Author: commy2 - * * Create a centered, colored text. * * Arguments: diff --git a/addons/common/functions/fnc_syncedEvent.sqf b/addons/common/functions/fnc_syncedEvent.sqf index 42b2147f10..34043fa8ae 100644 --- a/addons/common/functions/fnc_syncedEvent.sqf +++ b/addons/common/functions/fnc_syncedEvent.sqf @@ -1,33 +1,27 @@ /* * Author: jaynus - * * Call and propegate a synced event * - * Argument: - * 0: Name (String) - * 1: Arguments (Array) - * 2: TTL (Number or Code) [Optional] for this specific event call + * Arguments: + * 0: Name + * 1: Arguments + * 2: TTL [Optional] for this specific event call * - * Return value: - * Boolean of success + * Return Value: + * Boolean of success + * + * Public: No */ -//#define DEBUG_MODE_FULL #include "script_component.hpp" -PARAMS_2(_name,_args); +params ["_name", "_args", ["_ttl", 0]]; -private["_ttl", "_eventData"]; - -if( (count _this) > 2) then { - _ttl = _this select 2; -} else { - _ttl = 0; -}; - -if(!HASH_HASKEY(GVAR(syncedEvents),_name)) exitWith { +if (!HASH_HASKEY(GVAR(syncedEvents),_name)) exitWith { ACE_LOGERROR("Synced event key not found."); false }; -_eventData = [_name, _args,_ttl]; +private "_eventData"; +_eventData = [_name, _args, _ttl]; + ["SEH", _eventData] call FUNC(globalEvent); diff --git a/addons/common/functions/fnc_syncedEventPFH.sqf b/addons/common/functions/fnc_syncedEventPFH.sqf index a5ec809706..923e445839 100644 --- a/addons/common/functions/fnc_syncedEventPFH.sqf +++ b/addons/common/functions/fnc_syncedEventPFH.sqf @@ -1,52 +1,66 @@ -//#define DEBUG_MODE_FULL +/* + * Author: ? + * + * ? + * + * Arguments: + * ? + * + * Return Value: + * ? + * + * Public: ? + */ #include "script_component.hpp" -if(!isServer) exitWith { false }; +if (!isServer) exitWith {false}; // Walk through the local synced events and clean up anything thats already EOL // @TODO: This should be iteration limited to prevent FPS lag -private["_data"]; + { - private["_data", "_eventLog", "_newEventLog", "_name", "_globalEventTTL"]; + private ["_name", "_data", "_newEventLog"]; + _name = _x; _data = HASH_GET(GVAR(syncedEvents),_name); - _eventLog = _data select 1; - _globalEventTTL = _data select 2; + _data params ["_eventTime", "_eventLog", "_globalEventTTL"]; + _newEventLog = []; - + // @TODO: This should be iteration limited to prevent FPS lag { - private["_eventEntry", "_ttlReturn"]; + private ["_eventEntry", "_ttlReturn"]; + _eventEntry = _x; - _ttlReturn = true; - if(typeName _globalEventTTL == "CODE") then { - _ttlReturn = [(_data select 0),_eventEntry] call _globalEventTTL; + + if (typeName _globalEventTTL == "CODE") then { + _ttlReturn = [_eventTime, _eventEntry] call _globalEventTTL; } else { - _ttlReturn = call { _globalEventTTL < 1 || {ACE_diagTime < (_eventEntry select 0) + _globalEventTTL} }; + _ttlReturn = call {_globalEventTTL < 1 || {ACE_diagTime < (_eventEntry select 0) + _globalEventTTL}}; }; - if(_ttlReturn) then { + if (_ttlReturn) then { // Do event based TTL check - private["_eventTTL"]; - _eventTTL = _eventEntry select 2; - - if(typeName _eventTTL == "CODE") then { - _ttlReturn = [(_data select 0),_eventEntry] call _eventTTL; + _eventEntry params ["_time", "", "_eventTTL"]; + + if (typeName _eventTTL == "CODE") then { + _ttlReturn = [_eventTime, _eventEntry] call _eventTTL; } else { - _ttlReturn = call { _eventTTL < 1 || {ACE_diagTime < (_eventEntry select 0) + _eventTTL} }; + _ttlReturn = call {_eventTTL < 1 || {ACE_diagTime < _time + _eventTTL}}; }; }; // Finally drop it if the TTL check fails - if(_ttlReturn) then { + if (_ttlReturn) then { _newEventLog pushBack _x; }; - } forEach _eventLog; - - _data set[1, _newEventLog]; -} forEach (GVAR(syncedEvents) select 0); + false + } count _eventLog; + _data set [1, _newEventLog]; + false +} count (GVAR(syncedEvents) select 0); // @TODO: Next, detect if we had a new request from a JIP player, and we need to continue syncing events diff --git a/addons/common/functions/fnc_throttledPublicVariable.sqf b/addons/common/functions/fnc_throttledPublicVariable.sqf index d43841146a..cdc72f4450 100644 --- a/addons/common/functions/fnc_throttledPublicVariable.sqf +++ b/addons/common/functions/fnc_throttledPublicVariable.sqf @@ -17,21 +17,20 @@ */ #include "script_component.hpp" -PARAMS_3(_unit,_varName,_maxDelay); +params ["_unit", "_varName", "_maxDelay"]; // Create the publish scheduler PFH the first ACE_time if (isNil QGVAR(publishSchedId)) then { - GVAR(publishVarNames) = []; GVAR(publishNextTime) = 1e7; GVAR(publishSchedId) = [{ - if (ACE_diagTime > GVAR(publishNextTime)) then { { - EXPLODE_2_PVT(_x,_unit,_varName); - _unit setVariable [_varName, (_unit getVariable _varName), true]; - } forEach GVAR(publishVarNames); + _x params [_unit, _varName]; + _unit setVariable [_varName, _unit getVariable _varName, true]; + false + } count GVAR(publishVarNames); GVAR(publishVarNames) = []; GVAR(publishNextTime) = 1e7; @@ -40,10 +39,10 @@ if (isNil QGVAR(publishSchedId)) then { }; // If the variable is not on the list -if (GVAR(publishVarNames) find [_unit,_varName] == -1) exitWith { - GVAR(publishVarNames) pushBack [_unit,_varName]; +if (GVAR(publishVarNames) find [_unit, _varName] == -1) exitWith { + GVAR(publishVarNames) pushBack [_unit, _varName]; GVAR(publishNextTime) = GVAR(publishNextTime) min (ACE_diagTime + _maxDelay); }; // If the variable is on the list -GVAR(publishNextTime) = GVAR(publishNextTime) min (ACE_diagTime + _maxDelay); \ No newline at end of file +GVAR(publishNextTime) = GVAR(publishNextTime) min (ACE_diagTime + _maxDelay); diff --git a/addons/common/functions/fnc_timePFH.sqf b/addons/common/functions/fnc_timePFH.sqf index 1c66974c0d..4f099ea68c 100644 --- a/addons/common/functions/fnc_timePFH.sqf +++ b/addons/common/functions/fnc_timePFH.sqf @@ -21,6 +21,7 @@ ACE_gameTime = time; ACE_diagTime = diag_tickTime; _delta = ACE_diagTime - _lastTickTime; + if (ACE_gameTime <= _lastGameTime) then { TRACE_1("paused",_delta); ACE_paused = true; diff --git a/addons/common/functions/fnc_toBitmask.sqf b/addons/common/functions/fnc_toBitmask.sqf index 7c6beba733..35b1e06f9f 100644 --- a/addons/common/functions/fnc_toBitmask.sqf +++ b/addons/common/functions/fnc_toBitmask.sqf @@ -12,14 +12,11 @@ */ #include "script_component.hpp" -private ["_array", "_result"]; - -_array = _this; - +private "_result"; _result = 0; { if (_x) then {_result = _result + 2 ^ _forEachIndex}; -} forEach _array; +} forEach _this; _result diff --git a/addons/common/functions/fnc_toNumber.sqf b/addons/common/functions/fnc_toNumber.sqf index 56d14f6d18..6b1aacde1e 100644 --- a/addons/common/functions/fnc_toNumber.sqf +++ b/addons/common/functions/fnc_toNumber.sqf @@ -1,6 +1,5 @@ /* * Author: Garth de Wet (LH) - * * Takes a string/number and returns the number. * * Arguments: diff --git a/addons/common/functions/fnc_translateToModelSpace.sqf b/addons/common/functions/fnc_translateToModelSpace.sqf index 578feb8d5b..b05a19bed6 100644 --- a/addons/common/functions/fnc_translateToModelSpace.sqf +++ b/addons/common/functions/fnc_translateToModelSpace.sqf @@ -1,6 +1,5 @@ /* * Author: ? - * * ? * * Arguments: diff --git a/addons/common/functions/fnc_translateToWeaponSpace.sqf b/addons/common/functions/fnc_translateToWeaponSpace.sqf index a226265987..db3a5eaf37 100644 --- a/addons/common/functions/fnc_translateToWeaponSpace.sqf +++ b/addons/common/functions/fnc_translateToWeaponSpace.sqf @@ -1,6 +1,5 @@ /* * Author: ? - * * ? * * Arguments: diff --git a/addons/common/functions/fnc_unhideUnit.sqf b/addons/common/functions/fnc_unhideUnit.sqf index 488c4475fd..5bcafc3509 100644 --- a/addons/common/functions/fnc_unhideUnit.sqf +++ b/addons/common/functions/fnc_unhideUnit.sqf @@ -1,6 +1,5 @@ /* * Author: SilentSpike (based on unmuteUnit) - * * Globally unhides a unit. Only unhides if the last reason was removed. * * Arguments: diff --git a/addons/common/functions/fnc_uniqueElements.sqf b/addons/common/functions/fnc_uniqueElements.sqf new file mode 100644 index 0000000000..812bf59dba --- /dev/null +++ b/addons/common/functions/fnc_uniqueElements.sqf @@ -0,0 +1,27 @@ +/* + * Author: Glowbal + * Make a copy of an array with only the unique elements. + * + * Arguments: + * 0: array + * + * Return Value: + * Copy of original array + * + * Public: Yes + */ +#include "script_component.hpp" + +params ["_array"]; + +private "_result"; +_result = []; + +{ + if !(_x in _result) then { + _result pushBack _x; + }; + false +} count _array; + +_result diff --git a/addons/common/functions/fnc_uniqueElementsOnly.sqf b/addons/common/functions/fnc_uniqueElementsOnly.sqf index c81efb8308..e8d469867e 100644 --- a/addons/common/functions/fnc_uniqueElementsOnly.sqf +++ b/addons/common/functions/fnc_uniqueElementsOnly.sqf @@ -1,24 +1,17 @@ -/** - * fn_uniqueElementsOnly.sqf - * @Descr: Make a copy of an array with only the unique elements. - * @Author: Glowbal +/* + * Author: Glowbal + * Make a copy of an array with only the unique elements. * - * @Arguments: [array ARRAY] - * @Return: ARRAY Copy of original array - * @PublicAPI: true + * Arguments: + * 0: array + * + * Return Value: + * Copy of original array + * + * Public: Yes + * + * Deprecated */ - #include "script_component.hpp" -private ["_result", "_value"]; -PARAMS_1(_array); - -_result = []; -{ - _value = _x; - if ({_x isEqualTo _value} count _result == 0) then { - _result pushback _x; - }; -} forEach _array; - -_result; \ No newline at end of file +_this call FUNC(uniqueElements) diff --git a/addons/common/functions/fnc_unmuteUnit.sqf b/addons/common/functions/fnc_unmuteUnit.sqf index e234cb80db..bf02fe676f 100644 --- a/addons/common/functions/fnc_unmuteUnit.sqf +++ b/addons/common/functions/fnc_unmuteUnit.sqf @@ -1,6 +1,5 @@ /* * Author: commy2 - * * Unmutes the unit. Only unmutes if the last reason was removed. * * Arguments: diff --git a/addons/common/functions/fnc_useItem.sqf b/addons/common/functions/fnc_useItem.sqf index 03589cd56d..acf359813c 100644 --- a/addons/common/functions/fnc_useItem.sqf +++ b/addons/common/functions/fnc_useItem.sqf @@ -1,36 +1,37 @@ -/** - * fn_useItem.sqf - * @Descr: - * @Author: Glowbal +/* + * Author: Glowbal + * Use item * - * @Arguments: [] - * @Return: - * @PublicAPI: true + * Arguments: + * 0: unit + * 1: item + * + * Return Value: + * if item has been used. + * + * Public: Yes */ - #include "script_component.hpp" -PARAMS_2(_unit,_item); - -private ["_return", "_vehicleUsage"]; - -_vehicleUsage = [_this, 2, false, [false]] call BIS_fnc_Param; +params ["_unit", "_item", ["_vehicleUsage", false]]; +private "_return"; _return = false; -if (!_vehicleUsage) then { + +if !(_vehicleUsage) then { if (_item != "") then { - if (_item in (items _unit)) then { + if (_item in items _unit) then { _unit removeItem _item; _return = true; } else { - if (_item in (assignedItems _unit)) then { - _unit unassignItem _item; - _unit removeItem _item; + if (_item in assignedItems _unit) then { + _unit unlinkItem _item; _return = true; }; }; }; +//} else { + // @todo implement shared item functionality for with vehicles. }; -// TODO implement shared item functionality for with vehicles. -_return; \ No newline at end of file +_return diff --git a/addons/common/functions/fnc_useMagazine.sqf b/addons/common/functions/fnc_useMagazine.sqf index f21a04d026..1a77d0b3f3 100644 --- a/addons/common/functions/fnc_useMagazine.sqf +++ b/addons/common/functions/fnc_useMagazine.sqf @@ -1,28 +1,32 @@ -/** - * fn_useMagazine.sqf - * @Descr: Use magazine - * @Author: Glowbal +/* + * Author: Glowbal + * Use magazine * - * @Arguments: [unit OBJECt, magazine STRING] - * @Return: BOOL True if magazine has been used. - * @PublicAPI: true + * Arguments: + * 0: unit + * 1: magazine + * + * Return Value: + * if magazine has been used. + * + * Public: Yes */ - #include "script_component.hpp" -private ["_return", "_vehicleUsage"]; -PARAMS_2(_unit,_magazine); -_vehicleUsage = [_this, 2, false, [false]] call BIS_fnc_Param; +params ["_unit", "_magazine", ["_vehicleUsage", false]]; -if (!_vehicleUsage) then { +private "_return"; +_return = false; + +if !(_vehicleUsage) then { if (_magazine != "") then { _unit removeMagazine _magazine; _return = true; - } else { - _return = false; }; - [format["fnc_useMagazine: %1 | %2",_this,_return]] call FUNC(debug); + + [format ["fnc_useMagazine: %1 | %2", _this, _return]] call FUNC(debug); +//} else { + // @todo implement shared magazine functionality +}; + _return -} else { - // TODO implement shared magazine functionality -}; \ No newline at end of file diff --git a/addons/common/functions/fnc_waitAndExecute.sqf b/addons/common/functions/fnc_waitAndExecute.sqf index 6fcf83a58f..c8f078854b 100644 --- a/addons/common/functions/fnc_waitAndExecute.sqf +++ b/addons/common/functions/fnc_waitAndExecute.sqf @@ -1,6 +1,5 @@ /* * Author: esteldunedain - * * Executes a code once with a given game ACE_time delay, using a PFH * * Arguments: @@ -20,5 +19,5 @@ params ["_func", "_params", "_delay"]; -GVAR(waitAndExecArray) pushBack [(ACE_time + _delay), _func, _params]; +GVAR(waitAndExecArray) pushBack [ACE_time + _delay, _func, _params]; GVAR(waitAndExecArray) sort true; diff --git a/addons/common/functions/fnc_waveHeightAt.sqf b/addons/common/functions/fnc_waveHeightAt.sqf index ac9eed10bb..a3f2447729 100644 --- a/addons/common/functions/fnc_waveHeightAt.sqf +++ b/addons/common/functions/fnc_waveHeightAt.sqf @@ -19,6 +19,7 @@ params ["_position"]; if (isNil QGVAR(waveHeightLogic)) then { GVAR(waveHeightLogic) = "Logic" createVehicleLocal [0,0,0]; }; + GVAR(waveHeightLogic) setPosASL _position; (getPosASLW GVAR(waveHeightLogic) select 2) - (getPosASL GVAR(waveHeightLogic) select 2) From e62683a0c411193cfda99b43a085e097a507e9e7 Mon Sep 17 00:00:00 2001 From: commy2 Date: Sun, 20 Sep 2015 16:40:49 +0200 Subject: [PATCH 2/4] more common code cleanup --- addons/common/functions/fnc_globalEvent.sqf | 18 +++++----- addons/common/functions/fnc_goKneeling.sqf | 34 +++++++------------ addons/common/functions/fnc_hashHasKey.sqf | 1 - .../functions/fnc_hashListCreateHash.sqf | 1 - .../functions/fnc_hashListCreateList.sqf | 1 - addons/common/functions/fnc_hashListPush.sqf | 1 - .../common/functions/fnc_hashListSelect.sqf | 1 - addons/common/functions/fnc_hashListSet.sqf | 1 - addons/common/functions/fnc_hashRem.sqf | 1 - addons/common/functions/fnc_hashSet.sqf | 1 - addons/common/functions/fnc_isAlive.sqf | 2 +- addons/common/functions/fnc_isAwake.sqf | 3 +- addons/common/functions/fnc_isModLoaded.sqf | 4 ++- addons/common/functions/fnc_map.sqf | 1 + .../functions/fnc_moduleLSDVehicles.sqf | 1 - addons/common/functions/fnc_owned.sqf | 1 - addons/common/functions/fnc_player.sqf | 1 - addons/common/functions/fnc_playerSide.sqf | 1 - addons/common/functions/fnc_positionToASL.sqf | 2 +- .../functions/fnc_readSettingFromModule.sqf | 1 - .../fnc_removeCanInteractWithCondition.sqf | 1 - .../functions/fnc_restoreVariablesJIP.sqf | 1 - .../common/functions/fnc_sanitizeString.sqf | 29 ++++++++++------ 23 files changed, 48 insertions(+), 60 deletions(-) diff --git a/addons/common/functions/fnc_globalEvent.sqf b/addons/common/functions/fnc_globalEvent.sqf index b605a406b1..9928bc3468 100644 --- a/addons/common/functions/fnc_globalEvent.sqf +++ b/addons/common/functions/fnc_globalEvent.sqf @@ -3,18 +3,20 @@ * * Execute a global event on all clients, including self. * - * Argument: - * 0: Event name (string) - * 1: Event args (any) + * Arguments: + * 0: Event name + * 1: Event args * - * Return value: - * Nothing + * Return Value: + * None + * + * Public: Yes */ #include "script_component.hpp" -//IGNORE_PRIVATE_WARNING("_handleNetEvent"); -PARAMS_2(_eventName,_eventArgs); +params ["_eventName", "_eventArgs"]; ACEg = [_eventName, _eventArgs]; publicVariable "ACEg"; -["ACEg", ACEg] call FUNC(_handleNetEvent); \ No newline at end of file + +["ACEg", ACEg] call FUNC(_handleNetEvent); diff --git a/addons/common/functions/fnc_goKneeling.sqf b/addons/common/functions/fnc_goKneeling.sqf index 0ff25b460f..4ee502f929 100644 --- a/addons/common/functions/fnc_goKneeling.sqf +++ b/addons/common/functions/fnc_goKneeling.sqf @@ -1,32 +1,22 @@ /* * Author: commy2 + * Move unit to kneeling position. * - * Abhocken! Unit goes kneeling if not prone already and lowers weapon. Try, throw, catch because I'm bored. + * Arguments: + * 0: Unit * - * Argument: - * 0: Unit (Object) + * Return Value: + * None * - * Return value: - * None. + * Public: No */ #include "script_component.hpp" -PARAMS_1(_unit); +params ["_unit"]; -//IGNORE_PRIVATE_WARNING("_exception"); +if (stance _unit == "PRONE") exitWith {}; -try { - if (_unit == vehicle _unit) then { - switch (currentWeapon _unit) do { - case "" : {throw "AmovPknlMstpSnonWnonDnon"}; - case (primaryWeapon _unit) : {throw "AmovPknlMstpSlowWrflDnon"}; - case (secondaryWeapon _unit) : {throw "AmovPknlMstpSrasWlnrDnon"}; - case (handgunWeapon _unit) : {throw "AmovPknlMstpSlowWpstDnon"}; - case (binocular _unit) : {throw "AmovPknlMstpSoptWbinDnon"}; - }; - }; -} catch { - if (stance _unit != "PRONE") then { - [_unit, _exception] call FUNC(doAnimation); - }; -}; +[ + _unit, + ["AmovPknlMstpSnonWnonDnon", "AmovPknlMstpSlowWrflDnon", "AmovPknlMstpSrasWlnrDnon", "AmovPknlMstpSlowWpstDnon", "AmovPknlMstpSoptWbinDnon"] select ((["", primaryWeapon _unit, secondaryWeapon _unit, handgunWeapon _unit, binocular _unit] find currentWeapon _unit) max 0) +] call FUNC(doAnimation); diff --git a/addons/common/functions/fnc_hashHasKey.sqf b/addons/common/functions/fnc_hashHasKey.sqf index 951c95a2b3..5c6293fc85 100644 --- a/addons/common/functions/fnc_hashHasKey.sqf +++ b/addons/common/functions/fnc_hashHasKey.sqf @@ -1,6 +1,5 @@ /* * Author: ? - * * ? * * Arguments: diff --git a/addons/common/functions/fnc_hashListCreateHash.sqf b/addons/common/functions/fnc_hashListCreateHash.sqf index 4000c13056..d6a94445eb 100644 --- a/addons/common/functions/fnc_hashListCreateHash.sqf +++ b/addons/common/functions/fnc_hashListCreateHash.sqf @@ -1,6 +1,5 @@ /* * Author: ? - * * ? * * Arguments: diff --git a/addons/common/functions/fnc_hashListCreateList.sqf b/addons/common/functions/fnc_hashListCreateList.sqf index 065bec1de6..3d02b0cb0b 100644 --- a/addons/common/functions/fnc_hashListCreateList.sqf +++ b/addons/common/functions/fnc_hashListCreateList.sqf @@ -1,6 +1,5 @@ /* * Author: ? - * * ? * * Arguments: diff --git a/addons/common/functions/fnc_hashListPush.sqf b/addons/common/functions/fnc_hashListPush.sqf index a4d023de87..21651c2ed0 100644 --- a/addons/common/functions/fnc_hashListPush.sqf +++ b/addons/common/functions/fnc_hashListPush.sqf @@ -1,6 +1,5 @@ /* * Author: ? - * * ? * * Arguments: diff --git a/addons/common/functions/fnc_hashListSelect.sqf b/addons/common/functions/fnc_hashListSelect.sqf index 1ee09f4316..df072d55bd 100644 --- a/addons/common/functions/fnc_hashListSelect.sqf +++ b/addons/common/functions/fnc_hashListSelect.sqf @@ -1,6 +1,5 @@ /* * Author: ? - * * ? * * Arguments: diff --git a/addons/common/functions/fnc_hashListSet.sqf b/addons/common/functions/fnc_hashListSet.sqf index 3fbb20e414..5fea048327 100644 --- a/addons/common/functions/fnc_hashListSet.sqf +++ b/addons/common/functions/fnc_hashListSet.sqf @@ -1,6 +1,5 @@ /* * Author: ? - * * ? * * Arguments: diff --git a/addons/common/functions/fnc_hashRem.sqf b/addons/common/functions/fnc_hashRem.sqf index 0bf31c0f76..4346a509cf 100644 --- a/addons/common/functions/fnc_hashRem.sqf +++ b/addons/common/functions/fnc_hashRem.sqf @@ -1,6 +1,5 @@ /* * Author: ? - * * ? * * Arguments: diff --git a/addons/common/functions/fnc_hashSet.sqf b/addons/common/functions/fnc_hashSet.sqf index 0be700037c..af7a361dd6 100644 --- a/addons/common/functions/fnc_hashSet.sqf +++ b/addons/common/functions/fnc_hashSet.sqf @@ -1,6 +1,5 @@ /* * Author: ? - * * ? * * Arguments: diff --git a/addons/common/functions/fnc_isAlive.sqf b/addons/common/functions/fnc_isAlive.sqf index 381b19bc24..f9e8caadec 100644 --- a/addons/common/functions/fnc_isAlive.sqf +++ b/addons/common/functions/fnc_isAlive.sqf @@ -14,4 +14,4 @@ */ #include "script_component.hpp" -!isNull (_this select 0) && {alive (_this select 0)} +!isNull (_this select 0) && {alive (_this select 0)} // return diff --git a/addons/common/functions/fnc_isAwake.sqf b/addons/common/functions/fnc_isAwake.sqf index f640eaa012..8a123cfec9 100644 --- a/addons/common/functions/fnc_isAwake.sqf +++ b/addons/common/functions/fnc_isAwake.sqf @@ -1,6 +1,5 @@ /* * Author: Glowbal - * * Check if unit is awake. Will be false when death or unit is unconscious. * * Arguments: @@ -15,4 +14,4 @@ params ["_unit"]; -!(_unit getvariable ["ACE_isUnconscious", false]) && alive _unit && !(_unit getvariable ["ACE_isDead", false]); +!(_unit getvariable ["ACE_isUnconscious", false]) && alive _unit && !(_unit getvariable ["ACE_isDead", false]) // return diff --git a/addons/common/functions/fnc_isModLoaded.sqf b/addons/common/functions/fnc_isModLoaded.sqf index 3628777f6c..e5f94b202d 100644 --- a/addons/common/functions/fnc_isModLoaded.sqf +++ b/addons/common/functions/fnc_isModLoaded.sqf @@ -12,4 +12,6 @@ */ #include "script_component.hpp" -isClass (configFile >> "cfgPatches" >> _this select 0) // return +params ["_modName"]; + +isClass (configFile >> "cfgPatches" >> _modName) // return diff --git a/addons/common/functions/fnc_map.sqf b/addons/common/functions/fnc_map.sqf index 13e315924e..30499a2ef2 100644 --- a/addons/common/functions/fnc_map.sqf +++ b/addons/common/functions/fnc_map.sqf @@ -24,4 +24,5 @@ _array = + _array; { _array set [_forEachIndex, _x call _code]; } forEach _array; + _array diff --git a/addons/common/functions/fnc_moduleLSDVehicles.sqf b/addons/common/functions/fnc_moduleLSDVehicles.sqf index 59c87f68cc..8a6cb90eca 100644 --- a/addons/common/functions/fnc_moduleLSDVehicles.sqf +++ b/addons/common/functions/fnc_moduleLSDVehicles.sqf @@ -1,6 +1,5 @@ /* * Author: KoffeinFlummi, joko // Jonas - * * Nothing to see here, move along. * * Arguments: diff --git a/addons/common/functions/fnc_owned.sqf b/addons/common/functions/fnc_owned.sqf index d94e3975db..e352795c5e 100644 --- a/addons/common/functions/fnc_owned.sqf +++ b/addons/common/functions/fnc_owned.sqf @@ -1,6 +1,5 @@ /* * Author: commy2 - * * Counterpart of ace_common_fnc_claim. Check if the given object is claimed by another unit. * * Arguments: diff --git a/addons/common/functions/fnc_player.sqf b/addons/common/functions/fnc_player.sqf index 5f6f272e5e..1a268515a7 100644 --- a/addons/common/functions/fnc_player.sqf +++ b/addons/common/functions/fnc_player.sqf @@ -1,6 +1,5 @@ /* * Author: bux578, commy2 - * * Returns the player or curator controlled unit. * Use this in INIT and RESPAWN eh scripts, because ACE_player isn't reset yet. * diff --git a/addons/common/functions/fnc_playerSide.sqf b/addons/common/functions/fnc_playerSide.sqf index 1607b5b7fc..3a7ce5bba9 100644 --- a/addons/common/functions/fnc_playerSide.sqf +++ b/addons/common/functions/fnc_playerSide.sqf @@ -1,6 +1,5 @@ /* * Author: commy2 - * * Return the current side of the player * * Arguments: diff --git a/addons/common/functions/fnc_positionToASL.sqf b/addons/common/functions/fnc_positionToASL.sqf index d933e67125..267bbf2353 100644 --- a/addons/common/functions/fnc_positionToASL.sqf +++ b/addons/common/functions/fnc_positionToASL.sqf @@ -10,7 +10,7 @@ * Return Value: * None * - * Public: No + * Public: Yes */ #include "script_component.hpp" diff --git a/addons/common/functions/fnc_readSettingFromModule.sqf b/addons/common/functions/fnc_readSettingFromModule.sqf index 25158779e7..f7cb361c1b 100644 --- a/addons/common/functions/fnc_readSettingFromModule.sqf +++ b/addons/common/functions/fnc_readSettingFromModule.sqf @@ -1,6 +1,5 @@ /* * Author: esteldunedain - * * Reads a setting value from a module, set it and force it. Logs if the setting is missing from the module. * Must be called on the server, effect is global. * diff --git a/addons/common/functions/fnc_removeCanInteractWithCondition.sqf b/addons/common/functions/fnc_removeCanInteractWithCondition.sqf index 5f8ca43467..6c3fa8354b 100644 --- a/addons/common/functions/fnc_removeCanInteractWithCondition.sqf +++ b/addons/common/functions/fnc_removeCanInteractWithCondition.sqf @@ -1,6 +1,5 @@ /* * Author: commy2 - * * Remove a condition that gets checked by ace_common_fnc_canInteractWith. * * Arguments: diff --git a/addons/common/functions/fnc_restoreVariablesJIP.sqf b/addons/common/functions/fnc_restoreVariablesJIP.sqf index 1937c615a4..491ce89bb4 100644 --- a/addons/common/functions/fnc_restoreVariablesJIP.sqf +++ b/addons/common/functions/fnc_restoreVariablesJIP.sqf @@ -1,6 +1,5 @@ /* * Author: commy2 - * * Called from respawn eventhandler. Resets all public object namespace variables that are added via FUNC(setVariableJIP). * * Arguments: diff --git a/addons/common/functions/fnc_sanitizeString.sqf b/addons/common/functions/fnc_sanitizeString.sqf index f502da43dd..fff3288db6 100644 --- a/addons/common/functions/fnc_sanitizeString.sqf +++ b/addons/common/functions/fnc_sanitizeString.sqf @@ -4,7 +4,7 @@ * * Arguments: * 0: Source string - * 1: Remove html tags (optional) + * 1: Remove html tags (default: false) * * Return Value: * Sanitized string @@ -15,28 +15,37 @@ params ["_string", ["_removeTags", false]]; -private ["_array", "_arrayNew"]; +private "_array"; +_array = []; -_array = toArray _string; - -_arrayNew = []; { switch _x do { case 60 : { - _arrayNew = if (_removeTags) then {_arrayNew + toArray "<";} else {_arrayNew + [_x];}; + if (_removeTags) then { + _array append toArray "<"; + } else { + _array pushBack _x; + }; }; case 62 : { - _arrayNew = if (_removeTags) then {_arrayNew + toArray ">";} else {_arrayNew + [_x];}; + if (_removeTags) then { + _array append toArray ">"; + } else { + _array pushBack _x; + }; }; + case 34 : { }; + case 39 : { }; + default { - _arrayNew = _arrayNew + [_x]; + _array pushBack _x; }; }; false -} count _array; +} count toArray _string; -toString _arrayNew +toString _array // return From 0a01bbdc762da9e2f45c127a3cf9b8e845fe22e0 Mon Sep 17 00:00:00 2001 From: commy2 Date: Sun, 20 Sep 2015 16:56:35 +0200 Subject: [PATCH 3/4] more common code cleanup --- addons/common/functions/fnc_filter.sqf | 26 +++++++++---------- addons/common/functions/fnc_fixCollision.sqf | 7 ++--- .../common/functions/fnc_fixCrateContent.sqf | 17 +++++++++--- addons/common/functions/fnc_fixFloating.sqf | 6 ++--- .../fnc_fixLoweredRifleAnimation.sqf | 4 +-- addons/common/functions/fnc_fixPosition.sqf | 8 +++--- addons/common/functions/fnc_isAlive.sqf | 8 +++--- addons/common/functions/fnc_map.sqf | 2 +- 8 files changed, 46 insertions(+), 32 deletions(-) diff --git a/addons/common/functions/fnc_filter.sqf b/addons/common/functions/fnc_filter.sqf index 3d84d9d3a2..0b30e59cf9 100644 --- a/addons/common/functions/fnc_filter.sqf +++ b/addons/common/functions/fnc_filter.sqf @@ -1,6 +1,5 @@ /* * Author: KoffeinFlummi, commy2 - * * Filters array and removes every element not fitting the condition * * Arguments: @@ -12,22 +11,21 @@ * * Usage: * [[0,1,2,3,4], {_this > 2}] call FUNC(filter) ==> [3,4] + * + * Public: Yes */ #include "script_component.hpp" -private ["_newArray", "_index"]; +params ["_array", "_code"]; -PARAMS_2(_array,_code); +private "_result"; +_result = []; -if (isNil "_array") exitWith { - ACE_LOGERROR_1("No array for function filter in %1.",_fnc_scriptNameParent); - [] -}; - -_newArray = []; -for "_index" from 0 to (count _array - 1) do { - if ((_array select _index) call _code) then { - _newArray pushBack (_array select _index); +{ + if (_x call _code) then { + _result pushBack _x; }; -}; -_newArray + false +} count _array; + +_result diff --git a/addons/common/functions/fnc_fixCollision.sqf b/addons/common/functions/fnc_fixCollision.sqf index 6b43cec469..1d55eb1454 100644 --- a/addons/common/functions/fnc_fixCollision.sqf +++ b/addons/common/functions/fnc_fixCollision.sqf @@ -1,13 +1,14 @@ /* * Author: commy2 - * Attempt to fix physx collisions causing unreasonable impact forces and damage. + * Attempt to fix PhysX collisions causing unreasonable impact forces and damage. * * Arguments: - * 0: Object + * Object * * Return Value: - * Nothing + * None * + * Public: No */ #include "script_component.hpp" diff --git a/addons/common/functions/fnc_fixCrateContent.sqf b/addons/common/functions/fnc_fixCrateContent.sqf index ad3ed8e528..a067c29c63 100644 --- a/addons/common/functions/fnc_fixCrateContent.sqf +++ b/addons/common/functions/fnc_fixCrateContent.sqf @@ -1,9 +1,20 @@ -// by commy2 +/* + * Author: commy2 + * Fixes zeus placed crates containing buged mine detectors and ace items. + * + * Arguments: + * 0: Crate + * + * Return Value: + * None + * + * Public: No + */ #include "script_component.hpp" -private ["_weapons", "_items"]; +params ["_crate"]; -PARAMS_1(_crate); +private ["_weapons", "_items"]; // get all weapons inside the crate _weapons = weaponCargo _crate; diff --git a/addons/common/functions/fnc_fixFloating.sqf b/addons/common/functions/fnc_fixFloating.sqf index 6f08af1482..5fe94dcef7 100644 --- a/addons/common/functions/fnc_fixFloating.sqf +++ b/addons/common/functions/fnc_fixFloating.sqf @@ -3,16 +3,16 @@ * Attempt to fix floating physx with disabled damage after setPosXXX commands. * * Arguments: - * Physx object (Object) + * PhysX object * * Return Value: - * Nothing + * None * + * Public: No */ #include "script_component.hpp" private "_object"; - _object = _this; // setHitPointDamage requires local object diff --git a/addons/common/functions/fnc_fixLoweredRifleAnimation.sqf b/addons/common/functions/fnc_fixLoweredRifleAnimation.sqf index f39f85cc94..9e230b00ad 100644 --- a/addons/common/functions/fnc_fixLoweredRifleAnimation.sqf +++ b/addons/common/functions/fnc_fixLoweredRifleAnimation.sqf @@ -15,8 +15,8 @@ */ #include "script_component.hpp" -PARAMS_1(_unit); +params ["_unit"]; -if (currentWeapon _unit != "" && {currentWeapon _unit == primaryWeapon _unit} && {weaponLowered _unit} && {stance _unit == "STAND"} && {(vehicle _unit) == _unit}) then { +if (currentWeapon _unit != "" && {currentWeapon _unit == primaryWeapon _unit} && {weaponLowered _unit} && {stance _unit == "STAND"} && {vehicle _unit == _unit}) then { [_unit, "amovpercmstpsraswrfldnon", 0] call FUNC(doAnimation); }; diff --git a/addons/common/functions/fnc_fixPosition.sqf b/addons/common/functions/fnc_fixPosition.sqf index 32cde87e52..54d0cdfbf6 100644 --- a/addons/common/functions/fnc_fixPosition.sqf +++ b/addons/common/functions/fnc_fixPosition.sqf @@ -4,10 +4,12 @@ * Fixes position of an object. E.g. moves object above ground and adjusts to terrain slope. Requires local object. * * Argument: - * Object (Object) + * Object * - * Return value: - * NONE + * Return Value: + * None + * + * Public: No */ #include "script_component.hpp" diff --git a/addons/common/functions/fnc_isAlive.sqf b/addons/common/functions/fnc_isAlive.sqf index f9e8caadec..343466c00d 100644 --- a/addons/common/functions/fnc_isAlive.sqf +++ b/addons/common/functions/fnc_isAlive.sqf @@ -3,10 +3,10 @@ * Check if the object still exists and is alive. This function exists because 'alive objNull' actually returns true. * * Argument: - * 0: Any object (Object) + * 0: Any object * * Return value: - * The object exists and is alive (Bool). + * The object exists and is alive . * * Public: Yes * @@ -14,4 +14,6 @@ */ #include "script_component.hpp" -!isNull (_this select 0) && {alive (_this select 0)} // return +params ["_unit"]; + +!isNull _unit && {alive _unit} // return diff --git a/addons/common/functions/fnc_map.sqf b/addons/common/functions/fnc_map.sqf index 30499a2ef2..a727de08bf 100644 --- a/addons/common/functions/fnc_map.sqf +++ b/addons/common/functions/fnc_map.sqf @@ -12,7 +12,7 @@ * Usage: * [["2", "gobblecock", "25"], {parseNumber _this}] call FUNC(map) ==> [2, 0, 25] * - * Public: No + * Public: Yes */ #include "script_component.hpp" From 2348c25e1a6c994010c7035eda82f814e4b1189e Mon Sep 17 00:00:00 2001 From: commy2 Date: Sun, 20 Sep 2015 20:25:25 +0200 Subject: [PATCH 4/4] more common code cleanup --- addons/common/functions/fnc_displayIcon.sqf | 108 ++++++++++-------- addons/common/functions/fnc_displayText.sqf | 37 +++--- .../functions/fnc_endRadioTransmission.sqf | 5 +- addons/common/functions/fnc_eraseCache.sqf | 2 +- addons/common/functions/fnc_errorMessage.sqf | 6 +- addons/common/functions/fnc_execNextFrame.sqf | 15 +-- .../functions/fnc_execPersistentFnc.sqf | 30 ++--- addons/common/functions/fnc_execRemoteFnc.sqf | 40 +++---- .../functions/fnc_executePersistent.sqf | 17 ++- addons/common/functions/fnc_exportConfig.sqf | 24 ++-- .../common/functions/fnc_uniqueElements.sqf | 12 +- 11 files changed, 152 insertions(+), 144 deletions(-) diff --git a/addons/common/functions/fnc_displayIcon.sqf b/addons/common/functions/fnc_displayIcon.sqf index 2fd5245465..8421f5be7e 100644 --- a/addons/common/functions/fnc_displayIcon.sqf +++ b/addons/common/functions/fnc_displayIcon.sqf @@ -1,24 +1,23 @@ /* -* Author: Glowbal -* -* Draw progress bar and execute given function if succesful. -* Finish/Failure/Conditional are all passed [args, elapsedTime, totalTime, errorCode] -* -* Argument: -* 0: icon ID -* 1: show -* 2: Icon Path -* 3: Icon color -* 4: timeAlive. -1 = forever -* -* Return value: -* Nothing -* -* Example: -* ["myID", true, QUOTE(PATHTOF(data\icon_group.paa)), [1,1,1,1], 0] call ace_gui_fnc_displayIcon; -*/ - - + * Author: Glowbal + * Draw progress bar and execute given function if succesful. + * Finish/Failure/Conditional are all passed [args, elapsedTime, totalTime, errorCode] + * + * Arguments: + * 0: icon ID + * 1: show + * 2: Icon Path + * 3: Icon color + * 4: timeAlive. -1 = forever (default: 6) + * + * Return Value: + * None + * + * Example: + * ["myID", true, QUOTE(PATHTOF(data\icon_group.paa)), [1,1,1,1], 0] call ace_gui_fnc_displayIcon; + * + * Public: Yes + */ #include "script_component.hpp" // positions for the icon UI @@ -42,31 +41,37 @@ // other constants #define DEFAULT_TIME 6 -private ["_allControls", "_refresh", "_timeAlive", "_list"]; - -PARAMS_4(_iconId,_show,_icon,_color); - -_timeAlive = if (count _this > 4) then {_this select 4} else {DEFAULT_TIME}; - disableSerialization; -_list = missionNamespace getvariable [QGVAR(displayIconList),[]]; + +params ["_iconId", "_show", "_icon", "_color", ["_timeAlive", DEFAULT_TIME]]; + +private ["_list", "_refresh"]; + +_list = missionNamespace getVariable [QGVAR(displayIconList), []]; _refresh = { - private ["_allControls"]; // Refreshing of all icons.. - _allControls = missionNamespace getvariable [QGVAR(displayIconListControls), []]; + private "_allControls"; + _allControls = missionNamespace getVariable [QGVAR(displayIconListControls), []]; + { ctrlDelete _x; - }foreach _allControls; + false + } count _allControls; _allControls = []; - private ["_ctrl", "_setting", "_position"]; - _setting = missionNamespace getvariable[QGVAR(settingFeedbackIcons), 0]; + private ["_setting", "_ctrl", "_position"]; + + _setting = missionNamespace getVariable [QGVAR(settingFeedbackIcons), 0]; + if (_setting > 0) then { { + _x params ["", "_xicon", "_xcolor"]; + // +19000 because we want to make certain we are using free IDCs.. - _ctrl = ((findDisplay 46) ctrlCreate ["RscPicture", _foreachIndex + 19000]); + _ctrl = (findDisplay 46) ctrlCreate ["RscPicture", _forEachIndex + 19000]; + _position = switch (_setting) do { case TOP_RIGHT_DOWN: {[X_POS_ICONS, Y_POS_ICONS + (_foreachIndex * DIFFERENCE_ICONS), ICON_WIDTH, ICON_WIDTH]}; case TOP_RIGHT_LEFT: {[X_POS_ICONS_SECOND - ((_foreachIndex+3) * DIFFERENCE_ICONS), Y_POS_ICONS_SECOND - (ICON_WIDTH / 2), ICON_WIDTH, ICON_WIDTH]}; @@ -74,46 +79,53 @@ _refresh = { case TOP_LEFT_RIGHT: {[LEFT_SIDE + (0.5 * ICON_WIDTH) - ((_foreachIndex+3) * DIFFERENCE_ICONS), Y_POS_ICONS_SECOND, ICON_WIDTH, ICON_WIDTH]}; default {[X_POS_ICONS, Y_POS_ICONS + (_foreachIndex * DIFFERENCE_ICONS), ICON_WIDTH, ICON_WIDTH]}; }; + _ctrl ctrlSetPosition _position; - _ctrl ctrlsetText (_x select 1); - _ctrl ctrlSetTextColor (_x select 2); + _ctrl ctrlSetText _xicon; + _ctrl ctrlSetTextColor _xcolor; _ctrl ctrlCommit 0; - _allControls pushback _ctrl; - }foreach (missionNamespace getvariable [QGVAR(displayIconList),[]]); + _allControls pushBack _ctrl; + false + } forEach (missionNamespace getVariable [QGVAR(displayIconList),[]]); }; - missionNamespace setvariable [QGVAR(displayIconListControls), _allControls]; + + missionNamespace setVariable [QGVAR(displayIconListControls), _allControls]; }; if (_show) then { - if ({(_x select 0 == _iconId)} count _list == 0) then { - _list pushback [_iconId, _icon, _color, ACE_time]; + if ({_x select 0 == _iconId} count _list == 0) then { + _list pushBack [_iconId, _icon, _color, ACE_time]; } else { { if (_x select 0 == _iconId) exitwith { - _list set [_foreachIndex, [_iconId, _icon, _color, ACE_time]]; + _list set [_forEachIndex, [_iconId, _icon, _color, ACE_time]]; }; } forEach _list; }; - missionNamespace setvariable [QGVAR(displayIconList), _list]; + + missionNamespace setVariable [QGVAR(displayIconList), _list]; call _refresh; if (_timeAlive >= 0) then { [{ - [_this select 0, false, "", [0,0,0], 0] call FUNC(displayIcon); - }, [_iconId], _timeAlive, _timeAlive] call EFUNC(common,waitAndExecute); + [_this select 0, false, "", [0,0,0], 0] call FUNC(displayIcon); + }, [_iconId], _timeAlive, _timeAlive] call FUNC(waitAndExecute); }; } else { - if ({(_x select 0 == _iconId)} count _list == 1) then { + + if ({_x select 0 == _iconId} count _list == 1) then { private "_newList"; _newList = []; + { if (_x select 0 != _iconId) then { - _newList pushback _x; + _newList pushBack _x; }; - } forEach _list; + false + } count _list; - missionNamespace setvariable [QGVAR(displayIconList), _newList]; + missionNamespace setVariable [QGVAR(displayIconList), _newList]; call _refresh; }; }; diff --git a/addons/common/functions/fnc_displayText.sqf b/addons/common/functions/fnc_displayText.sqf index 22349962ac..fce8fdd832 100644 --- a/addons/common/functions/fnc_displayText.sqf +++ b/addons/common/functions/fnc_displayText.sqf @@ -1,42 +1,35 @@ /* * Author: commy2 - * * Display a message. * - * Argument: - * 0: Message (String) - * 1: Play a clicking sound (Bool, optional default: false) - * 2: How long before hiding the message in seconds (Number, optional default: 2 sec) - * 3: Priority, higher priority messages will override lesser important ones (Number, optional default: 0) + * Arguments: + * 0: Message + * 1: Play a clicking sound (default: false) + * 2: How long before hiding the message in seconds (default: 2) + * 3: Priority, higher priority messages will override lesser important ones (default: 0) * - * Return value: - * Nothing + * Return Value: + * None + * + * Public: Yes */ #include "script_component.hpp" -#define DEFAULT_PLAY_SOUND false -#define DEFAULT_DELAY 2 -#define DEFAULT_PRIORITY 0 - -_this resize 4; - -private ["_lastHintTime", "_lastHintPriority", "_time"]; - -PARAMS_4(_text,_sound,_delay,_priority); +params ["_text", ["_sound", false], ["_delay", 2], ["_priority", 0]]; if (isNil QGVAR(lastHint)) then { GVAR(lastHint) = [0, 0]; }; +if !(typeName _text in ["STRING", "TEXT"]) then {_text = str _text}; + +private ["_lastHintTime", "_lastHintPriority", "_time"]; + _lastHintTime = GVAR(lastHint) select 0; _lastHintPriority = GVAR(lastHint) select 1; -if !(typeName _text in ["STRING", "TEXT"]) then {_text = str _text}; -if (isNil "_sound") then {_sound = DEFAULT_PLAY_SOUND}; -if (isNil "_delay") then {_delay = DEFAULT_DELAY}; -if (isNil "_priority") then {_priority = DEFAULT_PRIORITY}; - _time = ACE_time; + if (_time > _lastHintTime + _delay || {_priority >= _lastHintPriority}) then { hintSilent _text; if (_sound) then {playSound "ACE_Sound_Click"}; diff --git a/addons/common/functions/fnc_endRadioTransmission.sqf b/addons/common/functions/fnc_endRadioTransmission.sqf index 78a50e9f2c..4597426d67 100644 --- a/addons/common/functions/fnc_endRadioTransmission.sqf +++ b/addons/common/functions/fnc_endRadioTransmission.sqf @@ -4,11 +4,12 @@ * End radio transmissions of addons TFAR and ACRE2. TFAR v0.9.7, ACRE Public Beta 2.0.3.571 * * Arguments: - * None. + * None * * Return Value: - * None. + * None * + * Public: No */ #include "script_component.hpp" diff --git a/addons/common/functions/fnc_eraseCache.sqf b/addons/common/functions/fnc_eraseCache.sqf index 9521bb3630..ae988ced28 100644 --- a/addons/common/functions/fnc_eraseCache.sqf +++ b/addons/common/functions/fnc_eraseCache.sqf @@ -13,6 +13,6 @@ */ #include "script_component.hpp" -PARAMS_2(_namespace,_uid); +params ["_namespace", "_uid"]; _namespace setVariable [_uid, nil]; diff --git a/addons/common/functions/fnc_errorMessage.sqf b/addons/common/functions/fnc_errorMessage.sqf index 3929477e76..f06aa2d30d 100644 --- a/addons/common/functions/fnc_errorMessage.sqf +++ b/addons/common/functions/fnc_errorMessage.sqf @@ -29,11 +29,7 @@ if (isNull (call BIS_fnc_displayMission)) exitWith { }, 1, _this] call CBA_fnc_addPerFrameHandler; }; -private ["_onOK", "_onCancel"]; - -PARAMS_2(_textHeader,_textMessage); -_onOK = ARR_SELECT(_this,2,{}); -_onCancel = ARR_SELECT(_this,3,{}); +params ["_textHeader", "_textMessage", ["_onOK", {}], ["_onCancel", {}]]; if (typeName _textMessage == "STRING") then { _textMessage = parseText _textMessage; diff --git a/addons/common/functions/fnc_execNextFrame.sqf b/addons/common/functions/fnc_execNextFrame.sqf index ddd36be073..7b3f034c6d 100644 --- a/addons/common/functions/fnc_execNextFrame.sqf +++ b/addons/common/functions/fnc_execNextFrame.sqf @@ -1,18 +1,19 @@ /* * Author: esteldunedain - * * Executes a code on the next frame * - * Argument: - * 0: Code to execute (Code) - * 1: Parameters to run the code with (Array) + * Arguments: + * 0: Code to execute + * 1: Parameters to run the code with * - * Return value: - * PFH handler ID + * Return Value: + * PFH handler ID + * + * Public: Yes */ #include "script_component.hpp" -PARAMS_2(_func,_params); +params ["_func", "_params"]; if (diag_frameno != GVAR(nextFrameNo)) then { GVAR(nextFrameBufferA) pushBack [_params, _func]; diff --git a/addons/common/functions/fnc_execPersistentFnc.sqf b/addons/common/functions/fnc_execPersistentFnc.sqf index dd160b8bfd..dc88a7c3c9 100644 --- a/addons/common/functions/fnc_execPersistentFnc.sqf +++ b/addons/common/functions/fnc_execPersistentFnc.sqf @@ -1,29 +1,29 @@ /* * Author: commy2 - * * Execute a function on every machine. Function will also be called upon JIP (postInit). The arguments are stored in (_this select 0), while the assigned namespace is stored in (_this select 1). * - * Argument: - * 0: Function arguments (Array) - * 1: Function to execute, has to be defined on the remote machine first (String) - * 2: Namespace to save that variable in (Object or Namespace) - * 3: Name. Will overwrite previously defined functions with that name (String) + * Arguments: + * 0: Function arguments + * 1: Function to execute, has to be defined on the remote machine first + * 2: Namespace to save that variable in + * 3: Name. Will overwrite previously defined functions with that name * - * Return value: - * Nothing. + * Return Value: + * None + * + * Public: No + * + * Deprecated */ #include "script_component.hpp" -private ["_arguments", "_function", "_unit", "_name"]; - GVAR(remoteFnc) = _this; -_arguments = _this select 0; -_function = call compile (_this select 1); -_unit = _this select 2; -_name = _this select 3; +params ["_arguments", "_function", "_unit", "_name"]; -["Remote", [_arguments, _this select 1, _name], {format ["%1 call %2 id: %3", _this select 0, _this select 1, _this select 2]}, false] call FUNC(log); +_function = call compile _function; + +//["Remote", [_arguments, _this select 1, _name], {format ["%1 call %2 id: %3", _this select 0, _this select 1, _this select 2]}, false] call FUNC(log); // execute function on every currently connected machine [[_arguments, _unit], _this select 1, 2] call FUNC(execRemoteFnc); diff --git a/addons/common/functions/fnc_execRemoteFnc.sqf b/addons/common/functions/fnc_execRemoteFnc.sqf index 1df17050e6..6b617bf92f 100644 --- a/addons/common/functions/fnc_execRemoteFnc.sqf +++ b/addons/common/functions/fnc_execRemoteFnc.sqf @@ -1,35 +1,32 @@ /* * Author: commy2 - * * Execute a function on a remote machine in mp. * - * Argument: - * 0: Function arguments (Array) - * 1: Function to execute, has to be defined on the remote machine first (String) - * 2: The function will be executed where this unit is local OR the mode were this function should be executed. (Object OR Number, optional default: 2) - * Mode 0: execute on this machine only - * Mode 1: execute on server - * Mode 2: execute on all clients + server - * Mode 3: execute on dedicated only + * Arguments: + * 0: Function arguments + * 1: Function to execute, has to be defined on the remote machine first + * 2: The function will be executed where this unit is local OR the mode were this function should be executed. (default: 2) + * 0 = execute on this machine only + * 1 = execute on server + * 2 = execute on all clients + server + * 3 = execute on dedicated only * - * Return value: - * Nothing + * Return Value: + * None + * + * Public: No + * + * Deprecated */ #include "script_component.hpp" -private ["_arguments", "_function", "_unit", "_id"]; - GVAR(remoteFnc) = _this; -_arguments = _this select 0; -_function = call compile (_this select 1); -_unit = _this select 2; +params ["_arguments", "_function", ["_unit", 2]]; -if (isNil "_unit") then { - _unit = 2; -}; +_function = call compile _function; -["Remote", [_arguments, _this select 1, _unit], {format ["%1 call %2 to: %3", _this select 0, _this select 1, _this select 2]}, false] call FUNC(log); +//["Remote", [_arguments, _this select 1, _unit], {format ["%1 call %2 to: %3", _this select 0, _this select 1, _this select 2]}, false] call FUNC(log); if (typeName _unit == "SCALAR") exitWith { switch (_unit) do { @@ -63,8 +60,7 @@ if (local _unit) then { _arguments call _function; } else { if (isServer) then { - _id = owner _unit; - _id publicVariableClient QGVAR(remoteFnc); + (owner _unit) publicVariableClient QGVAR(remoteFnc); } else { publicVariableServer QGVAR(remoteFnc); }; diff --git a/addons/common/functions/fnc_executePersistent.sqf b/addons/common/functions/fnc_executePersistent.sqf index bbc4e91ea7..3763d1bb58 100644 --- a/addons/common/functions/fnc_executePersistent.sqf +++ b/addons/common/functions/fnc_executePersistent.sqf @@ -1,11 +1,22 @@ -// by commy2 +/* + * Author: commy2 + * Execute all Persistent Functions + * + * Arguments: + * ? + * + * Return Value: + * None + * + * Public: No + */ #include "script_component.hpp" -PARAMS_1(_target); +params ["_target"]; { if (isNil "_x") then { - ACE_LOGERROR_1("No argument and function for remote function. ID: %1",_forEachIndex); + ACE_LOGERROR_1("No arguments and function for remote function. ID: %1",_forEachIndex); } else { if (typeName _x == "ARRAY") then { [_x select 0, _target] call (_x select 1); diff --git a/addons/common/functions/fnc_exportConfig.sqf b/addons/common/functions/fnc_exportConfig.sqf index e8370c8f0f..9b28786e43 100644 --- a/addons/common/functions/fnc_exportConfig.sqf +++ b/addons/common/functions/fnc_exportConfig.sqf @@ -1,17 +1,25 @@ -// by commy2 /* - usage: - - (configFile >> "CfgAmmo") call FUNC(exportConfig); -*/ + * Author: commy2 + * Export Config Entrys to RPT logs + * + * Arguments: + * Config Path + * + * Return Value: + * None + * + * Example: + * [configFile >> "CfgAmmo"] call ace_common_fnc_exportConfig; + * + * Public: No + */ #include "script_component.hpp" private "_fnc_logEntries"; - _fnc_logEntries = { - private ["_p", "_t", "_e", "_a", "_i"]; + params ["_c", "_d"]; - PARAMS_2(_c,_d); + private ["_p", "_t", "_e", "_a", "_i"]; _p = inheritsFrom _c; diff --git a/addons/common/functions/fnc_uniqueElements.sqf b/addons/common/functions/fnc_uniqueElements.sqf index 812bf59dba..55d8c4ef5f 100644 --- a/addons/common/functions/fnc_uniqueElements.sqf +++ b/addons/common/functions/fnc_uniqueElements.sqf @@ -14,14 +14,4 @@ params ["_array"]; -private "_result"; -_result = []; - -{ - if !(_x in _result) then { - _result pushBack _x; - }; - false -} count _array; - -_result +_array arrayIntersect _array // return