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

Use remote exec in network #275

Merged
merged 3 commits into from
Feb 24, 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
50 changes: 0 additions & 50 deletions addons/network/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ OBSOLETE(fnc_removePersistentMarker,REMOVE_PERSISTENT_MARKER);

// TODO: Add functions that add to opc/opd, instead of direct handling?

GVAR(init) = false;

if (SLX_XEH_MACHINE select 3) then {
ISNIL(MARKERS,[]); // Sync Markers for JIP

Expand All @@ -76,59 +74,11 @@ if (SLX_XEH_MACHINE select 3) then {
// TODO: Handle OPD without actually using opd
// Disabled for now, either not used, or annoying to mission makers
// onPlayerDisconnected '[_name,_id] call FUNC(opd)';

// Looped Weather Sync
/*
SLX_XEH_STR spawn {
// Every 60 Seconds weather sync
while { true } do {
sleep 60;
call FUNC(sync);
};
};
*/
} else {
FUNC(id) = {
if (player == player) then { str(player); } else { "client"; };
};
};

// 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");
};
};

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");
//[QUOTE(GVAR(weather)), { private "_weather"; _weather = _this; CHANGETIME setOverCast (_weather select 0); CHANGETIME setRain (_weather select 2); (_weather select 1) spawn { sleep (CHANGETIME + 2); CHANGETIME setFog _this } }] call (uiNamespace getVariable "CBA_fnc_addEventHandler");
GVAR(init) = true; // Deprecated

// Announce the completion of the initialization of the script
ADDON = true;
1 change: 0 additions & 1 deletion addons/network/XEH_preStart.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
PREP(opc);
PREP(opd);
PREP(sync);
PREP(exec);
42 changes: 0 additions & 42 deletions addons/network/fnc_exec.sqf

This file was deleted.

44 changes: 37 additions & 7 deletions addons/network/fnc_globalExecute.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
Function: CBA_fnc_globalExecute

Description:
Executes code on given destinations
Executes code on given destinations. DEPRECATED. Use remoteExec instead.

Parameters:
_channel - All: -2, ClientsOnly: -1, ServerOnly: 0 [Integer]
_code - Code to execute [Code]
_parameter - OPTIONAL. Parameter to pass to the code in the _this variables [Any]
_channel - All: -2, ClientsOnly: -1, ServerOnly: 0 [Integer]
_code - Code to execute [Code]
_parameters - OPTIONAL. Parameter to pass to the code in the _this variables [Any]

Returns:

Expand All @@ -17,8 +17,38 @@ Example:
(end)

Author:
Sickboy
Sickboy, commy2
*/
#include "script_component.hpp"
TRACE_1("",_this);
[QGVAR(cmd), [call FUNC(id), _this]] call CBA_fnc_globalEvent;

#define CBA_SEND_TO_ALL -2
#define CBA_SEND_TO_CLIENTS_ONLY -1
#define CBA_SEND_TO_SERVER_ONLY 0

#define BI_SEND_TO_ALL 0
#define BI_SEND_TO_CLIENTS_ONLY -2
#define BI_SEND_TO_SERVER_ONLY 2

params [["_channel", CBA_SEND_TO_ALL, [CBA_SEND_TO_ALL]], ["_code", {}, [{}]], ["_parameters", []]];

// translate CBA channel to BI channel
_channel = [
BI_SEND_TO_ALL,
BI_SEND_TO_CLIENTS_ONLY,
BI_SEND_TO_SERVER_ONLY
] param [[
CBA_SEND_TO_ALL,
CBA_SEND_TO_CLIENTS_ONLY,
CBA_SEND_TO_SERVER_ONLY
] find _channel];

// we want to execute ClientsOnly on dedicated clients and SP clients too
if (_channel isEqualTo BI_SEND_TO_CLIENTS_ONLY) then {
_channel = BI_SEND_TO_ALL;
_parameters = [_parameters, _code];
_code = {if (!isDedicated) then {(_this select 0) call (_this select 1)}};
};

[_parameters, _code] remoteExec ["BIS_fnc_Call", _channel];

nil
20 changes: 14 additions & 6 deletions addons/network/fnc_globalSay.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Function: CBA_fnc_globalSay

Description:
Says sound on all client computer
Says sound on all client computer. DEPRECATED. Use remoteExec ["say"] instead.

Parameters:
[_objects] - Array of Objects that perform Say [Object]
Expand All @@ -12,14 +12,22 @@ Returns:

Example:
(begin example)
[[player], "Alarm01"] call CBA_fnc_globalSay;
[[player], "Alarm"] call CBA_fnc_globalSay;
(end)

Author:
Sickboy
Sickboy, commy2
*/
// Deprecated?, use now globalEvent
#include "script_component.hpp"
TRACE_1("",_this);

[QGVAR(say), _this] call CBA_fnc_globalEvent;
params [["_objects", [], [[], objNull]], ["_params", "", ["", []]]];

if (_objects isEqualType objNull) then {
_objects = [_objects];
};

{
[_x, _params] remoteExecCall ["say"];
} forEach _objects;

nil
23 changes: 18 additions & 5 deletions addons/network/fnc_globalSay3d.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Function: CBA_fnc_globalSay3d

Description:
Says sound on all client computer in 3d
Says sound on all client computer in 3d. DEPRECATED. Use remoteExec ["say3D"] instead.

Parameters:
_object - Object that performs Say [Object] can also be _array - [object, targetObject]
Expand All @@ -13,13 +13,26 @@ Returns:

Example:
(begin example)
[player, "Alarm01",500] call CBA_fnc_globalSay3d;
[player, "Alarm", 500] call CBA_fnc_globalSay3d;
(end)

Author:
Sickboy
Sickboy, commy2
*/
#include "script_component.hpp"
TRACE_1("",_this);

[QGVAR(say3d), _this] call CBA_fnc_globalEvent;
params [["_objects", [], [[], objNull]], ["_params", "", ["", []]], ["_distance", nil, [0]]];

if (_objects isEqualType objNull) then {
_objects = [_objects];
};

if (!isNil "_distance") then {
_params = [_params, _distance];
};

{
[_x, _params] remoteExecCall ["say3D"];
} forEach _objects;

nil