diff --git a/ace_dynload.dll b/ace_dynload.dll index 77d7f0a035..c057473c23 100644 Binary files a/ace_dynload.dll and b/ace_dynload.dll differ diff --git a/ace_vd.dll b/ace_vd.dll deleted file mode 100644 index 8b64685b58..0000000000 Binary files a/ace_vd.dll and /dev/null differ diff --git a/addons/vehicledamage/XEH_postInit.sqf b/addons/vehicledamage/XEH_postInit.sqf index b51b76f82a..d1bac8263e 100644 --- a/addons/vehicledamage/XEH_postInit.sqf +++ b/addons/vehicledamage/XEH_postInit.sqf @@ -3,4 +3,6 @@ // Handle damage to local vehicles [QGVAR(hp), FUNC(dispatchHitPart)] call EFUNC(common,addEventHandler); -[FUNC(monitorResultsPFH), 0, []] call CBA_fnc_addPerFrameHandler; \ No newline at end of file +[FUNC(monitorResultsPFH), 0, []] call CBA_fnc_addPerFrameHandler; + +[QGVAR(setAnimationNames), FUNC(setAnimationNames)] call EFUNC(common,addEventHandler); \ No newline at end of file diff --git a/addons/vehicledamage/functions/fnc_initializeExtension.sqf b/addons/vehicledamage/functions/fnc_initializeExtension.sqf index a393f1db92..b9568c6747 100644 --- a/addons/vehicledamage/functions/fnc_initializeExtension.sqf +++ b/addons/vehicledamage/functions/fnc_initializeExtension.sqf @@ -18,7 +18,7 @@ if(GVAR(async)) then { diag_log text format["[ACE] - Vehicle damage extension caching..."]; "init:" call FUNC(callExtension); -#ifdef ACE_VEHICLEDAMAGE_RENDER_DEBUG +#ifdef DEBUG_VEHICLEDAMAGE_RENDER "debug_render:" call FUNC(callExtension); diag_log text format["[ACE] - DEBUG - DirectX11 Debug Rendering initialized"]; #endif diff --git a/addons/vehicledamage/functions/fnc_setAnimationNames.sqf b/addons/vehicledamage/functions/fnc_setAnimationNames.sqf new file mode 100644 index 0000000000..320adf21dc --- /dev/null +++ b/addons/vehicledamage/functions/fnc_setAnimationNames.sqf @@ -0,0 +1,3 @@ +#include "script_component.hpp" + +diag_log text format["ENTEERED!!!! %1", _this]; \ No newline at end of file diff --git a/addons/vehicledamage/script_component.hpp b/addons/vehicledamage/script_component.hpp index 93b1714dbb..12ad20d6a1 100644 --- a/addons/vehicledamage/script_component.hpp +++ b/addons/vehicledamage/script_component.hpp @@ -15,4 +15,5 @@ #define VECTOR_TEXT(x) ([(x)] call FUNC(_textVector)) #define RELATIVE_VECTOR_TEXT(o,x) ([(o worldToModelVisual ((x) call EFUNC(common,ASLToPosition)))] call FUNC(_textVector)) -#define DEBUG_EXTENSION_DYNLOAD \ No newline at end of file +#define DEBUG_EXTENSION_DYNLOAD +#define DEBUG_VEHICLEDAMAGE_RENDER \ No newline at end of file diff --git a/extensions/common/dispatch.hpp b/extensions/common/dispatch.hpp index 76e8a5202e..0a37824b83 100644 --- a/extensions/common/dispatch.hpp +++ b/extensions/common/dispatch.hpp @@ -55,7 +55,7 @@ namespace ace { class threaded_dispatcher : public dispatcher { public: - threaded_dispatcher() : _worker(&ace::threaded_dispatcher::monitor, this) { + threaded_dispatcher() : _stop(false), _worker(&ace::threaded_dispatcher::monitor, this) { } ~threaded_dispatcher() {} @@ -99,11 +99,14 @@ namespace ace { void push_result(const std::string & result) { push_result(dispatch_result(result, -1)); } - + void stop() { + std::lock_guard lock(_messages_lock); + _stop = true; + } protected: void monitor() { _ready = false; - while (true) { + while (!_stop) { { std::lock_guard lock(_messages_lock); while (!_messages.empty()) { @@ -135,15 +138,16 @@ namespace ace { sleep(5); } } - std::queue _results; - std::mutex _results_lock; + std::atomic_bool _stop; + std::queue _results; + std::mutex _results_lock; - std::queue _messages; - std::mutex _messages_lock; + std::queue _messages; + std::mutex _messages_lock; - std::thread _worker; + std::thread _worker; - uint64_t _message_id; + uint64_t _message_id; }; class threaded_dispatch : public threaded_dispatcher, public singleton { }; }; \ No newline at end of file diff --git a/extensions/common/pbo/search.cpp b/extensions/common/pbo/search.cpp index 019e9dc1f0..01324339fd 100644 --- a/extensions/common/pbo/search.cpp +++ b/extensions/common/pbo/search.cpp @@ -135,6 +135,8 @@ namespace ace { pbo_stream.close(); } + LOG(INFO) << "PBO Index complete"; + return true; } diff --git a/extensions/dynload/dynloader.hpp b/extensions/dynload/dynloader.hpp index 43d0dcdac9..6c35155179 100644 --- a/extensions/dynload/dynloader.hpp +++ b/extensions/dynload/dynloader.hpp @@ -11,11 +11,11 @@ namespace ace { class module { public: module() : handle(nullptr), function(nullptr), name("") {} - module(const std::string & name_, HANDLE handle_, RVExtension function_, const std::string & file_) : handle(nullptr), function(function_), name(name_), temp_filename(file_) {} + module(const std::string & name_, HMODULE handle_, RVExtension function_, const std::string & file_) : handle(handle_), function(function_), name(name_), temp_filename(file_) {} std::string name; std::string temp_filename; - HINSTANCE handle; + HMODULE handle; RVExtension function; }; @@ -32,7 +32,7 @@ namespace ace { #ifdef _WINDOWS bool load(const arguments & args_, std::string & result) { - HINSTANCE dllHandle; + HMODULE dllHandle; RVExtension function; LOG(INFO) << "Load requested [" << args_.as_string(0) << "]"; @@ -55,9 +55,9 @@ namespace ace { return false; } std::string temp_filename = buffer; - if (!CopyFileA(args_.as_string(0).c_str(), temp_filename.c_str(), TRUE)) { + if (!CopyFileA(args_.as_string(0).c_str(), temp_filename.c_str(), FALSE)) { DeleteFile(temp_filename.c_str()); - if (!CopyFileA(args_.as_string(0).c_str(), temp_filename.c_str(), TRUE)) { + if (!CopyFileA(args_.as_string(0).c_str(), temp_filename.c_str(), FALSE)) { LOG(ERROR) << "CopyFile() , e=" << GetLastError(); return false; } @@ -89,17 +89,25 @@ namespace ace { LOG(INFO) << "Unload requested [" << args_.as_string(0) << "]"; - if (_modules.find(args_.as_string(0)) != _modules.end()) { + if (_modules.find(args_.as_string(0)) == _modules.end()) { LOG(INFO) << "Unload failed, module not loaded [" << args_.as_string(0) << "]"; return true; } - FreeLibrary(_modules[args_.as_string(0)].handle); + if (!FreeLibrary(_modules[args_.as_string(0)].handle)) { + LOG(INFO) << "FreeLibrary() failed during unload, e=" << GetLastError(); + return false; + } + //if (!DeleteFileA(_modules[args_.as_string(0)].temp_filename.c_str())) { + // LOG(INFO) << "DeleteFile() failed during unload, e=" << GetLastError(); + // return false; + //} + _modules.erase(args_.as_string(0)); LOG(INFO) << "Unload complete [" << args_.as_string(0) << "]"; - return false; + return true; } #endif diff --git a/extensions/tests/test.pbo.txt b/extensions/tests/test.pbo.txt new file mode 100644 index 0000000000..0efa05ee5c --- /dev/null +++ b/extensions/tests/test.pbo.txt @@ -0,0 +1,3 @@ +init: +debug_render: +register_vehicle:\test\test.p3d,2,4050.18;3802.55;5.075 diff --git a/extensions/vd/ace_vd_dllmain.cpp b/extensions/vd/ace_vd_dllmain.cpp index 4084982341..415ca0372a 100644 --- a/extensions/vd/ace_vd_dllmain.cpp +++ b/extensions/vd/ace_vd_dllmain.cpp @@ -1,6 +1,6 @@ #include "shared.hpp" #include "logging.hpp" - +#include "controller.hpp" INITIALIZE_EASYLOGGINGPP BOOLEAN WINAPI DllMain(IN HINSTANCE hDllHandle, @@ -25,6 +25,10 @@ BOOLEAN WINAPI DllMain(IN HINSTANCE hDllHandle, break; case DLL_PROCESS_DETACH: + if (Reserved == NULL) { + ace::vehicledamage::controller::get().stop(); + LOG(INFO) << "Vehicle Damage unloaded and halted"; + } break; } diff --git a/extensions/vd/base_vehicle.cpp b/extensions/vd/base_vehicle.cpp index cfb0ec0d01..0511e23b0f 100644 --- a/extensions/vd/base_vehicle.cpp +++ b/extensions/vd/base_vehicle.cpp @@ -28,9 +28,9 @@ namespace ace { // P3d store in x,z,y format for (auto & face : object_->lods[fire_lod]->faces) { bt_mesh->addTriangle( - btVector3(face->vertices[0]->x(), face->vertices[0]->z(), face->vertices[0]->y()), - btVector3(face->vertices[1]->x(), face->vertices[1]->z(), face->vertices[1]->y()), - btVector3(face->vertices[2]->x(), face->vertices[2]->z(), face->vertices[2]->y()) + btVector3(face->vertices[0]->x(), face->vertices[0]->y(), face->vertices[0]->z()), + btVector3(face->vertices[1]->x(), face->vertices[1]->y(), face->vertices[1]->z()), + btVector3(face->vertices[2]->x(), face->vertices[2]->y(), face->vertices[2]->z()) ); } diff --git a/extensions/vd/controller.cpp b/extensions/vd/controller.cpp index 549ca44f14..021f6fcc63 100644 --- a/extensions/vd/controller.cpp +++ b/extensions/vd/controller.cpp @@ -111,8 +111,14 @@ namespace ace { vehicle_p _vehicle = std::make_shared(static_cast(_args[1]), _object, _args[2]); vehicles[static_cast(_args[1])] = _vehicle; - LOG(INFO) << "vehicle registered: [id=" << _args[1].as_uint32() << ", type=" << _args[0].as_string() << "]"; + // For results on a valid vehicle registration, we return its animation names for that given vehicle + std::stringstream _animationNames; + for (auto & anim : _vehicle->object->animations) { + _animationNames << anim->name << ","; + } + this->push_result("setAnimationNames:"+_animationNames.str()); + LOG(INFO) << "vehicle registered: [id=" << _args[1].as_uint32() << ", type=" << _args[0].as_string() << "]"; DEBUG_DISPATCH("register_vehicle", _args[1].as_string()); return true; diff --git a/extensions/vd/debug/penetration_display.cpp b/extensions/vd/debug/penetration_display.cpp index ee990ccbde..aef801220b 100644 --- a/extensions/vd/debug/penetration_display.cpp +++ b/extensions/vd/debug/penetration_display.cpp @@ -44,13 +44,13 @@ namespace ace { _BatchEffect.reset(new BasicEffect(_pd3dDevice)); _BatchEffect->SetVertexColorEnabled(true); - + { void const* shaderByteCode; size_t byteCodeLength; _BatchEffect->GetVertexShaderBytecode(&shaderByteCode, &byteCodeLength); - + hr = _pd3dDevice->CreateInputLayout(VertexPositionColor::InputElements, VertexPositionColor::InputElementCount, shaderByteCode, byteCodeLength, @@ -162,7 +162,6 @@ namespace ace { vertices[1] = { face->vertices[1]->x(), face->vertices[1]->y(), face->vertices[1]->z() }; vertices[2] = { face->vertices[2]->x(), face->vertices[2]->y(), face->vertices[2]->z() }; - XMVECTORF32 v[3] = { { vertices[0].x(), vertices[0].y(), vertices[0].z() }, { vertices[1].x(), vertices[1].y(), vertices[1].z() },