From 582792472e9a224e6d4c089937399443053cdcf1 Mon Sep 17 00:00:00 2001 From: Starbuck5 <46412508+Starbuck5@users.noreply.github.com> Date: Sat, 12 Oct 2024 17:07:03 -0700 Subject: [PATCH] Rework pg_EnvShouldBlendAlphaSDL2 for SDL3 SDL_getenv now returns a const char* instead of a char*, so rather than worry about propagating that through or casting it away, lets just have pg_EnvShouldBlendAlphaSDL2 return an int, and have the callers evaluate that instead of evaluating whether a char* is NULL or not. This requires no changes to the callers. --- src_c/base.c | 8 ++++---- src_c/include/_pygame.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src_c/base.c b/src_c/base.c index d4f33c813c..04379ba0f2 100644 --- a/src_c/base.c +++ b/src_c/base.c @@ -81,7 +81,7 @@ static int pg_is_init = 0; static int pg_sdl_was_init = 0; SDL_Window *pg_default_window = NULL; pgSurfaceObject *pg_default_screen = NULL; -static char *pg_env_blend_alpha_SDL2 = NULL; +static int pg_env_blend_alpha_SDL2 = 0; static void pg_install_parachute(void); @@ -170,7 +170,7 @@ static pgSurfaceObject * pg_GetDefaultWindowSurface(void); static void pg_SetDefaultWindowSurface(pgSurfaceObject *); -static char * +static int pg_EnvShouldBlendAlphaSDL2(void); /* compare compiled to linked, raise python error on incompatibility */ @@ -347,7 +347,7 @@ pg_init(PyObject *self, PyObject *_null) pg_sdl_was_init = SDL_Init(PG_INIT_TIMER | PG_INIT_NOPARACHUTE) == 0; #endif - pg_env_blend_alpha_SDL2 = SDL_getenv("PYGAME_BLEND_ALPHA_SDL2"); + pg_env_blend_alpha_SDL2 = SDL_getenv("PYGAME_BLEND_ALPHA_SDL2") != NULL; /* initialize all pygame modules */ for (i = 0; modnames[i]; i++) { @@ -2096,7 +2096,7 @@ pg_SetDefaultConvertFormat(Uint32 format) return pg_default_convert_format; // returns for NULL error checking } -static char * +static int pg_EnvShouldBlendAlphaSDL2(void) { return pg_env_blend_alpha_SDL2; diff --git a/src_c/include/_pygame.h b/src_c/include/_pygame.h index bcfb0fdc8c..8158fe68df 100644 --- a/src_c/include/_pygame.h +++ b/src_c/include/_pygame.h @@ -181,7 +181,7 @@ typedef struct pg_bufferinfo_s { (*(void (*)(pgSurfaceObject *))PYGAMEAPI_GET_SLOT(base, 22)) #define pg_EnvShouldBlendAlphaSDL2 \ - (*(char *(*)(void))PYGAMEAPI_GET_SLOT(base, 23)) + (*(int (*)(void))PYGAMEAPI_GET_SLOT(base, 23)) #define pg_GetDefaultConvertFormat \ (*(SDL_PixelFormat * (*)(void)) PYGAMEAPI_GET_SLOT(base, 27))