From ba0b696fb62d4356b1e3326cac5813d4f378d49b Mon Sep 17 00:00:00 2001 From: John Rehbein Date: Sat, 24 Aug 2024 16:51:34 -0700 Subject: [PATCH] Fix ImGui conditional compilation --- Source/UnrealLibretro/Private/LibretroContext.cpp | 13 +++++++------ Source/UnrealLibretro/Public/UnrealLibretro.h | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Source/UnrealLibretro/Private/LibretroContext.cpp b/Source/UnrealLibretro/Private/LibretroContext.cpp index 4bcc3ba..9434ca3 100644 --- a/Source/UnrealLibretro/Private/LibretroContext.cpp +++ b/Source/UnrealLibretro/Private/LibretroContext.cpp @@ -5,8 +5,11 @@ extern "C" extern void LibretroSam2LogWrite(int level, const char* file, int line, const char* fmt, ...); } +#include "UnrealLibretro.h" // For Libretro debug log category #define ULNET_IMPLEMENTATION +#if UNREALLIBRETRO_NETIMGUI #define ULNET_IMGUI +#endif #define SAM2_IMPLEMENTATION #define SAM2_LOG_WRITE(level, file, line, ...) LibretroSam2LogWrite(level, file, line, "Netplay: " __VA_ARGS__) @@ -15,7 +18,6 @@ THIRD_PARTY_INCLUDES_START #include "ulnet.h" THIRD_PARTY_INCLUDES_END -#include "UnrealLibretro.h" // For Libretro debug log category #if UNREALLIBRETRO_NETIMGUI #include "NetImgui_Api.h" #endif @@ -1068,7 +1070,7 @@ FLibretroContext* FLibretroContext::Launch(ULibretroCoreInstance* LibretroCoreIn AbsoluteCoreDirectory.Len()); }; -#ifdef UNREALLIBRETRO_NETIMGUI +#if UNREALLIBRETRO_NETIMGUI static ImFontAtlas* GlobalFontAtlas = nullptr; if (GlobalFontAtlas == nullptr) { GlobalFontAtlas = new ImFontAtlas(); @@ -1079,7 +1081,9 @@ FLibretroContext* FLibretroContext::Launch(ULibretroCoreInstance* LibretroCoreIn #endif l->netplay_session = (ulnet_session_t *) calloc(1, sizeof(ulnet_session_t)); +#if UNREALLIBRETRO_NETIMGUI l->netplay_session->sample_size = ULNET_MAX_SAMPLE_SIZE; +#endif l->netplay_session->delay_frames = 2; // @todo Make configurable auto LibretroSettings = GetDefault(); @@ -1112,9 +1116,6 @@ FLibretroContext* FLibretroContext::Launch(ULibretroCoreInstance* LibretroCoreIn #endif ); - uint64 frames = 0; - auto start = FDateTime::Now(); - verify(IPlatformFile::GetPlatformPhysical().CopyFile(*InstancedCorePath, *core)); l->core.hw.version_major = 4; @@ -1301,9 +1302,9 @@ FLibretroContext* FLibretroContext::Launch(ULibretroCoreInstance* LibretroCoreIn // These ImGui routines all cleanup thread_local objects if they aren't NULL #if UNREALLIBRETRO_NETIMGUI NetImgui::Shutdown(); -#endif ImPlot::DestroyContext(); ImGui::DestroyContext(); +#endif if (l->CoreState.load(std::memory_order_relaxed) == ECoreState::StartFailed) { diff --git a/Source/UnrealLibretro/Public/UnrealLibretro.h b/Source/UnrealLibretro/Public/UnrealLibretro.h index fcd9e59..faae6a5 100644 --- a/Source/UnrealLibretro/Public/UnrealLibretro.h +++ b/Source/UnrealLibretro/Public/UnrealLibretro.h @@ -18,7 +18,7 @@ extern char UnrealLibretroVersionAnsi[]; #define UNREALLIBRETRO_NETIMGUI 1 #elif PLATFORM_MAC #define UNREALLIBRETRO_NETIMGUI 1 -#elif +#else #define UNREALLIBRETRO_NETIMGUI 0 #endif