X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Flibgame%2Fsdl.c;h=04fa05e8c5151be5721ad9c07bcce1e1f06173ca;hp=ee43dc05b0c1b1795328b129d1ca0a563f0398e2;hb=aa931ed885e278dc0102b5e10f59b2ba52fb690a;hpb=aa77ac7ad31e0a9ab20bb85b51e429cd45f12455 diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index ee43dc05..04fa05e8 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -2603,7 +2603,7 @@ static boolean sdl_is_controller[MAX_PLAYERS]; static boolean SDLOpenJoystick(int nr) { - if (nr < 0 || nr > MAX_PLAYERS) + if (nr < 0 || nr >= MAX_PLAYERS) return FALSE; #if defined(TARGET_SDL2) @@ -2631,7 +2631,7 @@ static boolean SDLOpenJoystick(int nr) static void SDLCloseJoystick(int nr) { - if (nr < 0 || nr > MAX_PLAYERS) + if (nr < 0 || nr >= MAX_PLAYERS) return; #if 1 @@ -2659,7 +2659,7 @@ static void SDLCloseJoystick(int nr) boolean SDLCheckJoystickOpened(int nr) { - if (nr < 0 || nr > MAX_PLAYERS) + if (nr < 0 || nr >= MAX_PLAYERS) return FALSE; #if defined(TARGET_SDL2) @@ -2680,6 +2680,9 @@ static void setJoystickAxis(int nr, int axis_id_raw, int axis_value) int axis_id = axis_id_raw % 2; #endif + if (nr < 0 || nr >= MAX_PLAYERS) + return; + if (axis_id == -1) return; @@ -2723,6 +2726,9 @@ static void setJoystickButton(int nr, int button_id_raw, int button_state) int button_id = button_id_raw % 2; #endif + if (nr < 0 || nr >= MAX_PLAYERS) + return; + if (button_id == -1) return; @@ -2913,8 +2919,8 @@ void SDLInitJoysticks() joystick_nr = -1; } - /* misuse joystick file descriptor variable to store joystick number */ - joystick.fd[i] = joystick_nr; + /* store configured joystick number for each player */ + joystick.nr[i] = joystick_nr; } /* now open all connected joysticks (regardless if configured or not) */