-
Notifications
You must be signed in to change notification settings - Fork 151
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
Add removeGlobalEventJIP #741
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* ---------------------------------------------------------------------------- | ||
Function: CBA_fnc_removeGlobalEventJIP | ||
|
||
Description: | ||
Removes a globalEventJIP ID. Optionaly will wait until an object is deleted. | ||
|
||
Parameters: | ||
_jipID - A unique ID from CBA_fnc_globalEventJIP. <STRING> | ||
_object - Object, will remove jip EH when object is deleted. Or pass nil to ignore and remove immediately [optional] <OBJECT>or<NIL> | ||
|
||
Returns: | ||
Nothing | ||
|
||
Author: | ||
PabstMirror (idea from Dystopian) | ||
---------------------------------------------------------------------------- */ | ||
#include "script_component.hpp" | ||
SCRIPT(removeGlobalEventJIP); | ||
|
||
params [["_jipID", "", [""]], ["_object", nil, [nil, objNull]]]; | ||
|
||
if ((isNil "_object") || {isNull _object}) then { | ||
GVAR(eventNamespaceJIP) setVariable [_jipID, nil, true]; | ||
} else { | ||
[_object, "Deleted", { | ||
GVAR(eventNamespaceJIP) setVariable [_thisArgs, nil, true]; | ||
}, _jipID] call CBA_fnc_addBISEventHandler; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// ----------------------------------------------------------------------------- | ||
// Automatically generated by 'functions_config.rb' | ||
// DO NOT MANUALLY EDIT THIS FILE! | ||
// ----------------------------------------------------------------------------- | ||
#define DEBUG_MODE_FULL | ||
#include "script_component.hpp" | ||
|
||
#define TESTS ["globalEventJIP"] | ||
|
||
SCRIPT(test-events); | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
LOG("=== Testing Events ==="); | ||
|
||
{ | ||
0 spawn compile preprocessFileLineNumbers format ["\x\cba\addons\events\test_%1.sqf", _x]; | ||
} forEach TESTS; | ||
|
||
nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// ---------------------------------------------------------------------------- | ||
#define DEBUG_SYNCHRONOUS | ||
#include "script_component.hpp" | ||
|
||
SCRIPT(test_globalEventJIP); | ||
|
||
// ---------------------------------------------------------------------------- | ||
#define DEBUG_MODE_FULL | ||
|
||
LOG("Testing globalEventJIP"); | ||
|
||
// UNIT TESTS | ||
TEST_DEFINED("CBA_fnc_globalEventJIP",""); | ||
TEST_DEFINED("CBA_fnc_removeGlobalEventJIP",""); | ||
|
||
// Add basic testing event handler: | ||
GVAR(test_A) = 0; | ||
[QGVAR(test_globalEventJIP), {GVAR(test_A) = _this}] call CBA_fnc_addEventHandler; | ||
|
||
// Test adding globalEventJIP | ||
private _ret = [QGVAR(test_globalEventJIP), 1] call CBA_fnc_globalEventJIP; | ||
private _expected = 1; | ||
TEST_DEFINED_AND_OP(GVAR(test_A),==,_expected,"Verify EH ran"); | ||
TEST_FALSE(isNil {GVAR(eventNamespaceJIP) getVariable _ret},"Verify in global event namespace"); | ||
|
||
// Test removing globalEventJIP | ||
[_ret] call CBA_fnc_removeGlobalEventJIP; | ||
TEST_TRUE(isNil {GVAR(eventNamespaceJIP) getVariable _ret},"Verify removed from global event namespace"); | ||
|
||
// Test removing on objNull | ||
private _ret = [QGVAR(test_globalEventJIP), 2] call CBA_fnc_globalEventJIP; | ||
[_ret, objNull] call CBA_fnc_removeGlobalEventJIP; | ||
TEST_TRUE(isNil {GVAR(eventNamespaceJIP) getVariable _ret},"Verify deleted on null object"); | ||
|
||
// Test removing on non-null object | ||
private _dummyObject = "Land_bakedBeans_F" createVehicle [0,0,0]; | ||
private _ret = [QGVAR(test_globalEventJIP), 3] call CBA_fnc_globalEventJIP; | ||
[_ret, _dummyObject] call CBA_fnc_removeGlobalEventJIP; | ||
TEST_FALSE(isNil {GVAR(eventNamespaceJIP) getVariable _ret},"Verify not removed"); | ||
deleteVehicle _dummyObject; | ||
sleep 0.05; | ||
TEST_TRUE(isNull _dummyObject,"Verify Object Deleted"); | ||
TEST_TRUE(isNil {GVAR(eventNamespaceJIP) getVariable _ret},"Verify removed when deleted"); | ||
|
||
|
||
nil; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.