# HG changeset patch # User Wuzzy # Date 1531765681 -7200 # Node ID 4faebbf9c44fa973b1229121375b133a671c4a9e # Parent 8935dcc0e1307f3963d2d21e4f7ce1cca8407579 Fix hwengine crash when using >1 controllers Reason: Data type mismatch for SDL_JoystickName, we wed in an index, but it expected a controller handle. Solution: Switch to SDL_JoystickNameForIndex. diff -r 8935dcc0e130 -r 4faebbf9c44f hedgewars/SDLh.pas --- a/hedgewars/SDLh.pas Mon Jul 16 19:15:22 2018 +0200 +++ b/hedgewars/SDLh.pas Mon Jul 16 20:28:01 2018 +0200 @@ -1165,7 +1165,7 @@ procedure SDL_UnlockAudio; cdecl; external SDLLibName; function SDL_NumJoysticks: LongInt; cdecl; external SDLLibName; -function SDL_JoystickName(idx: LongInt): PChar; cdecl; external SDLLibName; +function SDL_JoystickNameForIndex(idx: LongInt): PChar; cdecl; external SDLLibName; function SDL_JoystickOpen(idx: LongInt): PSDL_Joystick; cdecl; external SDLLibName; function SDL_JoystickOpened(idx: LongInt): LongInt; cdecl; external SDLLibName; function SDL_JoystickIndex(joy: PSDL_Joystick): LongInt; cdecl; external SDLLibName; diff -r 8935dcc0e130 -r 4faebbf9c44f hedgewars/uInputHandler.pas --- a/hedgewars/uInputHandler.pas Mon Jul 16 19:15:22 2018 +0200 +++ b/hedgewars/uInputHandler.pas Mon Jul 16 20:28:01 2018 +0200 @@ -514,10 +514,10 @@ begin for j:= 0 to pred(ControllerNumControllers) do begin - WriteLnToConsole('Using game controller: ' + shortstring(SDL_JoystickName(j))); + WriteLnToConsole('Game controller no. ' + IntToStr(j) + ', name "' + shortstring(SDL_JoystickNameForIndex(j)) + '":'); Controller[j]:= SDL_JoystickOpen(j); if Controller[j] = nil then - WriteLnToConsole('* Failed to open game controller!') + WriteLnToConsole('* Failed to open game controller no. ' + IntToStr(j) + '!') else begin ControllerNumAxes[j]:= SDL_JoystickNumAxes(Controller[j]);