Skip to content

Commit

Permalink
Merge pull request #381 from CBATeam/global_cba_namespace
Browse files Browse the repository at this point in the history
add parameter to 'createNamespace' to create a public namespace
  • Loading branch information
Killswitch00 committed Jun 18, 2016
2 parents d609d2a + a25de21 commit f7f5010
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 6 deletions.
8 changes: 8 additions & 0 deletions addons/common/CfgVehicles.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

class CfgVehicles {
class Static;
class CBA_NamespaceDummy: Static {
scope = 1;
displayName = "";
};
};
2 changes: 2 additions & 0 deletions addons/common/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class CfgPatches {

#include "CfgEventHandlers.hpp"
#include "CfgFunctions.hpp"

#include "CfgVehicles.hpp"
#include "CfgLocationTypes.hpp"

class CBA_DirectCall {
Expand Down
17 changes: 14 additions & 3 deletions addons/common/fnc_createNamespace.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ Description:
The Namespace is destroyed after the mission ends. getVariable ARRAY is not supported.
Parameters:
None
_isGlobal - create a global namespace (optional, default: false) <BOOLEAN>
Returns:
_namespace - a namespace <LOCATION>
_namespace - a namespace <LOCATION, OBJECT>
Examples:
(begin example)
_namespace = call CBA_fnc_createNamespace;
My_GlobalNamespace = true call CBA_fnc_createNamespace;
publicVariable "My_GlobalNamespace";
(end)
Author:
Expand All @@ -23,4 +26,12 @@ Author:
#include "script_component.hpp"
SCRIPT(createNamespace);

createLocation ["CBA_NamespaceDummy", [-1000, -1000, 0], 0, 0]
#define DUMMY_POSITION [-1000, -1000, 0]

params [["_isGlobal", false]];

if (_isGlobal isEqualTo true) then {
createVehicle ["CBA_NamespaceDummy", DUMMY_POSITION, [], 0, "NONE"]
} else {
createLocation ["CBA_NamespaceDummy", DUMMY_POSITION, 0, 0]
};
4 changes: 2 additions & 2 deletions addons/common/fnc_deleteNamespace.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ Author:
#include "script_component.hpp"
SCRIPT(deleteNamespace);

params [["_namespace", locationNull, [locationNull]]];
params [["_namespace", locationNull, [locationNull, objNull]]];

deleteLocation _namespace;
_namespace call CBA_fnc_deleteEntity;
2 changes: 1 addition & 1 deletion addons/events/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ GVAR(eventNamespace) = call CBA_fnc_createNamespace;
GVAR(eventHashes) = call CBA_fnc_createNamespace;

if (isServer) then {
GVAR(eventNamespaceJIP) = (sideLogic call CBA_fnc_getSharedGroup) createUnit ["Logic", [0,0,0], [], 0, "NONE"]; // createVehicle fails on game logics. Have to use createUnit instead.
GVAR(eventNamespaceJIP) = true call CBA_fnc_createNamespace;
publicVariable QGVAR(eventNamespaceJIP);
};

Expand Down

0 comments on commit f7f5010

Please sign in to comment.