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

Add the ability to disable fnc_globalExecute #270

Merged
merged 3 commits into from
Feb 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
33 changes: 30 additions & 3 deletions addons/network/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ ADDON = false;
ISNIL(timeSync_Disabled,true); // deprecated
ISNIL(weatherSync_Disabled,true);

PREP(exec);

DEPRECATE(fnc_remoteExecute,fnc_globalExecute);
DEPRECATE(fnc_remoteSay,fnc_globalSay);

Expand Down Expand Up @@ -95,8 +93,37 @@ if (SLX_XEH_MACHINE select 3) then {
};
};

// CBA_fnc_globalExecute is normally enabled
private _disableGE = false;

// Check the CfgSettings >> "CBA" >> "network" >> "disableGlobalExecute" value
private _entry = (CFGSETTINGSS(CBA,COMPONENT) >> "disableGlobalExecute");
if (isNumber _entry) then {
_disableGE = (getNumber _entry == 1);
} else {
if (isText _entry) then {
_disableGE = (getText _entry == "true");
};
};

// Check the mission configuration
private _dGE = getMissionConfigValue ["CBA_disableGlobalExecute", -1];
if (_dGE isEqualType 0) then {
if (_dGE in [0, 1]) then {
_disableGE = (_dGE == 1);
};
} else {
if (_dGE isEqualType "") then {
_disableGE = (_dGE == "true");
};
};

[QUOTE(GVAR(cmd)), { if (GVAR(init)) then { _this spawn FUNC(exec) } }] call (uiNamespace getVariable "CBA_fnc_addEventHandler");
if (_disableGE) then {
missionNamespace setVariable [QUOTE(FUNC(exec)), compileFinal ""];
} else {
PREP(exec);
[QUOTE(GVAR(cmd)), { if (GVAR(init)) then { _this spawn FUNC(exec) } }] call (uiNamespace getVariable "CBA_fnc_addEventHandler");
};
[QUOTE(GVAR(say)), { private "_say"; _say = _this; _objects = _say select 0; if (typeName _objects != "ARRAY") then { _objects = [_objects] }; { _x say (_say select 1) } forEach _objects }] call (uiNamespace getVariable "CBA_fnc_addEventHandler");
[QUOTE(GVAR(say3d)), { private "_say"; _say = _this; if (count _this > 2) then { if ((positionCameraToWorld [0,0,0]) distance (_say select 0) <= (_say select 2)) then { (_say select 0) say3d (_say select 1) } } else { (_say select 0) say3d (_say select 1) } }] call (uiNamespace getVariable "CBA_fnc_addEventHandler");
[QUOTE(GVAR(date)), { private "_date"; _date = _this; setDate _date }] call (uiNamespace getVariable "CBA_fnc_addEventHandler");
Expand Down
9 changes: 7 additions & 2 deletions addons/network/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ class CfgPatches
authorUrl = "https://github.com/CBATeam/CBA_A3";
};
};
class CfgSettings {
class CBA {
class COMPONENT {
disableGlobalExecute = 0;
};
};
};
#include "CfgEventHandlers.hpp"
#include "CfgFunctions.hpp"


24 changes: 24 additions & 0 deletions optionals/disable_globalexec/config.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
Disable network code execution

This is an optional addon that can be used to disable the network
execution function "CBA_fnc_globalExecute" from running code on
other machines.
*/

class CfgPatches {
class CBA_Disable_GlobalExec {
units[] = {};
weapons[] = {};
requiredVersion = 0.1;
requiredAddons[] = {"cba_network"};
};
};

class CfgSettings {
class CBA {
class Network {
disableGlobalExecute = 1;
};
};
};