Merge pull request #2539 from acemod/commoncleanup8

common code cleanup part 8
This commit is contained in:
commy2 2015-09-20 21:23:54 +02:00
commit 5907bccc77
65 changed files with 410 additions and 379 deletions

View File

@ -179,6 +179,7 @@ PREP(toBitmask);
PREP(toHex);
PREP(toNumber);
PREP(unhideUnit);
PREP(uniqueElements);
PREP(uniqueElementsOnly);
PREP(unloadPerson);
PREP(unloadPersonLocal);

View File

@ -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 <STRING>
* 1: show <BOOL>
* 2: Icon Path <STRING>
* 3: Icon color <ARRAY>
* 4: timeAlive. -1 = forever <NUMBER> <OPTIONAL>
*
* 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 <STRING>
* 1: show <BOOL>
* 2: Icon Path <STRING>
* 3: Icon color <ARRAY>
* 4: timeAlive. -1 = forever (default: 6) <NUMBER>
*
* 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;
};
};

View File

@ -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 <STRING>
* 1: Play a clicking sound (default: false) <BOOL>
* 2: How long before hiding the message in seconds (default: 2) <NUMBER>
* 3: Priority, higher priority messages will override lesser important ones (default: 0) <NUMBER>
*
* 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"};

View File

@ -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"

View File

@ -13,6 +13,6 @@
*/
#include "script_component.hpp"
PARAMS_2(_namespace,_uid);
params ["_namespace", "_uid"];
_namespace setVariable [_uid, nil];

View File

@ -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;

View File

@ -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 <CODE>
* 1: Parameters to run the code with <ARRAY>
*
* Return value:
* PFH handler ID
* Return Value:
* PFH handler ID <NUMBER>
*
* Public: Yes
*/
#include "script_component.hpp"
PARAMS_2(_func,_params);
params ["_func", "_params"];
if (diag_frameno != GVAR(nextFrameNo)) then {
GVAR(nextFrameBufferA) pushBack [_params, _func];

View File

@ -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 <ARRAY>
* 1: Function to execute, has to be defined on the remote machine first <STRING>
* 2: Namespace to save that variable in <OBJECT, NAMESPACE>
* 3: Name. Will overwrite previously defined functions with that name <STRING>
*
* 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);

View File

@ -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 <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. (default: 2) <OBJECT, NUMBER>
* 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);
};

View File

@ -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);

View File

@ -1,17 +1,25 @@
// by commy2
/*
usage:
(configFile >> "CfgAmmo") call FUNC(exportConfig);
*/
* Author: commy2
* Export Config Entrys to RPT logs
*
* Arguments:
* Config Path <CONFIG>
*
* 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;

View File

@ -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

View File

@ -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>
* Object <OBJECT>
*
* Return Value:
* Nothing
* None
*
* Public: No
*/
#include "script_component.hpp"

View File

@ -1,9 +1,20 @@
// by commy2
/*
* Author: commy2
* Fixes zeus placed crates containing buged mine detectors and ace items.
*
* Arguments:
* 0: Crate <OBJECT>
*
* 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;

View File

@ -3,16 +3,16 @@
* Attempt to fix floating physx with disabled damage after setPosXXX commands.
*
* Arguments:
* Physx object (Object)
* PhysX object <OBJECT>
*
* Return Value:
* Nothing
* None
*
* Public: No
*/
#include "script_component.hpp"
private "_object";
_object = _this;
// setHitPointDamage requires local object

View File

@ -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);
};

View File

@ -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 <OBJECT>
*
* Return value:
* NONE
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"

View File

@ -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 <STRING>
* 1: Event args <ANY>
*
* 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);
["ACEg", ACEg] call FUNC(_handleNetEvent);

View File

@ -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 <OBJECT>
*
* 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);

View File

@ -1,6 +1,5 @@
/*
* Author: ?
*
* ?
*
* Arguments:

View File

@ -1,6 +1,5 @@
/*
* Author: ?
*
* ?
*
* Arguments:

View File

@ -1,6 +1,5 @@
/*
* Author: ?
*
* ?
*
* Arguments:

View File

@ -1,6 +1,5 @@
/*
* Author: ?
*
* ?
*
* Arguments:

View File

@ -1,6 +1,5 @@
/*
* Author: ?
*
* ?
*
* Arguments:

View File

@ -1,6 +1,5 @@
/*
* Author: ?
*
* ?
*
* Arguments:

View File

@ -1,6 +1,5 @@
/*
* Author: ?
*
* ?
*
* Arguments:

View File

@ -1,6 +1,5 @@
/*
* Author: ?
*
* ?
*
* Arguments:

View File

@ -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 <OBJECT>
*
* Return value:
* The object exists and is alive (Bool).
* The object exists and is alive <BOOL>.
*
* Public: Yes
*
@ -14,4 +14,6 @@
*/
#include "script_component.hpp"
!isNull (_this select 0) && {alive (_this select 0)}
params ["_unit"];
!isNull _unit && {alive _unit} // return

View File

@ -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

View File

@ -12,4 +12,6 @@
*/
#include "script_component.hpp"
isClass (configFile >> "cfgPatches" >> _this select 0) // return
params ["_modName"];
isClass (configFile >> "cfgPatches" >> _modName) // return

View File

@ -12,7 +12,7 @@
* Usage:
* [["2", "gobblecock", "25"], {parseNumber _this}] call FUNC(map) ==> [2, 0, 25]
*
* Public: No
* Public: Yes
*/
#include "script_component.hpp"
@ -24,4 +24,5 @@ _array = + _array;
{
_array set [_forEachIndex, _x call _code];
} forEach _array;
_array

View File

@ -1,6 +1,5 @@
/*
* Author: KoffeinFlummi, joko // Jonas
*
* Nothing to see here, move along.
*
* Arguments:

View File

@ -1,6 +1,5 @@
/*
* Author: commy2
*
* Counterpart of ace_common_fnc_claim. Check if the given object is claimed by another unit.
*
* Arguments:

View File

@ -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.
*

View File

@ -1,6 +1,5 @@
/*
* Author: commy2
*
* Return the current side of the player
*
* Arguments:

View File

@ -10,7 +10,7 @@
* Return Value:
* None
*
* Public: No
* Public: Yes
*/
#include "script_component.hpp"

View File

@ -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.
*

View File

@ -1,6 +1,5 @@
/*
* Author: commy2
*
* Remove a condition that gets checked by ace_common_fnc_canInteractWith.
*
* Arguments:

View File

@ -1,6 +1,5 @@
/*
* Author: commy2
*
* Called from respawn eventhandler. Resets all public object namespace variables that are added via FUNC(setVariableJIP).
*
* Arguments:

View File

@ -4,7 +4,7 @@
*
* Arguments:
* 0: Source string <STRING>
* 1: Remove html tags (optional) <BOOL>
* 1: Remove html tags (default: false) <BOOL>
*
* 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 "&lt;";} else {_arrayNew + [_x];};
if (_removeTags) then {
_array append toArray "&lt;";
} else {
_array pushBack _x;
};
};
case 62 : {
_arrayNew = if (_removeTags) then {_arrayNew + toArray "&gt;";} else {_arrayNew + [_x];};
if (_removeTags) then {
_array append toArray "&gt;";
} 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

View File

@ -11,6 +11,8 @@
* None
*
* Public: Yes
*
* Note: uses player
*/
#include "script_component.hpp"

View File

@ -1,6 +1,5 @@
/*
* Author: commy2
*
* Sets the name variable of the object. Used to prevent issues with the name command.
*
* Arguments:

View File

@ -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"

View File

@ -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:

View File

@ -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:

View File

@ -1,6 +1,6 @@
/*
* Author: Glowbal
* ? deprecated
* ?
*
* Arguments:
* ?

View File

@ -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 <STRING>
* 1: stringB <STRING>
*
* 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
_matchingCharacters

View File

@ -10,17 +10,9 @@
* copy of string <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 ""

View File

@ -1,6 +1,5 @@
/*
* Author: commy2
*
* Create a centered, colored text.
*
* Arguments:

View File

@ -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 <STRING>
* 1: Arguments <ARRAY>
* 2: TTL <NUMBER, CODE> [Optional] for this specific event call
*
* Return value:
* Boolean of success
* Return Value:
* Boolean of success <BOOL>
*
* 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);

View File

@ -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

View File

@ -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);
GVAR(publishNextTime) = GVAR(publishNextTime) min (ACE_diagTime + _maxDelay);

View File

@ -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;

View File

@ -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

View File

@ -1,6 +1,5 @@
/*
* Author: Garth de Wet (LH)
*
* Takes a string/number and returns the number.
*
* Arguments:

View File

@ -1,6 +1,5 @@
/*
* Author: ?
*
* ?
*
* Arguments:

View File

@ -1,6 +1,5 @@
/*
* Author: ?
*
* ?
*
* Arguments:

View File

@ -1,6 +1,5 @@
/*
* Author: SilentSpike (based on unmuteUnit)
*
* Globally unhides a unit. Only unhides if the last reason was removed.
*
* Arguments:

View File

@ -0,0 +1,17 @@
/*
* Author: Glowbal
* Make a copy of an array with only the unique elements.
*
* Arguments:
* 0: array <ARRAY>
*
* Return Value:
* Copy of original array <ARRAY>
*
* Public: Yes
*/
#include "script_component.hpp"
params ["_array"];
_array arrayIntersect _array // return

View File

@ -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 <ARRAY>
*
* Return Value:
* Copy of original array <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;
_this call FUNC(uniqueElements)

View File

@ -1,6 +1,5 @@
/*
* Author: commy2
*
* Unmutes the unit. Only unmutes if the last reason was removed.
*
* Arguments:

View File

@ -1,36 +1,37 @@
/**
* fn_useItem.sqf
* @Descr:
* @Author: Glowbal
/*
* Author: Glowbal
* Use item
*
* @Arguments: []
* @Return:
* @PublicAPI: true
* Arguments:
* 0: unit <OBJECT>
* 1: item <STRING>
*
* Return Value:
* if item has been used. <BOOL>
*
* 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;
_return

View File

@ -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 <OBJECT>
* 1: magazine <STRING>
*
* Return Value:
* if magazine has been used. <BOOL>
*
* 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
};

View File

@ -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;

View File

@ -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)