mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
more common cleanup
This commit is contained in:
parent
dee025bbea
commit
b0704e486f
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Author: esteldunedain and Jaynus
|
||||
* Author: esteldunedain, Jaynus
|
||||
* Returns the result of the function and caches it up to a given ACE_time or event
|
||||
*
|
||||
* Arguments:
|
||||
@ -8,7 +8,7 @@
|
||||
* 2: Namespace to store the cache on <NAMESPACE>
|
||||
* 3: Cache uid <STRING>
|
||||
* 4: Max duration of the cache <NUMBER>
|
||||
* 5: Event that clears the cache <STRING> (Optional)
|
||||
* 5: Event that clears the cache (default: nil) <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* Result of the function <ANY>
|
||||
@ -17,33 +17,31 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_5(_params,_function,_namespace,_uid,_duration);
|
||||
params ["_params", "_function", "_namespace", "_uid", "_duration", "_event"];
|
||||
|
||||
//IGNORE_PRIVATE_WARNING("_eventName");
|
||||
|
||||
if (((_namespace getVariable [_uid, [-99999]]) select 0) < ACE_diagTime) then {
|
||||
if ((_namespace getVariable [_uid, [-99999]]) select 0 < ACE_diagTime) then {
|
||||
_namespace setVariable [_uid, [ACE_diagTime + _duration, _params call _function]];
|
||||
|
||||
// Does the cache needs to be cleared on an event?
|
||||
if (count _this > 5) then {
|
||||
private ["_event","_varName","_cacheList"];
|
||||
_event = _this select 5;
|
||||
_varName = format [QGVAR(clearCache_%1),_event];
|
||||
if (!isNil "_event") then {
|
||||
private ["_varName", "_cacheList"];
|
||||
|
||||
_varName = format [QGVAR(clearCache_%1), _event];
|
||||
_cacheList = missionNamespace getVariable _varName;
|
||||
|
||||
// If there was no EH to clear these caches, add one
|
||||
if (isNil {_cacheList}) then {
|
||||
if (isNil "_cacheList") then {
|
||||
_cacheList = [];
|
||||
missionNamespace setVariable [_varName, _cacheList];
|
||||
|
||||
[_event, {
|
||||
private ["_varName","_cacheList"];
|
||||
private ["_varName", "_cacheList"];
|
||||
// _eventName is defined on the function that calls the event
|
||||
#ifdef DEBUG_MODE_FULL
|
||||
ACE_LOGINFO_1("Clear cached variables on event: %1",_eventName);
|
||||
#endif
|
||||
// Get the list of caches to clear
|
||||
_varName = format [QGVAR(clearCache_%1),_eventName];
|
||||
_varName = format [QGVAR(clearCache_%1), _eventName];
|
||||
_cacheList = missionNamespace getVariable [_varName, []];
|
||||
// Erase all the cached results
|
||||
{
|
||||
@ -57,11 +55,13 @@ if (((_namespace getVariable [_uid, [-99999]]) select 0) < ACE_diagTime) then {
|
||||
// Add this cache to the list of the event
|
||||
_cacheList pushBack [_namespace, _uid];
|
||||
};
|
||||
|
||||
#ifdef DEBUG_MODE_FULL
|
||||
ACE_LOGINFO_2("Calculated result: %1 %2",_namespace,_uid);
|
||||
} else {
|
||||
ACE_LOGINFO_2("Cached result: %1 %2",_namespace,_uid);
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
(_namespace getVariable _uid) select 1
|
||||
|
@ -4,32 +4,26 @@
|
||||
* Is the unit able to enter the vehicle in the given position?
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit to enter the vehicle (Object)
|
||||
* 1: The vehicle to be entered (Object)
|
||||
* 2: Position. Can be "Driver", "Pilot", "Gunner", "Commander", "Copilot", "Turret", "FFV", "Codriver" or "Cargo" (String)
|
||||
* 3: Check current distance to vehicles memory point? (Bool, optional default: false)
|
||||
* 0: Unit to enter the vehicle <OBJECT>
|
||||
* 1: The vehicle to be entered <OBJECT>
|
||||
* 2: Position. Can be "Driver", "Pilot", "Gunner", "Commander", "Copilot", "Turret", "FFV", "Codriver" or "Cargo" <STRING>
|
||||
* 3: Check current distance to vehicles memory point? (default: false) <BOOL>
|
||||
* 4: Index. "Turret", "FFV", "Codriver" and "Cargo" support this optional parameter. Which position should be taken.
|
||||
* Note: This index is diffrent from Armas "cargoIndex". (Number, optional default: next free index)
|
||||
* Note: This index is diffrent from Armas "cargoIndex". (default: next free index) <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* Nothing
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
#define CANGETINDRIVER (isNull (driver _vehicle) || {!alive driver _vehicle}) && {!lockedDriver _vehicle} && {getNumber (_config >> "isUav") != 1}
|
||||
#define CANGETINTURRETINDEX (isNull (_vehicle turretUnit _turret) || {!alive (_vehicle turretUnit _turret)}) && {!(_vehicle lockedTurret _turret)} && {getNumber (_config >> "isUav") != 1}
|
||||
|
||||
private ["_position", "_checkDistance", "_index"];
|
||||
params ["_unit", "_vehicle", "_position", ["_checkDistance",false], ["_index",-1]];
|
||||
|
||||
_this resize 5;
|
||||
|
||||
PARAMS_2(_unit,_vehicle);
|
||||
_position = toLower (_this select 2);
|
||||
_checkDistance = _this select 3;
|
||||
_index = _this select 4; // optional, please don't use
|
||||
|
||||
if (isNil "_checkDistance") then {_checkDistance = false};
|
||||
if (isNil "_index") then {_index = -1};
|
||||
_position = toLower _position;
|
||||
|
||||
// general
|
||||
if (!alive _vehicle || {locked _vehicle > 1}) exitWith {false};
|
||||
|
@ -1,14 +1,19 @@
|
||||
/**
|
||||
* fn_canInteract.sqf
|
||||
* @Descr: Check if unit can interact with enviroment. Unit has to be awake and not be in arrested state.
|
||||
* @Author: Glowbal
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Check if unit can interact with enviroment. Unit has to be awake and not be in arrested state.
|
||||
*
|
||||
* @Arguments: [unit OBJECT]
|
||||
* @Return: BOOL True if unit can interact with enviroment.
|
||||
* @PublicAPI: true
|
||||
* Arguments:
|
||||
* 0: Unit that try to Interact <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Can interact with enviroment <BOOL>
|
||||
*
|
||||
* Public: No
|
||||
*
|
||||
* Deprecated
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_1(_unit);
|
||||
params ["_unit"];
|
||||
|
||||
(((_unit getvariable [QGVAR(canInteract),0]) < 1) && ([_unit] call FUNC(isAwake)) && !([_unit] call FUNC(isArrested)))
|
||||
(_unit getvariable [QGVAR(canInteract),0]) < 1 && [_unit] call FUNC(isAwake) && !([_unit] call FUNC(isArrested))
|
||||
|
@ -5,45 +5,34 @@
|
||||
* Arguments:
|
||||
* 0: The player. <OBJECT>
|
||||
* 1: The interaction target. objNull to ignore. <OBJECT>
|
||||
* 2: Exceptions. What general conditions are to skip? <ARRAY> (Optional)
|
||||
* 2: Exceptions. What general conditions are to skip? (default: []) <ARRAY>
|
||||
*
|
||||
* Return Value:
|
||||
* Unit can interact?
|
||||
*
|
||||
* Public: No
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_exceptions"];
|
||||
params ["_unit", "_target", ["_exceptions", []]];
|
||||
|
||||
PARAMS_2(_unit,_target);
|
||||
|
||||
_exceptions = if (count _this > 2) then {
|
||||
_this select 2;
|
||||
} else {
|
||||
[];
|
||||
};
|
||||
private ["_exceptions", "_owner"];
|
||||
|
||||
_exceptions = [_exceptions, {toLower _this}] call FUNC(map);
|
||||
|
||||
// exit if the target is not free to interact
|
||||
private "_owner";
|
||||
_owner = _target getVariable [QGVAR(owner), objNull];
|
||||
|
||||
// exit if the target is not free to interact
|
||||
if (!isNull _owner && {_unit != _owner}) exitWith {false};
|
||||
|
||||
// check general conditions
|
||||
|
||||
private ["_conditions", "_conditionNames", "_conditionFuncs"];
|
||||
private ["_conditions", "_canInteract"];
|
||||
|
||||
_conditions = missionNamespace getVariable [QGVAR(InteractionConditions), [[],[]]];
|
||||
|
||||
_conditionNames = _conditions select 0;
|
||||
_conditionFuncs = _conditions select 1;
|
||||
_conditions params ["_conditionNames", "_conditionFuncs"];
|
||||
|
||||
private "_canInteract";
|
||||
_canInteract = true;
|
||||
|
||||
{
|
||||
if (!(_x in _exceptions) && {!([_unit, _target] call (_conditionFuncs select _forEachIndex))}) exitWith {
|
||||
_canInteract = false;
|
||||
|
@ -1,14 +1,23 @@
|
||||
// by commy2
|
||||
/*
|
||||
* Author: commy2
|
||||
* Check if the unit can use a Weapon.
|
||||
* Returns true if the unit is on foot or in a FFV position.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: The Unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Can the Unit use Weapons <BOOL>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
// returns true if the unit is on foot or in a ffv position
|
||||
|
||||
private ["_config"];
|
||||
|
||||
PARAMS_1(_unit);
|
||||
params ["_unit"];
|
||||
|
||||
if (_unit == vehicle _unit) exitWith {true};
|
||||
|
||||
private "_config";
|
||||
_config = configFile >> "CfgMovesMaleSdr" >> "States" >> animationState _unit;
|
||||
|
||||
isClass _config
|
||||
|
@ -1,30 +1,25 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Adjust a projectiles velocity and dir + up vector.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Projectile (Object, CfgAmmo)
|
||||
* 1: Adjust azimuth this much. (Number)
|
||||
* 2: Adjust inclination this much. (Number)
|
||||
* 3: Adjust projectile speed this much. In m/s. (Number, optional default: 0 m/s)
|
||||
* Arguments:
|
||||
* 0: Projectile <OBJECT>
|
||||
* 1: Adjust azimuth this much. <NUMBER>
|
||||
* 2: Adjust inclination this much. <NUMBER>
|
||||
* 3: Adjust projectile speed this much. In m/s. (optional: 0) <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* None.
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_adjustSpeed", "_vdir", "_dir", "_up", "_vup", "_vel", "_vlat"];
|
||||
params ["_projectile", "_adjustDir", "_adjustUp", ["_adjustSpeed",0]];
|
||||
|
||||
PARAMS_3(_projectile,_adjustDir,_adjustUp);
|
||||
//["CPD", [_fnc_scriptNameParent, _adjustDir, _adjustUp, _adjustSpeed], nil, false] call FUNC(log);
|
||||
|
||||
_adjustSpeed = if (count _this > 3) then {
|
||||
_this select 3
|
||||
} else {
|
||||
0
|
||||
};
|
||||
|
||||
["CPD", [_fnc_scriptNameParent, _adjustDir, _adjustUp, _adjustSpeed], nil, false] call FUNC(log);
|
||||
private ["_vdir", "_dir", "_up", "_vlat", "_vup", "_vel"];
|
||||
|
||||
// get old direction vector
|
||||
_vdir = vectorNormalized velocity _projectile;
|
||||
|
@ -1,13 +1,14 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Compares version numbers of PBOs and DLLs.
|
||||
*
|
||||
* Argument:
|
||||
* None.
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* Return value:
|
||||
* None.
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
@ -36,13 +37,17 @@ _addons = [_addons, {_this find "ace_" == 0}] call FUNC(filter);
|
||||
["[ACE] ERROR", _errorMsg, {findDisplay 46 closeDisplay 0}] call FUNC(errorMessage);
|
||||
};
|
||||
};
|
||||
} forEach _addons;
|
||||
false
|
||||
} count _addons;
|
||||
|
||||
///////////////
|
||||
// check dlls
|
||||
///////////////
|
||||
{
|
||||
if (_x callExtension "version" == "") then {
|
||||
private "_versionEx";
|
||||
_versionEx = _x callExtension "version";
|
||||
|
||||
if (_versionEx == "") then {
|
||||
private "_errorMsg";
|
||||
_errorMsg = format ["Extension %1.dll not installed.", _x];
|
||||
|
||||
@ -53,9 +58,10 @@ _addons = [_addons, {_this find "ace_" == 0}] call FUNC(filter);
|
||||
};
|
||||
} else {
|
||||
// Print the current extension version
|
||||
ACE_LOGINFO_2("Extension version: %1: %2",_x,(_x callExtension "version"));
|
||||
ACE_LOGINFO_2("Extension version: %1: %2",_x,_versionEx);
|
||||
};
|
||||
} forEach getArray (configFile >> "ACE_Extensions" >> "extensions");
|
||||
false
|
||||
} count getArray (configFile >> "ACE_Extensions" >> "extensions");
|
||||
|
||||
///////////////
|
||||
// check server version/addons
|
||||
@ -75,9 +81,7 @@ if (isMultiplayer) then {
|
||||
[{
|
||||
if (isNil QGVAR(ServerVersion) || isNil QGVAR(ServerAddons)) exitWith {};
|
||||
|
||||
private ["_version","_addons"];
|
||||
_version = (_this select 0) select 0;
|
||||
_addons = (_this select 0) select 1;
|
||||
(_this select 0) params ["_version", "_addons"];
|
||||
|
||||
if (_version != GVAR(ServerVersion)) then {
|
||||
private "_errorMsg";
|
||||
|
@ -5,22 +5,20 @@
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Mode <NUMBER>
|
||||
* 0: Warn once
|
||||
* 1: Warn permanently
|
||||
* 2: Kick
|
||||
* 1: Check all PBOs? <BOOL> (Optional - default: false)
|
||||
* 2: Whitelist <STRING> (Optinal - default: "[]")
|
||||
* 0 = Warn once
|
||||
* 1 = Warn permanently
|
||||
* 2 = Kick
|
||||
* 1: Check all PBOs? (default: false) <BOOL>
|
||||
* 2: Whitelist (default: "[]") <STRING>
|
||||
*
|
||||
* Return value:
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_mode", "_checkAll", "_whitelist"];
|
||||
|
||||
_mode = _this select 0;
|
||||
_checkAll = if (count _this > 1) then {_this select 1} else {false};
|
||||
_whitelist = if (count _this > 2) then {_this select 2} else {"[]"};
|
||||
params ["_mode", ["_checkAll", false], ["_whitelist", "[]"]];
|
||||
|
||||
_whitelist = [_whitelist, {toLower _this}] call FUNC(map);
|
||||
|
||||
@ -30,22 +28,17 @@ ACE_Version_Whitelist = _whitelist;
|
||||
if (!_checkAll) exitWith {}; //ACE is checked by FUNC(checkFiles)
|
||||
|
||||
if (!isServer) then {
|
||||
[_mode, _checkAll, _whitelist] spawn {
|
||||
private ["_missingAddon", "_missingAddonServer", "_oldVersionClient", "_oldVersionServer", "_text", "_error", "_rscLayer", "_ctrlHint"];
|
||||
PARAMS_3(_mode,_checkAll,_whitelist);
|
||||
[{
|
||||
if (isNil "ACE_Version_ClientErrors") exitWith {};
|
||||
|
||||
waitUntil {
|
||||
sleep 1;
|
||||
!isNil "ACE_Version_ClientErrors"
|
||||
};
|
||||
ACE_Version_ClientErrors params ["_missingAddon", "_missingAddonServer", "_oldVersionClient", "_oldVersionServer"];
|
||||
|
||||
_missingAddon = ACE_Version_ClientErrors select 0;
|
||||
_missingAddonServer = ACE_Version_ClientErrors select 1;
|
||||
_oldVersionClient = ACE_Version_ClientErrors select 2;
|
||||
_oldVersionServer = ACE_Version_ClientErrors select 3;
|
||||
(_this select 0) params ["_mode", "_checkAll", "_whitelist"];
|
||||
|
||||
// Display error message.
|
||||
if (_missingAddon || {_missingAddonServer} || {_oldVersionClient} || {_oldVersionServer}) then {
|
||||
private ["_text", "_error"];
|
||||
|
||||
_text = "[ACE] Version mismatch:<br/><br/>";
|
||||
_error = format ["ACE version mismatch: %1: ", profileName];
|
||||
|
||||
@ -72,6 +65,8 @@ if (!isServer) then {
|
||||
if (_mode < 2) then {
|
||||
_text = composeText [lineBreak, parseText format ["<t align='center'>%1</t>", _text]];
|
||||
|
||||
private ["_rscLayer", "_ctrlHint"];
|
||||
|
||||
_rscLayer = "ACE_RscErrorHint" call BIS_fnc_rscLayer;
|
||||
_rscLayer cutRsc ["ACE_RscErrorHint", "PLAIN", 0, true];
|
||||
|
||||
@ -91,9 +86,11 @@ if (!isServer) then {
|
||||
["[ACE] ERROR", _text, {findDisplay 46 closeDisplay 0}] call FUNC(errorMessage);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||
}, 1, [_mode, _checkAll, _whitelist]] call CBA_fnc_addPerFrameHandler;
|
||||
};
|
||||
|
||||
if (_checkAll) then {
|
||||
0 spawn COMPILE_FILE(scripts\Version\checkVersionNumber);
|
||||
0 spawn COMPILE_FILE(scripts\Version\checkVersionNumber); // @todo
|
||||
};
|
||||
|
@ -1,22 +1,19 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Unit claims the ownership over an object. This is used to prevent multiple players from draging the same ammo box or using up the same wheel when repairing etc.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit that claims another object. ObjNull to remove claim. (Object)
|
||||
* 1: The object that gets claimed. (Object)
|
||||
* 2: Lock the claimed object aswell? (Bool)
|
||||
* 0: Unit that claims another object. ObjNull to remove claim. <OBJECT>
|
||||
* 1: The object that gets claimed. <OBJECT>
|
||||
* 2: Lock the claimed object aswell? (optional: false) <BOOL>
|
||||
*
|
||||
* Return Value:
|
||||
* NONE
|
||||
* None
|
||||
*
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_3(_unit,_target,_lockTarget);
|
||||
|
||||
if (isNil "_lockTarget") then {_lockTarget = false};
|
||||
params ["_unit", "_target", ["_lockTarget", false]];
|
||||
|
||||
private "_owner";
|
||||
_owner = _target getVariable [QGVAR(owner), objNull];
|
||||
|
Loading…
Reference in New Issue
Block a user