From 3a51f0014706a2f856db932a9a4cfb99e605ca74 Mon Sep 17 00:00:00 2001 From: sukibaby <163092272+sukibaby@users.noreply.github.com> Date: Fri, 3 Jan 2025 10:57:30 -0800 Subject: [PATCH] (Win32 refresh) Update DirectXHelpers.cpp The DirectInput / DirectSound version defs need to be exposed to other parts of the engine, so they are moved to the header instead of the cpp file. The includes can be consolidated after that. I'm also replacing the usage of a raw array of char *'s with an RString and using c_str() to get its value - a small change, but raw arrays are unreliable. --- src/archutils/Win32/DirectXHelpers.cpp | 20 ++++++++++---------- src/archutils/Win32/DirectXHelpers.h | 4 ++++ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/archutils/Win32/DirectXHelpers.cpp b/src/archutils/Win32/DirectXHelpers.cpp index 04423e8476..add4a8ec33 100644 --- a/src/archutils/Win32/DirectXHelpers.cpp +++ b/src/archutils/Win32/DirectXHelpers.cpp @@ -1,6 +1,14 @@ #include "global.h" #include "DirectXHelpers.h" #include "RageUtil.h" +#include +#include +#include +#include // dsound.h needs this +#include +#include + +RString GetErrorString(HRESULT hr); RString hr_ssprintf( int hr, const char *fmt, ... ) { @@ -9,18 +17,10 @@ RString hr_ssprintf( int hr, const char *fmt, ... ) RString s = vssprintf( fmt, va ); va_end(va); - const char *szError = GetErrorString( hr ); - return s + ssprintf( " (%s)", szError ); + RString szError = GetErrorString(hr); + return s + ssprintf(" (%s)", szError.c_str()); } -// needed for defines -#define DIRECTINPUT_VERSION 0x0800 -#define DIRECTSOUND_VERSION 0x0700 -#include -#include -#include // dsound.h needs this -#include - #define DXERRMSG(hrcode, dummy) case hrcode: return #hrcode; RString GetErrorString(HRESULT hr) diff --git a/src/archutils/Win32/DirectXHelpers.h b/src/archutils/Win32/DirectXHelpers.h index d8c56232b4..c2fc67c94e 100644 --- a/src/archutils/Win32/DirectXHelpers.h +++ b/src/archutils/Win32/DirectXHelpers.h @@ -7,6 +7,10 @@ RString hr_ssprintf( int hr, const char *fmt, ... ); RString GetErrorString(HRESULT hr); +// These defined need to be exposed anywhere this is included. +#define DIRECTINPUT_VERSION 0x0800 +#define DIRECTSOUND_VERSION 0x0700 + #endif /*