From: Holger Schemel Date: Sat, 5 Sep 2020 18:45:45 +0000 (+0200) Subject: added macros for converting vsync mode string and integer values X-Git-Tag: 4.2.0.2~9 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=2420800e428feaa01663bb5b9fa334b5efe9221b;p=rocksndiamonds.git added macros for converting vsync mode string and integer values --- diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index c7a87297..d34feb4c 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -877,10 +877,7 @@ void SDLSetScreenRenderingMode(char *screen_rendering_mode) void SDLSetScreenVsyncMode(char *vsync_mode) { - int interval = - (strEqual(vsync_mode, STR_VSYNC_MODE_NORMAL) ? VSYNC_MODE_NORMAL : - strEqual(vsync_mode, STR_VSYNC_MODE_ADAPTIVE) ? VSYNC_MODE_ADAPTIVE : - VSYNC_MODE_OFF); + int interval = VSYNC_MODE_STR_TO_INT(vsync_mode); int result = SDL_GL_SetSwapInterval(interval); // if adaptive vsync requested, but not supported, retry with normal vsync diff --git a/src/libgame/system.h b/src/libgame/system.h index e3f0fba9..6e0296ef 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -87,6 +87,16 @@ #define VSYNC_MODE_DEFAULT VSYNC_MODE_OFF +#define VSYNC_MODE_STR_TO_INT(s) \ + (strEqual((s), STR_VSYNC_MODE_NORMAL) ? VSYNC_MODE_NORMAL : \ + strEqual((s), STR_VSYNC_MODE_ADAPTIVE) ? VSYNC_MODE_ADAPTIVE : \ + VSYNC_MODE_OFF) + +#define VSYNC_MODE_INT_TO_STR(i) \ + ((i) == VSYNC_MODE_NORMAL ? STR_VSYNC_MODE_NORMAL : \ + (i) == VSYNC_MODE_ADAPTIVE ? STR_VSYNC_MODE_ADAPTIVE : \ + STR_VSYNC_MODE_OFF) + // values for network server settings #define STR_NETWORK_AUTO_DETECT "auto_detect_network_server" #define STR_NETWORK_AUTO_DETECT_SETUP "(auto detect network server)"