From 56243d9e05b3b2da26398e56a4fd9952ea4263bd Mon Sep 17 00:00:00 2001 From: Colin Pitrat Date: Sat, 3 Oct 2020 10:30:29 +0100 Subject: [PATCH] Fix entering player's name with SDL 1. The static bool means there's one copy of the variable per compilation unit using the header. So changing its value in one compilation unit doesn't affect the other compilation units. This is clearly not what is wanted here. Fixing this requires adding a CPP in SourceS. This is the first one there, I hope it's not an issue. The sdl2_to_1_2_backports should only be used with SDL1 so I only include it in the list of sources for SDL1 builds. I'm not familiar with cmake so I hope I don't do anything stupid there! --- CMakeLists.txt | 5 +++++ SourceS/sdl2_to_1_2_backports.cpp | 3 +++ SourceS/sdl2_to_1_2_backports.h | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 SourceS/sdl2_to_1_2_backports.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index b76673863..7768e1961 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -299,6 +299,11 @@ set(devilutionx_SRCS Packaging/resources/CharisSILB.ttf Packaging/windows/devilutionx.rc) +if(USE_SDL1) + list(APPEND devilutionx_SRCS + SourceS/sdl2_to_1_2_backports.cpp) +endif() + if(NOT NONET) list(APPEND devilutionx_SRCS SourceX/dvlnet/tcp_client.cpp diff --git a/SourceS/sdl2_to_1_2_backports.cpp b/SourceS/sdl2_to_1_2_backports.cpp new file mode 100644 index 000000000..4783c1f5b --- /dev/null +++ b/SourceS/sdl2_to_1_2_backports.cpp @@ -0,0 +1,3 @@ +#include "sdl2_to_1_2_backports.h" + +SDL_bool SDLBackport_IsTextInputActive = SDL_FALSE; diff --git a/SourceS/sdl2_to_1_2_backports.h b/SourceS/sdl2_to_1_2_backports.h index 5a8b59f3c..50a87a2a6 100644 --- a/SourceS/sdl2_to_1_2_backports.h +++ b/SourceS/sdl2_to_1_2_backports.h @@ -59,7 +59,7 @@ inline void SDL_Log(const char *fmt, ...) puts(""); } -static SDL_bool SDLBackport_IsTextInputActive = SDL_FALSE; +extern SDL_bool SDLBackport_IsTextInputActive; inline SDL_bool SDL_IsTextInputActive() {