File: sdl-joystick-api.patch

package info (click to toggle)
heroes 0.21-21
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,796 kB
  • sloc: ansic: 27,951; sh: 3,941; makefile: 651; yacc: 318; sed: 51; lisp: 10; perl: 9
file content (27 lines) | stat: -rw-r--r-- 938 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Description: Avoid SDL's joystick API if it's uninitialised
Author: Alexandre Duret-Lutz <duret_g@epita.fr>
Bug-Debian: https://bugs.debian.org/169525
Last-Update: 2016-01-21

2002-04-07  Alexandre Duret-Lutz  <duret_g@epita.fr>

	* src/media/sdl/joystick.c (get_joystick_state): Make sure we
	  never use SDL's Joystick API if it wasn't initialized.
	  Reported by William Black.

--- heroes-0.21.orig/src/media/sdl/joystick.c
+++ heroes-0.21/src/media/sdl/joystick.c
@@ -63,6 +63,13 @@ char joyinit (void)
 
 void get_joystick_state (void)
 {
+  /* Make sure we never use SDL's Joystick API if it wasn't
+     initialized (this happens when the game is run with -J): crashes
+     have been reported by a Windows user.  More generally, avoid
+     these extra calls if no joystick was detected.  */
+  if (joystick_detected == 0)
+    return;
+
   SDL_JoystickUpdate();
   if (joystick[0]) {
     joystick_b[0] = (joystick_b[0] & ~1) |