From 545c16eab331dd30f84bb35fc5d60e0af8c56464 Mon Sep 17 00:00:00 2001 From: Dedmen Miller Date: Fri, 25 Jan 2019 09:36:19 +0100 Subject: [PATCH 1/9] Move zeus SelfActions to config --- addons/zeus/CfgVehicles.hpp | 31 +++++++++++++++++++++++++++++++ addons/zeus/XEH_postInit.sqf | 32 -------------------------------- 2 files changed, 31 insertions(+), 32 deletions(-) diff --git a/addons/zeus/CfgVehicles.hpp b/addons/zeus/CfgVehicles.hpp index 74095cb4a2d..77b4a6a1afb 100644 --- a/addons/zeus/CfgVehicles.hpp +++ b/addons/zeus/CfgVehicles.hpp @@ -317,4 +317,35 @@ class CfgVehicles { class ModuleArsenal_F: Module_F { function=QFUNC(bi_moduleArsenal); }; + + class Man; + class CAManBase: Man { + class ACE_SelfActions { + class GVAR(create) { + displayName = CSTRING(CreateZeus); + condition = QUOTE(\ + isNil QQGVAR(zeus) && {\ + switch (GVAR(canCreateZeus)) do {\ + case CAN_CREATE_ADMIN: {isServer || {IS_ADMIN_LOGGED}};\ + case CAN_CREATE_CONSOLE: {call BIS_fnc_isDebugConsoleAllowed};\ + case CAN_CREATE_ALL: {true};\ + default {false};\ + }\ + }); + exceptions[] = {"isNotSwimming", "isNotInside", "isNotSitting", "isNotOnLadder", "isNotRefueling"}; + //Set GVAR(zeus) to null first to disable the action through the isNil check + statement = QUOTE(GVAR(zeus) = objNull; [ARR_2(QQGVAR(createZeus), ACE_player)] call CBA_fnc_serverEvent); + showDisabled = 1; + icon = "\A3\Ui_F_Curator\Data\Logos\arma3_curator_eye_32_ca.paa"; + }; + class GVAR(delete) { + displayName = CSTRING(DeleteZeus); + condition = QUOTE(!(isNil QQGVAR(zeus) || {isNull GVAR(zeus)})); + exceptions[] = {"isNotSwimming", "isNotInside", "isNotSitting", "isNotOnLadder", "isNotRefueling"}; + statement = QUOTE(deleteVehicle GVAR(zeus); GVAR(zeus) = nil); + showDisabled = 1; + icon = "\A3\Ui_F_Curator\Data\Logos\arma3_curator_eye_32_ca.paa"; + }; + }; + }; }; diff --git a/addons/zeus/XEH_postInit.sqf b/addons/zeus/XEH_postInit.sqf index 85527f0ab26..6de64b6d999 100644 --- a/addons/zeus/XEH_postInit.sqf +++ b/addons/zeus/XEH_postInit.sqf @@ -81,36 +81,4 @@ if (hasInterface) then { GVAR(zeus) = _zeus; [localize "str_a3_cfgvehicles_moduletasksetstate_f_arguments_state_values_created_0"] call EFUNC(common,displayTextStructured); }] call CBA_fnc_addEventHandler; - - private _action = [ - QGVAR(create), - LLSTRING(CreateZeus), - "\A3\Ui_F_Curator\Data\Logos\arma3_curator_eye_32_ca.paa", - { - GVAR(zeus) = objNull; // to disable menu while zeus is being created - [QGVAR(createZeus), ACE_player] call CBA_fnc_serverEvent; - }, - { - switch (GVAR(canCreateZeus)) do { - case CAN_CREATE_ADMIN: {isServer || {IS_ADMIN_LOGGED}}; - case CAN_CREATE_CONSOLE: {call BIS_fnc_isDebugConsoleAllowed}; - case CAN_CREATE_ALL: {true}; - default {false}; - } - && {isNil QGVAR(zeus)} - } - ] call EFUNC(interact_menu,createAction); - ["CAManBase", 1, ["ACE_SelfActions"], _action, true] call EFUNC(interact_menu,addActionToClass); - - _action = [ - QGVAR(delete), - LLSTRING(DeleteZeus), - "\A3\Ui_F_Curator\Data\Logos\arma3_curator_eye_32_ca.paa", - { - deleteVehicle GVAR(zeus); - GVAR(zeus) = nil; - }, - {!(isNil QGVAR(zeus) || {isNull GVAR(zeus)})} - ] call EFUNC(interact_menu,createAction); - ["CAManBase", 1, ["ACE_SelfActions"], _action, true] call EFUNC(interact_menu,addActionToClass); }; From 8f74185ca7e03f16df84f883cd5f7945a0657236 Mon Sep 17 00:00:00 2001 From: Dedmen Miller Date: Fri, 25 Jan 2019 09:52:59 +0100 Subject: [PATCH 2/9] Port CBA PR #1048 --- include/x/cba/addons/main/script_macros_common.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/x/cba/addons/main/script_macros_common.hpp b/include/x/cba/addons/main/script_macros_common.hpp index 77feb5171e0..8ad4817900d 100644 --- a/include/x/cba/addons/main/script_macros_common.hpp +++ b/include/x/cba/addons/main/script_macros_common.hpp @@ -1707,7 +1707,7 @@ Macro: IS_ADMIN Author: commy2 ------------------------------------------- */ -#define IS_ADMIN serverCommandAvailable "#kick" +#define IS_ADMIN serverCommandAvailable '#kick' /* ------------------------------------------- Macro: IS_ADMIN_LOGGED @@ -1727,7 +1727,7 @@ Macro: IS_ADMIN_LOGGED Author: commy2 ------------------------------------------- */ -#define IS_ADMIN_LOGGED serverCommandAvailable "#shutdown" +#define IS_ADMIN_LOGGED serverCommandAvailable '#shutdown' /* ------------------------------------------- Macro: FILE_EXISTS From 812ba5da303a81022f527bae5b18c7864854f4d5 Mon Sep 17 00:00:00 2001 From: Dedmen Miller Date: Fri, 25 Jan 2019 10:13:05 +0100 Subject: [PATCH 3/9] Move Land_Camping_Light_off_F TurnOn action to config --- addons/interaction/CfgVehicles.hpp | 24 ++++++++++++++++++++++++ addons/interaction/XEH_postInit.sqf | 18 ------------------ 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/addons/interaction/CfgVehicles.hpp b/addons/interaction/CfgVehicles.hpp index 558a0779fec..7a49f43a957 100644 --- a/addons/interaction/CfgVehicles.hpp +++ b/addons/interaction/CfgVehicles.hpp @@ -706,6 +706,30 @@ class CfgVehicles { }; }; + class Land_Camping_Light_off_F: ThingX { + class ACE_Actions { + class ACE_MainActions { + displayName = CSTRING(MainAction); + distance = 2; + + // to make "Camping Lantern (Off)" be turned on we replace it with "Camping Lantern" + class GVAR(TurnOn) { + displayName = CSTRING(TurnOn); + icon = "\A3\Ui_f\data\IGUI\Cfg\VehicleToggles\LightsIconOn_ca.paa"; + condition = QUOTE(alive _target); + statement = QUOTE(\ + private _position = getPosATL _target;\ + private _vectorDirAndUp = [ARR_2(vectorDir _target,vectorUp _target)];\ + deleteVehicle _target;\ + private _newLamp = 'Land_Camping_Light_F' createVehicle [ARR_3(0,0,0)];\ + _newLamp setPosATL _position;\ + _newLamp setVectorDirAndUp _vectorDirAndUp;\ + ); + }; + }; + }; + }; + class RoadCone_F: ThingX { class ACE_Actions { class ACE_MainActions { diff --git a/addons/interaction/XEH_postInit.sqf b/addons/interaction/XEH_postInit.sqf index 4b97c408aae..7a9f2b6572d 100644 --- a/addons/interaction/XEH_postInit.sqf +++ b/addons/interaction/XEH_postInit.sqf @@ -135,21 +135,3 @@ GVAR(isOpeningDoor) = false; }]; }; }] call CBA_fnc_addEventHandler; - - -// to make "Camping Lantern (Off)" be turned on we replace it with "Camping Lantern" -private _action = [ - QGVAR(TurnOn), - localize LSTRING(TurnOn), - "\A3\Ui_f\data\IGUI\Cfg\VehicleToggles\LightsIconOn_ca.paa", - { - private _position = getPosATL _target; - private _vectorDirAndUp = [vectorDir _target, vectorUp _target]; - deleteVehicle _target; - private _newLamp = "Land_Camping_Light_F" createVehicle [0,0,0]; - _newLamp setPosATL _position; - _newLamp setVectorDirAndUp _vectorDirAndUp; - }, - {alive _target} -] call EFUNC(interact_menu,createAction); -["Land_Camping_Light_off_F", 0, ["ACE_MainActions"], _action] call EFUNC(interact_menu,addActionToClass); From 728ca103ad02bfe194c825c5723f833d40e3cd0c Mon Sep 17 00:00:00 2001 From: Dedmen Miller Date: Tue, 5 Feb 2019 09:43:33 +0100 Subject: [PATCH 4/9] Move createModule function to script func --- addons/zeus/CfgVehicles.hpp | 10 +------ addons/zeus/XEH_PREP.hpp | 1 + addons/zeus/functions/fnc_canCreateModule.sqf | 26 +++++++++++++++++++ 3 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 addons/zeus/functions/fnc_canCreateModule.sqf diff --git a/addons/zeus/CfgVehicles.hpp b/addons/zeus/CfgVehicles.hpp index 8251c333c9e..1d86d5fee32 100644 --- a/addons/zeus/CfgVehicles.hpp +++ b/addons/zeus/CfgVehicles.hpp @@ -330,15 +330,7 @@ class CfgVehicles { class ACE_SelfActions { class GVAR(create) { displayName = CSTRING(CreateZeus); - condition = QUOTE(\ - isNil QQGVAR(zeus) && {\ - switch (GVAR(canCreateZeus)) do {\ - case CAN_CREATE_ADMIN: {isServer || {IS_ADMIN_LOGGED}};\ - case CAN_CREATE_CONSOLE: {call BIS_fnc_isDebugConsoleAllowed};\ - case CAN_CREATE_ALL: {true};\ - default {false};\ - }\ - }); + condition = QUOTE(call FUNC(canCreateModule)); exceptions[] = {"isNotSwimming", "isNotInside", "isNotSitting", "isNotOnLadder", "isNotRefueling"}; //Set GVAR(zeus) to null first to disable the action through the isNil check statement = QUOTE(GVAR(zeus) = objNull; [ARR_2(QQGVAR(createZeus), ACE_player)] call CBA_fnc_serverEvent); diff --git a/addons/zeus/XEH_PREP.hpp b/addons/zeus/XEH_PREP.hpp index efa01be7d52..2d218ddb8fe 100644 --- a/addons/zeus/XEH_PREP.hpp +++ b/addons/zeus/XEH_PREP.hpp @@ -5,6 +5,7 @@ PREP(bi_moduleCurator); PREP(bi_moduleMine); PREP(bi_moduleProjectile); PREP(bi_moduleRemoteControl); +PREP(canCreateModule); PREP(getModuleDestination); PREP(handleZeusUnitAssigned); PREP(moduleAddArsenal); diff --git a/addons/zeus/functions/fnc_canCreateModule.sqf b/addons/zeus/functions/fnc_canCreateModule.sqf new file mode 100644 index 00000000000..ee6536b6131 --- /dev/null +++ b/addons/zeus/functions/fnc_canCreateModule.sqf @@ -0,0 +1,26 @@ +#include "script_component.hpp" +/* + * Author: Dystopian + * Check whether local player is currently allowed to create a Zeus Module + * + * Arguments: + * None + * + * Return Value: + * Allowed to create module + * + * Example: + * call ace_zeus_fnc_canCreateModule + * + * Public: No + */ + +isNil QQGVAR(zeus) && +{ + switch (GVAR(canCreateZeus)) do { + case CAN_CREATE_ADMIN: {isServer || {IS_ADMIN_LOGGED}}; + case CAN_CREATE_CONSOLE: {call BIS_fnc_isDebugConsoleAllowed}; + case CAN_CREATE_ALL: {true}; + default {false}; + } +} \ No newline at end of file From cd2dbcc24bbd4c8980b4e368a62a78858ebe86e3 Mon Sep 17 00:00:00 2001 From: commy2 Date: Tue, 5 Feb 2019 10:15:37 +0100 Subject: [PATCH 5/9] Update addons/zeus/functions/fnc_canCreateModule.sqf Co-Authored-By: dedmen --- addons/zeus/functions/fnc_canCreateModule.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/zeus/functions/fnc_canCreateModule.sqf b/addons/zeus/functions/fnc_canCreateModule.sqf index ee6536b6131..e985ac13a9c 100644 --- a/addons/zeus/functions/fnc_canCreateModule.sqf +++ b/addons/zeus/functions/fnc_canCreateModule.sqf @@ -23,4 +23,4 @@ isNil QQGVAR(zeus) && case CAN_CREATE_ALL: {true}; default {false}; } -} \ No newline at end of file +} From 7d0a9bdc386f6c9a5b4b8be6f715e783ded41083 Mon Sep 17 00:00:00 2001 From: commy2 Date: Tue, 5 Feb 2019 10:16:19 +0100 Subject: [PATCH 6/9] Apply suggestions from code review Co-Authored-By: dedmen --- addons/zeus/functions/fnc_canCreateModule.sqf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/zeus/functions/fnc_canCreateModule.sqf b/addons/zeus/functions/fnc_canCreateModule.sqf index e985ac13a9c..faa0b5275d3 100644 --- a/addons/zeus/functions/fnc_canCreateModule.sqf +++ b/addons/zeus/functions/fnc_canCreateModule.sqf @@ -15,8 +15,7 @@ * Public: No */ -isNil QQGVAR(zeus) && -{ +isNil QQGVAR(zeus) && { switch (GVAR(canCreateZeus)) do { case CAN_CREATE_ADMIN: {isServer || {IS_ADMIN_LOGGED}}; case CAN_CREATE_CONSOLE: {call BIS_fnc_isDebugConsoleAllowed}; From dfe1afc2b544889567bd94ab397e46c35cd9681e Mon Sep 17 00:00:00 2001 From: Dedmen Miller Date: Tue, 5 Feb 2019 10:18:15 +0100 Subject: [PATCH 7/9] Teaching it a lesson about spacing --- addons/zeus/functions/fnc_canCreateModule.sqf | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/zeus/functions/fnc_canCreateModule.sqf b/addons/zeus/functions/fnc_canCreateModule.sqf index faa0b5275d3..3b681528743 100644 --- a/addons/zeus/functions/fnc_canCreateModule.sqf +++ b/addons/zeus/functions/fnc_canCreateModule.sqf @@ -16,10 +16,10 @@ */ isNil QQGVAR(zeus) && { - switch (GVAR(canCreateZeus)) do { - case CAN_CREATE_ADMIN: {isServer || {IS_ADMIN_LOGGED}}; - case CAN_CREATE_CONSOLE: {call BIS_fnc_isDebugConsoleAllowed}; - case CAN_CREATE_ALL: {true}; - default {false}; - } + switch (GVAR(canCreateZeus)) do { + case CAN_CREATE_ADMIN: {isServer || {IS_ADMIN_LOGGED}}; + case CAN_CREATE_CONSOLE: {call BIS_fnc_isDebugConsoleAllowed}; + case CAN_CREATE_ALL: {true}; + default {false}; + } } From 080cecc13483b452430251fbb3fe9250a2aec005 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Fri, 22 Feb 2019 18:58:32 -0600 Subject: [PATCH 8/9] Update CBA: script_macros_common.hpp --- .../cba/addons/main/script_macros_common.hpp | 105 +++++++++++++----- 1 file changed, 76 insertions(+), 29 deletions(-) diff --git a/include/x/cba/addons/main/script_macros_common.hpp b/include/x/cba/addons/main/script_macros_common.hpp index 8ad4817900d..18f33c785a2 100644 --- a/include/x/cba/addons/main/script_macros_common.hpp +++ b/include/x/cba/addons/main/script_macros_common.hpp @@ -478,8 +478,8 @@ Group: General // ************************************* // Internal Functions -#define DOUBLES(var1,var2) var1##_##var2 -#define TRIPLES(var1,var2,var3) var1##_##var2##_##var3 +#define DOUBLES(var1,var2) ##var1##_##var2 +#define TRIPLES(var1,var2,var3) ##var1##_##var2##_##var3 #define QUOTE(var1) #var1 #ifdef MODULAR @@ -733,29 +733,29 @@ Macro: ISNILS() Author: Sickboy ------------------------------------------- */ -#define ISNILS(VARIABLE,DEFAULT_VALUE) if (isNil #VARIABLE) then { VARIABLE = DEFAULT_VALUE } +#define ISNILS(VARIABLE,DEFAULT_VALUE) if (isNil #VARIABLE) then { ##VARIABLE = ##DEFAULT_VALUE } #define ISNILS2(var1,var2,var3,var4) ISNILS(TRIPLES(var1,var2,var3),var4) #define ISNILS3(var1,var2,var3) ISNILS(DOUBLES(var1,var2),var3) #define ISNIL(var1,var2) ISNILS2(PREFIX,COMPONENT,var1,var2) #define ISNILMAIN(var1,var2) ISNILS3(PREFIX,var1,var2) -#define CREATELOGICS(var1,var2) var1##_##var2 = ([sideLogic] call CBA_fnc_getSharedGroup) createUnit ["LOGIC", [0, 0, 0], [], 0, "NONE"] -#define CREATELOGICLOCALS(var1,var2) var1##_##var2 = "LOGIC" createVehicleLocal [0, 0, 0] -#define CREATELOGICGLOBALS(var1,var2) var1##_##var2 = ([sideLogic] call CBA_fnc_getSharedGroup) createUnit ["LOGIC", [0, 0, 0], [], 0, "NONE"]; publicVariable QUOTE(DOUBLES(var1,var2)) -#define CREATELOGICGLOBALTESTS(var1,var2) var1##_##var2 = ([sideLogic] call CBA_fnc_getSharedGroup) createUnit [QUOTE(DOUBLES(ADDON,logic)), [0, 0, 0], [], 0, "NONE"] +#define CREATELOGICS(var1,var2) ##var1##_##var2## = ([sideLogic] call CBA_fnc_getSharedGroup) createUnit ["LOGIC", [0, 0, 0], [], 0, "NONE"] +#define CREATELOGICLOCALS(var1,var2) ##var1##_##var2## = "LOGIC" createVehicleLocal [0, 0, 0] +#define CREATELOGICGLOBALS(var1,var2) ##var1##_##var2## = ([sideLogic] call CBA_fnc_getSharedGroup) createUnit ["LOGIC", [0, 0, 0], [], 0, "NONE"]; publicVariable QUOTE(DOUBLES(var1,var2)) +#define CREATELOGICGLOBALTESTS(var1,var2) ##var1##_##var2## = ([sideLogic] call CBA_fnc_getSharedGroup) createUnit [QUOTE(DOUBLES(ADDON,logic)), [0, 0, 0], [], 0, "NONE"] -#define GETVARS(var1,var2,var3) (var1##_##var2 getVariable #var3) +#define GETVARS(var1,var2,var3) (##var1##_##var2 getVariable #var3) #define GETVARMAINS(var1,var2) GETVARS(var1,MAINLOGIC,var2) #ifndef PATHTO_SYS - #define PATHTO_SYS(var1,var2,var3) \MAINPREFIX\var1\SUBPREFIX\var2\var3.sqf + #define PATHTO_SYS(var1,var2,var3) \MAINPREFIX\##var1\SUBPREFIX\##var2\##var3.sqf #endif #ifndef PATHTOF_SYS - #define PATHTOF_SYS(var1,var2,var3) \MAINPREFIX\var1\SUBPREFIX\var2\var3 + #define PATHTOF_SYS(var1,var2,var3) \MAINPREFIX\##var1\SUBPREFIX\##var2\##var3 #endif #ifndef PATHTOF2_SYS - #define PATHTOF2_SYS(var1,var2,var3) MAINPREFIX\var1\SUBPREFIX\var2\var3 + #define PATHTOF2_SYS(var1,var2,var3) MAINPREFIX\##var1\SUBPREFIX\##var2\##var3 #endif #define PATHTO_R(var1) PATHTOF2_SYS(PREFIX,COMPONENT_C,var1) @@ -775,15 +775,15 @@ Macro: ISNILS() // This only works for binarized configs after recompiling the pbos // TODO: Reduce amount of calls / code.. -#define COMPILE_FILE2_CFG_SYS(var1) compile preProcessFileLineNumbers var1 +#define COMPILE_FILE2_CFG_SYS(var1) compile preprocessFileLineNumbers var1 #define COMPILE_FILE2_SYS(var1) COMPILE_FILE2_CFG_SYS(var1) #define COMPILE_FILE_SYS(var1,var2,var3) COMPILE_FILE2_SYS('PATHTO_SYS(var1,var2,var3)') #define COMPILE_FILE_CFG_SYS(var1,var2,var3) COMPILE_FILE2_CFG_SYS('PATHTO_SYS(var1,var2,var3)') -#define SETVARS(var1,var2) var1##_##var2 setVariable +#define SETVARS(var1,var2) ##var1##_##var2 setVariable #define SETVARMAINS(var1) SETVARS(var1,MAINLOGIC) -#define GVARMAINS(var1,var2) var1##_##var2 +#define GVARMAINS(var1,var2) ##var1##_##var2## #define CFGSETTINGSS(var1,var2) configFile >> "CfgSettings" >> #var1 >> #var2 //#define SETGVARS(var1,var2,var3) ##var1##_##var2##_##var3 = //#define SETGVARMAINS(var1,var2) ##var1##_##var2 = @@ -794,9 +794,9 @@ Macro: ISNILS() // #define PREP_SYS2(var1,var2,var3,var4) ##var1##_##var2##_fnc_##var4 = { ##var1##_##var2##_fnc_##var4 = COMPILE_FILE_SYS(var1,var3,DOUBLES(fnc,var4)); if (isNil "_this") then { call ##var1##_##var2##_fnc_##var4 } else { _this call ##var1##_##var2##_fnc_##var4 } } // Compile-Once, at Macro. As opposed to Compile-Once, on first use. -#define PREPMAIN_SYS(var1,var2,var3) var1##_fnc_##var3 = COMPILE_FILE_SYS(var1,var2,DOUBLES(fnc,var3)) -#define PREP_SYS(var1,var2,var3) var1##_##var2##_fnc_##var3 = COMPILE_FILE_SYS(var1,var2,DOUBLES(fnc,var3)) -#define PREP_SYS2(var1,var2,var3,var4) var1##_##var2##_fnc_##var4 = COMPILE_FILE_SYS(var1,var3,DOUBLES(fnc,var4)) +#define PREPMAIN_SYS(var1,var2,var3) ##var1##_fnc_##var3 = COMPILE_FILE_SYS(var1,var2,DOUBLES(fnc,var3)) +#define PREP_SYS(var1,var2,var3) ##var1##_##var2##_fnc_##var3 = COMPILE_FILE_SYS(var1,var2,DOUBLES(fnc,var3)) +#define PREP_SYS2(var1,var2,var3,var4) ##var1##_##var2##_fnc_##var4 = COMPILE_FILE_SYS(var1,var3,DOUBLES(fnc,var4)) #define LSTR(var1) TRIPLES(ADDON,STR,var1) @@ -888,8 +888,41 @@ Macro: GVARMAIN() #define GETVAR(var1) GETVARS(PREFIX,COMPONENT,var1) #define SETVAR SETVARS(PREFIX,COMPONENT) #define SETVARMAIN SETVARMAINS(PREFIX) -#define IFCOUNT(var1,var2,var3) if (count var1 > var2) then { var3 = var1 select var2 }; +#define IFCOUNT(var1,var2,var3) if (count ##var1 > ##var2) then { ##var3 = ##var1 select ##var2 }; +/* ------------------------------------------- +Macro: PREP() + +Description: + Defines a function. + + Full file path: + '\MAINPREFIX\PREFIX\SUBPREFIX\COMPONENT\fnc_.sqf' + + Resulting function name: + 'PREFIX_COMPONENT_' + + The PREP macro should be placed in a script run by a XEH preStart and XEH preInit event. + + The PREP macro allows for CBA function caching, which drastically speeds up load times. + Beware though that function caching is enabled by default and as such to disable it, you need to + #define DISABLE_COMPILE_CACHE above your #include "script_components.hpp" include! + + The function will be defined in ui and mission namespace. It can not be overwritten without + a mission restart. + +Parameters: + FUNCTION NAME - Name of the function, unquoted + +Examples: + (begin example) + PREP(banana); + call FUNC(banana); + (end) + +Author: + dixon13 + ------------------------------------------- */ //#define PREP(var1) PREP_SYS(PREFIX,COMPONENT_F,var1) #ifdef DISABLE_COMPILE_CACHE @@ -900,13 +933,6 @@ Macro: GVARMAIN() #define PREPMAIN(var1) ['PATHTO_SYS(PREFIX,COMPONENT_F,DOUBLES(fnc,var1))', 'TRIPLES(PREFIX,fnc,var1)'] call SLX_XEH_COMPILE_NEW #endif -#ifdef RECOMPILE - #undef RECOMPILE - #define RECOMPILE recompile = 1 -#else - #define RECOMPILE recompile = 0 -#endif - /* ------------------------------------------- Macro: PATHTO_FNC() @@ -916,6 +942,7 @@ Macro: PATHTO_FNC() Full file path in addons: '\MAINPREFIX\PREFIX\SUBPREFIX\COMPONENT\fnc_.sqf' Define 'RECOMPILE' to enable recompiling. + Define 'SKIP_FUNCTION_HEADER' to skip adding function header. Parameters: FUNCTION NAME - Name of the function, unquoted @@ -936,8 +963,22 @@ Macro: PATHTO_FNC() Author: dixon13, commy2 ------------------------------------------- */ +#ifdef RECOMPILE + #undef RECOMPILE + #define RECOMPILE recompile = 1 +#else + #define RECOMPILE recompile = 0 +#endif +// Set function header type: -1 - no header; 0 - default header; 1 - system header. +#ifdef SKIP_FUNCTION_HEADER + #define CFGFUNCTION_HEADER headerType = -1 +#else + #define CFGFUNCTION_HEADER headerType = 0 +#endif + #define PATHTO_FNC(func) class func {\ file = QPATHTOF(DOUBLES(fnc,func).sqf);\ + CFGFUNCTION_HEADER;\ RECOMPILE;\ } @@ -1086,6 +1127,7 @@ Macros: IS_x() /* ------------------------------------------- Macro: SCRIPT() Sets name of script (relies on PREFIX and COMPONENT values being #defined). + Define 'SKIP_SCRIPT_NAME' to skip adding scriptName. Parameters: NAME - Name of script [Indentifier] @@ -1098,8 +1140,11 @@ Macro: SCRIPT() Author: Spooner ------------------------------------------- */ -#define SCRIPT(NAME) \ - scriptName 'PREFIX\COMPONENT\NAME' +#ifndef SKIP_SCRIPT_NAME + #define SCRIPT(NAME) scriptName 'PREFIX\COMPONENT\NAME' +#else + #define SCRIPT(NAME) /* nope */ +#endif /* ------------------------------------------- Macros: EXPLODE_n() @@ -1707,7 +1752,8 @@ Macro: IS_ADMIN Author: commy2 ------------------------------------------- */ -#define IS_ADMIN serverCommandAvailable '#kick' +#define IS_ADMIN_SYS(x) x##kick +#define IS_ADMIN serverCommandAvailable 'IS_ADMIN_SYS(#)' /* ------------------------------------------- Macro: IS_ADMIN_LOGGED @@ -1727,7 +1773,8 @@ Macro: IS_ADMIN_LOGGED Author: commy2 ------------------------------------------- */ -#define IS_ADMIN_LOGGED serverCommandAvailable '#shutdown' +#define IS_ADMIN_LOGGED_SYS(x) x##shutdown +#define IS_ADMIN_LOGGED serverCommandAvailable 'IS_ADMIN_LOGGED_SYS(#)' /* ------------------------------------------- Macro: FILE_EXISTS From f4cf0c934599a0c754d0cc63ac948f2e9012c4a2 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sat, 23 Feb 2019 10:36:19 -0600 Subject: [PATCH 9/9] Just change admin in cba macro --- .../cba/addons/main/script_macros_common.hpp | 99 +++++-------------- 1 file changed, 27 insertions(+), 72 deletions(-) diff --git a/include/x/cba/addons/main/script_macros_common.hpp b/include/x/cba/addons/main/script_macros_common.hpp index 18f33c785a2..4efb3c71280 100644 --- a/include/x/cba/addons/main/script_macros_common.hpp +++ b/include/x/cba/addons/main/script_macros_common.hpp @@ -478,8 +478,8 @@ Group: General // ************************************* // Internal Functions -#define DOUBLES(var1,var2) ##var1##_##var2 -#define TRIPLES(var1,var2,var3) ##var1##_##var2##_##var3 +#define DOUBLES(var1,var2) var1##_##var2 +#define TRIPLES(var1,var2,var3) var1##_##var2##_##var3 #define QUOTE(var1) #var1 #ifdef MODULAR @@ -733,29 +733,29 @@ Macro: ISNILS() Author: Sickboy ------------------------------------------- */ -#define ISNILS(VARIABLE,DEFAULT_VALUE) if (isNil #VARIABLE) then { ##VARIABLE = ##DEFAULT_VALUE } +#define ISNILS(VARIABLE,DEFAULT_VALUE) if (isNil #VARIABLE) then { VARIABLE = DEFAULT_VALUE } #define ISNILS2(var1,var2,var3,var4) ISNILS(TRIPLES(var1,var2,var3),var4) #define ISNILS3(var1,var2,var3) ISNILS(DOUBLES(var1,var2),var3) #define ISNIL(var1,var2) ISNILS2(PREFIX,COMPONENT,var1,var2) #define ISNILMAIN(var1,var2) ISNILS3(PREFIX,var1,var2) -#define CREATELOGICS(var1,var2) ##var1##_##var2## = ([sideLogic] call CBA_fnc_getSharedGroup) createUnit ["LOGIC", [0, 0, 0], [], 0, "NONE"] -#define CREATELOGICLOCALS(var1,var2) ##var1##_##var2## = "LOGIC" createVehicleLocal [0, 0, 0] -#define CREATELOGICGLOBALS(var1,var2) ##var1##_##var2## = ([sideLogic] call CBA_fnc_getSharedGroup) createUnit ["LOGIC", [0, 0, 0], [], 0, "NONE"]; publicVariable QUOTE(DOUBLES(var1,var2)) -#define CREATELOGICGLOBALTESTS(var1,var2) ##var1##_##var2## = ([sideLogic] call CBA_fnc_getSharedGroup) createUnit [QUOTE(DOUBLES(ADDON,logic)), [0, 0, 0], [], 0, "NONE"] +#define CREATELOGICS(var1,var2) var1##_##var2 = ([sideLogic] call CBA_fnc_getSharedGroup) createUnit ["LOGIC", [0, 0, 0], [], 0, "NONE"] +#define CREATELOGICLOCALS(var1,var2) var1##_##var2 = "LOGIC" createVehicleLocal [0, 0, 0] +#define CREATELOGICGLOBALS(var1,var2) var1##_##var2 = ([sideLogic] call CBA_fnc_getSharedGroup) createUnit ["LOGIC", [0, 0, 0], [], 0, "NONE"]; publicVariable QUOTE(DOUBLES(var1,var2)) +#define CREATELOGICGLOBALTESTS(var1,var2) var1##_##var2 = ([sideLogic] call CBA_fnc_getSharedGroup) createUnit [QUOTE(DOUBLES(ADDON,logic)), [0, 0, 0], [], 0, "NONE"] -#define GETVARS(var1,var2,var3) (##var1##_##var2 getVariable #var3) +#define GETVARS(var1,var2,var3) (var1##_##var2 getVariable #var3) #define GETVARMAINS(var1,var2) GETVARS(var1,MAINLOGIC,var2) #ifndef PATHTO_SYS - #define PATHTO_SYS(var1,var2,var3) \MAINPREFIX\##var1\SUBPREFIX\##var2\##var3.sqf + #define PATHTO_SYS(var1,var2,var3) \MAINPREFIX\var1\SUBPREFIX\var2\var3.sqf #endif #ifndef PATHTOF_SYS - #define PATHTOF_SYS(var1,var2,var3) \MAINPREFIX\##var1\SUBPREFIX\##var2\##var3 + #define PATHTOF_SYS(var1,var2,var3) \MAINPREFIX\var1\SUBPREFIX\var2\var3 #endif #ifndef PATHTOF2_SYS - #define PATHTOF2_SYS(var1,var2,var3) MAINPREFIX\##var1\SUBPREFIX\##var2\##var3 + #define PATHTOF2_SYS(var1,var2,var3) MAINPREFIX\var1\SUBPREFIX\var2\var3 #endif #define PATHTO_R(var1) PATHTOF2_SYS(PREFIX,COMPONENT_C,var1) @@ -775,15 +775,15 @@ Macro: ISNILS() // This only works for binarized configs after recompiling the pbos // TODO: Reduce amount of calls / code.. -#define COMPILE_FILE2_CFG_SYS(var1) compile preprocessFileLineNumbers var1 +#define COMPILE_FILE2_CFG_SYS(var1) compile preProcessFileLineNumbers var1 #define COMPILE_FILE2_SYS(var1) COMPILE_FILE2_CFG_SYS(var1) #define COMPILE_FILE_SYS(var1,var2,var3) COMPILE_FILE2_SYS('PATHTO_SYS(var1,var2,var3)') #define COMPILE_FILE_CFG_SYS(var1,var2,var3) COMPILE_FILE2_CFG_SYS('PATHTO_SYS(var1,var2,var3)') -#define SETVARS(var1,var2) ##var1##_##var2 setVariable +#define SETVARS(var1,var2) var1##_##var2 setVariable #define SETVARMAINS(var1) SETVARS(var1,MAINLOGIC) -#define GVARMAINS(var1,var2) ##var1##_##var2## +#define GVARMAINS(var1,var2) var1##_##var2 #define CFGSETTINGSS(var1,var2) configFile >> "CfgSettings" >> #var1 >> #var2 //#define SETGVARS(var1,var2,var3) ##var1##_##var2##_##var3 = //#define SETGVARMAINS(var1,var2) ##var1##_##var2 = @@ -794,9 +794,9 @@ Macro: ISNILS() // #define PREP_SYS2(var1,var2,var3,var4) ##var1##_##var2##_fnc_##var4 = { ##var1##_##var2##_fnc_##var4 = COMPILE_FILE_SYS(var1,var3,DOUBLES(fnc,var4)); if (isNil "_this") then { call ##var1##_##var2##_fnc_##var4 } else { _this call ##var1##_##var2##_fnc_##var4 } } // Compile-Once, at Macro. As opposed to Compile-Once, on first use. -#define PREPMAIN_SYS(var1,var2,var3) ##var1##_fnc_##var3 = COMPILE_FILE_SYS(var1,var2,DOUBLES(fnc,var3)) -#define PREP_SYS(var1,var2,var3) ##var1##_##var2##_fnc_##var3 = COMPILE_FILE_SYS(var1,var2,DOUBLES(fnc,var3)) -#define PREP_SYS2(var1,var2,var3,var4) ##var1##_##var2##_fnc_##var4 = COMPILE_FILE_SYS(var1,var3,DOUBLES(fnc,var4)) +#define PREPMAIN_SYS(var1,var2,var3) var1##_fnc_##var3 = COMPILE_FILE_SYS(var1,var2,DOUBLES(fnc,var3)) +#define PREP_SYS(var1,var2,var3) var1##_##var2##_fnc_##var3 = COMPILE_FILE_SYS(var1,var2,DOUBLES(fnc,var3)) +#define PREP_SYS2(var1,var2,var3,var4) var1##_##var2##_fnc_##var4 = COMPILE_FILE_SYS(var1,var3,DOUBLES(fnc,var4)) #define LSTR(var1) TRIPLES(ADDON,STR,var1) @@ -888,41 +888,8 @@ Macro: GVARMAIN() #define GETVAR(var1) GETVARS(PREFIX,COMPONENT,var1) #define SETVAR SETVARS(PREFIX,COMPONENT) #define SETVARMAIN SETVARMAINS(PREFIX) -#define IFCOUNT(var1,var2,var3) if (count ##var1 > ##var2) then { ##var3 = ##var1 select ##var2 }; +#define IFCOUNT(var1,var2,var3) if (count var1 > var2) then { var3 = var1 select var2 }; -/* ------------------------------------------- -Macro: PREP() - -Description: - Defines a function. - - Full file path: - '\MAINPREFIX\PREFIX\SUBPREFIX\COMPONENT\fnc_.sqf' - - Resulting function name: - 'PREFIX_COMPONENT_' - - The PREP macro should be placed in a script run by a XEH preStart and XEH preInit event. - - The PREP macro allows for CBA function caching, which drastically speeds up load times. - Beware though that function caching is enabled by default and as such to disable it, you need to - #define DISABLE_COMPILE_CACHE above your #include "script_components.hpp" include! - - The function will be defined in ui and mission namespace. It can not be overwritten without - a mission restart. - -Parameters: - FUNCTION NAME - Name of the function, unquoted - -Examples: - (begin example) - PREP(banana); - call FUNC(banana); - (end) - -Author: - dixon13 - ------------------------------------------- */ //#define PREP(var1) PREP_SYS(PREFIX,COMPONENT_F,var1) #ifdef DISABLE_COMPILE_CACHE @@ -933,6 +900,13 @@ Macro: PREP() #define PREPMAIN(var1) ['PATHTO_SYS(PREFIX,COMPONENT_F,DOUBLES(fnc,var1))', 'TRIPLES(PREFIX,fnc,var1)'] call SLX_XEH_COMPILE_NEW #endif +#ifdef RECOMPILE + #undef RECOMPILE + #define RECOMPILE recompile = 1 +#else + #define RECOMPILE recompile = 0 +#endif + /* ------------------------------------------- Macro: PATHTO_FNC() @@ -942,7 +916,6 @@ Macro: PATHTO_FNC() Full file path in addons: '\MAINPREFIX\PREFIX\SUBPREFIX\COMPONENT\fnc_.sqf' Define 'RECOMPILE' to enable recompiling. - Define 'SKIP_FUNCTION_HEADER' to skip adding function header. Parameters: FUNCTION NAME - Name of the function, unquoted @@ -963,22 +936,8 @@ Macro: PATHTO_FNC() Author: dixon13, commy2 ------------------------------------------- */ -#ifdef RECOMPILE - #undef RECOMPILE - #define RECOMPILE recompile = 1 -#else - #define RECOMPILE recompile = 0 -#endif -// Set function header type: -1 - no header; 0 - default header; 1 - system header. -#ifdef SKIP_FUNCTION_HEADER - #define CFGFUNCTION_HEADER headerType = -1 -#else - #define CFGFUNCTION_HEADER headerType = 0 -#endif - #define PATHTO_FNC(func) class func {\ file = QPATHTOF(DOUBLES(fnc,func).sqf);\ - CFGFUNCTION_HEADER;\ RECOMPILE;\ } @@ -1127,7 +1086,6 @@ Macros: IS_x() /* ------------------------------------------- Macro: SCRIPT() Sets name of script (relies on PREFIX and COMPONENT values being #defined). - Define 'SKIP_SCRIPT_NAME' to skip adding scriptName. Parameters: NAME - Name of script [Indentifier] @@ -1140,11 +1098,8 @@ Macro: SCRIPT() Author: Spooner ------------------------------------------- */ -#ifndef SKIP_SCRIPT_NAME - #define SCRIPT(NAME) scriptName 'PREFIX\COMPONENT\NAME' -#else - #define SCRIPT(NAME) /* nope */ -#endif +#define SCRIPT(NAME) \ + scriptName 'PREFIX\COMPONENT\NAME' /* ------------------------------------------- Macros: EXPLODE_n()