From 2845fcd0832f6b527e582c77354e82d433e4459b Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sat, 9 Sep 2023 15:55:44 +0200 Subject: [PATCH] improved forced restart of global animations when restarting game 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 | 6 +++++- src/libgame/system.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/anim.c b/src/anim.c index 8b307ea4..710383f3 100644 --- a/src/anim.c +++ b/src/anim.c @@ -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; } diff --git a/src/libgame/system.h b/src/libgame/system.h index d74b057b..44745de9 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -289,6 +289,7 @@ #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 -- 2.34.1