Merge pull request #2683 from acemod/commonCleanupX

Common cleanup x
This commit is contained in:
Glowbal 2015-10-11 12:15:27 +02:00
commit 1e26fee3ba
9 changed files with 36 additions and 144 deletions

View File

@ -9,11 +9,11 @@
//Singe PFEH to handle execNextFrame, waitAndExec and waitUntilAndExec:
[{
private ["_entry", "_deleted"];
BEGIN_COUNTER(waitAndExec);
//Handle the waitAndExec array:
while {!(GVAR(waitAndExecArray) isEqualTo []) && {GVAR(waitAndExecArray) select 0 select 0 <= ACE_Time}} do {
_entry = GVAR(waitAndExecArray) deleteAt 0;
local _entry = GVAR(waitAndExecArray) deleteAt 0;
(_entry select 2) call (_entry select 1);
};
@ -29,7 +29,7 @@
GVAR(nextFrameNo) = diag_frameno + 1;
//Handle the waitUntilAndExec array:
_deleted = 0;
local _deleted = 0;
{
// if condition is satisifed call statement
if ((_x select 2) call (_x select 0)) then {
@ -39,6 +39,8 @@
(_x select 2) call (_x select 1);
};
} forEach GVAR(waitUntilAndExecArray);
END_COUNTER(waitAndExec);
}, 0, []] call CBA_fnc_addPerFrameHandler;

View File

@ -1,22 +1,24 @@
/*
* Author: ?
* ?
* Dumps an array to the RPT, showing the depth of each element.
*
* Arguments:
* 0: Array to be dumped <ARRAY>
* 1: Depth <NUMBER>
* 1: Depth <NUMBER><OPTIONAL>
*
* Return Value:
* None
*
* Example:
* [[0, [1,2], [[3]]]] call ace_common_fnc_dumpArray
*
* Public: No
*/
#include "script_component.hpp"
params ["_var", "_depth"];
params ["_var", ["_depth", 0, [0]]];
private "_pad";
_pad = "";
local _pad = "";
for "_i" from 0 to _depth do {
_pad = _pad + toString [9];
@ -38,5 +40,5 @@ if (IS_ARRAY(_var)) then {
diag_log text format ["%1],", _pad];
};
} else {
diag_log text format ["%1%2", _pad, [_var] call FUNC(formatVar)];
diag_log text format ["%1%2", _pad, _var];
};

View File

@ -20,11 +20,10 @@
GVAR(remoteFnc) = _this;
params ["_arguments", "_function", "_unit", "_name"];
TRACE_4("params", _arguments, _function, _unit, _name);
_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

@ -23,11 +23,10 @@
GVAR(remoteFnc) = _this;
params ["_arguments", "_function", ["_unit", 2]];
TRACE_3("params", _arguments, _function, _unit);
_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);
if (typeName _unit == "SCALAR") exitWith {
switch (_unit) do {
case 0 : {

View File

@ -8,29 +8,23 @@
* Return Value:
* Turret Index <ARRAY>
*
* Example:
* [ace_player] call ace_common_fnc_getTurretIndex
*
* Public: Yes
*/
#include "script_component.hpp"
params ["_unit"];
private ["_vehicle", "_turrets", "_units", "_index"];
_vehicle = vehicle _unit;
local _vehicle = vehicle _unit;
if (_unit == _vehicle) exitWith {[]};
_turrets = allTurrets [_vehicle, true];
_units = [];
scopeName "main";
{
_units pushBack (_vehicle turretUnit _x);
false
} count _turrets;
if (_unit == (_vehicle turretUnit _x)) then {_x breakOut "main"};
nil
} count allTurrets [_vehicle, true];
_index = _units find _unit;
if (_index == -1) exitWith {[]};
_turrets select _index;
[]

View File

@ -21,7 +21,7 @@ private ["_vehicle", "_loadcar", "_loadair", "_loadtank", "_loadboat"];
_vehicle = objNull;
if (!([_caller] call FUNC(canInteract)) || {_caller == _unit}) exitwith {_vehicle};
if (!([_caller, _unit, ["isNotDragging", "isNotCarrying"]] call FUNC(canInteractWith)) || {_caller == _unit}) exitwith {_vehicle};
_loadcar = nearestObject [_unit, "Car"];

View File

@ -1,53 +0,0 @@
/*
* Author: Glowbal
* Sends a display information hint to a receiver
*
* Arguments:
* 0: receiver <OBJECT>
* 1: title <STRING>
* 2: content <ARRAY>
* 3: type (optional) <NUMBER>
*
* Return Value:
* None
*
* Public: Yes
*/
#include "script_component.hpp"
params [["_reciever", objNull], ["_title", ""], ["_content", ""], ["_type", 0], ["_parameters", []]];
if (isPlayer _reciever) then {
if (!local _reciever) then {
[_this, QFUNC(sendDisplayInformationTo), _reciever, false] call FUNC(execRemoteFnc);
} else {
if (isLocalized _title) then {
_title = localize _title;
};
private "_localizationArray";
_localizationArray = [_title];
{
_localizationArray pushback _x;
false
} count _parameters;
_title = format _localizationArray;
{
if (isLocalized _x) then {
_localizationArray = [localize _x];
{
_localizationArray pushBack _x;
false
} count _parameters;
_content set [_forEachIndex, format _localizationArray];
};
} forEach _content;
[_title, _content, _type] call FUNC(displayInformation);
};
};

View File

@ -1,53 +0,0 @@
/*
* Author: Glowbal
* Displays a message on locality of receiver
*
* Arguments:
* 0: receiver <OBJECT>
* 1: title <STRING>
* 2: content <ARRAY>
* 3: type (optional) <NUMBER>
*
* Return Value:
* None
*
* Public: Yes
*/
#include "script_component.hpp"
params [["_reciever", objNull], ["_title", ""], ["_content", ""], ["_type", 0], ["_parameters", []]];
if (isPlayer _reciever) then {
if (!local _reciever) then {
[_this, QFUNC(sendDisplayMessageTo), _reciever, false] call FUNC(execRemoteFnc);
} else {
if (isLocalized _title) then {
_title = localize _title;
};
if (isLocalized _content) then {
_content = localize _content;
};
private "_localizationArray";
_localizationArray = [_title];
{
_localizationArray pushBack _x;
false
} count _parameters;
_title = format _localizationArray;
_localizationArray = [_content];
{
_localizationArray pushBack _x;
false
} count _parameters;
_content = format _localizationArray;
[_title, _content, _type] call FUNC(displayMessage);
};
};

View File

@ -1,26 +1,26 @@
/*
* Author: ?
* ?
* Author: jaynus
* PFEH to set all Ace Time Variables
*
* Arguments:
* ?
* None
*
* Return Value:
* ?
* None
*
* Public: ?
* Public: No
*/
#include "script_component.hpp"
private ["_lastTickTime", "_lastGameTime", "_delta"];
BEGIN_COUNTER(timePFH);
_lastTickTime = ACE_diagTime;
_lastGameTime = ACE_gameTime;
local _lastTickTime = ACE_diagTime;
local _lastGameTime = ACE_gameTime;
ACE_gameTime = time;
ACE_diagTime = diag_tickTime;
_delta = ACE_diagTime - _lastTickTime;
local _delta = ACE_diagTime - _lastTickTime;
if (ACE_gameTime <= _lastGameTime) then {
TRACE_1("paused",_delta);
@ -36,3 +36,5 @@ if (ACE_gameTime <= _lastGameTime) then {
ACE_virtualTime = ACE_virtualTime + (_delta * accTime);
ACE_time = ACE_virtualTime;
};
END_COUNTER(timePFH);