cleanup of some common and specific game engine function calls
[rocksndiamonds.git] / src / game.c
index 1f64845d156cbe6a3d9b739e61f376a8ebdbb468..49acec5bed46a4c70b979dd4fc3f5d795284c645 100644 (file)
@@ -4392,13 +4392,16 @@ void GameEnd()
 
   local_player->LevelSolved_GameEnd = TRUE;
 
-  CloseDoor(DOOR_CLOSE_1);
+  if (!global.use_envelope_request)
+    CloseDoor(DOOR_CLOSE_1);
 
   if (local_player->LevelSolved_SaveTape)
   {
     SaveTapeChecked(tape.level_nr);    /* ask to save tape */
   }
 
+  CloseDoor(DOOR_CLOSE_ALL);
+
   if (level_editor_test_game)
   {
     game_status = GAME_MODE_MAIN;
@@ -4433,6 +4436,9 @@ void GameEnd()
   {
     game_status = GAME_MODE_SCORES;
 
+    /* needed if different viewport properties defined for scores */
+    ChangeViewportPropertiesIfNeeded();
+
     DrawHallOfFame(hi_pos);
 
     if (raise_level)
@@ -11188,8 +11194,14 @@ void GameActions()
   }
   else
   {
-    GameActions_RND();
+    GameActions_RND_Main();
   }
+
+  BlitScreenToBitmap(backbuffer);
+
+  CheckLevelTime();
+
+  AdvanceFrameAndPlayerCounters(-1);   /* advance counters for all players */
 }
 
 void GameActions_EM_Main()
@@ -11202,10 +11214,6 @@ void GameActions_EM_Main()
     effective_action[i] = stored_player[i].effective_action;
 
   GameActions_EM(effective_action, warp_mode);
-
-  CheckLevelTime();
-
-  AdvanceFrameAndPlayerCounters(-1);   /* advance counters for all players */
 }
 
 void GameActions_SP_Main()
@@ -11218,10 +11226,11 @@ void GameActions_SP_Main()
     effective_action[i] = stored_player[i].effective_action;
 
   GameActions_SP(effective_action, warp_mode);
+}
 
-  CheckLevelTime();
-
-  AdvanceFrameAndPlayerCounters(-1);   /* advance counters for all players */
+void GameActions_RND_Main()
+{
+  GameActions_RND();
 }
 
 void GameActions_RND()
@@ -11723,8 +11732,6 @@ void GameActions_RND()
   }
 #endif
 
-  CheckLevelTime();
-
   DrawAllPlayers();
   PlayAllPlayersSound();
 
@@ -11747,8 +11754,6 @@ void GameActions_RND()
     redraw_mask |= REDRAW_FPS;
   }
 
-  AdvanceFrameAndPlayerCounters(-1);   /* advance counters for all players */
-
   if (local_player->show_envelope != 0 && local_player->MovPos == 0)
   {
     ShowEnvelope(local_player->show_envelope - EL_ENVELOPE_1);
@@ -11802,16 +11807,16 @@ static boolean AllPlayersInVisibleScreen()
 
 void ScrollLevel(int dx, int dy)
 {
-  int softscroll_offset = (setup.soft_scrolling ? 2 * TILEX_VAR : 0);
+  int scroll_offset = 2 * TILEX_VAR;
   int x, y;
 
   BlitBitmap(drawto_field, drawto_field,
-            FX + TILEX_VAR * (dx == -1) - softscroll_offset,
-            FY + TILEY_VAR * (dy == -1) - softscroll_offset,
-            SXSIZE - TILEX_VAR * (dx != 0) + 2 * softscroll_offset,
-            SYSIZE - TILEY_VAR * (dy != 0) + 2 * softscroll_offset,
-            FX + TILEX_VAR * (dx == 1) - softscroll_offset,
-            FY + TILEY_VAR * (dy == 1) - softscroll_offset);
+            FX + TILEX_VAR * (dx == -1) - scroll_offset,
+            FY + TILEY_VAR * (dy == -1) - scroll_offset,
+            SXSIZE - TILEX_VAR * (dx != 0) + 2 * scroll_offset,
+            SYSIZE - TILEY_VAR * (dy != 0) + 2 * scroll_offset,
+            FX + TILEX_VAR * (dx == 1) - scroll_offset,
+            FY + TILEY_VAR * (dy == 1) - scroll_offset);
 
   if (dx != 0)
   {