Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Common - New: updatePerFrameHandlerDelay #1689

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
65acac0
New Function: updatePerFrameHandlerDelay
OverlordZorn Sep 7, 2024
d69b249
update header
OverlordZorn Sep 7, 2024
d7c0d00
macro'fied
OverlordZorn Sep 7, 2024
40d67ed
param -> select
OverlordZorn Sep 7, 2024
1eff683
Revert "param -> select"
OverlordZorn Sep 7, 2024
709a41a
preperation for updateExectuionTime
OverlordZorn Sep 7, 2024
920e85a
fnc_directCall and type
OverlordZorn Sep 7, 2024
469d975
Update fnc_removePerFrameHandler.sqf
OverlordZorn Sep 7, 2024
38a60cf
_idx -> _index like fn_removePFH
OverlordZorn Sep 9, 2024
e964840
Revert "_idx -> _index like fn_removePFH"
OverlordZorn Sep 9, 2024
dd89444
idx -> index alike removePFH.sqf
OverlordZorn Sep 9, 2024
42d0f5f
updates the current executionTime
OverlordZorn Sep 9, 2024
bf87d7a
testmisison
OverlordZorn Sep 9, 2024
a43ed7e
Update fnc_updatePerFrameHandlerDelay.sqf
OverlordZorn Sep 9, 2024
61f257a
removed Debug Lines
OverlordZorn Sep 9, 2024
0fd482d
remove test environment
OverlordZorn Sep 9, 2024
6627b5e
remove _updateExecutionTime param
OverlordZorn Sep 9, 2024
d3ff94f
missed a _updateExecutionTime - removed
OverlordZorn Sep 9, 2024
0e1ed4a
Update CfgFunctions.hpp
OverlordZorn Sep 9, 2024
8c80b94
Create fnc_getPerFrameHandlerDelay.sqf
OverlordZorn Sep 9, 2024
163056a
another overlooked _updateExecutionTime
OverlordZorn Sep 9, 2024
0d0b5c2
Merge branch 'zrn-pfh-delay' into zrn-pfh-delay-get
OverlordZorn Sep 9, 2024
f32d8c3
Update fnc_getPerFrameHandlerDelay.sqf
OverlordZorn Sep 9, 2024
6a305bd
updated description in header
OverlordZorn Sep 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions addons/common/CfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class CfgFunctions {
class Misc {
PATHTO_FNC(addPerFrameHandler);
PATHTO_FNC(removePerFrameHandler);
PATHTO_FNC(updatePerFrameHandlerDelay);
PATHTO_FNC(createPerFrameHandlerObject);
PATHTO_FNC(deletePerFrameHandlerObject);
PATHTO_FNC(addPlayerAction);
Expand Down
42 changes: 42 additions & 0 deletions addons/common/fnc_updatePerFrameHandlerDelay.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include "script_component.hpp"
/* ----------------------------------------------------------------------------
Function: CBA_fnc_updatePerFrameHandlerDelay

Description:
Updates the delay of an existing perFrameHandler.

Parameters:
_handle - The existing perFrameHandler's handle. <NUMBER>
OverlordZorn marked this conversation as resolved.
Show resolved Hide resolved
_delay - The amount of time in seconds between executions, 0 for every frame. (optional, default: 0) <NUMBER>
_updateExecutionTime - <BOOL> When true, adjusts the nextExecution time.
OverlordZorn marked this conversation as resolved.
Show resolved Hide resolved

Returns:
true if successful, false otherwise <BOOLEAN>

Examples:
(begin example)
_wasSuccessful = [_handle, _newDelay] call CBA_fnc_updatePerFrameHandlerDelay;
(end)

Author:
Mokka, OverlordZorn
---------------------------------------------------------------------------- */

params [["_handle", -1, [0]], ["_newDelay", 0, [0]], ["_updateExecutionTime", false, [false]]];

[{
params ["_handle", "_newDelay", "_updateExecutionTime"];

private _index = GVAR(PFHhandles) param [_handle];
if (isNil "_index") exitWith {false};
private _entry = GVAR(perFrameHandlerArray) select _index;
private _prevDelay = _entry select 1;
_entry set [1, _newDelay];

if (_updateExecutionTime) then {
_entry set [2, _entry#2 - prevDelay + _newDelay];
};

true

}, [_handle, _newDelay, _updateExecutionTime]] call CBA_fnc_directCall;