improved forced restart of global animations when restarting game
authorHolger Schemel <info@artsoft.org>
Sat, 9 Sep 2023 13:55:44 +0000 (15:55 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 9 Sep 2023 14:03:15 +0000 (16:03 +0200)
When forcing a restart of global animations when restarting the game,
a full screen redraw is neither required nor desired. Therefore, this
change only restarts global animations according to the game status
passed to function "RestartGlobalAnimsByStatus()", but does not redraw
the screen (including global animations, so nothing is drawn at all).

src/anim.c
src/libgame/system.h

index 8b307ea4482f1c54d0a892ea4250b689cc04ec37..710383f3c608c03e4e3832fea3b13e6ab6cc3bbf 100644 (file)
@@ -857,6 +857,10 @@ static void DrawGlobalAnimationsExt(int drawing_target, int drawing_stage)
     }
   }
 
+  // when restarting global animations, do not redraw them, but stop here
+  if (drawing_stage == DRAW_GLOBAL_ANIM_STAGE_RESTART)
+    return;
+
   if (global.anim_status == GAME_MODE_LOADING)
     return;
 
@@ -2155,7 +2159,7 @@ void RestartGlobalAnimsByStatus(int status)
   global.anim_status = status;
 
   // force restarting global animations by changed global animation status
-  SDLRedrawWindow();
+  DrawGlobalAnimationsExt(DRAW_TO_SCREEN, DRAW_GLOBAL_ANIM_STAGE_RESTART);
 
   global.anim_status = anim_status_last;
 }
index d74b057b60b28314dbf760ac72ec0293d8d5c50c..44745de9c32c7143fc5300fda3701f25db550024 100644 (file)
 #define DRAW_GLOBAL_ANIM_STAGE_1       1
 #define DRAW_GLOBAL_ANIM_STAGE_2       2
 #define DRAW_GLOBAL_ANIM_STAGE_3       3
+#define DRAW_GLOBAL_ANIM_STAGE_RESTART 4
 
 // values for drawing target (various functions)
 #define DRAW_TO_BACKBUFFER             0