From ac1ae6c596d904e99577db325acd260dca0b937d Mon Sep 17 00:00:00 2001 From: jaynus Date: Mon, 11 May 2015 16:40:15 -0700 Subject: [PATCH] Stability fixes. --- addons/vehicledamage/functions/fnc_doHit.sqf | 3 +- addons/vehicledamage/script_component.hpp | 2 +- extensions/common/arguments.hpp | 2 +- extensions/common/directx/d3d_display.cpp | 33 ++++++++++++++++++-- 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/addons/vehicledamage/functions/fnc_doHit.sqf b/addons/vehicledamage/functions/fnc_doHit.sqf index c70940b2a8..646f67394c 100644 --- a/addons/vehicledamage/functions/fnc_doHit.sqf +++ b/addons/vehicledamage/functions/fnc_doHit.sqf @@ -35,7 +35,8 @@ _vehicleId = _vehicle getVariable[QGVAR(id), -1]; _command = format["hit:%1,%2,%3,%4,%5,%6,%7,%8,%9,%10,%11,%12,%13,%14,%15,%16,%17,%18", _vehicleId, // vehicle id registered - _model, _selection, +// _model, _selection, + _model, "BALLS", VECTOR_TEXT(vectorDir _vehicle), VECTOR_TEXT(vectorUp _vehicle), _projectileType, //projectile type id diff --git a/addons/vehicledamage/script_component.hpp b/addons/vehicledamage/script_component.hpp index 1f81f8bd09..44d6dd6ad7 100644 --- a/addons/vehicledamage/script_component.hpp +++ b/addons/vehicledamage/script_component.hpp @@ -18,4 +18,4 @@ #define DEBUG_EXTENSION_DYNLOAD #define DEBUG_LOG_EXTENSION //#define DEBUG_EXTENSION_DYNLOAD_RELOAD -//#define DEBUG_VEHICLEDAMAGE_RENDER \ No newline at end of file +#define DEBUG_VEHICLEDAMAGE_RENDER \ No newline at end of file diff --git a/extensions/common/arguments.hpp b/extensions/common/arguments.hpp index df51d6148c..72e15da497 100644 --- a/extensions/common/arguments.hpp +++ b/extensions/common/arguments.hpp @@ -82,6 +82,6 @@ namespace ace { protected: std::vector _args; - const std::string &_original; + const std::string _original; }; } \ No newline at end of file diff --git a/extensions/common/directx/d3d_display.cpp b/extensions/common/directx/d3d_display.cpp index ffb9d39877..bfc7a0e013 100644 --- a/extensions/common/directx/d3d_display.cpp +++ b/extensions/common/directx/d3d_display.cpp @@ -3,12 +3,36 @@ #include "shared.hpp" #include "d3d_display.hpp" +#include + #include using namespace DirectX; namespace ace { namespace debug { + + DWORD GetMainThreadId() { + const std::shared_ptr hThreadSnapshot( + CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0), CloseHandle); + if (hThreadSnapshot.get() == INVALID_HANDLE_VALUE) { + throw std::runtime_error("GetMainThreadId failed"); + } + THREADENTRY32 tEntry; + tEntry.dwSize = sizeof(THREADENTRY32); + DWORD result = 0; + DWORD currentPID = GetCurrentProcessId(); + for (BOOL success = Thread32First(hThreadSnapshot.get(), &tEntry); + !result && success && GetLastError() != ERROR_NO_MORE_FILES; + success = Thread32Next(hThreadSnapshot.get(), &tEntry)) + { + if (tEntry.th32OwnerProcessID == currentPID) { + result = tEntry.th32ThreadID; + } + } + return result; + } + d3d_display::d3d_display() : _fullscreen(false) {} d3d_display::~d3d_display() {} @@ -210,6 +234,9 @@ namespace ace { return false; } + // Attach our input to the master input + //AttachThreadInput(GetCurrentThreadId(), GetMainThraedId()); + SetWindowLongPtr(_hWnd, GWLP_USERDATA, (LONG)this); ShowWindow(_hWnd, 5); @@ -307,11 +334,13 @@ namespace ace { LRESULT CALLBACK d3d_display::_wndproc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT ps; HDC hdc; - + switch (message) { case WM_INPUT: { UINT dwSize; - + if (GetActiveWindow() != _hWnd) { + return DefWindowProc(hWnd, message, wParam, lParam); + } GetRawInputData((HRAWINPUT)lParam, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER)); LPBYTE lpb = new BYTE[dwSize];