mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
more common code cleanup
This commit is contained in:
parent
f3a175e9d6
commit
85fd9d9d75
@ -132,7 +132,6 @@ PREP(loadSettingsLocalizedText);
|
||||
PREP(map);
|
||||
PREP(moduleCheckPBOs);
|
||||
PREP(moduleLSDVehicles);
|
||||
PREP(moveToTempGroup);
|
||||
PREP(muteUnit);
|
||||
PREP(muteUnitHandleInitPost);
|
||||
PREP(muteUnitHandleRespawn);
|
||||
|
@ -29,13 +29,7 @@ _defaultLogDisplayLevel = [GVAR(LOGDISPLAY_LEVEL), DEFAULT_TEXT_DISPLAY] select
|
||||
if (_level <= _defaultLoglevel) then {
|
||||
private ["_prefix", "_message"];
|
||||
|
||||
switch (_level) do {
|
||||
case 0: {_prefix = "Error"};
|
||||
case 1: {_prefix = "Warn"};
|
||||
case 2: {_prefix = "Debug"};
|
||||
case 3: {_prefix = "Info"};
|
||||
default {_prefix = "Unknown"};
|
||||
};
|
||||
_prefix = ["Error", "Warn", "Debug", "Info"] select (_level min 3);
|
||||
|
||||
_message = format ["[ACE %1] %2", _prefix, _msg];
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Author: KoffeinFlummi, commy2
|
||||
*
|
||||
* Applies given code to every element in an array, LIKE SOMETHING SQF SHOULD HAVE BY DEFAULT.
|
||||
*
|
||||
* Arguments:
|
||||
@ -12,18 +11,15 @@
|
||||
*
|
||||
* Usage:
|
||||
* [["2", "gobblecock", "25"], {parseNumber _this}] call FUNC(map) ==> [2, 0, 25]
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_array", "_code"];
|
||||
params ["_array", "_code"];
|
||||
|
||||
_array = + _this select 0;
|
||||
_code = _this select 1;
|
||||
|
||||
if (isNil "_array") exitWith {
|
||||
ACE_LOGERROR_1("No array for function map in %1.",_fnc_scriptNameParent);
|
||||
[]
|
||||
};
|
||||
// copy array to not alter the original one
|
||||
_array = + _array;
|
||||
|
||||
{
|
||||
_array set [_forEachIndex, _x call _code];
|
||||
|
@ -9,12 +9,14 @@
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
if !(isServer) exitWith {};
|
||||
|
||||
PARAMS_3(_logic,_units,_activated);
|
||||
params ["_logic", "_units", "_activated"];
|
||||
|
||||
if !(_activated) exitWith {};
|
||||
|
||||
|
@ -8,21 +8,25 @@
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_3(_logic,_units,_activated);
|
||||
|
||||
private["_colors", "_hSCount", "_hiddenSelections", "_i", "_index", "_vehicle"];
|
||||
params ["_logic", "_units", "_activated"];
|
||||
|
||||
if !(_activated) exitWith {};
|
||||
|
||||
{
|
||||
_hiddenSelections = count (getArray (configFile >> "CfgVehicles" >> (typeOf _x) >> "hiddenSelections"));
|
||||
if (_hiddenSelections > 0) then {
|
||||
nul = [_x, _hiddenSelections] spawn {
|
||||
_vehicle = _this select 0;
|
||||
_hSCount = _this select 1;
|
||||
private "_hSCount";
|
||||
_hSCount = count (getArray (configFile >> "CfgVehicles" >> typeOf _x >> "hiddenSelections"));
|
||||
|
||||
if (_hSCount > 0) then {
|
||||
[_x, _hSCount] spawn {
|
||||
params ["_vehicle", "_hSCount"];
|
||||
|
||||
private ["_colors", "_index"];
|
||||
|
||||
_colors = [
|
||||
"#(argb,8,8,3)color(1,0,0,1,co)",
|
||||
"#(argb,8,8,3)color(1,0.5,0,1,co)",
|
||||
@ -32,16 +36,21 @@ if !(_activated) exitWith {};
|
||||
"#(argb,8,8,3)color(0.2,0,0.5,1,co)",
|
||||
"#(argb,8,8,3)color(0.5,0,1,1,co)"
|
||||
];
|
||||
|
||||
_index = 0;
|
||||
while {True} do {
|
||||
|
||||
while {true} do {
|
||||
for "_i" from 0 to (_hSCount - 1) do {
|
||||
_vehicle setObjectTexture [_i, (_colors select _index)];
|
||||
_vehicle setObjectTexture [_i, _colors select _index];
|
||||
};
|
||||
|
||||
_index = (_index + 1) % 7;
|
||||
|
||||
sleep 0.02;
|
||||
};
|
||||
};
|
||||
};
|
||||
false
|
||||
} count _units;
|
||||
|
||||
ACE_LOGINFO("WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE.");
|
||||
|
@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* hint retun value of given function every frame
|
||||
*
|
||||
* Argument:
|
||||
|
@ -1,32 +0,0 @@
|
||||
/**
|
||||
* fn_moveToTempGroup_f.sqf
|
||||
* Moves a unit into a temporarly group and stores its original group to allow rejoining.
|
||||
* @Author: Glowbal
|
||||
*
|
||||
* @Arguments: [unit OBJECT, moveToTempGroup BOOL]
|
||||
* @Return: void
|
||||
* @PublicAPI: false
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit","_moveTo","_previousGroup","_newGroup", "_currentGroup"];
|
||||
_unit = [_this, 0,ObjNull,[ObjNull]] call BIS_fnc_Param;
|
||||
_moveTo = [_this, 1,false,[false]] call BIS_fnc_Param;
|
||||
|
||||
if (_moveTo) then {
|
||||
_previousGroup = group _unit;
|
||||
_newGroup = createGroup (side _previousGroup);
|
||||
[_unit] joinSilent _newGroup;
|
||||
_unit setvariable [QGVAR(previousGroup),_previousGroup];
|
||||
} else {
|
||||
_previousGroup = _unit getvariable QGVAR(previousGroup);
|
||||
if (!isnil "_previousGroup") then {
|
||||
_currentGroup = group _unit;
|
||||
_unit setvariable [QGVAR(previousGroup),nil];
|
||||
[_unit] joinSilent _previousGroup;
|
||||
if (count units _currentGroup == 0) then {
|
||||
deleteGroup _currentGroup;
|
||||
};
|
||||
};
|
||||
};
|
@ -1,23 +1,25 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Mutes the unit. It won't trigger auto generated chat messages either.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Unit (Object)
|
||||
* 1: Reason to mute the unit (String)
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
* 1: Reason to mute the unit <STRING>
|
||||
*
|
||||
* Return value:
|
||||
* Nothing
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_2(_unit,_reason);
|
||||
params ["_unit", "_reason"];
|
||||
|
||||
if (isNull _unit) exitWith {};
|
||||
|
||||
private ["_muteUnitReasons", "_speaker"];
|
||||
|
||||
// add reason to mute to the unit
|
||||
private "_muteUnitReasons";
|
||||
_muteUnitReasons = _unit getVariable [QGVAR(muteUnitReasons), []];
|
||||
|
||||
if !(_reason in _muteUnitReasons) then {
|
||||
@ -25,7 +27,6 @@ if !(_reason in _muteUnitReasons) then {
|
||||
_unit setVariable [QGVAR(muteUnitReasons), _muteUnitReasons, true];
|
||||
};
|
||||
|
||||
private "_speaker";
|
||||
_speaker = speaker _unit;
|
||||
|
||||
if (_speaker == "ACE_NoVoice") exitWith {};
|
||||
|
@ -1,7 +1,18 @@
|
||||
// by commy2
|
||||
/*
|
||||
* Author: commy2
|
||||
* Applies speaker changes on init post. Used because setSpeaker is broken on init.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_1(_unit);
|
||||
params ["_unit"];
|
||||
|
||||
// setSpeaker gets overwritten after init on remote units; if unit is muted, setSpeaker again
|
||||
if (count (_unit getVariable [QGVAR(muteUnitReasons), []]) > 0) then {
|
||||
|
@ -1,7 +1,18 @@
|
||||
// by commy2
|
||||
/*
|
||||
* Author: commy2
|
||||
* Applies speaker changes on respawn. Used because speaker is respawning breaks the speaker on non-local clients. Also resets the public object variable (broken for JIP clients, that join after respawn)
|
||||
*
|
||||
* Arguments:
|
||||
* 0: unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_1(_unit);
|
||||
params ["_unit"];
|
||||
|
||||
// setVariable is broken on JIP after respawn
|
||||
_unit setVariable [QGVAR(muteUnitReasons), _unit getVariable [QGVAR(muteUnitReasons), []], true];
|
||||
|
@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Transforms a number to an array of the correspondending digits.
|
||||
*
|
||||
* Arguments:
|
||||
@ -8,7 +7,7 @@
|
||||
* 1: Set the minimal length of the returned array. Useful for getting left hand zeroes. <NUMBER>, optional
|
||||
*
|
||||
* Return Value:
|
||||
* Digits. The maximum count is six digits. (Array)
|
||||
* Digits. The maximum count is six digits. <ARRAY>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
|
@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Transforms a number to an string of the correspondending digits.
|
||||
*
|
||||
* Arguments:
|
||||
@ -8,7 +7,7 @@
|
||||
* 1: Set the minimal length of the returned string. Useful for getting left hand zeroes. (Number, optional)
|
||||
*
|
||||
* Return Value:
|
||||
* Digits. The maximum length is six digits. (String)
|
||||
* Digits. The maximum length is six digits. <STRING>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
|
@ -1,13 +1,12 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Converts a number to a string without losing as much precission as str or format.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: A number <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* The number as string (String)
|
||||
* The number as string <STRING>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
|
@ -1,19 +1,23 @@
|
||||
/**
|
||||
* fn_onAnswerRequest.sqf
|
||||
* @Descr: N/A
|
||||
* @Author: Glowbal
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* N/A
|
||||
*
|
||||
* @Arguments: []
|
||||
* @Return:
|
||||
* @PublicAPI: false
|
||||
* Arguments:
|
||||
* ?
|
||||
*
|
||||
* Return Value:
|
||||
* ?
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit", "_id", "_accepted"];
|
||||
|
||||
private ["_requestID", "_info", "_callBack", "_caller", "_replyParams", "_requestMessage", "_target"];
|
||||
|
||||
PARAMS_3(_unit,_id,_accepted);
|
||||
|
||||
_info = _unit getvariable _id;
|
||||
|
||||
if (!isnil "_info") then {
|
||||
_caller = _info select 0;
|
||||
_target = _info select 1;
|
||||
@ -21,7 +25,7 @@ if (!isnil "_info") then {
|
||||
_requestMessage = _info select 3;
|
||||
_callBack = _info select 4;
|
||||
_replyParams = [_info, _accepted];
|
||||
[_replyParams, QUOTE(FUNC(requestCallback)), _caller, false] call FUNC(execRemoteFnc);
|
||||
[_replyParams, QFUNC(requestCallback), _caller, false] call FUNC(execRemoteFnc);
|
||||
_unit setvariable [_id, nil];
|
||||
};
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
* None
|
||||
*
|
||||
* Return Value:
|
||||
* current local side (Side)
|
||||
* current local side <SIDE>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user