From fdf0ff2d24e692338d7509843fd934445085dcac Mon Sep 17 00:00:00 2001 From: jaynus Date: Sun, 10 May 2015 09:51:16 -0700 Subject: [PATCH] Added: Result parsing, ext->sqf dispatch to localEvents Fixed: Bullet build Fixed: results are all 0=true, -1=failure, otherwise its a dispatch message. --- addons/vehicledamage/XEH_postInit.sqf | 8 ++----- addons/vehicledamage/XEH_preInit.sqf | 9 ++----- .../functions/fnc_initializeExtension.sqf | 1 + .../functions/fnc_monitorResultsPFH.sqf | 15 +++++++++--- .../functions/fnc_parseResult.sqf | 24 +++++++++++++++++++ extensions/CMakeLists.txt | 2 +- extensions/vd/ace_vd.cpp | 10 +++++++- extensions/vd/controller.cpp | 6 ++--- 8 files changed, 54 insertions(+), 21 deletions(-) create mode 100644 addons/vehicledamage/functions/fnc_parseResult.sqf diff --git a/addons/vehicledamage/XEH_postInit.sqf b/addons/vehicledamage/XEH_postInit.sqf index 4ba8069a6b..fafc91f7b2 100644 --- a/addons/vehicledamage/XEH_postInit.sqf +++ b/addons/vehicledamage/XEH_postInit.sqf @@ -3,9 +3,5 @@ // Handle damage to local vehicles [QGVAR(hp), FUNC(dispatchHitPart)] call EFUNC(common,addEventHandler); -/* -"ace_vd" callExtension "reset:"; -"ace_vd" callExtension "init:"; - -[FUNC(monitorResultsPFH), 0, []] call CBA_fnc_addPerFrameHandler; -*/ \ No newline at end of file +[] call FUNC(initializeExtension); +[FUNC(monitorResultsPFH), 0, []] call CBA_fnc_addPerFrameHandler; \ No newline at end of file diff --git a/addons/vehicledamage/XEH_preInit.sqf b/addons/vehicledamage/XEH_preInit.sqf index 84a5dfa908..91df183b45 100644 --- a/addons/vehicledamage/XEH_preInit.sqf +++ b/addons/vehicledamage/XEH_preInit.sqf @@ -3,8 +3,9 @@ ADDON = false; // Core engine functions - +PREP(initializeExtension); PREP(monitorResultsPFH); +PREP(parseResult); PREP(registerVehicleDamageHandler); PREP(registerVehicleWithExtension); @@ -14,12 +15,6 @@ PREP(dispatchHitPart); PREP(dispatchDamage); PREP(doHit); -// Extension calling functionality -PREP(initializeExtension); - -// VD specific effects middlemen - - // Unique local vehicle ID GVAR(vehicle_id) = 0; diff --git a/addons/vehicledamage/functions/fnc_initializeExtension.sqf b/addons/vehicledamage/functions/fnc_initializeExtension.sqf index 99ed2ad3e1..7ebc9fbb13 100644 --- a/addons/vehicledamage/functions/fnc_initializeExtension.sqf +++ b/addons/vehicledamage/functions/fnc_initializeExtension.sqf @@ -1,4 +1,5 @@ #include "script_component.hpp" +GVAR(ready) = false; CALL_EXT "init:"; diff --git a/addons/vehicledamage/functions/fnc_monitorResultsPFH.sqf b/addons/vehicledamage/functions/fnc_monitorResultsPFH.sqf index 421b355c8f..abfe95a8e3 100644 --- a/addons/vehicledamage/functions/fnc_monitorResultsPFH.sqf +++ b/addons/vehicledamage/functions/fnc_monitorResultsPFH.sqf @@ -3,8 +3,17 @@ PARAMS_2(_args,_handle); private["_result"]; -//_result = "ace_vd" callExtension "fetch_result:1"; +_result = "ace_vd" callExtension "fetch_result:1"; while { _result != "" && {_result != "-1"} } do { - //diag_log text format["result={%1}", _result]; - //_result = "ace_vd" callExtension "fetch_result:1"; + TRACE_1("", _result); + _result = "ace_vd" callExtension "fetch_result:1"; + + _resultArgs = [_result] call FUNC(parseResult); + if(!isNil "_resultArgs") then { + if((_resultArgs select 0) == "exec") then { + [] call (_resultArgs select 1); + } else { + [format["ace_vehicledamage_%1", (_result select 0)], (_result select 1)] call EFUNC(common,localEvent); + }; + }; }; \ No newline at end of file diff --git a/addons/vehicledamage/functions/fnc_parseResult.sqf b/addons/vehicledamage/functions/fnc_parseResult.sqf new file mode 100644 index 0000000000..4841f44f13 --- /dev/null +++ b/addons/vehicledamage/functions/fnc_parseResult.sqf @@ -0,0 +1,24 @@ +//#define DEBUG_MODE_FULL + +#include "script_component.hpp" +PARAMS_1(_resultString); +private["_values", "_result", "_strings", "_command", "_arguments"]; +TRACE_1("", _resultString); + +if(!(_resultString find ":") ) exitWith { nil }; + +_strings = [_resultString, ":"] call CBA_fnc_split; +TRACE_1("", _strings); +// Invalid comman + +// Command with no parameters +_command = _strings select 0; +if((count _strings) < 2) exitWith { [_command, []] }; + +if(_command == "exec") exitWith { + _code = compile (_strings select 1); + [_command, _code] +}; + +_arguments = [(_strings select 1), ","] call CBA_fnc_split; +[(_strings select 0), _arguments] \ No newline at end of file diff --git a/extensions/CMakeLists.txt b/extensions/CMakeLists.txt index 670854b363..0f2720ce89 100644 --- a/extensions/CMakeLists.txt +++ b/extensions/CMakeLists.txt @@ -30,7 +30,7 @@ include_directories("common") if(USE_BULLET) add_definitions(-DUSE_BULLET) - include_directories(BEFORE "lib/bullet3/include") + include_directories(BEFORE "lib/bullet3/src") link_directories("lib/bullet3/lib") set(BULLET_LIBS_DEBUG "BulletCollision_vs2010_debug.lib;LinearMath_vs2010_debug.lib;BulletDynamics_vs2010_debug.lib") set(BULLET_LIBS "BulletCollision_vs2010.lib;LinearMath_vs2010.lib;BulletDynamics_vs2010.lib") diff --git a/extensions/vd/ace_vd.cpp b/extensions/vd/ace_vd.cpp index d1299fec31..5cbeffbec5 100644 --- a/extensions/vd/ace_vd.cpp +++ b/extensions/vd/ace_vd.cpp @@ -51,6 +51,14 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) { result = function; } + if (command == "ready") { + if (ace::model_collection::get().ready() && ace::model_collection::get().ready()) { + result = "0"; + } else { + result = "-1"; + } + } + /*************************/ // Real functionality goes here if (command == "init") { // init: @@ -58,7 +66,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) { ace::model_collection::get().init(); } ace::vehicledamage::controller::get(); - result = "1"; + result = "0"; EXTENSION_RETURN(); } else { ace::vehicledamage::controller::get().call(command, _args, result); diff --git a/extensions/vd/controller.cpp b/extensions/vd/controller.cpp index ee8a3e03cd..93218a0dcb 100644 --- a/extensions/vd/controller.cpp +++ b/extensions/vd/controller.cpp @@ -58,14 +58,14 @@ namespace ace { controller::~controller() { } bool controller::get_ready(const arguments &_args, std::string & result) { - result = "1"; + result = "0"; if (!ace::model_collection::get().ready()) { - result = "0"; + result = "-1"; } if (!_ready) - result = "0"; + result = "-1"; return true; }