diff --git a/addons/core/$PBOPREFIX$ b/addons/core/$PBOPREFIX$ deleted file mode 100644 index 3c54247..0000000 --- a/addons/core/$PBOPREFIX$ +++ /dev/null @@ -1 +0,0 @@ -z\hatchet\addons\core diff --git a/addons/core/CfgEventHandlers.hpp b/addons/core/CfgEventHandlers.hpp deleted file mode 100644 index 61f69fb..0000000 --- a/addons/core/CfgEventHandlers.hpp +++ /dev/null @@ -1,17 +0,0 @@ -class Extended_PreStart_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_preStart)); - }; -}; - -class Extended_PreInit_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_preInit)); - }; -}; - -class Extended_PostInit_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_postInit)); - }; -}; diff --git a/addons/core/CfgUI.hpp b/addons/core/CfgUI.hpp deleted file mode 100644 index 3ee97d4..0000000 --- a/addons/core/CfgUI.hpp +++ /dev/null @@ -1,31 +0,0 @@ -class RVAR(EngineOn) { - condition = QUOTE(!(isEngineOn (vehicle hatchet_player))); - label = CSTRING(EngineOn_Label); - radius = 0.3; - buttonDown = QUOTE(vehicle hatchet_player engineOn true); - action = "EngineOn"; -}; - -class RVAR(EngineOff) { - condition = QUOTE(isEngineOn (vehicle hatchet_player)); - label = CSTRING(EngineOff_Label); - radius = 0.3; - buttonDown = QUOTE(vehicle hatchet_player engineOn false); - action = "EngineOff"; -}; - -class RVAR(LightOn) { - condition = QUOTE(!(isLightOn (vehicle hatchet_player))); - label = CSTRING(LightsOn_Label); - radius = 0.3; - buttonDown = QUOTE(vehicle hatchet_player setPilotLight true); - action = "LightOn"; -}; - -class RVAR(LightOff) { - condition = QUOTE(isLightOn (vehicle hatchet_player)); - label = CSTRING(LightsOff_Label); - radius = 0.3; - buttonDown = QUOTE(vehicle hatchet_player setPilotLight false); - action = "LightOff"; -}; diff --git a/addons/core/XEH_PREP.hpp b/addons/core/XEH_PREP.hpp deleted file mode 100644 index 9dd3c75..0000000 --- a/addons/core/XEH_PREP.hpp +++ /dev/null @@ -1,10 +0,0 @@ -PREP(getVehicleConfig); -PREP(handleVehicleChanged); -PREP(hasModule); -PREP(load); -PREP(loadAll); -PREP(perFrame); -PREP(perSecond); -PREP(shutDownAll); -PREP(start); -PREP(startLoops); diff --git a/addons/core/XEH_postInit.sqf b/addons/core/XEH_postInit.sqf deleted file mode 100644 index 57f1635..0000000 --- a/addons/core/XEH_postInit.sqf +++ /dev/null @@ -1,10 +0,0 @@ -#include "script_component.hpp" - -["unit", { - hatchet_player = (_this select 0); -}, true] call CBA_fnc_addPlayerEventHandler; - -["vehicle", FUNC(handleVehicleChanged), true] call CBA_fnc_addPlayerEventHandler; -["turret", { - [hatchet_player, vehicle hatchet_player] call FUNC(handleVehicleChanged) -}, true] call CBA_fnc_addPlayerEventHandler; diff --git a/addons/core/XEH_preInit.sqf b/addons/core/XEH_preInit.sqf deleted file mode 100644 index bbf60b5..0000000 --- a/addons/core/XEH_preInit.sqf +++ /dev/null @@ -1,7 +0,0 @@ -#include "script_component.hpp" -ADDON = false; -#include "XEH_PREP.hpp" - -GVAR(paused) = false; - -ADDON = true; diff --git a/addons/core/XEH_preStart.sqf b/addons/core/XEH_preStart.sqf deleted file mode 100644 index a51262a..0000000 --- a/addons/core/XEH_preStart.sqf +++ /dev/null @@ -1,2 +0,0 @@ -#include "script_component.hpp" -#include "XEH_PREP.hpp" diff --git a/addons/core/config.cpp b/addons/core/config.cpp deleted file mode 100644 index 43549c2..0000000 --- a/addons/core/config.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "script_component.hpp" - -class CfgPatches { - class ADDON { - name = COMPONENT_NAME; - units[] = {}; - weapons[] = {}; - requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"hatchet_main"}; - author = "Project Hatchet"; - VERSION_CONFIG; - }; -}; - -#include "CfgEventHandlers.hpp" -#include "CfgUI.hpp" diff --git a/addons/core/functions/fnc_getVehicleConfig.sqf b/addons/core/functions/fnc_getVehicleConfig.sqf deleted file mode 100644 index 18813df..0000000 --- a/addons/core/functions/fnc_getVehicleConfig.sqf +++ /dev/null @@ -1,60 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_core_fnc_getVehicleConfig - * - * Function will look through the cfgVehicles for the vehicle - * and look for relevant hatchet config subclasses, when it finds them - * the most relevant one will be assigned to the vehicle's hatchet_core_config variable - * - * Params: (object) vehicle - * Returns: (bool) success - * - * Author: Yax - */ - -params ["_vehicle"]; - -private _configFound = false; -private _configSources = []; - -_vehicle setVariable [QRVAR(config), nil]; -private _turretIndex = [hatchet_player] call EFUNC(util,getTurretIndex); - -if (hatchet_player == driver _vehicle) then { - _configSources pushBack QRVAR(driver); -}; - -private _copilotTurretIndex = [_vehicle] call EFUNC(util,getTurretCopilot); -if ((count _copilotTurretIndex) > 0 && (count _turretIndex) > 0 && {(_turretIndex # 0) == (_copilotTurretIndex # 0)}) then { - _configSources pushBack QRVAR(copilot); -}; - -if (count _turretIndex > 0) then { - _configSources pushBack format [QRVAR(turret_%1), (_turretIndex # 0)]; -}; - -if (hatchet_player == gunner _vehicle) then { - _configSources pushBack QRVAR(gunner); -}; - -if (_vehicle getCargoIndex hatchet_player > -1) then { - _configSources pushBack QRVAR(cargo); -}; - -_configSources pushBack QUOTE(PREFIX); - -private _rootVehicleConfig = configOf _vehicle; -{ - private _config = (_rootVehicleConfig >> _x); - if (isClass _config) exitWith { - _configFound = true; - //if there was already a config present, a seat change happened, so do a shutdown of old systems - //if (!isNil {_vehicle getVariable QRVAR(config)}) then { - // [_vehicle] call FUNC(shutDown); - //}; - _vehicle setVariable [QRVAR(config), _config]; - _vehicle setVariable [QGVAR(projectPrefix), getText (_config >> "projectPrefix")]; - }; -} forEach _configSources; - -_configFound diff --git a/addons/core/functions/fnc_handleVehicleChanged.sqf b/addons/core/functions/fnc_handleVehicleChanged.sqf deleted file mode 100644 index 6501830..0000000 --- a/addons/core/functions/fnc_handleVehicleChanged.sqf +++ /dev/null @@ -1,40 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_core_fnc_handleVehicleChanged - * - * Function is triggered by cba vehicleChanged eventhandler - * when called, it will check if the vehicle has any Hatchet config, - * and if relevant, set up the functions for it - * - * Params: Array[(object) caller, (object) newVehicle] - * Returns: nil - * - * Author: Yax - */ - -params ["_caller", "_newVehicle"]; - -if (isNil "_caller" || isNil "_newVehicle") exitWith {}; -if !(_caller isEqualTo hatchet_player) exitWith {}; - -call EFUNC(interaction,removeActions); - -if !(isNil QGVAR(vehicle)) then { - [GVAR(vehicle)] call FUNC(shutDownAll); -}; - -private _isHatchetSetup = [_newVehicle] call FUNC(getVehicleConfig); - -//end the function if the vehicle isn't compatible -if !(_isHatchetSetup) exitWith { - _newVehicle setVariable [QGVAR(modules), nil]; - if !((vehicle hatchet_player) isEqualTo hatchet_player) then { - call EFUNC(interaction,addActions); - }; -}; - -[_newVehicle] call FUNC(loadAll); -[_newVehicle] call FUNC(startLoops); -GVAR(vehicle) = _newVehicle; - -call EFUNC(interaction,addActions); diff --git a/addons/core/functions/fnc_hasModule.sqf b/addons/core/functions/fnc_hasModule.sqf deleted file mode 100644 index b5a26b1..0000000 --- a/addons/core/functions/fnc_hasModule.sqf +++ /dev/null @@ -1,25 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_core_fnc_hasModule - * - * Checks if a module exists - * - * Params: array[array[(object) vehicle, (string) module name, (optional, string) classname] - * Returns: (boolean) has module - * - * Author: Yax - */ - -params ["_vehicle", "_moduleName", ["_className", nil]]; - -private _vehicleModuleArray = _vehicle getVariable [QGVAR(modules), []]; -private _isClass = if (!isNil "_className") then [{_vehicle isKindOf _className}, {true}]; -private _hasModule = false; -{ // forEach _vehicleModuleArray - _name = _x # 0; - if (_moduleName == _name) exitWith { - _hasModule = true; - }; -} forEach _vehicleModuleArray; - -(_hasModule && _isClass) diff --git a/addons/core/functions/fnc_load.sqf b/addons/core/functions/fnc_load.sqf deleted file mode 100644 index 34f169c..0000000 --- a/addons/core/functions/fnc_load.sqf +++ /dev/null @@ -1,43 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_core_fnc_load - * - * Loads a single module with default paths - * - * Params: array[array[(object) vehicle, (string) module name] - * Returns: nothing - * - * Author: Yax - */ - -params ["_vehicle", "_moduleName"]; - -private _vehicleModuleArray = _vehicle getVariable [QGVAR(modules), []]; -private _startUp = true; - -#define HANDLEDEFAULT(VAR,MODULENAME,PATH) private VAR = format[PATH, MODULENAME]; -HANDLEDEFAULT(_setup,_moduleName,"hatchet_%1_fnc_setup") -HANDLEDEFAULT(_perFrame,_moduleName,"hatchet_%1_fnc_perFrame") -HANDLEDEFAULT(_perSecond,_moduleName,"hatchet_%1_fnc_perSecond") -HANDLEDEFAULT(_shutDown,_moduleName,"hatchet_%1_fnc_shutDown") - -if (_startUp && {_setup != ""}) then { - private _func = missionNameSpace getVariable _setup; - if (!isNil "_func" && {typeName _func == "CODE"}) then { - _result = [_vehicle] call _func; - if (typeName _result == "BOOL" && {!_result}) then { - _startUp = false; - }; - }; -}; - -_vehicleModuleArray pushBack [ - _moduleName, - _startUp, - _setup, - _perFrame, - _perSecond, - _shutDown -]; - -_vehicle setVariable [QGVAR(modules), _vehicleModuleArray]; diff --git a/addons/core/functions/fnc_loadAll.sqf b/addons/core/functions/fnc_loadAll.sqf deleted file mode 100644 index a298342..0000000 --- a/addons/core/functions/fnc_loadAll.sqf +++ /dev/null @@ -1,57 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_core_fnc_loadAll - * - * Reads out relevant vehicle modules from config and stores them in vehicle variables - * - * Params: array[array[(object) vehicle] - * Returns: nothing - * - * Author: Yax - */ - -params ["_vehicle"]; - -private _vehicleModuleArray = []; - -private _vehicleConfig = _vehicle getVariable QRVAR(config); -private _modules = "true" configClasses (_vehicleConfig >> "modules"); - -private _projectPrefix = _vehicle getVariable [QGVAR(projectPrefix), ""]; -#define HANDLEDEFAULT(VAR,MODULENAME,PATH) if (VAR == "" && {!isNil{missionNameSpace getVariable format[PATH, MODULENAME]}}) then {VAR = format[PATH, MODULENAME];}; - -{ //forEach _modules - private _moduleConfig = _x; - private _moduleName = configName _x; - private _startUp = (getNumber (_moduleConfig >> "startOnEnter") == 1); - - private _setup = getText (_moduleConfig >> "setup"); - HANDLEDEFAULT(_setup,_moduleName,(_projectPrefix+"_%1_fnc_setup")) - private _shutDown = getText (_moduleConfig >> "shutDown"); - HANDLEDEFAULT(_shutDown,_moduleName,(_projectPrefix+"_%1_fnc_shutDown")) - private _perFrame = getText (_moduleConfig >> "perFrame"); - HANDLEDEFAULT(_perFrame,_moduleName,(_projectPrefix+"_%1_fnc_perFrame")) - private _perSecond = getText (_moduleConfig >> "perSecond"); - HANDLEDEFAULT(_perSecond,_moduleName,(_projectPrefix+"_%1_fnc_perSecond")) - - if (_startUp && _setup != "") then { - private _func = (missionNameSpace getVariable _setup); - if (!isNil "_func" && typeName _func == "CODE") then { - private _result = ([_vehicle] call _func); - if (typeName _result == "BOOL" && {!_result}) then { - _startUp = false; - }; - }; - }; - - _vehicleModuleArray pushBack [ - _moduleName, - _startUp, - _setup, - _perFrame, - _perSecond, - _shutDown - ]; -} forEach _modules; - -_vehicle setVariable [QGVAR(modules), _vehicleModuleArray]; diff --git a/addons/core/functions/fnc_perFrame.sqf b/addons/core/functions/fnc_perFrame.sqf deleted file mode 100644 index 55f6c80..0000000 --- a/addons/core/functions/fnc_perFrame.sqf +++ /dev/null @@ -1,49 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_core_fnc_perFrame - * - * Function will run relevante modules' per frame functions - * - * Params: array[array[(object) vehicle, (scalar) last frame time], (scalar)pfhId] - * Returns: nothing - * - * Author: Yax - */ - -params ["_args", "_pfhId"]; -_args params ["_vehicle", "_lastFrameTime"]; - -//shutdown conditions -if ( - !((vehicle hatchet_player) isEqualTo _vehicle) || - !(alive hatchet_player) || - !(alive _vehicle) -) exitWith { - [GVAR(vehicle)] call FUNC(shutDownAll); - [_pfhId] call CBA_fnc_removePerFrameHandler; - GVAR(perFrameHandler) = nil; - if (!isNil {GVAR(drawHandler)}) then { - removeMissionEventHandler ["Draw3d", GVAR(drawHandler)]; - GVAR(drawHandler) = nil; - }; -}; - -if (cba_missionTime == _lastFrameTime) exitWith {GVAR(paused) = true;}; -_args set [1, cba_missionTime]; -if (GVAR(paused)) then { - // unpause - [QGVAR(unPause), []] call CBA_fnc_localEvent; -}; -GVAR(paused) = false; - -//frame time will be passed on to modules -private _frameTime = (cba_missionTime - _lastFrameTime); -//skip a frame when unpausing so time between frames stays normal -if (_frameTime > 1) exitWith {}; - -{ //forEach vehicle hatchet_core_modules - if (_x # 1) then { - private _func = missionNameSpace getVariable (_x # 3); - if (!isNil {_func}) then {[_vehicle, _frameTime] call _func;}; - }; -} forEach (_vehicle getVariable [QGVAR(modules), []]); diff --git a/addons/core/functions/fnc_perSecond.sqf b/addons/core/functions/fnc_perSecond.sqf deleted file mode 100644 index 1c82595..0000000 --- a/addons/core/functions/fnc_perSecond.sqf +++ /dev/null @@ -1,40 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_core_fnc_perSecond - * - * Function will run relevante modules' per second functions - * - * Params: array[array[(object) vehicle], (scalar)pfhId] - * Returns: nothing - * - * Author: Yax - */ - -params ["_args", "_pfhId"]; -_args params ["_vehicle"]; - -// shutdown conditions -if ( - !((vehicle hatchet_player) isEqualTo _vehicle) || - !(alive hatchet_player) || - !(alive _vehicle) -) exitWith { - [_pfhId] call CBA_fnc_removePerFrameHandler; - GVAR(perSecondHandler) = nil; -}; - -if (GVAR(paused)) exitWith {}; - -private _modules = (_vehicle getVariable [QGVAR(modules), []]); -[_vehicle, _modules] spawn { - params ["_vehicle", "_modules"]; - private _moduleDelay = 1 / ((count _modules) + 1); - private ["_func"]; - { //forEach vehicle hatchet_core_modules - sleep _moduleDelay; - if (_x # 1) then { - _func = missionNameSpace getVariable (_x # 4); - if (!isNil {_func}) then {[_vehicle] call _func;}; - }; - } forEach _modules; -}; diff --git a/addons/core/functions/fnc_shutDownAll.sqf b/addons/core/functions/fnc_shutDownAll.sqf deleted file mode 100644 index 9cc038b..0000000 --- a/addons/core/functions/fnc_shutDownAll.sqf +++ /dev/null @@ -1,37 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_core_fnc_shutDownAll - * - * Reads out relevant vehicle modules from config and stores them in vehicle variables - * - * Params: array[array[(object) vehicle] - * Returns: nothing - * - * Author: Yax - */ - -params ["_vehicle"]; - -if (isNil "_vehicle") then {_vehicle = GVAR(vehicle)}; - -[GVAR(perFrameHandler)] call CBA_fnc_removePerFrameHandler; -[GVAR(perSecondHandler)] call CBA_fnc_removePerFrameHandler; - -if !(isNil QGVAR(drawHandler)) then { - removeMissionEventHandler ["Draw3d", GVAR(drawHandler)]; -}; - -GVAR(perFrameHandler) = nil; -GVAR(perSecondHandler) = nil; -GVAR(drawHandler) = nil; - -private ["_func"]; -{ //forEach vehicle hatchet_core_modules - if (_x # 1) then { - _func = missionNameSpace getVariable (_x # 5); - if (!isNil {_func}) then {[_vehicle] call _func;}; - }; - _x set [1, false]; -} forEach (_vehicle getVariable [QGVAR(modules), []]); - -GVAR(vehicle) = nil; diff --git a/addons/core/functions/fnc_start.sqf b/addons/core/functions/fnc_start.sqf deleted file mode 100644 index 0e2f750..0000000 --- a/addons/core/functions/fnc_start.sqf +++ /dev/null @@ -1,33 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_core_fnc_start - * - * Starts a loaded module - * - * Params: array[array[(object) vehicle, (string) module name] - * Returns: nothing - * - * Author: Yax - */ - -params ["_vehicle", "_moduleName", ["_parameters", nil]]; - -private _vehicleModuleArray = _vehicle getVariable [QGVAR(modules), []]; - -private ["_moduleName", "_running", "_setup"]; -{ // forEach _vehicleModuleArray - _module = _x; - _name = _module # 0; - if (_moduleName == _name) exitWith { - _running = _module # 1; - _setup = _module # 2; - if (!_running) then { - private _func = (missionNameSpace getVariable _setup); - if (!isNil "_func" && typeName _func == "CODE") then { - _running = ([_vehicle, _parameters] call _func); - }; - }; - _module set [1, _running]; - _vehicleModuleArray set [_forEachIndex, _module]; - }; -} forEach _vehicleModuleArray; diff --git a/addons/core/functions/fnc_startLoops.sqf b/addons/core/functions/fnc_startLoops.sqf deleted file mode 100644 index 6543114..0000000 --- a/addons/core/functions/fnc_startLoops.sqf +++ /dev/null @@ -1,30 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_core_fnc_startLoops - * - * starts the per per frameHandlers and the draw3D eventHandler - * - * Params: ARRAY[(object) vehicle] - * Returns: nil - * - * Author: Yax - */ - -params ["_vehicle"]; - -private _vehicleConfig = _vehicle getVariable QRVAR(config); - -// set up draw3D handler -if (isClass (_vehicleConfig >> "interaction")) then { - [_vehicle, "interaction"] call FUNC(load); -}; - -// set up perFrameHandler -if (isNil QGVAR(perFrameHandler)) then { - GVAR(perFrameHandler) = [FUNC(perFrame), 0, [_vehicle, cba_missionTime]] call CBA_fnc_addPerFrameHandler; -}; - -// set up perSecondHandler for once per second -if (isNil QGVAR(perSecondHandler)) then { - GVAR(perSecondHandler) = [FUNC(perSecond), 1, [_vehicle]] call CBA_fnc_addPerFrameHandler; -}; diff --git a/addons/core/functions/script_component.hpp b/addons/core/functions/script_component.hpp deleted file mode 100644 index cdc3ded..0000000 --- a/addons/core/functions/script_component.hpp +++ /dev/null @@ -1 +0,0 @@ -#include "../script_component.hpp" diff --git a/addons/core/script_component.hpp b/addons/core/script_component.hpp deleted file mode 100644 index 1fc9ed9..0000000 --- a/addons/core/script_component.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#define COMPONENT core -#define COMPONENT_BEAUTIFIED Core -#include "\z\hatchet\addons\main\script_mod.hpp" - -#ifdef DEBUG_ENABLED_CORE - #define DEBUG_MODE_FULL -#endif - -#ifdef DEBUG_SETTINGS_CORE - #define DEBUG_SETTINGS DEBUG_SETTINGS_CORE -#endif - -#include "\z\hatchet\addons\main\script_macros.hpp" diff --git a/addons/core/stringtable.xml b/addons/core/stringtable.xml deleted file mode 100644 index 7873447..0000000 --- a/addons/core/stringtable.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - Engine On - Motor An - - - Engine Off - Motor Aus - - - Lights On - Scheinwerfer Aus - - - Lights Off - Scheinwerfer Aus - - - diff --git a/addons/interaction/$PBOPREFIX$ b/addons/interaction/$PBOPREFIX$ deleted file mode 100644 index 2e76607..0000000 --- a/addons/interaction/$PBOPREFIX$ +++ /dev/null @@ -1 +0,0 @@ -z\hatchet\addons\interaction diff --git a/addons/interaction/CfgActions.hpp b/addons/interaction/CfgActions.hpp deleted file mode 100644 index 6b23d6c..0000000 --- a/addons/interaction/CfgActions.hpp +++ /dev/null @@ -1,15 +0,0 @@ -class CfgActions { - class None; - class EngineOn: None { - show = 0; - }; - class EngineOff: None { - show = 0; - }; - class LightOn: None { - show = 0; - }; - class LightOff: None { - show = 0; - }; -}; diff --git a/addons/interaction/CfgEventHandlers.hpp b/addons/interaction/CfgEventHandlers.hpp deleted file mode 100644 index 61f69fb..0000000 --- a/addons/interaction/CfgEventHandlers.hpp +++ /dev/null @@ -1,17 +0,0 @@ -class Extended_PreStart_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_preStart)); - }; -}; - -class Extended_PreInit_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_preInit)); - }; -}; - -class Extended_PostInit_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_postInit)); - }; -}; diff --git a/addons/interaction/CfgSounds.hpp b/addons/interaction/CfgSounds.hpp deleted file mode 100644 index 1650b05..0000000 --- a/addons/interaction/CfgSounds.hpp +++ /dev/null @@ -1,12 +0,0 @@ -#define SOUND(NAME,PATH) class RVAR(NAME) { name = QRVAR(NAME); sound[] = {QUOTE(\z\PREFIX\addons\COMPONENT\sounds\PATH.wss), 1, 1, 1}; titles[] = {}; } - -class CfgSounds { - SOUND(Switch_Sound,switch); - SOUND(Switch_Sound_1,switch1); - SOUND(Switch_Sound_2,switch2); - SOUND(Switch_Sound_3,switch3); - SOUND(Switch_Sound_4,switch4); - SOUND(Switch_Sound_5,switch5); - SOUND(HeavySwitch_Sound,heavySwitch); - SOUND(dial_sound,dial); -}; diff --git a/addons/interaction/XEH_PREP.hpp b/addons/interaction/XEH_PREP.hpp deleted file mode 100644 index 7a9026f..0000000 --- a/addons/interaction/XEH_PREP.hpp +++ /dev/null @@ -1,29 +0,0 @@ -// Keys -PREP(buttonDown); -PREP(buttonUp); -PREP(drag); -PREP(dragStart); -PREP(dragStop); -PREP(knobAnimate); -PREP(leverAnimate); - -// Pointing -PREP(pointCalculate); -PREP(pointDraw); -PREP(pointNetReceive); -PREP(pointNetSend); -PREP(pointStart); - -PREP(addAction); -PREP(addActions); -PREP(checkInteraction); -PREP(draw3D); -PREP(drawLabel); -PREP(findButton); -PREP(loadAll); -PREP(loadItem); -PREP(perFrame); -PREP(removeActions); -PREP(scriptedInteract); -PREP(setup); -PREP(shutDown); diff --git a/addons/interaction/XEH_postInit.sqf b/addons/interaction/XEH_postInit.sqf deleted file mode 100644 index ad65520..0000000 --- a/addons/interaction/XEH_postInit.sqf +++ /dev/null @@ -1,71 +0,0 @@ -#include "script_component.hpp" - -[ - COMPONENT_NAME, - QGVAR(ButtonPress), - "Vehicle Interaction", - {[vehicle hatchet_player, GVAR(currentButton)] call FUNC(buttonDown)}, - {[vehicle hatchet_player, GVAR(currentButton)] call FUNC(buttonUp)}, - [33, [false, false, false]], - false -] call CBA_fnc_addKeybind; - -[ - QGVAR(removeActions), - "CHECKBOX", - "Remove Vanilla Actions", - [COMPONENT_NAME, "Actions"], - [true], - nil, - {} -] call CBA_fnc_addSetting; - -[ - QGVAR(updateEvery), - "SLIDER", - "Label update rates (frames between)", - [COMPONENT_NAME, "Performance"], - [0,10,5,0], - nil, - {} -] call CBA_fnc_addSetting; - -[ - QGVAR(pointingEnabled), - "CHECKBOX", - "Enable pointing system(uses remoteCall)", - [COMPONENT_NAME, "Performance"], - [true], - nil, - {} -] call CBA_fnc_addSetting; - -[ - QGVAR(showLabel), - "CHECKBOX", - "Show Label", - [COMPONENT_NAME, "Labels"], - [true], - nil, - {} -] call CBA_fnc_addSetting; - -[ - QGVAR(showKeybind), - "CHECKBOX", - "Show Keybind", - [COMPONENT_NAME, "Labels"], - [true], - nil, - {} -] call CBA_fnc_addSetting; - - -["vtx_uh60m_enabled_jvmf","CHECKBOX","(DEBUG) Enable JVMF","UH-60M",[true],nil,{}] call CBA_Settings_fnc_init; -["vtx_uh60m_enabled_fms","CHECKBOX","(DEBUG) Enable FMS","UH-60M",[true],nil,{}] call CBA_Settings_fnc_init; -["vtx_uh60m_enabled_mfd","CHECKBOX","(DEBUG) Enable MFD","UH-60M",[true],nil,{}] call CBA_Settings_fnc_init; -["vtx_uh60m_enabled_fd","CHECKBOX","(DEBUG) Enable FD","UH-60M",[true],nil,{}] call CBA_Settings_fnc_init; -["vtx_uh60m_enabled_cas","CHECKBOX","(DEBUG) Enable CAS","UH-60M",[true],nil,{}] call CBA_Settings_fnc_init; -["vtx_uh60m_enabled_aar","CHECKBOX","(DEBUG) Enable AAR","UH-60M",[true],nil,{}] call CBA_Settings_fnc_init; -["vtx_uh60m_enabled_flir","CHECKBOX","(DEBUG) Enable FLIR","UH-60M",[true],nil,{}] call CBA_Settings_fnc_init; -["vtx_uh60m_enabled_engine","CHECKBOX","(DEBUG) Enable ENGINE","UH-60M",[true],nil,{}] call CBA_Settings_fnc_init; diff --git a/addons/interaction/XEH_preInit.sqf b/addons/interaction/XEH_preInit.sqf deleted file mode 100644 index 72c09fa..0000000 --- a/addons/interaction/XEH_preInit.sqf +++ /dev/null @@ -1,16 +0,0 @@ -#include "script_component.hpp" -ADDON = false; -#include "XEH_PREP.hpp" - -GVAR(updateIndex) = 0; -GVAR(currentButton) = nil; -GVAR(buttonHoldCode) = nil; -GVAR(buttonRadius) = 1; -GVAR(buttonHolding) = false; -GVAR(knobHolding) = nil; -GVAR(dragging) = false; - -GVAR(point_icons) = []; -GVAR(point_lifetime) = 2; - -ADDON = true; diff --git a/addons/interaction/XEH_preStart.sqf b/addons/interaction/XEH_preStart.sqf deleted file mode 100644 index a51262a..0000000 --- a/addons/interaction/XEH_preStart.sqf +++ /dev/null @@ -1,2 +0,0 @@ -#include "script_component.hpp" -#include "XEH_PREP.hpp" diff --git a/addons/interaction/config.cpp b/addons/interaction/config.cpp deleted file mode 100644 index b3dad46..0000000 --- a/addons/interaction/config.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "script_component.hpp" - -class CfgPatches { - class ADDON { - name = COMPONENT_NAME; - units[] = {}; - weapons[] = {}; - requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"hatchet_main"}; - author = "Project Hatchet"; - VERSION_CONFIG; - }; -}; - -#include "CfgActions.hpp" -#include "CfgEventHandlers.hpp" -#include "CfgSounds.hpp" diff --git a/addons/interaction/functions/fnc_addAction.sqf b/addons/interaction/functions/fnc_addAction.sqf deleted file mode 100644 index fe12d0c..0000000 --- a/addons/interaction/functions/fnc_addAction.sqf +++ /dev/null @@ -1,19 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_interaction_fnc_addAction - */ - -params ["_label", "_code", "_condition", "_action"]; - -private _actionConfig = (configFile >> "CfgActions" >> _action); -private _actionId = hatchet_player addAction [ - _label, - _code, - nil, - getNumber (_actionConfig >> "priority"), - false, - true, - getText (_actionConfig >> "shortcut"), - _condition -]; -GVAR(actionIds) pushBack _actionId; diff --git a/addons/interaction/functions/fnc_addActions.sqf b/addons/interaction/functions/fnc_addActions.sqf deleted file mode 100644 index 1a90e0a..0000000 --- a/addons/interaction/functions/fnc_addActions.sqf +++ /dev/null @@ -1,16 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_interaction_fnc_addActions - */ - -private _veh = vehicle hatchet_player; -if !((driver _veh) isEqualto hatchet_player || {(gunner _veh isEqualTo hatchet_player) && isCopilotEnabled _veh}) exitWith {}; - -// Engine -{ - if !(_x in GVAR(actionIgnore)) then { - private _config = (configFile >> (format [QRVAR(%1), _x])); - [getText (_config >> "label"), getText (_config >> "buttonDown"), getText (_config >> "condition"), _x] call FUNC(addAction); - }; -} forEach ["EngineOn", "EngineOff", "LightOn", "LightOff"]; - diff --git a/addons/interaction/functions/fnc_buttonDown.sqf b/addons/interaction/functions/fnc_buttonDown.sqf deleted file mode 100644 index da25ca9..0000000 --- a/addons/interaction/functions/fnc_buttonDown.sqf +++ /dev/null @@ -1,33 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_interaction_fnc_buttonDown - * - * interaction button press down functionality - */ - -params ["_vehicle", "_button", ["_forced", false]]; - -if (isNil {_vehicle getVariable QGVAR(points)}) exitWith {false}; -if (isNil QGVAR(currentButton) && {!_forced}) exitWith {}; - -_button PARAMS; -diag_log format ["%2: button down %1", _name, time]; - -if !(_vehicle call compile _interactCondition) exitWith {}; - -_buttonConfig BTNPARAMS; - -if !(_clickSound isEqualTo "") then { - playSound _clickSound; -}; - -[_vehicle] call _buttonDown; -[_vehicle, _position, 1, name hatchet_player] call FUNC(pointNetSend); - -if !(isNil "_buttonHold") then { - GVAR(buttonHoldCode) = _buttonHold; -}; -GVAR(buttonHolding) = true; -GVAR(dragging_buttonDownTime) = time; - -true diff --git a/addons/interaction/functions/fnc_buttonUp.sqf b/addons/interaction/functions/fnc_buttonUp.sqf deleted file mode 100644 index e7d0457..0000000 --- a/addons/interaction/functions/fnc_buttonUp.sqf +++ /dev/null @@ -1,29 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_interaction_fnc_buttonUp - * - * interaction button release functionality - */ - -GVAR(buttonHolding) = false; -params ["_vehicle", "_button"]; -if (isNil{_vehicle getVariable QGVAR(points)}) exitWith {false}; - -_button PARAMS; -diag_log format ["%2: button up %1", _name, time]; - -if !(_vehicle call compile _interactCondition) exitWith {}; - -_buttonConfig BTNPARAMS; - -[_vehicle] call _buttonUp; -GVAR(buttonHoldCode) = nil; -if (!isNil "_knobClick") then { - private _clickTime = time - GVAR(dragging_buttonDownTime); - if (_clickTime < 0.25) then { - systemChat format ["CLICK TIME %1", _clickTime]; - [_vehicle] call _knobClick; - }; -}; - -true diff --git a/addons/interaction/functions/fnc_checkInteraction.sqf b/addons/interaction/functions/fnc_checkInteraction.sqf deleted file mode 100644 index 8707a19..0000000 --- a/addons/interaction/functions/fnc_checkInteraction.sqf +++ /dev/null @@ -1,55 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_interaction_fnc_checkInteraction - * - * checks if a sub-item is valid for interaction - * - * params: (array)[ - * (string) name - * (string) condition - * (array) sub-items - * OPTIONAL: (string) position type - * OPTIONAL: (string) position - * OPTIONAL: (string) label - * OPTIONAL: (scalar) radius - * OPTIONAL: (string) buttonDown code - * OPTIONAL: (string) buttonUp code - * OPTIONAL: (string) buttonHold - * OPTIONAL: (string) buttonMove - * ] - * - * returns: on success array, on failure nil - */ - -PARAMS; - -scopeName "main"; - -// cut it off if the condition is false -if (_condition != "" && {!(_vehicle call (compile _condition))}) exitWith {nil}; - -if !(isNil "_positionType") then { - // get the selection position coordinates - if (_positionType == "anim") then { - _position = _vehicle selectionPosition _position; - }; - private _positionWorld = _vehicle modelToWorldVisual _position; - private _screenPos = worldToScreen _positionWorld; - // make sure the position is on the screen - if (count _screenPos == 2) then { - private _dis = (_screenPos distance GVAR(cursorPos)); - if (_dis < (_radius * GVAR(buttonRadius))) then { - _dis breakOut "main"; - }; - }; -}; - -private ["_result"]; -{ // forEach _subItems - _result = [_x] call FUNC(findButton); - if !(isNil "_result") then { - _result breakOut "main"; - }; -} forEach _subItems; - -nil diff --git a/addons/interaction/functions/fnc_drag.sqf b/addons/interaction/functions/fnc_drag.sqf deleted file mode 100644 index dee00ea..0000000 --- a/addons/interaction/functions/fnc_drag.sqf +++ /dev/null @@ -1,33 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_interaction_fnc_drag - * - * interaction button knob drag - */ - -params ["_vehicle"]; - -GVAR(currentButton) PARAMS; -_knobConfig params KNOBPARAMS; -diag_log format ["%2: dragging %1", _name, time]; - -if (_positionType isEqualTo "anim") then { - _position = _vehicle selectionPosition _position; -}; -private _positionWorld = _vehicle modelToWorldVisual _position; -private _screenPos = worldToScreen _positionWorld; -// make sure the position is on the screen -if (count _screenPos == 2) then { - private _verticalDistance = 0.5 - (_screenPos # 1); - //systemchat str (_verticalDistance / _dragRange) * _animRange; - //systemChat str [abs _verticalDistance, abs GVAR(dragging_lastDragDistance), abs (abs GVAR(dragging_lastDragDistance) - abs _verticalDistance)]; - if (abs (abs GVAR(dragging_lastDragDistance) - abs _verticalDistance) > 0.02) then { - systemChat str _verticalDistance; - private _animRange = (_animLimits # 0) - (_animLimits # 1); - GVAR(dragging_lastDragDistance) = _verticalDistance; - private _dragEndPoint = GVAR(dragging_startAnimPhase) + ((_verticalDistance / _dragRange) * _animRange); - _dragEndPoint = _dragEndPoint min (_animLimits # 1) max (_animLimits # 0); - _vehicle animateSource [_animation, _dragEndPoint, 10]; - [_vehicle, _animation] call _dragging; - }; -}; diff --git a/addons/interaction/functions/fnc_dragStart.sqf b/addons/interaction/functions/fnc_dragStart.sqf deleted file mode 100644 index 7bfc083..0000000 --- a/addons/interaction/functions/fnc_dragStart.sqf +++ /dev/null @@ -1,21 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_interaction_fnc_dragStart - * - * interaction button knob drag - */ - -params ["_vehicle"]; - -GVAR(currentButton) PARAMS; -_knobConfig params KNOBPARAMS; -diag_log format ["%2: drag start %1", _name, time]; - -if (isNil{_vehicle getVariable QGVAR(points)}) exitWith {false}; -if (!isNil QGVAR(knobHolding) && { GVAR(knobHolding) # 0 != _animation }) exitWith {false}; - -GVAR(knobHolding) = GVAR(currentButton); -GVAR(dragging) = true; -GVAR(dragging_startAnimPhase) = _vehicle animationPhase _animation; -GVAR(dragging_lastDragDistance) = 0; -[_vehicle, GVAR(dragging_startAnimPhase)] call _dragStart; diff --git a/addons/interaction/functions/fnc_dragStop.sqf b/addons/interaction/functions/fnc_dragStop.sqf deleted file mode 100644 index a321b8a..0000000 --- a/addons/interaction/functions/fnc_dragStop.sqf +++ /dev/null @@ -1,14 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_interaction_fnc_dragStop - */ - -params ["_vehicle"]; - -GVAR(currentButton) PARAMS; -_knobConfig params KNOBPARAMS; -diag_log format ["%2: drag stop %1", _name, time]; - -GVAR(dragging) = false; -GVAR(knobHolding) = nil; -[_vehicle, _vehicle animationPhase _animation] call _dragStop; diff --git a/addons/interaction/functions/fnc_draw3D.sqf b/addons/interaction/functions/fnc_draw3D.sqf deleted file mode 100644 index 472d1b6..0000000 --- a/addons/interaction/functions/fnc_draw3D.sqf +++ /dev/null @@ -1,47 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_interaction_fnc_draw3D - * - * runs the draw3D eventhandler code to check for interaction - * - */ - -private _vehicle = vehicle hatchet_player; - -if !(cameraView isEqualTo "INTERNAL") exitWith {}; -if !(isNull curatorCamera) exitWith {}; - -if (GVAR(updateIndex) >= GVAR(updateEvery) && !GVAR(dragging) && !GVAR(buttonHolding)) then { - GVAR(updateIndex) = 0; - GVAR(currentButton) = [_vehicle getVariable [QGVAR(points), []]] call FUNC(findButton); -}; -GVAR(updateIndex) = GVAR(updateIndex) + 1; - -_this call FUNC(drawLabel); - -if (GVAR(crosshair)) then { - ["+",-1, 0.485, 1, 0, 0, 794] spawn BIS_fnc_dynamicText; -}; - -if (GVAR(pointStart)) then { - [_vehicle] call FUNC(pointCalculate); -}; -[_vehicle] call FUNC(pointDraw); - -if (!isNil QGVAR(knobHolding) && !GVAR(dragging)) then { - GVAR(knobHolding) PARAMS; - _knobConfig params KNOBPARAMS; - private _animationPhase = _vehicle animationPhase _animation; - private _animationEnd =_vehicle getVariable ["knob_" + _animation, _animationPhase]; - if ( - (_animationPhase > _animationEnd - 0.02) && - (_animationPhase < _animationEnd + 0.02) - ) then { - GVAR(knobHolding) = nil; - [_vehicle, _animationPhase] call _dragStop; - _vehicle setVariable [("knob_" + _animation), nil]; - vxf_animating_keys deleteAt (vxf_animating_keys find _animation); - } else { - [_vehicle, _animationPhase] call _dragging; - }; -}; diff --git a/addons/interaction/functions/fnc_drawLabel.sqf b/addons/interaction/functions/fnc_drawLabel.sqf deleted file mode 100644 index 86f0905..0000000 --- a/addons/interaction/functions/fnc_drawLabel.sqf +++ /dev/null @@ -1,114 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_interaction_fnc_drawLabel - * - * interaction button release functionality - */ - -private _vehicle = vehicle hatchet_player; - -if (isNil QGVAR(currentButton)) exitWith { - ["",0,0.4,0,0,0, 1301] spawn BIS_fnc_dynamicText; - ["",0,0.4,0,0,0, 1302] spawn BIS_fnc_dynamicText; -}; - -GVAR(currentButton) PARAMS; -if (_positionType == "anim") then { - _position = _vehicle selectionPosition _position; -}; - -private _color = if (GVAR(buttonHolding)) then {[1,0,0,1]} else {[1,1,1,1]}; -private _size = if (GVAR(buttonHolding)) then {0.045} else {0.05}; -_label = if (GVAR(showLabel)) then { - if (count _buttonConfig > 0 && {count _knobConfig == 0}) then { - private _fmt = if (GVAR(showKeybind)) then { - "[%1] %2" - } else { - "%2" - }; - format [_fmt, (([COMPONENT_NAME, QGVAR(ButtonPress)] call CBA_fnc_getKeybind)# 5) call CBA_fnc_localizeKey, _label] - } else { - _label - } -} else { - "" -}; - -drawIcon3D [ - "\a3\ui_f\data\IGUI\Cfg\Cursors\selected_ca.paa", - _color, - _vehicle modelToWorldVisual _position, - 1, - 1, - 0, - _label, - 2, - _size -]; - -if (count _knobConfig > 0) then { - _knobConfig params KNOBPARAMS; - if (inputAction "prevAction" > 0 && !GVAR(scrolledHolding)) then { - [_vehicle, 1, _knobConfig] call FUNC(knobAnimate); - }; - if (inputAction "nextAction" > 0 && !GVAR(scrolledHolding)) then { - [_vehicle, -1, _knobConfig] call FUNC(knobAnimate); - }; - if (GVAR(showKeybinds)) then { - ["Scroll or drag to spin",0,0.6,0,0,0, 1303] spawn BIS_fnc_dynamicText; - } else { - ["",0,0.6,0,0,0, 1303] spawn BIS_fnc_dynamicText; - }; -} else { - ["",0,0.6,0,0,0, 1303] spawn BIS_fnc_dynamicText; -}; - -if (count _animConfig > 0 && count _knobConfig == 0) then { - _animConfig params ANIMPARAMS; - private _closestState = 0; - private _closestDiff = 9999; - private ["_diff"]; - private _animationPhase = (_vehicle animationPhase _animation); - { // forEach _animationSteps - _diff = abs(_animationPhase - _x); - if (_diff < _closestDiff) then { - _closestDiff = _diff; - _closestState = _forEachIndex; - }; - } forEach _animationSteps; - private _currentState = _closestState; - if (_currentState == -1) exitWith { - ["",0,0.4,0,0,0, 1301] spawn BIS_fnc_dynamicText; - ["",0,0.4,0,0,0, 1302] spawn BIS_fnc_dynamicText; - }; - private _loopFirst = if (_animLooping) then {0} else {-1}; - private _loopLast = if (_animLooping) then {(count _animationSteps) - 1} else {-1}; - private _prevStep = if (_currentState == 0) then {_loopLast} else {_currentState - 1}; - private _nextStep = if (_currentState == (count _animationSteps) - 1) then {_loopFirst} else {_currentState + 1}; - if (GVAR(showKeybinds)) then { - if (_prevStep > -1) then { - [format ["Set to %2 with %1", actionKeysNames "prevAction", _animationLabels # _prevStep],(-safeZoneX)+(GVAR(cursorPos) # 0) - (safeZoneW / 2),((GVAR(cursorPos) # 1) - 0.1),0,0,0, 1301] spawn BIS_fnc_dynamicText; - } else { - ["",0,0.4,0,0,0, 1301] spawn BIS_fnc_dynamicText; - }; - if (_nextStep > -1) then { - [format ["Set to %2 with %1", actionKeysNames "nextAction", _animationLabels # _nextStep],(-safeZoneX)+(GVAR(cursorPos) # 0) - (safeZoneW / 2),((GVAR(cursorPos) # 1) + 0.1),0,0,0, 1302] spawn BIS_fnc_dynamicText; - } else { - ["",0,0.4,0,0,0, 1302] spawn BIS_fnc_dynamicText; - }; - } else { - ["",0,0.4,0,0,0, 1301] spawn BIS_fnc_dynamicText; - ["",0,0.6,0,0,0, 1302] spawn BIS_fnc_dynamicText; - }; - if (inputAction "prevAction" > 0 && _prevStep > -1) then { - [_vehicle, _animation, _animationSteps # _prevStep, _animationLabels # _prevStep, _animationSpeed, _animStart, _animEnd, GVAR(currentButton)] call FUNC(leverAnimate); - }; - if (inputAction "nextAction" > 0 && _nextStep > -1) then { - [_vehicle, _animation, _animationSteps # _nextStep, _animationLabels # _nextStep, _animationSpeed, _animStart, _animEnd, GVAR(currentButton)] call FUNC(leverAnimate); - }; -} else { - ["",0,0.4,0,0,0, 1301] spawn BIS_fnc_dynamicText; - ["",0,0.6,0,0,0, 1302] spawn BIS_fnc_dynamicText; -}; - -if (inputAction "prevAction" == 0 && inputAction "nextAction" == 0) then {GVAR(scrolledHolding) = false;}; diff --git a/addons/interaction/functions/fnc_findButton.sqf b/addons/interaction/functions/fnc_findButton.sqf deleted file mode 100644 index fa154f4..0000000 --- a/addons/interaction/functions/fnc_findButton.sqf +++ /dev/null @@ -1,21 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_interaction_fnc_findButton - */ - -params ["_points"]; - -private _button = nil; -private _buttonDis = 1000; - -{ - private _dis = _x call FUNC(checkInteraction); - if !(isNil "_dis") then { - if (_dis < _buttonDis) then { - _button = _x; - _buttonDis = _dis; - }; - }; -} forEach _points; - -_button diff --git a/addons/interaction/functions/fnc_knobAnimate.sqf b/addons/interaction/functions/fnc_knobAnimate.sqf deleted file mode 100644 index c889207..0000000 --- a/addons/interaction/functions/fnc_knobAnimate.sqf +++ /dev/null @@ -1,35 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_interaction_fnc_knobAnimate - * - * interaction button animate knob scrollwheel functionality - */ - -params ["_vehicle", "_animDirection", "_knobConfig"]; -_knobConfig params KNOBPARAMS; -diag_log format ["%2: knob animate %1", _name, time]; - -if (isNil {_vehicle getVariable QGVAR(points)}) exitWith {false}; -if (!isNil QGVAR(knobHolding) && { GVAR(knobHolding) # 0 != _animation }) exitWith {false}; - -private _animationPhase = (_vehicle animationPhase _animation); -private _base = _vehicle getVariable [("knob_" + _animation), _animationPhase]; -private _endPoint = _base + (_scrollIncrement * _animDirection); -_endPoint = _endPoint min (_animLimits # 1) max (_animLimits # 0); -_vehicle setVariable [("knob_" + _animation), _endPoint]; -_vehicle animateSource [_animation, _endPoint, _animSpeed]; -GVAR(knobHolding) = GVAR(currentButton); - -GVAR(currentButton) PARAMS; - -//[] spawn { -// showCommandingMenu "RscMainMenu"; -// showCommandingMenu ""; -//}; - -if !(_vehicle call compile _interactCondition) exitWith {}; -if (_animation in vxf_animating_keys) exitWith {false}; - -[_vehicle] call _dragStart; -[_vehicle, _position, 1, name hatchet_player] call FUNC(pointNetSend); -vxf_animating_keys pushBack _animation; diff --git a/addons/interaction/functions/fnc_leverAnimate.sqf b/addons/interaction/functions/fnc_leverAnimate.sqf deleted file mode 100644 index 29092d5..0000000 --- a/addons/interaction/functions/fnc_leverAnimate.sqf +++ /dev/null @@ -1,54 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_interaction_fnc_leverAnimate - * - * interaction button animate lever/switch functionality - */ - -params ["_vehicle", "_animation", "_animationTarget", "_animationTargetLabel", "_animationSpeed", "_animStart", "_animEnd", "_button"]; - -if (isNil{_vehicle getVariable QGVAR(points)}) exitWith {false}; -if (_animation in vxf_animating_keys) exitWith {false}; - -_button PARAMS; -diag_log format ["%2: lever animate %1", _name, time]; - -if !(_this call compile _interactCondition) exitWith { - //[] spawn { - // showCommandingMenu "RscMainMenu"; - // showCommandingMenu ""; - //}; -}; - -if (_clickSound != "") then { - playSound _clickSound; -}; - -[_vehicle, _animation, _animationTargetLabel, _animationTarget] call _animStart; -[_vehicle, _position, 1, name hatchet_player] call FUNC(pointNetSend); -vxf_animating_keys pushBack _animation; - -_vehicle animateSource [_animation, _animationTarget, _animationSpeed]; - -#define OUTER_ARGS(ARRAY) ARRAY params ["_vehicle", "_animation", "_animationTarget", "_animationTargetLabel", "_animEnd"] -#define INNER_ARGS \ - _this params ["_p1", "_startTime"]; \ - OUTER_ARGS(_p1) - -// Waits for 3 seconds, then begins a CBA waitUntil -[{ - OUTER_ARGS(_this); - [{ - INNER_ARGS; - (_vehicle animationPhase _animation > _animationTarget - 0.02) && - { (_vehicle animationPhase _animation < _animationTarget + 0.02) } - }, { - INNER_ARGS; - [_vehicle, _animation, _animationTargetLabel, _animationTarget] call _animEnd; - vxf_animating_keys deleteAt (vxf_animating_keys find _animation); - }, - [[_vehicle, _animation, _animationTarget, _animationTargetLabel, _animEnd], cba_missionTime] - ] call CBA_fnc_waitUntilAndExecute; -}, [ - _vehicle, _animation, _animationTarget, _animationTargetLabel, _animEnd -], 3] call CBA_fnc_waitAndExecute; diff --git a/addons/interaction/functions/fnc_loadAll.sqf b/addons/interaction/functions/fnc_loadAll.sqf deleted file mode 100644 index 29592f7..0000000 --- a/addons/interaction/functions/fnc_loadAll.sqf +++ /dev/null @@ -1,21 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_interaction_fnc_loadAll - * - * loads interaction from config - * - * params: (array)[(object) vehicle] - */ - -params ["_vehicle"]; - -private _vehicleInteraction = []; - -private _vehicleConfig = _vehicle getVariable QRVAR(config); -private _interaction = "true" configClasses (_vehicleConfig >> "interaction"); - -{ // forEach _interaction - _vehicleInteraction pushBack ([_vehicle, _x] call FUNC(loadItem)); -} forEach _interaction; - -_vehicle setVariable [QGVAR(points), _vehicleInteraction]; diff --git a/addons/interaction/functions/fnc_loadItem.sqf b/addons/interaction/functions/fnc_loadItem.sqf deleted file mode 100644 index 9c2a76a..0000000 --- a/addons/interaction/functions/fnc_loadItem.sqf +++ /dev/null @@ -1,137 +0,0 @@ -#include "script_component.hpp" -/* - * FUNC(loadItem) - * - * loads part of interaction from config - * - * params: (array)[(object) vehicle, (configClass) config] - * - * returns: (array)[ - * (string) name - * (string) condition - * (array) sub-items - * OPTIONAL: (string) position type - * OPTIONAL: (string) position - * OPTIONAL: (string) label - * OPTIONAL: (scalar) radius - * OPTIONAL: (array) button config - * OPTIONAL: (array) lever config - * ] - */ - -params ["_vehicle", "_config"]; - -private _result = [ - configName _config, - getText (_config >> "condition") -]; - -private _subItems = []; -private _subItemConfigs = "true" configClasses _config; -{ //forEach _subItems - _subItems pushBack ([_vehicle, _x] call FUNC(loadItem)); -} forEach _subItemConfigs; - -_result pushBack _subItems; - -private _positionType = getText (_config >> "positionType"); -private _position = getText (_config >> "position"); -if (_positionType == "static") then { - _position = _vehicle selectionPosition _position; -}; -if (_positionType == "coordinates") then { - _positionType = "static"; - _position = getArray (_config >> "position"); -}; -private _label = getText (_config >> "label"); -private _radius = getNumber (_config >> "radius"); -private _interactCondition = getText (_config >> "interactionCondition"); -private _buttonDown = getText (_config >> "buttonDown"); -private _buttonUp = getText (_config >> "buttonUp"); -private _buttonHold = getText (_config >> "buttonHold"); -private _clickSound = getText (_config >> "clickSound"); -private _action = getText (_config >> "action"); - -if !(_action isEqualTo "") then { - if (GVAR(removeActions)) then { - GVAR(actionIgnore) pushBack _action; - }; -}; - -private _buttonConfig = []; -if (_buttonDown != "" || _buttonUp != "" || _buttonHold != "") then { - _buttonConfig = [ - compile _buttonDown, - compile _buttonUp, - (if (_buttonHold != "") then {compile _buttonHold} else {nil}) - ]; -}; - -private _animation = getText (_config >> "animation"); -private _animStates = (_config >> "animStates") call BIS_fnc_getCfgData; -private _animLabels = (_config >> "animLabels") call BIS_fnc_getCfgData; -private _animSpeed = getNumber (_config >> "animSpeed"); -private _animLooping = getNumber (_config >> "looping"); -private _animStart = getText (_config >> "animStart"); -private _animEnd = getText (_config >> "animEnd"); -private _animConfig = []; -if (_animation != "" && ISFULLARRAY(_animStates) && ISFULLARRAY(_animLabels)) then { - _animConfig = [ - _animation, - (if (_animSpeed == 0) then {true} else {_animSpeed}), - (_animLooping == 1), - _animStates, - _animLabels, - compile _animStart, - compile _animEnd - ]; -}; - -private _scrollIncrement = getNumber (_config >> "scrollIncrement"); -private _dragRange = getNumber (_config >> "dragRange"); -private _animLimits = (_config >> "animLimits") call BIS_fnc_getCfgData; -private _dragStart = getText (_config >> "dragStart"); -private _dragging = getText (_config >> "dragging"); -private _dragStop = getText (_config >> "dragStop"); -private _knobConfig = []; -if (_animation != "" && _dragRange > 0 && ISFULLARRAY(_animLimits)) then { - _knobConfig = [ - _animation, - _scrollIncrement, - _dragRange, - _animLooping, - _animLimits, - (if (_animSpeed == 0) then {true} else {_animSpeed}), - compile _dragStart, - (if (_dragging != "") then {compile _dragging} else {nil}), - compile _dragStop - ]; - _buttonConfig = [ - {_this call FUNC(dragStart)}, - {_this call FUNC(dragStop)}, - {_this call FUNC(drag)}, - compile _buttonUp - ]; -}; - -//check if there is sufficient data for an interaction -if ( - _positionType != "" && - (typeName _position == "STRING" && {_position != ""}) || (typeName _position == "ARRAY") && - // _label != "" && - _radius > -1 -) then { - _result = _result + [ - _positionType, - _position, - _label, - _radius, - _clickSound, - _interactCondition, - _buttonConfig, - _animConfig, - _knobConfig - ]; -}; - -_result diff --git a/addons/interaction/functions/fnc_perFrame.sqf b/addons/interaction/functions/fnc_perFrame.sqf deleted file mode 100644 index a6f8ab6..0000000 --- a/addons/interaction/functions/fnc_perFrame.sqf +++ /dev/null @@ -1,16 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_interaction_fnc_perFrame - * - * Runs per frame for interaction, handles button holding code - * - * Params: array[(object) vehicle, (scalar) frame time] - */ - -params ["_vehicle", "_frameTime"]; - -if !(isNil QGVAR(buttonHoldCode)) then { - _this call GVAR(buttonHoldCode); -}; - -GVAR(buttonRadius) = (call cba_fnc_getFov # 1); diff --git a/addons/interaction/functions/fnc_pointCalculate.sqf b/addons/interaction/functions/fnc_pointCalculate.sqf deleted file mode 100644 index 5307945..0000000 --- a/addons/interaction/functions/fnc_pointCalculate.sqf +++ /dev/null @@ -1,31 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_interaction_fnc_pointCalculate - * - * calculates pointing position and sends it to other crew - * - * params (array)[(object) vehicle] - */ - -params ["_vehicle"]; - -GVAR(pointStart) = false; - -private _eye = eyePos hatchet_player; -private _visualDiff = getPosVisual hatchet_player vectorDiff getPos hatchet_player; -_eye = _eye vectorAdd _visualDiff; -private _beginVec = (vectorNormalized (getCameraViewDirection hatchet_player)) vectorMultiply 0.5; -private _begin = _eye vectorAdd _beginVec; -private _endVec = (vectorNormalized (getCameraViewDirection hatchet_player)) vectorMultiply 5; -private _end = _eye vectorAdd _endVec; -private _intersections = lineIntersectsSurfaces [_begin, _end, hatchet_player, objNull, true, 1, "FIRE", "VIEW"]; -private _keyDownPos = if (count _intersections > 0) then { - _intersections # 0 # 0 -} else { - (eyePos hatchet_player vectorAdd _endVec) -}; - -if !(isNil {_keyDownPos}) then { - private _pointPos = _vehicle worldToModelVisual ASLtoAGL _keyDownPos; - [_vehicle, _pointPos, 0, name hatchet_player] call FUNC(pointNetSend); -}; diff --git a/addons/interaction/functions/fnc_pointDraw.sqf b/addons/interaction/functions/fnc_pointDraw.sqf deleted file mode 100644 index 752b6ef..0000000 --- a/addons/interaction/functions/fnc_pointDraw.sqf +++ /dev/null @@ -1,19 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_interaction_fnc_pointDraw - * - * draws pointing positions - * - * params (array)[(object) vehicle] - */ - -params ["_vehicle"]; - -{ - if (cba_missionTime > (_x # 1) + GVAR(point_lifetime)) then { - GVAR(point_icons) deleteAt _forEachIndex; - } else { - private _drawPos = if (typeName (_x # 0) == "STRING") then {_vehicle selectionPosition (_x # 0)} else {(_x # 0)}; - drawIcon3D [_x # 2, [1,0,0,1], _vehicle modelToWorldVisual _drawPos, 2, 2, 0, (_x # 3)]; - }; -} forEach GVAR(point_icons); diff --git a/addons/interaction/functions/fnc_pointNetReceive.sqf b/addons/interaction/functions/fnc_pointNetReceive.sqf deleted file mode 100644 index 49108ad..0000000 --- a/addons/interaction/functions/fnc_pointNetReceive.sqf +++ /dev/null @@ -1,17 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_interaction_fnc_pointNetReceive - * - * receives pointing positions and adds timestamps and textures - * - * params (array)[(positionModel) pointPos, (SCALAR) type, (string) player name] - */ - -params ["_pointPos", "_pointType", "_name"]; - -private _pointTextures = [ - "\a3\ui_f\data\IGUI\Cfg\CrewAimIndicator\commander_ca.paa", - "\a3\ui_f\data\IGUI\Cfg\Cursors\freelook_ca.paa" -]; - -GVAR(point_icons) pushBack [_pointPos, cba_missionTime, _pointTextures # _pointType, _name]; diff --git a/addons/interaction/functions/fnc_pointNetSend.sqf b/addons/interaction/functions/fnc_pointNetSend.sqf deleted file mode 100644 index 4076ab7..0000000 --- a/addons/interaction/functions/fnc_pointNetSend.sqf +++ /dev/null @@ -1,14 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_interaction_fnc_pointNetSend - * - * sends pointing positions - * - * params (array)[(object) vehicle, (positionModel) pointPos, (SCALAR) icon index, (string) label] - */ - -params ["_vehicle", "_pointPos", "_iconIndex", "_label"]; - -if (GVAR(pointingEnabled)) then { - [_pointPos, _iconIndex, _label] remoteExecCall [QFUNC(pointNetReceive), crew _vehicle]; -}; diff --git a/addons/interaction/functions/fnc_pointStart.sqf b/addons/interaction/functions/fnc_pointStart.sqf deleted file mode 100644 index 42f9000..0000000 --- a/addons/interaction/functions/fnc_pointStart.sqf +++ /dev/null @@ -1,14 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_interaction_fnc_pointStart - * - * used to point at something inside a vehicle, will draw a marker for other crew - * this function only starts pointing, actual pointing code is handled inside draw3D - * - */ - -private _vehicle = vehicle hatchet_player; -if (isNil{_vehicle getVariable QGVAR(points)}) exitWith {false}; - -GVAR(pointStart) = true; -true diff --git a/addons/interaction/functions/fnc_removeActions.sqf b/addons/interaction/functions/fnc_removeActions.sqf deleted file mode 100644 index bb640fa..0000000 --- a/addons/interaction/functions/fnc_removeActions.sqf +++ /dev/null @@ -1,11 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_interaction_fnc_removeActions - */ - -{ - hatchet_player removeAction _x; -} forEach GVAR(actionIds); - -GVAR(actionIds) = []; -GVAR(actionIgnore) = []; diff --git a/addons/interaction/functions/fnc_scriptedInteract.sqf b/addons/interaction/functions/fnc_scriptedInteract.sqf deleted file mode 100644 index 378dd12..0000000 --- a/addons/interaction/functions/fnc_scriptedInteract.sqf +++ /dev/null @@ -1,29 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_interaction_fnc_scriptedInteract - * - * call a button or lever from a script - */ - -params ["_vehicle", "_config", ["_animationTargetLabel", nil]]; - -private _vehicleConfig = _vehicle getVariable QRVAR(config); - -if (isNil "_vehicleConfig") exitWith {}; - -private _configPath = _vehicleConfig >> "interaction"; -{_configPath = _configPath >> _x} forEach _config; -private _interactionConfig = [_vehicle, _configPath] call FUNC(loadItem); - -if (isNil "_animationTargetLabel") exitWith { - [_vehicle, _interactionConfig, true] call FUNC(buttonDown); - [_vehicle, _interactionConfig, true] call FUNC(buttonUp); -}; - -_interactionConfig params ["_name","_condition","_subItems",["_positionType", nil],["_position", nil],["_label", nil],["_radius", nil],["_clickSound",""],["_interactCondition",{true}],["_buttonConfig", nil], ["_animConfig", nil], ["_knobConfig", nil]]; -_animConfig params ["_animation", "_animationSpeed", "_animLooping", "_animationSteps", "_animationLabels", "_animStart", "_animEnd"]; - -private _stepIndex = _animationLabels find _animationTargetLabel; -if (_stepIndex == -1) exitWith {}; -private _targetAnimStep = _animationSteps # _stepIndex; -[_vehicle, _animation, _targetAnimStep, _animationTargetLabel, _animationSpeed, _animStart, _animEnd, _interactionConfig] call FUNC(leverAnimate); diff --git a/addons/interaction/functions/fnc_setup.sqf b/addons/interaction/functions/fnc_setup.sqf deleted file mode 100644 index e5cbadf..0000000 --- a/addons/interaction/functions/fnc_setup.sqf +++ /dev/null @@ -1,27 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_interaction_fnc_setup - * - * starts the interaction system - * - * params (array)[(object) vehicle] - */ - -params ["_vehicle"]; - -GVAR(actionIds) = []; -GVAR(actionIgnore) = []; - -_this call FUNC(loadAll); - -if (isNil {GVAR(drawHandler)}) then { - GVAR(drawHandler) = addMissionEventHandler ["Draw3d", FUNC(draw3D)]; -}; - -private _vehicleConfig = _vehicle getVariable RVAR(config); -GVAR(crosshair) = (getNumber (_vehicleConfig >> "interaction" >> "crossHair") == 1); - -vxf_animating_keys = []; -GVAR(cursorPos) = [0.5, 0.5]; - -true diff --git a/addons/interaction/functions/fnc_shutDown.sqf b/addons/interaction/functions/fnc_shutDown.sqf deleted file mode 100644 index e34c5aa..0000000 --- a/addons/interaction/functions/fnc_shutDown.sqf +++ /dev/null @@ -1,10 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_interaction_fnc_shutdown - * - * starts the interaction system - * - * params (array)[(object) vehicle] - */ - -call FUNC(removeActions); diff --git a/addons/interaction/functions/script_component.hpp b/addons/interaction/functions/script_component.hpp deleted file mode 100644 index cdc3ded..0000000 --- a/addons/interaction/functions/script_component.hpp +++ /dev/null @@ -1 +0,0 @@ -#include "../script_component.hpp" diff --git a/addons/interaction/script_component.hpp b/addons/interaction/script_component.hpp deleted file mode 100644 index 89ee450..0000000 --- a/addons/interaction/script_component.hpp +++ /dev/null @@ -1,14 +0,0 @@ -#define COMPONENT interaction -#define COMPONENT_BEAUTIFIED Interaction -#include "\z\hatchet\addons\main\script_mod.hpp" - -#ifdef DEBUG_ENABLED_INTERACTION - #define DEBUG_MODE_FULL -#endif - -#ifdef DEBUG_SETTINGS_INTERACTION - #define DEBUG_SETTINGS DEBUG_SETTINGS_INTERACTION -#endif - -#include "\z\hatchet\addons\main\script_macros.hpp" -#include "script_macros.hpp" diff --git a/addons/interaction/script_macros.hpp b/addons/interaction/script_macros.hpp deleted file mode 100644 index a7c4faf..0000000 --- a/addons/interaction/script_macros.hpp +++ /dev/null @@ -1,6 +0,0 @@ -#define PARAMS params ["_name","_condition","_subItems",["_positionType", nil],["_position", nil],["_label", nil],["_radius", nil],["_clickSound",""],["_interactCondition",{true}],["_buttonConfig", nil], ["_animConfig", nil], ["_knobConfig", nil]] -#define BTNPARAMS params ["_buttonDown", "_buttonUp", "_buttonHold", ["_knobClick", nil]] -#define ANIMPARAMS ["_animation", "_animationSpeed", "_animLooping", "_animationSteps", "_animationLabels", "_animStart", "_animEnd"] -#define KNOBPARAMS ["_animation", "_scrollIncrement", "_dragRange", "_animLooping", "_animLimits", "_animSpeed", "_dragStart", "_dragging", "_dragStop"] -#define FNC_STRING(NAME) (if(!isNil{missionNameSpace getVariable NAME}) then {missionNameSpace getVariable NAME} else {{nil}}) -#define ISFULLARRAY(ARR) (!isNil QUOTE(ARR) && {typeName ARR == "ARRAY"} && {count ARR > 0}) diff --git a/addons/interaction/sounds/dial.wss b/addons/interaction/sounds/dial.wss deleted file mode 100644 index 8ef0330..0000000 Binary files a/addons/interaction/sounds/dial.wss and /dev/null differ diff --git a/addons/interaction/sounds/heavySwitch.wss b/addons/interaction/sounds/heavySwitch.wss deleted file mode 100644 index ef082fe..0000000 Binary files a/addons/interaction/sounds/heavySwitch.wss and /dev/null differ diff --git a/addons/interaction/sounds/switch.wss b/addons/interaction/sounds/switch.wss deleted file mode 100644 index b77b93e..0000000 Binary files a/addons/interaction/sounds/switch.wss and /dev/null differ diff --git a/addons/interaction/sounds/switch1.wss b/addons/interaction/sounds/switch1.wss deleted file mode 100644 index fbadb93..0000000 Binary files a/addons/interaction/sounds/switch1.wss and /dev/null differ diff --git a/addons/interaction/sounds/switch2.wss b/addons/interaction/sounds/switch2.wss deleted file mode 100644 index 375a063..0000000 Binary files a/addons/interaction/sounds/switch2.wss and /dev/null differ diff --git a/addons/interaction/sounds/switch3.wss b/addons/interaction/sounds/switch3.wss deleted file mode 100644 index 785709d..0000000 Binary files a/addons/interaction/sounds/switch3.wss and /dev/null differ diff --git a/addons/interaction/sounds/switch4.wss b/addons/interaction/sounds/switch4.wss deleted file mode 100644 index 533fb5c..0000000 Binary files a/addons/interaction/sounds/switch4.wss and /dev/null differ diff --git a/addons/interaction/sounds/switch5.wss b/addons/interaction/sounds/switch5.wss deleted file mode 100644 index 485e181..0000000 Binary files a/addons/interaction/sounds/switch5.wss and /dev/null differ diff --git a/addons/main/$PBOPREFIX$ b/addons/main/$PBOPREFIX$ deleted file mode 100644 index 145fc49..0000000 --- a/addons/main/$PBOPREFIX$ +++ /dev/null @@ -1 +0,0 @@ -z\hatchet\addons\main diff --git a/addons/main/config.cpp b/addons/main/config.cpp deleted file mode 100644 index 68570ac..0000000 --- a/addons/main/config.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "script_component.hpp" - -class CfgPatches { - class ADDON { - name = QUOTE(COMPONENT); - units[] = {}; - weapons[] = {}; - requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"cba_common"}; - author = "Project Hatchet"; - VERSION_CONFIG; - }; -}; diff --git a/addons/main/script_component.hpp b/addons/main/script_component.hpp deleted file mode 100644 index e40025b..0000000 --- a/addons/main/script_component.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#define COMPONENT main -#define COMPONENT_BEAUTIFIED Main -#include "\z\hatchet\addons\main\script_mod.hpp" - -// #define DEBUG_MODE_FULL -// #define DISABLE_COMPILE_CACHE -// #define ENABLE_PERFORMANCE_COUNTERS - -#ifdef DEBUG_ENABLED_MAIN - #define DEBUG_MODE_FULL -#endif - -#ifdef DEBUG_SETTINGS_MAIN - #define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN -#endif - -#include "\z\hatchet\addons\main\script_macros.hpp" diff --git a/addons/main/script_macros.hpp b/addons/main/script_macros.hpp deleted file mode 100644 index d1d3f3d..0000000 --- a/addons/main/script_macros.hpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "\x\cba\addons\main\script_macros_common.hpp" - -#define DFUNC(var1) TRIPLES(ADDON,fnc,var1) - -#ifdef DISABLE_COMPILE_CACHE - #undef PREP - #define PREP(fncName) DFUNC(fncName) = compile preprocessFileLineNumbers QPATHTOF(functions\DOUBLES(fnc,fncName).sqf) -#else - #undef PREP - #define PREP(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf), QFUNC(fncName)] call CBA_fnc_compileFunction -#endif - -#define RVAR(var1) DOUBLES(PREFIX,var1) -#define QRVAR(var1) QUOTE(RVAR(var1)) diff --git a/addons/main/script_mod.hpp b/addons/main/script_mod.hpp deleted file mode 100644 index cb073d8..0000000 --- a/addons/main/script_mod.hpp +++ /dev/null @@ -1,16 +0,0 @@ -// COMPONENT should be defined in the script_component.hpp and included BEFORE this hpp - -#define MAINPREFIX z -#define PREFIX hatchet -#define SUBPREFIX addons - -#include "script_version.hpp" - -// MINIMAL required version for the Mod. Components can specify others.. -#define REQUIRED_VERSION 2.00 - -#ifdef COMPONENT_BEAUTIFIED - #define COMPONENT_NAME QUOTE(Hatchet - COMPONENT_BEAUTIFIED) -#else - #define COMPONENT_NAME QUOTE(Hatchet - COMPONENT) -#endif diff --git a/addons/main/script_version.hpp b/addons/main/script_version.hpp deleted file mode 100644 index aba696b..0000000 --- a/addons/main/script_version.hpp +++ /dev/null @@ -1,4 +0,0 @@ -#define MAJOR 0 -#define MINOR 2 -#define PATCH 0 -#define BUILD 0 diff --git a/addons/util/$PBOPREFIX$ b/addons/util/$PBOPREFIX$ deleted file mode 100644 index 579219b..0000000 --- a/addons/util/$PBOPREFIX$ +++ /dev/null @@ -1 +0,0 @@ -z\hatchet\addons\util diff --git a/addons/util/CfgEventHandlers.hpp b/addons/util/CfgEventHandlers.hpp deleted file mode 100644 index c7a3aec..0000000 --- a/addons/util/CfgEventHandlers.hpp +++ /dev/null @@ -1,11 +0,0 @@ -class Extended_PreStart_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_preStart)); - }; -}; - -class Extended_PreInit_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_preInit)); - }; -}; diff --git a/addons/util/XEH_PREP.hpp b/addons/util/XEH_PREP.hpp deleted file mode 100644 index 6a561a3..0000000 --- a/addons/util/XEH_PREP.hpp +++ /dev/null @@ -1,6 +0,0 @@ -PREP(pidCreate); -PREP(pidReset); -PREP(pidRun); - -PREP(getTurretCopilot); -PREP(getTurretIndex); diff --git a/addons/util/XEH_preInit.sqf b/addons/util/XEH_preInit.sqf deleted file mode 100644 index a9c2702..0000000 --- a/addons/util/XEH_preInit.sqf +++ /dev/null @@ -1,5 +0,0 @@ -#include "script_component.hpp" -ADDON = false; -#include "XEH_PREP.hpp" - -ADDON = true; diff --git a/addons/util/XEH_preStart.sqf b/addons/util/XEH_preStart.sqf deleted file mode 100644 index a51262a..0000000 --- a/addons/util/XEH_preStart.sqf +++ /dev/null @@ -1,2 +0,0 @@ -#include "script_component.hpp" -#include "XEH_PREP.hpp" diff --git a/addons/util/config.cpp b/addons/util/config.cpp deleted file mode 100644 index ce28ef9..0000000 --- a/addons/util/config.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "script_component.hpp" - -class CfgPatches { - class ADDON { - name = COMPONENT_NAME; - units[] = {}; - weapons[] = {}; - requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"hatchet_main"}; - author = "Project Hatchet"; - VERSION_CONFIG; - }; -}; - -#include "CfgEventHandlers.hpp" diff --git a/addons/util/functions/fnc_getTurretCopilot.sqf b/addons/util/functions/fnc_getTurretCopilot.sqf deleted file mode 100644 index c139ded..0000000 --- a/addons/util/functions/fnc_getTurretCopilot.sqf +++ /dev/null @@ -1,22 +0,0 @@ -#include "script_component.hpp" -/* - * Author: commy2 - * Get the turret index of a vehicles copilot. - * - * Arguments: - * 0: Vehicle - * - * Return Value: - * Vehicle Copilot Turret indecies - * - * Example: - * [car] call hatchet_util_fnc_getTurretCopilot - * - * Public: Yes - */ - -params [["_vehicle", objNull, [objNull]]]; - -fullCrew [_vehicle, "turret", true] apply {_x select 3} select { - getNumber ([_vehicle, _x] call CBA_fnc_getTurret >> "isCopilot") == 1 -} param [0, []] // return diff --git a/addons/util/functions/fnc_getTurretIndex.sqf b/addons/util/functions/fnc_getTurretIndex.sqf deleted file mode 100644 index 10bd9a8..0000000 --- a/addons/util/functions/fnc_getTurretIndex.sqf +++ /dev/null @@ -1,30 +0,0 @@ -#include "script_component.hpp" -/* - * Author: commy2 - * Get the turret index of a units current turret. - * - * Arguments: - * 0: Unit - * - * Return Value: - * Turret Index - * - * Example: - * [hatchet_player] call hatchet_util_fnc_getTurretIndex - * - * Public: Yes - */ - -params [["_unit", objNull, [objNull]]]; - -private _vehicle = vehicle _unit; -if (_unit == _vehicle) exitWith {[]}; - -scopeName "main"; - -{ - if (_unit == (_vehicle turretUnit _x)) then {_x breakOut "main"}; - nil -} count allTurrets [_vehicle, true]; - -[] diff --git a/addons/util/functions/fnc_pidCreate.sqf b/addons/util/functions/fnc_pidCreate.sqf deleted file mode 100644 index 0213348..0000000 --- a/addons/util/functions/fnc_pidCreate.sqf +++ /dev/null @@ -1,18 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_util_fnc_pidCreate - * - * Creates a new PiD controller - * - * params: (array)[(SCALAR) proportional, (SCALAR) integral, (SCALAR) derivative] - * - * returns: (bool) success - */ - -params ["_vehicle", "_name", "_kp", "_ki", "_kd"]; - -if (isNil "_vehicle" || _name == "") exitWith {false}; - -_vehicle setVariable [PID(_name), [_kp, _ki, _kd, 0, 0]]; - -true diff --git a/addons/util/functions/fnc_pidReset.sqf b/addons/util/functions/fnc_pidReset.sqf deleted file mode 100644 index 5781243..0000000 --- a/addons/util/functions/fnc_pidReset.sqf +++ /dev/null @@ -1,21 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_util_fnc_pidReset - * - * Resets a PiD controller - * - * params: (array)[(SCALAR) proportional, (SCALAR) integral, (SCALAR) derivative] - * - * returns: (bool) success - */ - -params ["_vehicle", "_name"]; - -if (isNil "_vehicle" || _name == "") exitWith {}; - -private _pid = _vehicle getVariable [PID(_name), nil]; -if (isNil "_pid") exitWith {}; - -_pid set [3, 0]; -_pid set [4, 0]; -_vehicle setVariable [PID(_name), _pid]; diff --git a/addons/util/functions/fnc_pidRun.sqf b/addons/util/functions/fnc_pidRun.sqf deleted file mode 100644 index 2af2a5c..0000000 --- a/addons/util/functions/fnc_pidRun.sqf +++ /dev/null @@ -1,26 +0,0 @@ -#include "script_component.hpp" -/* - * hatchet_util_fnc_pidRun - * - * Runs a pid controller update - * - * params: (array)[(object) vehicle, (string) name, (SCALAR) frameTime, (SCALAR) desired value, (SCALAR) actual value] - * - */ - -params ["_vehicle", "_name", "_frameTime", "_desiredValue", "_actualValue"]; - -private _pid = _vehicle getVariable [PID(_name), nil]; -if (isNil "_pid") exitWith {0}; - -_pid params ["_kp", "_ki", "_kd", "_priorError", "_integral"]; - -private _error = _desiredValue - _actualValue; -_integral = _integral + (_error * _frameTime); -private _derivative = (_error - _priorError) / _frameTime; -private _output = _kp * _error + _ki * _integral + _kd * _derivative; -_priorError = _error; - -_vehicle setVariable [PID(_name), [_kp, _ki, _kd, _priorError, _integral]]; - -_output diff --git a/addons/util/functions/script_component.hpp b/addons/util/functions/script_component.hpp deleted file mode 100644 index cdc3ded..0000000 --- a/addons/util/functions/script_component.hpp +++ /dev/null @@ -1 +0,0 @@ -#include "../script_component.hpp" diff --git a/addons/util/script_component.hpp b/addons/util/script_component.hpp deleted file mode 100644 index f739c24..0000000 --- a/addons/util/script_component.hpp +++ /dev/null @@ -1,14 +0,0 @@ -#define COMPONENT util -#define COMPONENT_BEAUTIFIED Utilities -#include "\z\hatchet\addons\main\script_mod.hpp" - -#ifdef DEBUG_ENABLED_UTIL - #define DEBUG_MODE_FULL -#endif - -#ifdef DEBUG_SETTINGS_UTIL - #define DEBUG_SETTINGS DEBUG_SETTINGS_UTIL -#endif - -#include "\z\hatchet\addons\main\script_macros.hpp" -#include "script_macros.hpp" diff --git a/addons/util/script_macros.hpp b/addons/util/script_macros.hpp deleted file mode 100644 index 0ff437a..0000000 --- a/addons/util/script_macros.hpp +++ /dev/null @@ -1 +0,0 @@ -#define PID(NAME) format [QUOTE(PREFIX_pid_%1), NAME] diff --git a/include/x/cba/addons/main/script_macros_common.hpp b/include/x/cba/addons/main/script_macros_common.hpp deleted file mode 100644 index 356853e..0000000 --- a/include/x/cba/addons/main/script_macros_common.hpp +++ /dev/null @@ -1,1763 +0,0 @@ -/* - Header: script_macros_common.hpp - - Description: - A general set of useful macro functions for use by CBA itself or by any module that uses CBA. - - Authors: - Sickboy and Spooner -*/ - -/* **************************************************** - New - Should be exported to general addon - Aim: - - Simplify (shorten) the amount of characters required for repetitive tasks - - Provide a solid structure that can be dynamic and easy editable (Which sometimes means we cannot adhere to Aim #1 ;-) - An example is the path that is built from defines. Some available in this file, others in mods and addons. - - Follows Standard: - Object variables: PREFIX_COMPONENT - Main-object variables: PREFIX_main - Paths: MAINPREFIX\PREFIX\SUBPREFIX\COMPONENT\SCRIPTNAME.sqf - e.g: x\six\addons\sys_menu\fDate.sqf - - Usage: - define PREFIX and COMPONENT, then include this file - (Note, you could have a main addon for your mod, define the PREFIX in a macros.hpp, - and include this script_macros_common.hpp file. - Then in your addons, add a component.hpp, define the COMPONENT, - and include your mod's script_macros.hpp - In your scripts you can then include the addon's component.hpp with relative path) - - TODO: - - Try only to use 1 string type " vs ' - - Evaluate double functions, and simplification - - Evaluate naming scheme; current = prototype - - Evaluate "Debug" features.. - - Evaluate "create mini function per precompiled script, that will load the script on first usage, rather than on init" - - Also saw "Namespace" typeName, evaluate which we need :P - - Single/Multi player gamelogics? (Incase of MP, you would want only 1 gamelogic per component, which is pv'ed from server, etc) - */ - -#ifndef MAINPREFIX - #define MAINPREFIX x -#endif - -#ifndef SUBPREFIX - #define SUBPREFIX addons -#endif - -#ifndef MAINLOGIC - #define MAINLOGIC main -#endif - -#ifndef VERSION - #define VERSION 0 -#endif - -#ifndef VERSION_AR - #define VERSION_AR VERSION -#endif - -#ifndef VERSION_CONFIG - #define VERSION_CONFIG version = QUOTE(VERSION); versionStr = QUOTE(VERSION); versionAr[] = {VERSION_AR} -#endif - -#define ADDON DOUBLES(PREFIX,COMPONENT) -#define MAIN_ADDON DOUBLES(PREFIX,main) - -/* ------------------------------------------- -Group: Debugging -------------------------------------------- */ - -/* ------------------------------------------- -Macros: DEBUG_MODE_x - Managing debugging based on debug level. - - According to the *highest* level of debugging that has been defined *before* script_macros_common.hpp is included, - only the appropriate debugging commands will be functional. With no level explicitely defined, assume DEBUG_MODE_NORMAL. - - DEBUG_MODE_FULL - Full debugging output. - DEBUG_MODE_NORMAL - All debugging except and (Default setting if none specified). - DEBUG_MODE_MINIMAL - Only and enabled. - -Examples: - In order to turn on full debugging for a single file, - (begin example) - // Top of individual script file. - #define DEBUG_MODE_FULL - #include "script_component.hpp" - (end) - - In order to force minimal debugging for a single component, - (begin example) - // Top of addons\\script_component.hpp - // Ensure that any FULL and NORMAL setting from the individual files are undefined and MINIMAL is set. - #ifdef DEBUG_MODE_FULL - #undef DEBUG_MODE_FULL - #endif - #ifdef DEBUG_MODE_NORMAL - #undef DEBUG_MODE_NORMAL - #endif - #ifndef DEBUG_MODE_MINIMAL - #define DEBUG_MODE_MINIMAL - #endif - #include "script_macros.hpp" - (end) - - In order to turn on full debugging for a whole addon, - (begin example) - // Top of addons\main\script_macros.hpp - #ifndef DEBUG_MODE_FULL - #define DEBUG_MODE_FULL - #endif - #include "\x\cba\addons\main\script_macros_common.hpp" - (end) - -Author: - Spooner -------------------------------------------- */ - -// If DEBUG_MODE_FULL, then also enable DEBUG_MODE_NORMAL. -#ifdef DEBUG_MODE_FULL -#define DEBUG_MODE_NORMAL -#endif - -// If DEBUG_MODE_NORMAL, then also enable DEBUG_MODE_MINIMAL. -#ifdef DEBUG_MODE_NORMAL -#define DEBUG_MODE_MINIMAL -#endif - -// If no debug modes specified, use DEBUG_MODE_NORMAL (+ DEBUG_MODE_MINIMAL). -#ifndef DEBUG_MODE_MINIMAL -#define DEBUG_MODE_NORMAL -#define DEBUG_MODE_MINIMAL -#endif - -#define LOG_SYS_FORMAT(LEVEL,MESSAGE) format ['[%1] (%2) %3: %4', toUpper 'PREFIX', 'COMPONENT', LEVEL, MESSAGE] - -#ifdef DEBUG_SYNCHRONOUS -#define LOG_SYS(LEVEL,MESSAGE) diag_log text LOG_SYS_FORMAT(LEVEL,MESSAGE) -#else -#define LOG_SYS(LEVEL,MESSAGE) LOG_SYS_FORMAT(LEVEL,MESSAGE) call CBA_fnc_log -#endif - -#define LOG_SYS_FILELINENUMBERS(LEVEL,MESSAGE) LOG_SYS(LEVEL,format [ARR_4('%1 %2:%3',MESSAGE,__FILE__,__LINE__ + 1)]) - -/* ------------------------------------------- -Macro: LOG() - Log a debug message into the RPT log. - - Only run if is defined. - -Parameters: - MESSAGE - Message to record - -Example: - (begin example) - LOG("Initiated clog-dancing simulator."); - (end) - -Author: - Spooner -------------------------------------------- */ -#ifdef DEBUG_MODE_FULL - -#define LOG(MESSAGE) LOG_SYS_FILELINENUMBERS('LOG',MESSAGE) -#define LOG_1(MESSAGE,ARG1) LOG(FORMAT_1(MESSAGE,ARG1)) -#define LOG_2(MESSAGE,ARG1,ARG2) LOG(FORMAT_2(MESSAGE,ARG1,ARG2)) -#define LOG_3(MESSAGE,ARG1,ARG2,ARG3) LOG(FORMAT_3(MESSAGE,ARG1,ARG2,ARG3)) -#define LOG_4(MESSAGE,ARG1,ARG2,ARG3,ARG4) LOG(FORMAT_4(MESSAGE,ARG1,ARG2,ARG3,ARG4)) -#define LOG_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5) LOG(FORMAT_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5)) -#define LOG_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6) LOG(FORMAT_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6)) -#define LOG_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7) LOG(FORMAT_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7)) -#define LOG_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8) LOG(FORMAT_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8)) - -#else - -#define LOG(MESSAGE) /* disabled */ -#define LOG_1(MESSAGE,ARG1) /* disabled */ -#define LOG_2(MESSAGE,ARG1,ARG2) /* disabled */ -#define LOG_3(MESSAGE,ARG1,ARG2,ARG3) /* disabled */ -#define LOG_4(MESSAGE,ARG1,ARG2,ARG3,ARG4) /* disabled */ -#define LOG_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5) /* disabled */ -#define LOG_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6) /* disabled */ -#define LOG_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7) /* disabled */ -#define LOG_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8) /* disabled */ - -#endif - -/* ------------------------------------------- -Macro: INFO() - Record a message without file and line number in the RPT log. - -Parameters: - MESSAGE - Message to record - -Example: - (begin example) - INFO("Mod X is loaded, do Y"); - (end) - -Author: - commy2 -------------------------------------------- */ -#define INFO(MESSAGE) LOG_SYS('INFO',MESSAGE) -#define INFO_1(MESSAGE,ARG1) INFO(FORMAT_1(MESSAGE,ARG1)) -#define INFO_2(MESSAGE,ARG1,ARG2) INFO(FORMAT_2(MESSAGE,ARG1,ARG2)) -#define INFO_3(MESSAGE,ARG1,ARG2,ARG3) INFO(FORMAT_3(MESSAGE,ARG1,ARG2,ARG3)) -#define INFO_4(MESSAGE,ARG1,ARG2,ARG3,ARG4) INFO(FORMAT_4(MESSAGE,ARG1,ARG2,ARG3,ARG4)) -#define INFO_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5) INFO(FORMAT_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5)) -#define INFO_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6) INFO(FORMAT_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6)) -#define INFO_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7) INFO(FORMAT_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7)) -#define INFO_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8) INFO(FORMAT_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8)) - -/* ------------------------------------------- -Macro: WARNING() - Record a non-critical error in the RPT log. - - Only run if or higher is defined. - -Parameters: - MESSAGE - Message to record - -Example: - (begin example) - WARNING("This function has been deprecated. Please don't use it in future!"); - (end) - -Author: - Spooner -------------------------------------------- */ -#ifdef DEBUG_MODE_NORMAL - -#define WARNING(MESSAGE) LOG_SYS_FILELINENUMBERS('WARNING',MESSAGE) -#define WARNING_1(MESSAGE,ARG1) WARNING(FORMAT_1(MESSAGE,ARG1)) -#define WARNING_2(MESSAGE,ARG1,ARG2) WARNING(FORMAT_2(MESSAGE,ARG1,ARG2)) -#define WARNING_3(MESSAGE,ARG1,ARG2,ARG3) WARNING(FORMAT_3(MESSAGE,ARG1,ARG2,ARG3)) -#define WARNING_4(MESSAGE,ARG1,ARG2,ARG3,ARG4) WARNING(FORMAT_4(MESSAGE,ARG1,ARG2,ARG3,ARG4)) -#define WARNING_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5) WARNING(FORMAT_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5)) -#define WARNING_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6) WARNING(FORMAT_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6)) -#define WARNING_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7) WARNING(FORMAT_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7)) -#define WARNING_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8) WARNING(FORMAT_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8)) - -#else - -#define WARNING(MESSAGE) /* disabled */ -#define WARNING_1(MESSAGE,ARG1) /* disabled */ -#define WARNING_2(MESSAGE,ARG1,ARG2) /* disabled */ -#define WARNING_3(MESSAGE,ARG1,ARG2,ARG3) /* disabled */ -#define WARNING_4(MESSAGE,ARG1,ARG2,ARG3,ARG4) /* disabled */ -#define WARNING_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5) /* disabled */ -#define WARNING_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6) /* disabled */ -#define WARNING_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7) /* disabled */ -#define WARNING_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8) /* disabled */ - -#endif - -/* ------------------------------------------- -Macro: ERROR() - Record a critical error in the RPT log. - -Parameters: - MESSAGE - Message to record - -Example: - (begin example) - ERROR("value of frog not found in config ...yada...yada..."); - (end) - -Author: - Spooner -------------------------------------------- */ -#define ERROR(MESSAGE) LOG_SYS_FILELINENUMBERS('ERROR',MESSAGE) -#define ERROR_1(MESSAGE,ARG1) ERROR(FORMAT_1(MESSAGE,ARG1)) -#define ERROR_2(MESSAGE,ARG1,ARG2) ERROR(FORMAT_2(MESSAGE,ARG1,ARG2)) -#define ERROR_3(MESSAGE,ARG1,ARG2,ARG3) ERROR(FORMAT_3(MESSAGE,ARG1,ARG2,ARG3)) -#define ERROR_4(MESSAGE,ARG1,ARG2,ARG3,ARG4) ERROR(FORMAT_4(MESSAGE,ARG1,ARG2,ARG3,ARG4)) -#define ERROR_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5) ERROR(FORMAT_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5)) -#define ERROR_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6) ERROR(FORMAT_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6)) -#define ERROR_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7) ERROR(FORMAT_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7)) -#define ERROR_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8) ERROR(FORMAT_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8)) - -/* ------------------------------------------- -Macro: ERROR_MSG() - Record a critical error in the RPT log and display on screen error message. - - Newlines (\n) in the MESSAGE will be put on separate lines. - -Parameters: - MESSAGE - Message to record - -Example: - (begin example) - ERROR_MSG("value of frog not found in config ...yada...yada..."); - (end) - -Author: - commy2 -------------------------------------------- */ -#define ERROR_MSG(MESSAGE) ['PREFIX', 'COMPONENT', nil, MESSAGE, __FILE__, __LINE__ + 1] call CBA_fnc_error -#define ERROR_MSG_1(MESSAGE,ARG1) ERROR_MSG(FORMAT_1(MESSAGE,ARG1)) -#define ERROR_MSG_2(MESSAGE,ARG1,ARG2) ERROR_MSG(FORMAT_2(MESSAGE,ARG1,ARG2)) -#define ERROR_MSG_3(MESSAGE,ARG1,ARG2,ARG3) ERROR_MSG(FORMAT_3(MESSAGE,ARG1,ARG2,ARG3)) -#define ERROR_MSG_4(MESSAGE,ARG1,ARG2,ARG3,ARG4) ERROR_MSG(FORMAT_4(MESSAGE,ARG1,ARG2,ARG3,ARG4)) -#define ERROR_MSG_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5) ERROR_MSG(FORMAT_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5)) -#define ERROR_MSG_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6) ERROR_MSG(FORMAT_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6)) -#define ERROR_MSG_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7) ERROR_MSG(FORMAT_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7)) -#define ERROR_MSG_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8) ERROR_MSG(FORMAT_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8)) - -/* ------------------------------------------- -Macro: ERROR_WITH_TITLE() - Record a critical error in the RPT log. - - The title can be specified (in the heading is always just "ERROR") - Newlines (\n) in the MESSAGE will be put on separate lines. - -Parameters: - TITLE - Title of error message - MESSAGE - Body of error message - -Example: - (begin example) - ERROR_WITH_TITLE("Value not found","Value of frog not found in config ...yada...yada..."); - (end) - -Author: - Spooner -------------------------------------------- */ -#define ERROR_WITH_TITLE(TITLE,MESSAGE) ['PREFIX', 'COMPONENT', TITLE, MESSAGE, __FILE__, __LINE__ + 1] call CBA_fnc_error -#define ERROR_WITH_TITLE_1(TITLE,MESSAGE,ARG1) ERROR_WITH_TITLE(TITLE,FORMAT_1(MESSAGE,ARG1)) -#define ERROR_WITH_TITLE_2(TITLE,MESSAGE,ARG1,ARG2) ERROR_WITH_TITLE(TITLE,FORMAT_2(MESSAGE,ARG1,ARG2)) -#define ERROR_WITH_TITLE_3(TITLE,MESSAGE,ARG1,ARG2,ARG3) ERROR_WITH_TITLE(TITLE,FORMAT_3(MESSAGE,ARG1,ARG2,ARG3)) -#define ERROR_WITH_TITLE_4(TITLE,MESSAGE,ARG1,ARG2,ARG3,ARG4) ERROR_WITH_TITLE(TITLE,FORMAT_4(MESSAGE,ARG1,ARG2,ARG3,ARG4)) -#define ERROR_WITH_TITLE_5(TITLE,MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5) ERROR_WITH_TITLE(TITLE,FORMAT_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5)) -#define ERROR_WITH_TITLE_6(TITLE,MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6) ERROR_WITH_TITLE(TITLE,FORMAT_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6)) -#define ERROR_WITH_TITLE_7(TITLE,MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7) ERROR_WITH_TITLE(TITLE,FORMAT_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7)) -#define ERROR_WITH_TITLE_8(TITLE,MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8) ERROR_WITH_TITLE(TITLE,FORMAT_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8)) - -/* ------------------------------------------- -Macro: MESSAGE_WITH_TITLE() - Record a single line in the RPT log. - -Parameters: - TITLE - Title of log message - MESSAGE - Body of message - -Example: - (begin example) - MESSAGE_WITH_TITLE("Value found","Value of frog found in config "); - (end) - -Author: - Killswitch -------------------------------------------- */ -#define MESSAGE_WITH_TITLE(TITLE,MESSAGE) LOG_SYS_FILELINENUMBERS(TITLE,MESSAGE) - -/* ------------------------------------------- -Macro: RETDEF() - If a variable is undefined, return the default value. Otherwise, return the - variable itself. - -Parameters: - VARIABLE - the variable to check - DEFAULT_VALUE - the default value to use if variable is undefined - -Example: - (begin example) - // _var is undefined - hintSilent format ["_var=%1", RETDEF(_var,5)]; // "_var=5" - _var = 7; - hintSilent format ["_var=%1", RETDEF(_var,5)]; // "_var=7" - (end example) -Author: - 654wak654 -------------------------------------------- */ -#define RETDEF(VARIABLE,DEFAULT_VALUE) (if (isNil {VARIABLE}) then [{DEFAULT_VALUE}, {VARIABLE}]) - -/* ------------------------------------------- -Macro: RETNIL() - If a variable is undefined, return the value nil. Otherwise, return the - variable itself. - -Parameters: - VARIABLE - the variable to check - -Example: - (begin example) - // _var is undefined - hintSilent format ["_var=%1", RETNIL(_var)]; // "_var=any" - (end example) - -Author: - Alef (see CBA issue #8514) -------------------------------------------- */ -#define RETNIL(VARIABLE) RETDEF(VARIABLE,nil) - -/* ------------------------------------------- -Macros: TRACE_n() - Log a message and 1-8 variables to the RPT log. - - Only run if is defined. - - TRACE_1(MESSAGE,A) - Log 1 variable. - TRACE_2(MESSAGE,A,B) - Log 2 variables. - TRACE_3(MESSAGE,A,B,C) - Log 3 variables. - TRACE_4(MESSAGE,A,B,C,D) - Log 4 variables. - TRACE_5(MESSAGE,A,B,C,D,E) - Log 5 variables. - TRACE_6(MESSAGE,A,B,C,D,E,F) - Log 6 variables. - TRACE_7(MESSAGE,A,B,C,D,E,F,G) - Log 7 variables. - TRACE_8(MESSAGE,A,B,C,D,E,F,G,H) - Log 8 variables. - TRACE_9(MESSAGE,A,B,C,D,E,F,G,H,I) - Log 9 variables. - -Parameters: - MESSAGE - Message to add to the trace [String] - A..H - Variable names to log values of [Any] - -Example: - (begin example) - TRACE_3("After takeoff",_vehicle player,getPos (_vehicle player), getPosASL (_vehicle player)); - (end) - -Author: - Spooner -------------------------------------------- */ -#define PFORMAT_1(MESSAGE,A) \ - format ['%1: A=%2', MESSAGE, RETNIL(A)] - -#define PFORMAT_2(MESSAGE,A,B) \ - format ['%1: A=%2, B=%3', MESSAGE, RETNIL(A), RETNIL(B)] - -#define PFORMAT_3(MESSAGE,A,B,C) \ - format ['%1: A=%2, B=%3, C=%4', MESSAGE, RETNIL(A), RETNIL(B), RETNIL(C)] - -#define PFORMAT_4(MESSAGE,A,B,C,D) \ - format ['%1: A=%2, B=%3, C=%4, D=%5', MESSAGE, RETNIL(A), RETNIL(B), RETNIL(C), RETNIL(D)] - -#define PFORMAT_5(MESSAGE,A,B,C,D,E) \ - format ['%1: A=%2, B=%3, C=%4, D=%5, E=%6', MESSAGE, RETNIL(A), RETNIL(B), RETNIL(C), RETNIL(D), RETNIL(E)] - -#define PFORMAT_6(MESSAGE,A,B,C,D,E,F) \ - format ['%1: A=%2, B=%3, C=%4, D=%5, E=%6, F=%7', MESSAGE, RETNIL(A), RETNIL(B), RETNIL(C), RETNIL(D), RETNIL(E), RETNIL(F)] - -#define PFORMAT_7(MESSAGE,A,B,C,D,E,F,G) \ - format ['%1: A=%2, B=%3, C=%4, D=%5, E=%6, F=%7, G=%8', MESSAGE, RETNIL(A), RETNIL(B), RETNIL(C), RETNIL(D), RETNIL(E), RETNIL(F), RETNIL(G)] - -#define PFORMAT_8(MESSAGE,A,B,C,D,E,F,G,H) \ - format ['%1: A=%2, B=%3, C=%4, D=%5, E=%6, F=%7, G=%8, H=%9', MESSAGE, RETNIL(A), RETNIL(B), RETNIL(C), RETNIL(D), RETNIL(E), RETNIL(F), RETNIL(G), RETNIL(H)] - -#define PFORMAT_9(MESSAGE,A,B,C,D,E,F,G,H,I) \ - format ['%1: A=%2, B=%3, C=%4, D=%5, E=%6, F=%7, G=%8, H=%9, I=%10', MESSAGE, RETNIL(A), RETNIL(B), RETNIL(C), RETNIL(D), RETNIL(E), RETNIL(F), RETNIL(G), RETNIL(H), RETNIL(I)] - - -#ifdef DEBUG_MODE_FULL -#define TRACE_1(MESSAGE,A) LOG_SYS_FILELINENUMBERS('TRACE',PFORMAT_1(str diag_frameNo + ' ' + (MESSAGE),A)) -#define TRACE_2(MESSAGE,A,B) LOG_SYS_FILELINENUMBERS('TRACE',PFORMAT_2(str diag_frameNo + ' ' + (MESSAGE),A,B)) -#define TRACE_3(MESSAGE,A,B,C) LOG_SYS_FILELINENUMBERS('TRACE',PFORMAT_3(str diag_frameNo + ' ' + (MESSAGE),A,B,C)) -#define TRACE_4(MESSAGE,A,B,C,D) LOG_SYS_FILELINENUMBERS('TRACE',PFORMAT_4(str diag_frameNo + ' ' + (MESSAGE),A,B,C,D)) -#define TRACE_5(MESSAGE,A,B,C,D,E) LOG_SYS_FILELINENUMBERS('TRACE',PFORMAT_5(str diag_frameNo + ' ' + (MESSAGE),A,B,C,D,E)) -#define TRACE_6(MESSAGE,A,B,C,D,E,F) LOG_SYS_FILELINENUMBERS('TRACE',PFORMAT_6(str diag_frameNo + ' ' + (MESSAGE),A,B,C,D,E,F)) -#define TRACE_7(MESSAGE,A,B,C,D,E,F,G) LOG_SYS_FILELINENUMBERS('TRACE',PFORMAT_7(str diag_frameNo + ' ' + (MESSAGE),A,B,C,D,E,F,G)) -#define TRACE_8(MESSAGE,A,B,C,D,E,F,G,H) LOG_SYS_FILELINENUMBERS('TRACE',PFORMAT_8(str diag_frameNo + ' ' + (MESSAGE),A,B,C,D,E,F,G,H)) -#define TRACE_9(MESSAGE,A,B,C,D,E,F,G,H,I) LOG_SYS_FILELINENUMBERS('TRACE',PFORMAT_9(str diag_frameNo + ' ' + (MESSAGE),A,B,C,D,E,F,G,H,I)) -#else -#define TRACE_1(MESSAGE,A) /* disabled */ -#define TRACE_2(MESSAGE,A,B) /* disabled */ -#define TRACE_3(MESSAGE,A,B,C) /* disabled */ -#define TRACE_4(MESSAGE,A,B,C,D) /* disabled */ -#define TRACE_5(MESSAGE,A,B,C,D,E) /* disabled */ -#define TRACE_6(MESSAGE,A,B,C,D,E,F) /* disabled */ -#define TRACE_7(MESSAGE,A,B,C,D,E,F,G) /* disabled */ -#define TRACE_8(MESSAGE,A,B,C,D,E,F,G,H) /* disabled */ -#define TRACE_9(MESSAGE,A,B,C,D,E,F,G,H,I) /* disabled */ -#endif - -/* ------------------------------------------- -Group: General -------------------------------------------- */ - -// ************************************* -// Internal Functions -#define DOUBLES(var1,var2) ##var1##_##var2 -#define TRIPLES(var1,var2,var3) ##var1##_##var2##_##var3 -#define QUOTE(var1) #var1 - -#ifdef MODULAR - #define COMPONENT_T DOUBLES(t,COMPONENT) - #define COMPONENT_M DOUBLES(m,COMPONENT) - #define COMPONENT_S DOUBLES(s,COMPONENT) - #define COMPONENT_C DOUBLES(c,COMPONENT) - #define COMPONENT_F COMPONENT_C -#else - #define COMPONENT_T COMPONENT - #define COMPONENT_M COMPONENT - #define COMPONENT_S COMPONENT - #define COMPONENT_F COMPONENT - #define COMPONENT_C COMPONENT -#endif - -/* ------------------------------------------- -Macro: INC() - -Description: - Increase a number by one. - -Parameters: - VAR - Variable to increment [Number] - -Example: - (begin example) - _counter = 0; - INC(_counter); - // _counter => 1 - (end) - -Author: - Spooner -------------------------------------------- */ -#define INC(var) var = (var) + 1 - -/* ------------------------------------------- -Macro: DEC() - -Description: - Decrease a number by one. - -Parameters: - VAR - Variable to decrement [Number] - -Example: - (begin example) - _counter = 99; - DEC(_counter); - // _counter => 98 - (end) - -Author: - Spooner -------------------------------------------- */ -#define DEC(var) var = (var) - 1 - -/* ------------------------------------------- -Macro: ADD() - -Description: - Add a value to a variable. Variable and value should be both Numbers or both Strings. - -Parameters: - VAR - Variable to add to [Number or String] - VALUE - Value to add [Number or String] - -Examples: - (begin example) - _counter = 2; - ADD(_counter,3); - // _counter => 5 - (end) - (begin example) - _str = "hello"; - ADD(_str," "); - ADD(_str,"Fred"); - // _str => "hello Fred" - (end) - -Author: - Sickboy -------------------------------------------- */ -#define ADD(var1,var2) var1 = (var1) + (var2) - -/* ------------------------------------------- -Macro: SUB() - -Description: - Subtract a value from a number variable. VAR and VALUE should both be Numbers. - -Parameters: - VAR - Variable to subtract from [Number] - VALUE - Value to subtract [Number] - -Examples: - (begin example) - _numChickens = 2; - SUB(_numChickens,3); - // _numChickens => -1 - (end) -------------------------------------------- */ -#define SUB(var1,var2) var1 = (var1) - (var2) - -/* ------------------------------------------- -Macro: REM() - -Description: - Remove an element from an array each time it occurs. - - This recreates the entire array, so use BIS_fnc_removeIndex if modification of the original array is required - or if only one of the elements that matches ELEMENT needs to be removed. - -Parameters: - ARRAY - Array to modify [Array] - ELEMENT - Element to remove [Any] - -Examples: - (begin example) - _array = [1, 2, 3, 4, 3, 8]; - REM(_array,3); - // _array = [1, 2, 4, 8]; - (end) - -Author: - Spooner -------------------------------------------- */ -#define REM(var1,var2) SUB(var1,[var2]) - -/* ------------------------------------------- -Macro: PUSH() - -Description: - Appends a single value onto the end of an ARRAY. Change is made to the ARRAY itself, not creating a new array. - -Parameters: - ARRAY - Array to push element onto [Array] - ELEMENT - Element to push [Any] - -Examples: - (begin example) - _fish = ["blue", "green", "smelly"]; - PUSH(_fish,"monkey-flavoured"); - // _fish => ["blue", "green", "smelly", "monkey-flavoured"] - (end) - -Author: - Spooner -------------------------------------------- */ -#define PUSH(var1,var2) (var1) pushBack (var2) - -/* ------------------------------------------- -Macro: MAP() -Description: - Applies given code to each element of the array, then assigns the - resulting array to the original -Parameters: - ARRAY - Array to be modified - CODE - Code that'll be applied to each element of the array. -Example: - (begin example) - _array = [1, 2, 3, 4, 3, 8]; - MAP(_array,_x + 1); - // _array is now [2, 3, 4, 5, 4, 9]; - (end) -Author: - 654wak654 -------------------------------------------- */ -#define MAP(ARR,CODE) ARR = ARR apply {CODE} - -/* ------------------------------------------- -Macro: FILTER() -Description: - Filters an array based on given code, then assigns the resulting array - to the original -Parameters: - ARRAY - Array to be filtered - CODE - Condition to pick elements -Example: - (begin example) - _array = [1, 2, 3, 4, 3, 8]; - FILTER(_array,_x % 2 == 0) - // _array is now [2, 4, 8]; - (end) -Author: - Commy2 -------------------------------------------- */ -#define FILTER(ARR,CODE) ARR = ARR select {CODE} - -/* ------------------------------------------- -Macro: UNIQUE() -Description: - Removes duplicate values in given array -Parameters: - ARRAY - The array to be modified -Example: - (begin example) - _someArray = [4, 4, 5, 5, 5, 2]; - UNIQUE(_someArray); - // _someArray is now [4, 5, 2] - (end) -Author: - Commy2 -------------------------------------------- */ -#define UNIQUE(ARR) ARR = ARR arrayIntersect ARR - -/* ------------------------------------------- -Macro: INTERSECTION() -Description: - Finds unique common elements between two arrays and assigns them - to the first array -Parameters: - ARRAY0 - The array to be modified - ARRAY1 - The array to find intersections with -Example: - (begin example) - _someArray = [1, 2, 3, 4, 5, 5]; - _anotherArray = [4, 5, 6, 7]; - INTERSECTION(_someArray,_anotherArray); - // _someArray is now [4, 5] - (end) -Author: - 654wak654 -------------------------------------------- */ -#define INTERSECTION(ARG0,ARG1) ARG0 = ARG0 arrayIntersect (ARG1) - -/* ------------------------------------------- -Macro: ISNILS() - -Description: - Sets a variable with a value, but only if it is undefined. - -Parameters: - VARIABLE - Variable to set [Any, not nil] - DEFAULT_VALUE - Value to set VARIABLE to if it is undefined [Any, not nil] - -Examples: - (begin example) - // _fish is undefined - ISNILS(_fish,0); - // _fish => 0 - (end) - (begin example) - _fish = 12; - // ...later... - ISNILS(_fish,0); - // _fish => 12 - (end) - -Author: - Sickboy -------------------------------------------- */ -#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 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 -#endif -#ifndef PATHTOF_SYS - #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 -#endif - -#define PATHTO_R(var1) PATHTOF2_SYS(PREFIX,COMPONENT_C,var1) -#define PATHTO_T(var1) PATHTOF_SYS(PREFIX,COMPONENT_T,var1) -#define PATHTO_M(var1) PATHTOF_SYS(PREFIX,COMPONENT_M,var1) -#define PATHTO_S(var1) PATHTOF_SYS(PREFIX,COMPONENT_S,var1) -#define PATHTO_C(var1) PATHTOF_SYS(PREFIX,COMPONENT_C,var1) -#define PATHTO_F(var1) PATHTO_SYS(PREFIX,COMPONENT_F,var1) - -// Already quoted "" -#define QPATHTO_R(var1) QUOTE(PATHTO_R(var1)) -#define QPATHTO_T(var1) QUOTE(PATHTO_T(var1)) -#define QPATHTO_M(var1) QUOTE(PATHTO_M(var1)) -#define QPATHTO_S(var1) QUOTE(PATHTO_S(var1)) -#define QPATHTO_C(var1) QUOTE(PATHTO_C(var1)) -#define QPATHTO_F(var1) QUOTE(PATHTO_F(var1)) - -// 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_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 SETVARMAINS(var1) SETVARS(var1,MAINLOGIC) -#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 = - -// Compile-Once, JIT: On first use. -// #define PREPMAIN_SYS(var1,var2,var3) ##var1##_fnc_##var3 = { ##var1##_fnc_##var3 = COMPILE_FILE_SYS(var1,var2,DOUBLES(fnc,var3)); if (isNil "_this") then { call ##var1##_fnc_##var3 } else { _this call ##var1##_fnc_##var3 } } -// #define PREP_SYS(var1,var2,var3) ##var1##_##var2##_fnc_##var3 = { ##var1##_##var2##_fnc_##var3 = COMPILE_FILE_SYS(var1,var2,DOUBLES(fnc,var3)); if (isNil "_this") then { call ##var1##_##var2##_fnc_##var3 } else { _this call ##var1##_##var2##_fnc_##var3 } } -// #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 LSTR(var1) TRIPLES(ADDON,STR,var1) - -#ifndef DEBUG_SETTINGS - #define DEBUG_SETTINGS [false, true, false] -#endif - -#define MSG_INIT QUOTE(Initializing: ADDON version: VERSION) - -// ************************************* -// User Functions -#define CFGSETTINGS CFGSETTINGSS(PREFIX,COMPONENT) -#define PATHTO(var1) PATHTO_SYS(PREFIX,COMPONENT_F,var1) -#define PATHTOF(var1) PATHTOF_SYS(PREFIX,COMPONENT,var1) -#define PATHTOEF(var1,var2) PATHTOF_SYS(PREFIX,var1,var2) -#define QPATHTOF(var1) QUOTE(PATHTOF(var1)) -#define QPATHTOEF(var1,var2) QUOTE(PATHTOEF(var1,var2)) - -#define COMPILE_FILE(var1) COMPILE_FILE_SYS(PREFIX,COMPONENT_F,var1) -#define COMPILE_FILE_CFG(var1) COMPILE_FILE_CFG_SYS(PREFIX,COMPONENT_F,var1) -#define COMPILE_FILE2(var1) COMPILE_FILE2_SYS('var1') -#define COMPILE_FILE2_CFG(var1) COMPILE_FILE2_CFG_SYS('var1') - - -#define VERSIONING_SYS(var1) class CfgSettings \ -{ \ - class CBA \ - { \ - class Versioning \ - { \ - class var1 \ - { \ - }; \ - }; \ - }; \ -}; - -#define VERSIONING VERSIONING_SYS(PREFIX) - -/* ------------------------------------------- -Macro: GVAR() - Get full variable identifier for a global variable owned by this component. - -Parameters: - VARIABLE - Partial name of global variable owned by this component [Any]. - -Example: - (begin example) - GVAR(frog) = 12; - // In SPON_FrogDancing component, equivalent to SPON_FrogDancing_frog = 12 - (end) - -Author: - Sickboy -------------------------------------------- */ -#define GVAR(var1) DOUBLES(ADDON,var1) -#define EGVAR(var1,var2) TRIPLES(PREFIX,var1,var2) -#define QGVAR(var1) QUOTE(GVAR(var1)) -#define QEGVAR(var1,var2) QUOTE(EGVAR(var1,var2)) -#define QQGVAR(var1) QUOTE(QGVAR(var1)) -#define QQEGVAR(var1,var2) QUOTE(QEGVAR(var1,var2)) - -/* ------------------------------------------- -Macro: GVARMAIN() - Get full variable identifier for a global variable owned by this addon. - -Parameters: - VARIABLE - Partial name of global variable owned by this addon [Any]. - -Example: - (begin example) - GVARMAIN(frog) = 12; - // In SPON_FrogDancing component, equivalent to SPON_frog = 12 - (end) - -Author: - Sickboy -------------------------------------------- */ -#define GVARMAIN(var1) GVARMAINS(PREFIX,var1) -#define QGVARMAIN(var1) QUOTE(GVARMAIN(var1)) -#define QQGVARMAIN(var1) QUOTE(QGVARMAIN(var1)) -// TODO: What's this? -#define SETTINGS DOUBLES(PREFIX,settings) -#define CREATELOGIC CREATELOGICS(PREFIX,COMPONENT) -#define CREATELOGICGLOBAL CREATELOGICGLOBALS(PREFIX,COMPONENT) -#define CREATELOGICGLOBALTEST CREATELOGICGLOBALTESTS(PREFIX,COMPONENT) -#define CREATELOGICLOCAL CREATELOGICLOCALS(PREFIX,COMPONENT) -#define CREATELOGICMAIN CREATELOGICS(PREFIX,MAINLOGIC) -#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 PREP(var1) PREP_SYS(PREFIX,COMPONENT_F,var1) - -#ifdef DISABLE_COMPILE_CACHE - #define PREP(var1) TRIPLES(ADDON,fnc,var1) = compile preProcessFileLineNumbers 'PATHTO_SYS(PREFIX,COMPONENT_F,DOUBLES(fnc,var1))' - #define PREPMAIN(var1) TRIPLES(PREFIX,fnc,var1) = compile preProcessFileLineNumbers 'PATHTO_SYS(PREFIX,COMPONENT_F,DOUBLES(fnc,var1))' -#else - #define PREP(var1) ['PATHTO_SYS(PREFIX,COMPONENT_F,DOUBLES(fnc,var1))', 'TRIPLES(ADDON,fnc,var1)'] call SLX_XEH_COMPILE_NEW - #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() - -Description: - Defines a function inside CfgFunctions. - - Full file path in addons: - '\MAINPREFIX\PREFIX\SUBPREFIX\COMPONENT\fnc_.sqf' - Define 'RECOMPILE' to enable recompiling. - -Parameters: - FUNCTION NAME - Name of the function, unquoted - -Examples: - (begin example) - // file name: fnc_addPerFrameHandler.sqf - class CfgFunctions { - class CBA { - class Misc { - PATHTO_FNC(addPerFrameHandler); - }; - }; - }; - // -> CBA_fnc_addPerFrameHandler - (end) - -Author: - dixon13, commy2 - ------------------------------------------- */ -#define PATHTO_FNC(func) class func {\ - file = QPATHTOF(DOUBLES(fnc,func).sqf);\ - RECOMPILE;\ -} - -#define FUNC(var1) TRIPLES(ADDON,fnc,var1) -#define FUNCMAIN(var1) TRIPLES(PREFIX,fnc,var1) -#define FUNC_INNER(var1,var2) TRIPLES(DOUBLES(PREFIX,var1),fnc,var2) -#define EFUNC(var1,var2) FUNC_INNER(var1,var2) -#define QFUNC(var1) QUOTE(FUNC(var1)) -#define QFUNCMAIN(var1) QUOTE(FUNCMAIN(var1)) -#define QFUNC_INNER(var1,var2) QUOTE(FUNC_INNER(var1,var2)) -#define QEFUNC(var1,var2) QUOTE(EFUNC(var1,var2)) -#define QQFUNC(var1) QUOTE(QFUNC(var1)) -#define QQFUNCMAIN(var1) QUOTE(QFUNCMAIN(var1)) -#define QQFUNC_INNER(var1,var2) QUOTE(QFUNC_INNER(var1,var2)) -#define QQEFUNC(var1,var2) QUOTE(QEFUNC(var1,var2)) - -#ifndef PRELOAD_ADDONS - #define PRELOAD_ADDONS class CfgAddons \ -{ \ - class PreloadAddons \ - { \ - class ADDON \ - { \ - list[]={ QUOTE(ADDON) }; \ - }; \ - }; \ -} -#endif - -/* ------------------------------------------- -Macros: ARG_#() - Select from list of array arguments - -Parameters: - VARIABLE(1-8) - elements for the list - -Author: - Rommel -------------------------------------------- */ -#define ARG_1(A,B) ((A) select (B)) -#define ARG_2(A,B,C) (ARG_1(ARG_1(A,B),C)) -#define ARG_3(A,B,C,D) (ARG_1(ARG_2(A,B,C),D)) -#define ARG_4(A,B,C,D,E) (ARG_1(ARG_3(A,B,C,D),E)) -#define ARG_5(A,B,C,D,E,F) (ARG_1(ARG_4(A,B,C,D,E),F)) -#define ARG_6(A,B,C,D,E,F,G) (ARG_1(ARG_5(A,B,C,D,E,F),G)) -#define ARG_7(A,B,C,D,E,F,G,H) (ARG_1(ARG_6(A,B,C,D,E,E,F,G),H)) -#define ARG_8(A,B,C,D,E,F,G,H,I) (ARG_1(ARG_7(A,B,C,D,E,E,F,G,H),I)) - -/* ------------------------------------------- -Macros: ARR_#() - Create list from arguments. Useful for working around , in macro parameters. - 1-8 arguments possible. - -Parameters: - VARIABLE(1-8) - elements for the list - -Author: - Nou -------------------------------------------- */ -#define ARR_1(ARG1) ARG1 -#define ARR_2(ARG1,ARG2) ARG1, ARG2 -#define ARR_3(ARG1,ARG2,ARG3) ARG1, ARG2, ARG3 -#define ARR_4(ARG1,ARG2,ARG3,ARG4) ARG1, ARG2, ARG3, ARG4 -#define ARR_5(ARG1,ARG2,ARG3,ARG4,ARG5) ARG1, ARG2, ARG3, ARG4, ARG5 -#define ARR_6(ARG1,ARG2,ARG3,ARG4,ARG5,ARG6) ARG1, ARG2, ARG3, ARG4, ARG5, ARG6 -#define ARR_7(ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7) ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7 -#define ARR_8(ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8) ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7, ARG8 - -/* ------------------------------------------- -Macros: FORMAT_#(STR, ARG1) - Format - Useful for working around , in macro parameters. - 1-8 arguments possible. - -Parameters: - STRING - string used by format - VARIABLE(1-8) - elements for usage in format - -Author: - Nou & Sickboy -------------------------------------------- */ -#define FORMAT_1(STR,ARG1) format[STR, ARG1] -#define FORMAT_2(STR,ARG1,ARG2) format[STR, ARG1, ARG2] -#define FORMAT_3(STR,ARG1,ARG2,ARG3) format[STR, ARG1, ARG2, ARG3] -#define FORMAT_4(STR,ARG1,ARG2,ARG3,ARG4) format[STR, ARG1, ARG2, ARG3, ARG4] -#define FORMAT_5(STR,ARG1,ARG2,ARG3,ARG4,ARG5) format[STR, ARG1, ARG2, ARG3, ARG4, ARG5] -#define FORMAT_6(STR,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6) format[STR, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6] -#define FORMAT_7(STR,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7) format[STR, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7] -#define FORMAT_8(STR,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8) format[STR, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7, ARG8] - -// CONTROL(46) 12 -#define DISPLAY(A) (findDisplay A) -#define CONTROL(A) DISPLAY(A) displayCtrl - -/* ------------------------------------------- -Macros: IS_x() - Checking the data types of variables. - - IS_ARRAY() - Array - IS_BOOL() - Boolean - IS_BOOLEAN() - UI display handle(synonym for ) - IS_CODE() - Code block (i.e a compiled function) - IS_CONFIG() - Configuration - IS_CONTROL() - UI control handle. - IS_DISPLAY() - UI display handle. - IS_FUNCTION() - A compiled function (synonym for ) - IS_GROUP() - Group. - IS_INTEGER() - Is a number a whole number? - IS_LOCATION() - World location. - IS_NUMBER() - A floating point number (synonym for ) - IS_OBJECT() - World object. - IS_SCALAR() - Floating point number. - IS_SCRIPT() - A script handle (as returned by execVM and spawn commands). - IS_SIDE() - Game side. - IS_STRING() - World object. - IS_TEXT() - Structured text. - -Parameters: - VARIABLE - Variable to check if it is of a particular type [Any, not nil] - -Author: - Spooner -------------------------------------------- */ -#define IS_META_SYS(VAR,TYPE) (if (isNil {VAR}) then {false} else {(VAR) isEqualType TYPE}) -#define IS_ARRAY(VAR) IS_META_SYS(VAR,[]) -#define IS_BOOL(VAR) IS_META_SYS(VAR,false) -#define IS_CODE(VAR) IS_META_SYS(VAR,{}) -#define IS_CONFIG(VAR) IS_META_SYS(VAR,configNull) -#define IS_CONTROL(VAR) IS_META_SYS(VAR,controlNull) -#define IS_DISPLAY(VAR) IS_META_SYS(VAR,displayNull) -#define IS_GROUP(VAR) IS_META_SYS(VAR,grpNull) -#define IS_OBJECT(VAR) IS_META_SYS(VAR,objNull) -#define IS_SCALAR(VAR) IS_META_SYS(VAR,0) -#define IS_SCRIPT(VAR) IS_META_SYS(VAR,scriptNull) -#define IS_SIDE(VAR) IS_META_SYS(VAR,west) -#define IS_STRING(VAR) IS_META_SYS(VAR,"STRING") -#define IS_TEXT(VAR) IS_META_SYS(VAR,text "") -#define IS_LOCATION(VAR) IS_META_SYS(VAR,locationNull) - -#define IS_BOOLEAN(VAR) IS_BOOL(VAR) -#define IS_FUNCTION(VAR) IS_CODE(VAR) -#define IS_INTEGER(VAR) (if (IS_SCALAR(VAR)) then {floor (VAR) == (VAR)} else {false}) -#define IS_NUMBER(VAR) IS_SCALAR(VAR) - -#define FLOAT_TO_STRING(num) (if (_this == 0) then {"0"} else {str parseNumber (str (_this % _this) + str floor abs _this) + "." + (str (abs _this - floor abs _this) select [2]) + "0"}) - -/* ------------------------------------------- -Macro: SCRIPT() - Sets name of script (relies on PREFIX and COMPONENT values being #defined). - -Parameters: - NAME - Name of script [Indentifier] - -Example: - (begin example) - SCRIPT(eradicateMuppets); - (end) - -Author: - Spooner -------------------------------------------- */ -#define SCRIPT(NAME) \ - scriptName 'PREFIX\COMPONENT\NAME' - -/* ------------------------------------------- -Macros: EXPLODE_n() - DEPRECATED - Use param/params commands added in Arma 3 1.48 - - Splitting an ARRAY into a number of variables (A, B, C, etc). - - Note that this NOT does make the created variables private. - _PVT variants do. - - EXPLODE_1(ARRAY,A,B) - Split a 1-element array into separate variable. - EXPLODE_2(ARRAY,A,B) - Split a 2-element array into separate variables. - EXPLODE_3(ARRAY,A,B,C) - Split a 3-element array into separate variables. - EXPLODE_4(ARRAY,A,B,C,D) - Split a 4-element array into separate variables. - EXPLODE_5(ARRAY,A,B,C,D,E) - Split a 5-element array into separate variables. - EXPLODE_6(ARRAY,A,B,C,D,E,F) - Split a 6-element array into separate variables. - EXPLODE_7(ARRAY,A,B,C,D,E,F,G) - Split a 7-element array into separate variables. - EXPLODE_8(ARRAY,A,B,C,D,E,F,G,H) - Split a 8-element array into separate variables. - EXPLODE_9(ARRAY,A,B,C,D,E,F,G,H,I) - Split a 9-element array into separate variables. - -Parameters: - ARRAY - Array to read from [Array] - A..H - Names of variables to set from array [Identifier] - -Example: - (begin example) - _array = ["fred", 156.8, 120.9]; - EXPLODE_3(_array,_name,_height,_weight); - (end) - -Author: - Spooner -------------------------------------------- */ -#define EXPLODE_1_SYS(ARRAY,A) A = ARRAY param [0] -#define EXPLODE_1(ARRAY,A) EXPLODE_1_SYS(ARRAY,A); TRACE_1("EXPLODE_1, " + QUOTE(ARRAY),A) -#define EXPLODE_1_PVT(ARRAY,A) ARRAY params [#A]; TRACE_1("EXPLODE_1, " + QUOTE(ARRAY),A) - -#define EXPLODE_2_SYS(ARRAY,A,B) EXPLODE_1_SYS(ARRAY,A); B = ARRAY param [1] -#define EXPLODE_2(ARRAY,A,B) EXPLODE_2_SYS(ARRAY,A,B); TRACE_2("EXPLODE_2, " + QUOTE(ARRAY),A,B) -#define EXPLODE_2_PVT(ARRAY,A,B) ARRAY params [#A,#B]; TRACE_2("EXPLODE_2, " + QUOTE(ARRAY),A,B) - -#define EXPLODE_3_SYS(ARRAY,A,B,C) EXPLODE_2_SYS(ARRAY,A,B); C = ARRAY param [2] -#define EXPLODE_3(ARRAY,A,B,C) EXPLODE_3_SYS(ARRAY,A,B,C); TRACE_3("EXPLODE_3, " + QUOTE(ARRAY),A,B,C) -#define EXPLODE_3_PVT(ARRAY,A,B,C) ARRAY params [#A,#B,#C]; TRACE_3("EXPLODE_3, " + QUOTE(ARRAY),A,B,C) - -#define EXPLODE_4_SYS(ARRAY,A,B,C,D) EXPLODE_3_SYS(ARRAY,A,B,C); D = ARRAY param [3] -#define EXPLODE_4(ARRAY,A,B,C,D) EXPLODE_4_SYS(ARRAY,A,B,C,D); TRACE_4("EXPLODE_4, " + QUOTE(ARRAY),A,B,C,D) -#define EXPLODE_4_PVT(ARRAY,A,B,C,D) ARRAY params [#A,#B,#C,#D]; TRACE_4("EXPLODE_4, " + QUOTE(ARRAY),A,B,C,D) - -#define EXPLODE_5_SYS(ARRAY,A,B,C,D,E) EXPLODE_4_SYS(ARRAY,A,B,C,D); E = ARRAY param [4] -#define EXPLODE_5(ARRAY,A,B,C,D,E) EXPLODE_5_SYS(ARRAY,A,B,C,D,E); TRACE_5("EXPLODE_5, " + QUOTE(ARRAY),A,B,C,D,E) -#define EXPLODE_5_PVT(ARRAY,A,B,C,D,E) ARRAY params [#A,#B,#C,#D,#E]; TRACE_5("EXPLODE_5, " + QUOTE(ARRAY),A,B,C,D,E) - -#define EXPLODE_6_SYS(ARRAY,A,B,C,D,E,F) EXPLODE_5_SYS(ARRAY,A,B,C,D,E); F = ARRAY param [5] -#define EXPLODE_6(ARRAY,A,B,C,D,E,F) EXPLODE_6_SYS(ARRAY,A,B,C,D,E,F); TRACE_6("EXPLODE_6, " + QUOTE(ARRAY),A,B,C,D,E,F) -#define EXPLODE_6_PVT(ARRAY,A,B,C,D,E,F) ARRAY params [#A,#B,#C,#D,#E,#F]; TRACE_6("EXPLODE_6, " + QUOTE(ARRAY),A,B,C,D,E,F) - -#define EXPLODE_7_SYS(ARRAY,A,B,C,D,E,F,G) EXPLODE_6_SYS(ARRAY,A,B,C,D,E,F); G = ARRAY param [6] -#define EXPLODE_7(ARRAY,A,B,C,D,E,F,G) EXPLODE_7_SYS(ARRAY,A,B,C,D,E,F,G); TRACE_7("EXPLODE_7, " + QUOTE(ARRAY),A,B,C,D,E,F,G) -#define EXPLODE_7_PVT(ARRAY,A,B,C,D,E,F,G) ARRAY params [#A,#B,#C,#D,#E,#F,#G]; TRACE_7("EXPLODE_7, " + QUOTE(ARRAY),A,B,C,D,E,F,G) - -#define EXPLODE_8_SYS(ARRAY,A,B,C,D,E,F,G,H) EXPLODE_7_SYS(ARRAY,A,B,C,D,E,F,G); H = ARRAY param [7] -#define EXPLODE_8(ARRAY,A,B,C,D,E,F,G,H) EXPLODE_8_SYS(ARRAY,A,B,C,D,E,F,G,H); TRACE_8("EXPLODE_8, " + QUOTE(ARRAY),A,B,C,D,E,F,G,H) -#define EXPLODE_8_PVT(ARRAY,A,B,C,D,E,F,G,H) ARRAY params [#A,#B,#C,#D,#E,#F,#G,#H]; TRACE_8("EXPLODE_8, " + QUOTE(ARRAY),A,B,C,D,E,F,G,H) - -#define EXPLODE_9_SYS(ARRAY,A,B,C,D,E,F,G,H,I) EXPLODE_8_SYS(ARRAY,A,B,C,D,E,F,G,H); I = ARRAY param [8] -#define EXPLODE_9(ARRAY,A,B,C,D,E,F,G,H,I) EXPLODE_9_SYS(ARRAY,A,B,C,D,E,F,G,H,I); TRACE_9("EXPLODE_9, " + QUOTE(ARRAY),A,B,C,D,E,F,G,H,I) -#define EXPLODE_9_PVT(ARRAY,A,B,C,D,E,F,G,H,I) ARRAY params [#A,#B,#C,#D,#E,#F,#G,#H,#I]; TRACE_9("EXPLODE_9, " + QUOTE(ARRAY),A,B,C,D,E,F,G,H,I) - -/* ------------------------------------------- -Macro: xSTRING() - Get full string identifier from a stringtable owned by this component. - -Parameters: - VARIABLE - Partial name of global variable owned by this component [Any]. - -Example: - ADDON is CBA_Balls. - (begin example) - // Localized String (localize command must still be used with it) - LSTRING(Example); // STR_CBA_Balls_Example; - // Config String (note the $) - CSTRING(Example); // $STR_CBA_Balls_Example; - (end) - -Author: - Jonpas -------------------------------------------- */ -#ifndef STRING_MACROS_GUARD -#define STRING_MACROS_GUARD - #define LSTRING(var1) QUOTE(TRIPLES(STR,ADDON,var1)) - #define ELSTRING(var1,var2) QUOTE(TRIPLES(STR,DOUBLES(PREFIX,var1),var2)) - #define CSTRING(var1) QUOTE(TRIPLES($STR,ADDON,var1)) - #define ECSTRING(var1,var2) QUOTE(TRIPLES($STR,DOUBLES(PREFIX,var1),var2)) - - #define LLSTRING(var1) localize QUOTE(TRIPLES(STR,ADDON,var1)) - #define LELSTRING(var1,var2) localize QUOTE(TRIPLES(STR,DOUBLES(PREFIX,var1),var2)) -#endif - - -/* ------------------------------------------- -Group: Managing Function Parameters -------------------------------------------- */ - -/* ------------------------------------------- -Macros: PARAMS_n() - DEPRECATED - Use param/params commands added in Arma 3 1.48 - - Setting variables based on parameters passed to a function. - - Each parameter is defines as private and set to the appropriate value from _this. - - PARAMS_1(A) - Get 1 parameter from the _this array (or _this if it's not an array). - PARAMS_2(A,B) - Get 2 parameters from the _this array. - PARAMS_3(A,B,C) - Get 3 parameters from the _this array. - PARAMS_4(A,B,C,D) - Get 4 parameters from the _this array. - PARAMS_5(A,B,C,D,E) - Get 5 parameters from the _this array. - PARAMS_6(A,B,C,D,E,F) - Get 6 parameters from the _this array. - PARAMS_7(A,B,C,D,E,F,G) - Get 7 parameters from the _this array. - PARAMS_8(A,B,C,D,E,F,G,H) - Get 8 parameters from the _this array. - -Parameters: - A..H - Name of variable to read from _this [Identifier] - -Example: - A function called like this: - (begin example) - [_name,_address,_telephone] call recordPersonalDetails; - (end) - expects 3 parameters and those variables could be initialised at the start of the function definition with: - (begin example) - recordPersonalDetails = { - PARAMS_3(_name,_address,_telephone); - // Rest of function follows... - }; - (end) - -Author: - Spooner -------------------------------------------- */ -#define PARAMS_1(A) EXPLODE_1_PVT(_this,A) -#define PARAMS_2(A,B) EXPLODE_2_PVT(_this,A,B) -#define PARAMS_3(A,B,C) EXPLODE_3_PVT(_this,A,B,C) -#define PARAMS_4(A,B,C,D) EXPLODE_4_PVT(_this,A,B,C,D) -#define PARAMS_5(A,B,C,D,E) EXPLODE_5_PVT(_this,A,B,C,D,E) -#define PARAMS_6(A,B,C,D,E,F) EXPLODE_6_PVT(_this,A,B,C,D,E,F) -#define PARAMS_7(A,B,C,D,E,F,G) EXPLODE_7_PVT(_this,A,B,C,D,E,F,G) -#define PARAMS_8(A,B,C,D,E,F,G,H) EXPLODE_8_PVT(_this,A,B,C,D,E,F,G,H) -#define PARAMS_9(A,B,C,D,E,F,G,H,I) EXPLODE_9_PVT(_this,A,B,C,D,E,F,G,H,I) - -/* ------------------------------------------- -Macro: DEFAULT_PARAM() - DEPRECATED - Use param/params commands added in Arma 3 1.48 - - Getting a default function parameter. This may be used together with to have a mix of required and - optional parameters. - -Parameters: - INDEX - Index of parameter in _this [Integer, 0+] - NAME - Name of the variable to set [Identifier] - DEF_VALUE - Default value to use in case the array is too short or the value at INDEX is nil [Any] - -Example: - A function called with optional parameters: - (begin example) - [_name] call myFunction; - [_name, _numberOfLegs] call myFunction; - [_name, _numberOfLegs, _hasAHead] call myFunction; - (end) - 1 required parameter and 2 optional parameters. Those variables could be initialised at the start of the function - definition with: - (begin example) - myFunction = { - PARAMS_1(_name); - DEFAULT_PARAM(1,_numberOfLegs,2); - DEFAULT_PARAM(2,_hasAHead,true); - // Rest of function follows... - }; - (end) - -Author: - Spooner -------------------------------------------- */ -#define DEFAULT_PARAM(INDEX,NAME,DEF_VALUE) \ - private [#NAME,"_this"]; \ - ISNILS(_this,[]); \ - NAME = _this param [INDEX, DEF_VALUE]; \ - TRACE_3("DEFAULT_PARAM",INDEX,NAME,DEF_VALUE) - -/* ------------------------------------------- -Macro: KEY_PARAM() - Get value from key in _this list, return default when key is not included in list. - -Parameters: - KEY - Key name [String] - NAME - Name of the variable to set [Identifier] - DEF_VALUE - Default value to use in case key not found [ANY] - -Example: - - -Author: - Muzzleflash -------------------------------------------- */ -#define KEY_PARAM(KEY,NAME,DEF_VALUE) \ - private #NAME; \ - NAME = [toLower KEY, toUpper KEY, DEF_VALUE, RETNIL(_this)] call CBA_fnc_getArg; \ - TRACE_3("KEY_PARAM",KEY,NAME,DEF_VALUE) - -/* ------------------------------------------- -Group: Assertions -------------------------------------------- */ - -#define ASSERTION_ERROR(MESSAGE) ERROR_WITH_TITLE("Assertion failed!",MESSAGE) - -/* ------------------------------------------- -Macro: ASSERT_TRUE() - Asserts that a CONDITION is true. When an assertion fails, an error is raised with the given MESSAGE. - -Parameters: - CONDITION - Condition to assert as true [Boolean] - MESSSAGE - Message to display if (A OPERATOR B) is false [String] - -Example: - (begin example) - ASSERT_TRUE(_frogIsDead,"The frog is alive"); - (end) - -Author: - Spooner -------------------------------------------- */ -#define ASSERT_TRUE(CONDITION,MESSAGE) \ - if (not (CONDITION)) then \ - { \ - ASSERTION_ERROR('Assertion (CONDITION) failed!\n\n' + (MESSAGE)); \ - } - -/* ------------------------------------------- -Macro: ASSERT_FALSE() - Asserts that a CONDITION is false. When an assertion fails, an error is raised with the given MESSAGE. - -Parameters: - CONDITION - Condition to assert as false [Boolean] - MESSSAGE - Message to display if (A OPERATOR B) is true [String] - -Example: - (begin example) - ASSERT_FALSE(_frogIsDead,"The frog died"); - (end) - -Author: - Spooner -------------------------------------------- */ -#define ASSERT_FALSE(CONDITION,MESSAGE) \ - if (CONDITION) then \ - { \ - ASSERTION_ERROR('Assertion (not (CONDITION)) failed!\n\n' + (MESSAGE)) \ - } - -/* ------------------------------------------- -Macro: ASSERT_OP() - Asserts that (A OPERATOR B) is true. When an assertion fails, an error is raised with the given MESSAGE. - -Parameters: - A - First value [Any] - OPERATOR - Binary operator to use [Operator] - B - Second value [Any] - MESSSAGE - Message to display if (A OPERATOR B) is false. [String] - -Example: - (begin example) - ASSERT_OP(_fish,>,5,"Too few fish!"); - (end) - -Author: - Spooner -------------------------------------------- */ -#define ASSERT_OP(A,OPERATOR,B,MESSAGE) \ - if (not ((A) OPERATOR (B))) then \ - { \ - ASSERTION_ERROR('Assertion (A OPERATOR B) failed!\n' + 'A: ' + (str (A)) + '\n' + 'B: ' + (str (B)) + "\n\n" + (MESSAGE)); \ - } - -/* ------------------------------------------- -Macro: ASSERT_DEFINED() - Asserts that a VARIABLE is defined. When an assertion fails, an error is raised with the given MESSAGE.. - -Parameters: - VARIABLE - Variable to test if defined [String or Function]. - MESSAGE - Message to display if variable is undefined [String]. - -Examples: - (begin example) - ASSERT_DEFINED("_anUndefinedVar","Too few fish!"); - ASSERT_DEFINED({ obj getVariable "anUndefinedVar" },"Too many fish!"); - (end) - -Author: - Spooner -------------------------------------------- */ -#define ASSERT_DEFINED(VARIABLE,MESSAGE) \ - if (isNil VARIABLE) then \ - { \ - ASSERTION_ERROR('Assertion (VARIABLE is defined) failed!\n\n' + (MESSAGE)); \ - } - -/* ------------------------------------------- -Group: Unit tests -------------------------------------------- */ -#define TEST_SUCCESS(MESSAGE) MESSAGE_WITH_TITLE("Test OK",MESSAGE) -#define TEST_FAIL(MESSAGE) ERROR_WITH_TITLE("Test FAIL",MESSAGE) - -/* ------------------------------------------- -Macro: TEST_TRUE() - Tests that a CONDITION is true. - If the condition is not true, an error is raised with the given MESSAGE. - -Parameters: - CONDITION - Condition to assert as true [Boolean] - MESSSAGE - Message to display if (A OPERATOR B) is false [String] - -Example: - (begin example) - TEST_TRUE(_frogIsDead,"The frog is alive"); - (end) - -Author: - Killswitch -------------------------------------------- */ -#define TEST_TRUE(CONDITION, MESSAGE) \ - if (CONDITION) then \ - { \ - TEST_SUCCESS('(CONDITION)'); \ - } \ - else \ - { \ - TEST_FAIL('(CONDITION) ' + (MESSAGE)); \ - } - -/* ------------------------------------------- -Macro: TEST_FALSE() - Tests that a CONDITION is false. - If the condition is not false, an error is raised with the given MESSAGE. - -Parameters: - CONDITION - Condition to test as false [Boolean] - MESSSAGE - Message to display if (A OPERATOR B) is true [String] - -Example: - (begin example) - TEST_FALSE(_frogIsDead,"The frog died"); - (end) - -Author: - Killswitch -------------------------------------------- */ -#define TEST_FALSE(CONDITION, MESSAGE) \ - if (not (CONDITION)) then \ - { \ - TEST_SUCCESS('(not (CONDITION))'); \ - } \ - else \ - { \ - TEST_FAIL('(not (CONDITION)) ' + (MESSAGE)); \ - } - -/* ------------------------------------------- -Macro: TEST_OP() - Tests that (A OPERATOR B) is true. - If the test fails, an error is raised with the given MESSAGE. - -Parameters: - A - First value [Any] - OPERATOR - Binary operator to use [Operator] - B - Second value [Any] - MESSSAGE - Message to display if (A OPERATOR B) is false. [String] - -Example: - (begin example) - TEST_OP(_fish,>,5,"Too few fish!"); - (end) - -Author: - Killswitch -------------------------------------------- */ -#define TEST_OP(A,OPERATOR,B,MESSAGE) \ - if ((A) OPERATOR (B)) then \ - { \ - TEST_SUCCESS('(A OPERATOR B)') \ - } \ - else \ - { \ - TEST_FAIL('(A OPERATOR B)') \ - }; - -/* ------------------------------------------- -Macro: TEST_DEFINED_AND_OP() - Tests that A and B are defined and (A OPERATOR B) is true. - If the test fails, an error is raised with the given MESSAGE. - -Parameters: - A - First value [Any] - OPERATOR - Binary operator to use [Operator] - B - Second value [Any] - MESSSAGE - Message to display [String] - -Example: - (begin example) - TEST_OP(_fish,>,5,"Too few fish!"); - (end) - -Author: - Killswitch, PabstMirror -------------------------------------------- */ -#define TEST_DEFINED_AND_OP(A,OPERATOR,B,MESSAGE) \ - if (isNil #A) then { \ - TEST_FAIL('(A is not defined) ' + (MESSAGE)); \ - } else { \ - if (isNil #B) then { \ - TEST_FAIL('(B is not defined) ' + (MESSAGE)); \ - } else { \ - if ((A) OPERATOR (B)) then { \ - TEST_SUCCESS('(A OPERATOR B) ' + (MESSAGE)) \ - } else { \ - TEST_FAIL('(A OPERATOR B) ' + (MESSAGE)) \ - }; }; }; - - -/* ------------------------------------------- -Macro: TEST_DEFINED() - Tests that a VARIABLE is defined. - -Parameters: - VARIABLE - Variable to test if defined [String or Function]. - MESSAGE - Message to display if variable is undefined [String]. - -Examples: - (begin example) - TEST_DEFINED("_anUndefinedVar","Too few fish!"); - TEST_DEFINED({ obj getVariable "anUndefinedVar" },"Too many fish!"); - (end) - -Author: - Killswitch -------------------------------------------- */ -#define TEST_DEFINED(VARIABLE,MESSAGE) \ - if (not isNil VARIABLE) then \ - { \ - TEST_SUCCESS('(' + VARIABLE + ' is defined)'); \ - } \ - else \ - { \ - TEST_FAIL('(' + VARIABLE + ' is not defined)' + (MESSAGE)); \ - } - -/* ------------------------------------------- -Group: Managing Deprecation -------------------------------------------- */ - -/* ------------------------------------------- -Macro: DEPRECATE_SYS() - Allow deprecation of a function that has been renamed. - - Replaces an old OLD_FUNCTION (which will have PREFIX_ prepended) with a NEW_FUNCTION - (PREFIX_ prepended) with the intention that the old function will be disabled in the future. - - Shows a warning in RPT each time the deprecated function is used, but runs the new function. - -Parameters: - OLD_FUNCTION - Full name of old function [Identifier for function that does not exist any more] - NEW_FUNCTION - Full name of new function [Function] - -Example: - (begin example) - // After renaming CBA_fnc_frog as CBA_fnc_fish - DEPRECATE_SYS(CBA_fnc_frog,CBA_fnc_fish); - (end) - -Author: - Sickboy -------------------------------------------- */ -#define DEPRECATE_SYS(OLD_FUNCTION,NEW_FUNCTION) \ - OLD_FUNCTION = { \ - WARNING('Deprecated function used: OLD_FUNCTION (new: NEW_FUNCTION) in ADDON'); \ - if (isNil "_this") then { call NEW_FUNCTION } else { _this call NEW_FUNCTION }; \ - } - -/* ------------------------------------------- -Macro: DEPRECATE() - Allow deprecation of a function, in the current component, that has been renamed. - - Replaces an OLD_FUNCTION (which will have PREFIX_ prepended) with a NEW_FUNCTION - (PREFIX_ prepended) with the intention that the old function will be disabled in the future. - - Shows a warning in RPT each time the deprecated function is used, but runs the new function. - -Parameters: - OLD_FUNCTION - Name of old function, assuming PREFIX [Identifier for function that does not exist any more] - NEW_FUNCTION - Name of new function, assuming PREFIX [Function] - -Example: - (begin example) - // After renaming CBA_fnc_frog as CBA_fnc_fish - DEPRECATE(fnc_frog,fnc_fish); - (end) - -Author: - Sickboy -------------------------------------------- */ -#define DEPRECATE(OLD_FUNCTION,NEW_FUNCTION) \ - DEPRECATE_SYS(DOUBLES(PREFIX,OLD_FUNCTION),DOUBLES(PREFIX,NEW_FUNCTION)) - -/* ------------------------------------------- -Macro: OBSOLETE_SYS() - Replace a function that has become obsolete. - - Replace an obsolete OLD_FUNCTION with a simple COMMAND_FUNCTION, with the intention that anyone - using the function should replace it with the simple command, since the function will be disabled in the future. - - Shows a warning in RPT each time the deprecated function is used, and runs the command function. - -Parameters: - OLD_FUNCTION - Full name of old function [Identifier for function that does not exist any more] - COMMAND_CODE - Code to replace the old function [Function] - -Example: - (begin example) - // In Arma2, currentWeapon command made the CBA_fMyWeapon function obsolete: - OBSOLETE_SYS(CBA_fMyWeapon,{ currentWeapon player }); - (end) - -Author: - Spooner -------------------------------------------- */ -#define OBSOLETE_SYS(OLD_FUNCTION,COMMAND_CODE) \ - OLD_FUNCTION = { \ - WARNING('Obsolete function used: (use: OLD_FUNCTION) in ADDON'); \ - if (isNil "_this") then { call COMMAND_CODE } else { _this call COMMAND_CODE }; \ - } - -/* ------------------------------------------- -Macro: OBSOLETE() - Replace a function, in the current component, that has become obsolete. - - Replace an obsolete OLD_FUNCTION (which will have PREFIX_ prepended) with a simple - COMMAND_CODE, with the intention that anyone using the function should replace it with the simple - command. - - Shows a warning in RPT each time the deprecated function is used. - -Parameters: - OLD_FUNCTION - Name of old function, assuming PREFIX [Identifier for function that does not exist any more] - COMMAND_CODE - Code to replace the old function [Function] - -Example: - (begin example) - // In Arma2, currentWeapon command made the CBA_fMyWeapon function obsolete: - OBSOLETE(fMyWeapon,{ currentWeapon player }); - (end) - -Author: - Spooner -------------------------------------------- */ -#define OBSOLETE(OLD_FUNCTION,COMMAND_CODE) \ - OBSOLETE_SYS(DOUBLES(PREFIX,OLD_FUNCTION),COMMAND_CODE) - -#define BWC_CONFIG(NAME) class NAME { \ - units[] = {}; \ - weapons[] = {}; \ - requiredVersion = REQUIRED_VERSION; \ - requiredAddons[] = {}; \ - version = VERSION; \ -} - -// XEH Specific -#define XEH_CLASS CBA_Extended_EventHandlers -#define XEH_CLASS_BASE DOUBLES(XEH_CLASS,base) -#define XEH_DISABLED class EventHandlers { class XEH_CLASS {}; }; SLX_XEH_DISABLED = 1 -#define XEH_ENABLED class EventHandlers { class XEH_CLASS { EXTENDED_EVENTHANDLERS }; }; SLX_XEH_DISABLED = 0 - -// TODO: These are actually outdated; _Once ? -#define XEH_PRE_INIT QUOTE(call COMPILE_FILE(XEH_PreInit_Once)) -#define XEH_PRE_CINIT QUOTE(call COMPILE_FILE(XEH_PreClientInit_Once)) -#define XEH_PRE_SINIT QUOTE(call COMPILE_FILE(XEH_PreServerInit_Once)) - -#define XEH_POST_INIT QUOTE(call COMPILE_FILE(XEH_PostInit_Once)) -#define XEH_POST_CINIT QUOTE(call COMPILE_FILE(XEH_PostClientInit_Once)) -#define XEH_POST_SINIT QUOTE(call COMPILE_FILE(XEH_PostServerInit_Once)) - -/* ------------------------------------------- -Macro: IS_ADMIN - Check if the local machine is an admin in the multiplayer environment. - - Reports 'true' for logged and voted in admins. - -Parameters: - None - -Example: - (begin example) - // print "true" if player is admin - systemChat str IS_ADMIN; - (end) - -Author: - commy2 -------------------------------------------- */ -#define IS_ADMIN serverCommandAvailable "#kick" - -/* ------------------------------------------- -Macro: IS_ADMIN_LOGGED - Check if the local machine is a logged in admin in the multiplayer environment. - - Reports 'false' if the player was voted to be the admin. - -Parameters: - None - -Example: - (begin example) - // print "true" if player is admin and entered in the server password - systemChat str IS_ADMIN_LOGGED; - (end) - -Author: - commy2 -------------------------------------------- */ -#define IS_ADMIN_LOGGED serverCommandAvailable "#shutdown" - -/* ------------------------------------------- -Macro: FILE_EXISTS - Check if a file exists on machines with interface - - Reports "false" if the file does not exist and throws an error in RPT. - -Parameters: - FILE - Path to the file - -Example: - (begin example) - // print "true" if file exists - systemChat str FILE_EXISTS("\A3\ui_f\data\igui\cfg\cursors\weapon_ca.paa"); - (end) - -Author: - commy2 -------------------------------------------- */ -#define FILE_EXISTS(FILE) (call {\ - private _return = false;\ - isNil {\ - private _control = (uiNamespace getVariable ["RscDisplayMain", displayNull]) ctrlCreate ["RscHTML", -1];\ - if (isNull _control) then {\ - _return = loadFile (FILE) != "";\ - } else {\ - _control htmlLoad (FILE);\ - _return = ctrlHTMLLoaded _control;\ - ctrlDelete _control;\ - };\ - };\ - _return\ -}) diff --git a/tools/config_style_checker.py b/tools/config_style_checker.py deleted file mode 100644 index afa78a2..0000000 --- a/tools/config_style_checker.py +++ /dev/null @@ -1,183 +0,0 @@ -#!/usr/bin/env python3 - -import fnmatch -import os -import re -import ntpath -import sys -import argparse - -def check_config_style(filepath): - bad_count_file = 0 - def pushClosing(t): - closingStack.append(closing.expr) - closing << Literal( closingFor[t[0]] ) - - def popClosing(): - closing << closingStack.pop() - - reIsClass = re.compile(r'^\s*class(.*)') - reIsClassInherit = re.compile(r'^\s*class(.*):') - reIsClassBody = re.compile(r'^\s*class(.*){') - reBadColon = re.compile(r'\s*class (.*) :') - reSpaceAfterColon = re.compile(r'\s*class (.*): ') - reSpaceBeforeCurly = re.compile(r'\s*class (.*) {') - reClassSingleLine = re.compile(r'\s*class (.*)[{;]') - - with open(filepath, 'r', encoding='utf-8', errors='ignore') as file: - content = file.read() - - # Store all brackets we find in this file, so we can validate everything on the end - brackets_list = [] - - # To check if we are in a comment block - isInCommentBlock = False - checkIfInComment = False - # Used in case we are in a line comment (//) - ignoreTillEndOfLine = False - # Used in case we are in a comment block (/* */). This is true if we detect a * inside a comment block. - # If the next character is a /, it means we end our comment block. - checkIfNextIsClosingBlock = False - - # We ignore everything inside a string - isInString = False - # Used to store the starting type of a string, so we can match that to the end of a string - inStringType = ''; - - lastIsCurlyBrace = False - checkForSemiColumn = False - - # Extra information so we know what line we find errors at - lineNumber = 1 - - indexOfCharacter = 0 - # Parse all characters in the content of this file to search for potential errors - for c in content: - if (lastIsCurlyBrace): - lastIsCurlyBrace = False - if c == '\n': # Keeping track of our line numbers - lineNumber += 1 # so we can print accurate line number information when we detect a possible error - if (isInString): # while we are in a string, we can ignore everything else, except the end of the string - if (c == inStringType): - isInString = False - # if we are not in a comment block, we will check if we are at the start of one or count the () {} and [] - elif (isInCommentBlock == False): - - # This means we have encountered a /, so we are now checking if this is an inline comment or a comment block - if (checkIfInComment): - checkIfInComment = False - if c == '*': # if the next character after / is a *, we are at the start of a comment block - isInCommentBlock = True - elif (c == '/'): # Otherwise, will check if we are in an line comment - ignoreTillEndOfLine = True # and an line comment is a / followed by another / (//) We won't care about anything that comes after it - - if (isInCommentBlock == False): - if (ignoreTillEndOfLine): # we are in a line comment, just continue going through the characters until we find an end of line - if (c == '\n'): - ignoreTillEndOfLine = False - else: # validate brackets - if (c == '"' or c == "'"): - isInString = True - inStringType = c - elif (c == '/'): - checkIfInComment = True - elif (c == '('): - brackets_list.append('(') - elif (c == ')'): - if (len(brackets_list) > 0 and brackets_list[-1] in ['{', '[']): - print("ERROR: Possible missing round bracket ')' detected at {0} Line number: {1}".format(filepath,lineNumber)) - bad_count_file += 1 - brackets_list.append(')') - elif (c == '['): - brackets_list.append('[') - elif (c == ']'): - if (len(brackets_list) > 0 and brackets_list[-1] in ['{', '(']): - print("ERROR: Possible missing square bracket ']' detected at {0} Line number: {1}".format(filepath,lineNumber)) - bad_count_file += 1 - brackets_list.append(']') - elif (c == '{'): - brackets_list.append('{') - elif (c == '}'): - lastIsCurlyBrace = True - if (len(brackets_list) > 0 and brackets_list[-1] in ['(', '[']): - print("ERROR: Possible missing curly brace '}}' detected at {0} Line number: {1}".format(filepath,lineNumber)) - bad_count_file += 1 - brackets_list.append('}') - elif (c== '\t'): - print("ERROR: Tab detected at {0} Line number: {1}".format(filepath,lineNumber)) - bad_count_file += 1 - - else: # Look for the end of our comment block - if (c == '*'): - checkIfNextIsClosingBlock = True; - elif (checkIfNextIsClosingBlock): - if (c == '/'): - isInCommentBlock = False - elif (c != '*'): - checkIfNextIsClosingBlock = False - indexOfCharacter += 1 - - if brackets_list.count('[') != brackets_list.count(']'): - print("ERROR: A possible missing square bracket [ or ] in file {0} [ = {1} ] = {2}".format(filepath,brackets_list.count('['),brackets_list.count(']'))) - bad_count_file += 1 - if brackets_list.count('(') != brackets_list.count(')'): - print("ERROR: A possible missing round bracket ( or ) in file {0} ( = {1} ) = {2}".format(filepath,brackets_list.count('('),brackets_list.count(')'))) - bad_count_file += 1 - if brackets_list.count('{') != brackets_list.count('}'): - print("ERROR: A possible missing curly brace {{ or }} in file {0} {{ = {1} }} = {2}".format(filepath,brackets_list.count('{'),brackets_list.count('}'))) - bad_count_file += 1 - - file.seek(0) - for lineNumber, line in enumerate(file.readlines()): - if reIsClass.match(line): - if reBadColon.match(line): - print(f"WARNING: bad class colon {filepath} Line number: {lineNumber+1}") - # bad_count_file += 1 - if reIsClassInherit.match(line): - if not reSpaceAfterColon.match(line): - print(f"WARNING: bad class missing space after colon {filepath} Line number: {lineNumber+1}") - if reIsClassBody.match(line): - if not reSpaceBeforeCurly.match(line): - print(f"WARNING: bad class inherit missing space before curly braces {filepath} Line number: {lineNumber+1}") - if not reClassSingleLine.match(line): - print(f"WARNING: bad class braces placement {filepath} Line number: {lineNumber+1}") - # bad_count_file += 1 - - return bad_count_file - -def main(): - - print("Validating Config Style") - - sqf_list = [] - bad_count = 0 - - parser = argparse.ArgumentParser() - parser.add_argument('-m','--module', help='only search specified module addon folder', required=False, default="") - args = parser.parse_args() - - for folder in ['addons', 'optionals']: - # Allow running from root directory as well as from inside the tools directory - rootDir = "../" + folder - if (os.path.exists(folder)): - rootDir = folder - - for root, dirnames, filenames in os.walk(rootDir + '/' + args.module): - for filename in fnmatch.filter(filenames, '*.cpp'): - sqf_list.append(os.path.join(root, filename)) - for filename in fnmatch.filter(filenames, '*.hpp'): - sqf_list.append(os.path.join(root, filename)) - - for filename in sqf_list: - bad_count = bad_count + check_config_style(filename) - - print("------\nChecked {0} files\nErrors detected: {1}".format(len(sqf_list), bad_count)) - if (bad_count == 0): - print("Config validation PASSED") - else: - print("Config validation FAILED") - - return bad_count - -if __name__ == "__main__": - sys.exit(main()) diff --git a/tools/sqf_validator.py b/tools/sqf_validator.py deleted file mode 100644 index c338b2d..0000000 --- a/tools/sqf_validator.py +++ /dev/null @@ -1,191 +0,0 @@ -#!/usr/bin/env python3 - -import fnmatch -import os -import re -import ntpath -import sys -import argparse - -def validKeyWordAfterCode(content, index): - keyWords = ["for", "do", "count", "each", "forEach", "else", "and", "not", "isEqualTo", "in", "call", "spawn", "execVM", "catch", "param", "select", "apply", "findIf", "remoteExec"]; - for word in keyWords: - try: - subWord = content.index(word, index, index+len(word)) - return True; - except: - pass - return False - -def check_sqf_syntax(filepath): - bad_count_file = 0 - def pushClosing(t): - closingStack.append(closing.expr) - closing << Literal( closingFor[t[0]] ) - - def popClosing(): - closing << closingStack.pop() - - with open(filepath, 'r', encoding='utf-8', errors='ignore') as file: - content = file.read() - - # Store all brackets we find in this file, so we can validate everything on the end - brackets_list = [] - - # To check if we are in a comment block - isInCommentBlock = False - checkIfInComment = False - # Used in case we are in a line comment (//) - ignoreTillEndOfLine = False - # Used in case we are in a comment block (/* */). This is true if we detect a * inside a comment block. - # If the next character is a /, it means we end our comment block. - checkIfNextIsClosingBlock = False - - # We ignore everything inside a string - isInString = False - # Used to store the starting type of a string, so we can match that to the end of a string - inStringType = ''; - - lastIsCurlyBrace = False - checkForSemicolon = False - onlyWhitespace = True - - # Extra information so we know what line we find errors at - lineNumber = 1 - - indexOfCharacter = 0 - # Parse all characters in the content of this file to search for potential errors - for c in content: - if (lastIsCurlyBrace): - lastIsCurlyBrace = False - # Test generates false positives with binary commands that take CODE as 2nd arg (e.g. findIf) - checkForSemicolon = not re.search('findIf', content, re.IGNORECASE) - - if c == '\n': # Keeping track of our line numbers - onlyWhitespace = True # reset so we can see if # is for a preprocessor command - lineNumber += 1 # so we can print accurate line number information when we detect a possible error - if (isInString): # while we are in a string, we can ignore everything else, except the end of the string - if (c == inStringType): - isInString = False - # if we are not in a comment block, we will check if we are at the start of one or count the () {} and [] - elif (isInCommentBlock == False): - - # This means we have encountered a /, so we are now checking if this is an inline comment or a comment block - if (checkIfInComment): - checkIfInComment = False - if c == '*': # if the next character after / is a *, we are at the start of a comment block - isInCommentBlock = True - elif (c == '/'): # Otherwise, will check if we are in an line comment - ignoreTillEndOfLine = True # and an line comment is a / followed by another / (//) We won't care about anything that comes after it - - if (isInCommentBlock == False): - if (ignoreTillEndOfLine): # we are in a line comment, just continue going through the characters until we find an end of line - if (c == '\n'): - ignoreTillEndOfLine = False - else: # validate brackets - if (c == '"' or c == "'"): - isInString = True - inStringType = c - elif (c == '#' and onlyWhitespace): - ignoreTillEndOfLine = True - elif (c == '/'): - checkIfInComment = True - elif (c == '('): - brackets_list.append('(') - elif (c == ')'): - if (brackets_list[-1] in ['{', '[']): - print("ERROR: Possible missing round bracket ')' detected at {0} Line number: {1}".format(filepath,lineNumber)) - bad_count_file += 1 - brackets_list.append(')') - elif (c == '['): - brackets_list.append('[') - elif (c == ']'): - if (brackets_list[-1] in ['{', '(']): - print("ERROR: Possible missing square bracket ']' detected at {0} Line number: {1}".format(filepath,lineNumber)) - bad_count_file += 1 - brackets_list.append(']') - elif (c == '{'): - brackets_list.append('{') - elif (c == '}'): - lastIsCurlyBrace = True - if (brackets_list[-1] in ['(', '[']): - print("ERROR: Possible missing curly brace '}}' detected at {0} Line number: {1}".format(filepath,lineNumber)) - bad_count_file += 1 - brackets_list.append('}') - elif (c== '\t'): - print("ERROR: Tab detected at {0} Line number: {1}".format(filepath,lineNumber)) - bad_count_file += 1 - - if (c not in [' ', '\t', '\n']): - onlyWhitespace = False - - if (checkForSemicolon): - if (c not in [' ', '\t', '\n', '/']): # keep reading until no white space or comments - checkForSemicolon = False - if (c not in [']', ')', '}', ';', ',', '&', '!', '|', '='] and not validKeyWordAfterCode(content, indexOfCharacter)): # , 'f', 'd', 'c', 'e', 'a', 'n', 'i']): - print("ERROR: Possible missing semicolon ';' detected at {0} Line number: {1}".format(filepath,lineNumber)) - bad_count_file += 1 - - else: # Look for the end of our comment block - if (c == '*'): - checkIfNextIsClosingBlock = True; - elif (checkIfNextIsClosingBlock): - if (c == '/'): - isInCommentBlock = False - elif (c != '*'): - checkIfNextIsClosingBlock = False - indexOfCharacter += 1 - - if brackets_list.count('[') != brackets_list.count(']'): - print("ERROR: A possible missing square bracket [ or ] in file {0} [ = {1} ] = {2}".format(filepath,brackets_list.count('['),brackets_list.count(']'))) - bad_count_file += 1 - if brackets_list.count('(') != brackets_list.count(')'): - print("ERROR: A possible missing round bracket ( or ) in file {0} ( = {1} ) = {2}".format(filepath,brackets_list.count('('),brackets_list.count(')'))) - bad_count_file += 1 - if brackets_list.count('{') != brackets_list.count('}'): - print("ERROR: A possible missing curly brace {{ or }} in file {0} {{ = {1} }} = {2}".format(filepath,brackets_list.count('{'),brackets_list.count('}'))) - bad_count_file += 1 - pattern = re.compile('\s*(/\*[\s\S]+?\*/)\s*#include') - if pattern.match(content): - print("ERROR: A found #include after block comment in file {0}".format(filepath)) - bad_count_file += 1 - - - - return bad_count_file - -def main(): - - print("Validating SQF") - - sqf_list = [] - bad_count = 0 - - parser = argparse.ArgumentParser() - parser.add_argument('-m','--module', help='only search specified module addon folder', required=False, default="") - args = parser.parse_args() - - for folder in ['addons', 'optionals']: - # Allow running from root directory as well as from inside the tools directory - rootDir = "../" + folder - if (os.path.exists(folder)): - rootDir = folder - - for root, dirnames, filenames in os.walk(rootDir + '/' + args.module): - for filename in fnmatch.filter(filenames, '*.sqf'): - sqf_list.append(os.path.join(root, filename)) - - for filename in sqf_list: - bad_count = bad_count + check_sqf_syntax(filename) - - - print("------\nChecked {0} files\nErrors detected: {1}".format(len(sqf_list), bad_count)) - if (bad_count == 0): - print("SQF validation PASSED") - else: - print("SQF validation FAILED") - - return bad_count - -if __name__ == "__main__": - sys.exit(main())