fixed changing key bindings if customization aborted by "Escape" key
authorHolger Schemel <info@artsoft.org>
Thu, 19 Apr 2018 18:37:32 +0000 (20:37 +0200)
committerHolger Schemel <info@artsoft.org>
Thu, 19 Apr 2018 18:37:32 +0000 (20:37 +0200)
Before, partially changed key bindings were kept even if keyboard
customization was aborted by pressing the "Escape" key during the
process. Now, the old key bindings are restored in this case.

src/screens.c

index e6397b5c6532a66e33ba9a46fde9accd84837853..33df999e188698611fa0a938fe74939d8a4a8dcb 100644 (file)
@@ -6497,11 +6497,13 @@ static boolean CustomizeKeyboardMain(int player_nr)
          {
            Key key = GetEventKey((KeyEvent *)&event, FALSE);
 
+           /* press 'Escape' to abort and keep the old key bindings */
            if (key == KSYM_Escape)
            {
              FadeSkipNextFadeIn();
 
              finished = TRUE;
+
              break;
            }
 
@@ -6563,8 +6565,9 @@ static boolean CustomizeKeyboardMain(int player_nr)
     BackToFront();
   }
 
-  /* write new key bindings back to player setup */
-  setup.input[player_nr].key = custom_key;
+  /* write new key bindings back to player setup, if successfully finished */
+  if (success)
+    setup.input[player_nr].key = custom_key;
 
   return success;
 }