diff --git a/Source/miniwin/miniwin.h b/Source/miniwin/miniwin.h index 17267e3bd..ec4805631 100644 --- a/Source/miniwin/miniwin.h +++ b/Source/miniwin/miniwin.h @@ -11,8 +11,6 @@ #include #include -#include "storm/storm_full.h" - namespace devilution { #ifndef MAX_PATH diff --git a/Source/storm/storm.cpp b/Source/storm/storm.cpp index 89a3855a1..3e5b9ec73 100644 --- a/Source/storm/storm.cpp +++ b/Source/storm/storm.cpp @@ -23,9 +23,19 @@ #include "utils/sdl_compat.h" #include "utils/stubs.h" -namespace devilution { +// Include Windows headers for Get/SetLastError. +#if defined(_WIN32) +// Suppress definitions of `min` and `max` macros by : +#define NOMINMAX 1 +#define WIN32_LEAN_AND_MEAN +#include +#else // !defined(_WIN32) +// On non-Windows, these are defined in 3rdParty/StormLib. +extern "C" void SetLastError(std::uint32_t dwErrCode); +extern "C" std::uint32_t GetLastError(); +#endif -uint32_t nLastError = 0; +namespace devilution { namespace { @@ -801,12 +811,12 @@ void SVidPlayEnd(HANDLE video) DWORD SErrGetLastError() { - return nLastError; + return ::GetLastError(); } void SErrSetLastError(DWORD dwErrCode) { - nLastError = dwErrCode; + ::SetLastError(dwErrCode); } bool SFileSetBasePath(const char *path) diff --git a/Source/storm/storm_full.h b/Source/storm/storm_full.h deleted file mode 100644 index d2304a6b7..000000000 --- a/Source/storm/storm_full.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#include - -namespace devilution { - -extern uint32_t nLastError; - -} // namespace devilution