From 97c27cc08c3bdf80cd5d84b78ce1c6fba815648e Mon Sep 17 00:00:00 2001 From: commy2 Date: Sun, 21 Aug 2016 13:37:10 +0200 Subject: [PATCH 1/2] update network function headers, cleanup files --- addons/network/CfgFunctions.hpp | 52 +++++++--------------------- addons/network/CfgSettings.hpp | 8 +++++ addons/network/config.cpp | 13 +++---- addons/network/fnc_globalExecute.sqf | 25 +++++-------- addons/network/fnc_globalSay.sqf | 15 ++++---- addons/network/fnc_globalSay3d.sqf | 17 ++++----- addons/network/script_component.hpp | 8 +++++ 7 files changed, 58 insertions(+), 80 deletions(-) create mode 100644 addons/network/CfgSettings.hpp diff --git a/addons/network/CfgFunctions.hpp b/addons/network/CfgFunctions.hpp index 559e6799c..871e2d9ce 100644 --- a/addons/network/CfgFunctions.hpp +++ b/addons/network/CfgFunctions.hpp @@ -1,44 +1,16 @@ -// ----------------------------------------------------------------------------- -// Automatically generated by 'functions_config.rb' -// DO NOT MANUALLY EDIT THIS FILE! -// ----------------------------------------------------------------------------- -class CfgFunctions -{ - class CBA - { - class Network - { - // CBA_fnc_globalExecute - class globalExecute - { - description = "Executes code on given destinations"; - file = "\x\cba\addons\network\fnc_globalExecute.sqf"; - }; - // CBA_fnc_globalSay - class globalSay - { - description = "Says sound on all client computer"; - file = "\x\cba\addons\network\fnc_globalSay.sqf"; - }; - // CBA_fnc_globalSay3d - class globalSay3d - { - description = "Says sound on all client computer in 3d"; - file = "\x\cba\addons\network\fnc_globalSay3d.sqf"; - }; - // CBA_fnc_publicVariable - class publicVariable - { - description = "CBA_fnc_publicVariable does only broadcast the new value if it doesn't exist in missionNamespace or the new value is different to the one in missionNamespace. Checks also for different types. Nil as value gets always broadcasted."; - file = "\x\cba\addons\network\fnc_publicVariable.sqf"; - }; - // CBA_fnc_setVarNet - class setVarNet - { - description = "Same as setVariable [""name"",var, true] but only broadcasts when the value of var is different to the one which is already saved in the variable space. Checks also for different types. Nil as value gets always broadcasted."; - file = "\x\cba\addons\network\fnc_setVarNet.sqf"; - }; +#define F_FILEPATH(func) class func {\ + file = QUOTE(PATHTOF(DOUBLES(fnc,func).sqf));\ +} + +class CfgFunctions { + class CBA { + class Network { + F_FILEPATH(globalExecute); + F_FILEPATH(globalSay); + F_FILEPATH(globalSay3d); + F_FILEPATH(publicVariable); + F_FILEPATH(setVarNet); }; }; }; diff --git a/addons/network/CfgSettings.hpp b/addons/network/CfgSettings.hpp new file mode 100644 index 000000000..8fd682e50 --- /dev/null +++ b/addons/network/CfgSettings.hpp @@ -0,0 +1,8 @@ + +class CfgSettings { + class CBA { + class COMPONENT { + disableGlobalExecute = 0; + }; + }; +}; diff --git a/addons/network/config.cpp b/addons/network/config.cpp index 95a0b0d51..23c28ced1 100644 --- a/addons/network/config.cpp +++ b/addons/network/config.cpp @@ -6,20 +6,15 @@ class CfgPatches { name = CSTRING(component); url = "$STR_CBA_URL"; units[] = {}; + weapons[] = {}; requiredVersion = REQUIRED_VERSION; - requiredAddons[] = { "CBA_common", "CBA_events" }; + requiredAddons[] = {"CBA_common", "CBA_events"}; version = VERSION; authors[] = {"Sickboy"}; }; }; -class CfgSettings { - class CBA { - class COMPONENT { - disableGlobalExecute = 0; - }; - }; -}; - #include "CfgEventHandlers.hpp" #include "CfgFunctions.hpp" + +#include "CfgSettings.hpp" diff --git a/addons/network/fnc_globalExecute.sqf b/addons/network/fnc_globalExecute.sqf index 27f68a6ff..29b537de4 100644 --- a/addons/network/fnc_globalExecute.sqf +++ b/addons/network/fnc_globalExecute.sqf @@ -1,17 +1,18 @@ -/* +/* ---------------------------------------------------------------------------- Function: CBA_fnc_globalExecute -DEPRECATED. Use instead. - -Description +Description: Executes code on given destinations. + DEPRECATED. Use instead. + Parameters: - _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] + _channel - All: -2, ClientsOnly: -1, ServerOnly: 0 + _code - Code to execute + _parameters - Parameter to pass in the _this variable. (optional) Returns: + Magazine of the units binocular Example: (begin example) @@ -20,17 +21,9 @@ Example: Author: Sickboy, commy2 -*/ +---------------------------------------------------------------------------- */ #include "script_component.hpp" -#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 diff --git a/addons/network/fnc_globalSay.sqf b/addons/network/fnc_globalSay.sqf index caab20855..6e8b70b91 100644 --- a/addons/network/fnc_globalSay.sqf +++ b/addons/network/fnc_globalSay.sqf @@ -1,16 +1,17 @@ -/* +/* ---------------------------------------------------------------------------- Function: CBA_fnc_globalSay -DEPRECATED. Use ["say"] instead. - Description: - Says sound on all client computer. + Says sound on all clients. + + DEPRECATED. Use ["say"] instead. Parameters: - [_objects] - Array of Objects that perform Say [Object] - _say - [sound, maxTitlesDistance,speed] or "sound" [Array or String] + _objects - Object or array of objects that perform Say + _params - [sound, maxTitlesDistance,speed] or "sound" Returns: + Nothing Example: (begin example) @@ -19,7 +20,7 @@ Example: Author: Sickboy, commy2 -*/ +---------------------------------------------------------------------------- */ #include "script_component.hpp" params [["_objects", [], [[], objNull]], ["_params", "", ["", []]]]; diff --git a/addons/network/fnc_globalSay3d.sqf b/addons/network/fnc_globalSay3d.sqf index f9bd5f5a0..f2fe7a931 100644 --- a/addons/network/fnc_globalSay3d.sqf +++ b/addons/network/fnc_globalSay3d.sqf @@ -1,17 +1,18 @@ -/* +/* ---------------------------------------------------------------------------- Function: CBA_fnc_globalSay3d -DEPRECATED. Use ["say3D"] instead. - Description: - Says sound on all client computer in 3D. + Says sound on all clients in 3D. + + DEPRECATED. Use ["say3D"] instead. Parameters: - _object - Object that performs Say [Object] can also be _array - [object, targetObject] - _speechName - Speechname - _range - (Optional parameter) maximum distance from camera to execute command [Number] + _objects - Object or array of objects that perform Say + _params - [sound, maxTitlesDistance,speed] or "sound" + _range - Maximum distance from camera to execute command (optional) Returns: + Nothing Example: (begin example) @@ -20,7 +21,7 @@ Example: Author: Sickboy, commy2 -*/ +---------------------------------------------------------------------------- */ #include "script_component.hpp" params [["_objects", [], [[], objNull]], ["_params", "", ["", []]], ["_distance", nil, [0]]]; diff --git a/addons/network/script_component.hpp b/addons/network/script_component.hpp index b0d3f977e..14567e551 100644 --- a/addons/network/script_component.hpp +++ b/addons/network/script_component.hpp @@ -11,3 +11,11 @@ #endif #include "\x\cba\addons\main\script_macros.hpp" + +#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 From 92f3185df8684d2fb64d0048284e9f4bb6a8f8ae Mon Sep 17 00:00:00 2001 From: commy2 Date: Sun, 21 Aug 2016 13:37:57 +0200 Subject: [PATCH 2/2] remove obsolte preInit for network --- addons/network/CfgEventHandlers.hpp | 6 --- addons/network/XEH_preInit.sqf | 66 ----------------------------- addons/network/config.cpp | 1 - 3 files changed, 73 deletions(-) delete mode 100644 addons/network/CfgEventHandlers.hpp delete mode 100644 addons/network/XEH_preInit.sqf diff --git a/addons/network/CfgEventHandlers.hpp b/addons/network/CfgEventHandlers.hpp deleted file mode 100644 index f0a9f14d9..000000000 --- a/addons/network/CfgEventHandlers.hpp +++ /dev/null @@ -1,6 +0,0 @@ - -class Extended_PreInit_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_preInit)); - }; -}; diff --git a/addons/network/XEH_preInit.sqf b/addons/network/XEH_preInit.sqf deleted file mode 100644 index b1f7900e0..000000000 --- a/addons/network/XEH_preInit.sqf +++ /dev/null @@ -1,66 +0,0 @@ -// Any registered functions used in the PreINIT phase must use the uiNamespace copies of the variable. -// So uiNamespace getVariable "CBA_fnc_hashCreate" instead of just CBA_fnc_hashCreate -VM -#include "script_component.hpp" -/* CBA_Network - by Sickboy (sb_at_dev-heaven.net) - * -------------------------------------------------------------- - * Enables network engine support to execute code over the network - * or make a global say command - * - * Notes: - * - Each player has a unique 'id', server has always id 0 - * - PublicVariableEventHandlers do not 'fire' on the computer where you PV the variable. As such we execute the functions also on the computer who calls - * - * Examples: - * - If you want a unit1,unit2, unit3 to say something on every computer: - * [ [unit1, unit2, unit3], "TestSound" ] call cba_network_fSay; - * unit1, 2 and 3 would say "TestSound" (if it existed :p) - * - * - To execute sth on server: - * [ 0, { superDebugMode = true } ] call cba_network_fSend; - * - * - To execute sth on all clients: - * [ -1, { superDebugMode = true; player sideChat "Woah A.C.E!!" }] call cba_network_fSend; - * - * - To execute sth on all clients, unit1, unit2, unit3 write something - * [ -1, { superDebugMode = true; { _x sideChat "Woah A.C.E!!" } forEach _this }, [unit1, unit2, unit3]] call cba_network_fSend; - * - * - To execute sth on all clients and server, use destination -2 - * - To execute sth on all clients and server, EXCEPT the sending node, use destination -3 - * You can always use if (!isServer) then { }; in the code or function you execute through the net-engine -*/ -#define CHANGETIME 5 - -LOG(MSG_INIT); - -// Announce the initialization of the script -ADDON = false; - -#ifdef DEBUG_MODE_FULL - ISNIL(debug,true); -#else - ISNIL(debug,false); -#endif - - -DEPRECATE(fnc_remoteExecute,fnc_globalExecute); -DEPRECATE(fnc_remoteSay,fnc_globalSay); - -// TODO: Add functions that add to opc/opd, instead of direct handling? - -if (SLX_XEH_MACHINE select 3) then { - FUNC(id) = { "server" }; - - // [QGVAR(join), { [QGVAR(opc), _this] call CBA_fnc_localEvent }] call CBA_fnc_addEventHandler; - - // onPlayerConnected '[_name,_id] call FUNC(opc)'; - // TODO: Handle OPD without actually using opd - // Disabled for now, either not used, or annoying to mission makers - // onPlayerDisconnected '[_name,_id] call FUNC(opd)'; -} else { - FUNC(id) = { - if (player == player) then { str(player); } else { "client"; }; - }; -}; - -// Announce the completion of the initialization of the script -ADDON = true; diff --git a/addons/network/config.cpp b/addons/network/config.cpp index 23c28ced1..34c0fa663 100644 --- a/addons/network/config.cpp +++ b/addons/network/config.cpp @@ -14,7 +14,6 @@ class CfgPatches { }; }; -#include "CfgEventHandlers.hpp" #include "CfgFunctions.hpp" #include "CfgSettings.hpp"