fixed horrible crash bug caused by dereferencing pointer just freed before
[rocksndiamonds.git] / src / screens.c
index 81a54b064ca2fbe7f52a214172f2b9d643409ca3..c82f2a962d6d5463c2d85565ac4d90dddf276286 100644 (file)
@@ -1739,6 +1739,16 @@ void DrawMainMenu(void)
   SetMouseCursor(CURSOR_DEFAULT);
 
   OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
+
+#if defined(PLATFORM_EMSCRIPTEN)
+  EM_ASM
+  (
+    FS.syncfs(function(err)
+    {
+      assert(!err);
+    });
+  );
+#endif
 }
 
 static void gotoTopLevelDir(void)
@@ -2213,7 +2223,8 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
        SaveLevelSetup_LastSeries();
        SaveLevelSetup_SeriesInfo();
 
-        if (Request("Do you really want to quit?", REQ_ASK | REQ_STAY_CLOSED))
+       if (!setup.ask_on_quit_program ||
+           Request("Do you really want to quit?", REQ_ASK | REQ_STAY_CLOSED))
          SetGameStatus(GAME_MODE_QUIT);
       }
     }
@@ -4869,6 +4880,9 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
            LoadLevelSetup_LastSeries();
            LoadLevelSetup_SeriesInfo();
 
+           // update list of last played level sets
+           UpdateLastPlayedLevels_TreeInfo();
+
            TapeErase();
 
            ToggleFullscreenIfNeeded();
@@ -6719,6 +6733,8 @@ static struct TokenInfo setup_info_game[] =
   { TYPE_SWITCH,       &setup.count_score_after_game,"Count Score After Game:" },
   { TYPE_SWITCH,       &setup.show_scores_after_game,"Show Scores After Game:" },
   { TYPE_YES_NO,       &setup.ask_on_game_over, "Ask on Game Over:"    },
+  { TYPE_YES_NO,       &setup.ask_on_quit_game, "Ask on Quit Game:"    },
+  { TYPE_YES_NO,       &setup.ask_on_quit_program, "Ask on Quit Program:" },
   { TYPE_SWITCH,       &setup.autorecord,      "Auto-Record Tapes:"    },
   { TYPE_ENTER_LIST,   execSetupChooseGameSpeed, "Game Speed:"         },
   { TYPE_STRING,       &game_speed_text,       ""                      },