From be3b72b3160b01cbadea1813b37650f6de28c67f Mon Sep 17 00:00:00 2001 From: zicodxx Date: Sun, 21 Nov 2010 21:19:45 +0100 Subject: [PATCH] When checking for redundant messages in HUD display, compare new message to most recent one for locking and check whole list only for messages marked with HM_REDUNDANT. This will show all messages in correct order while keeping redundancy-prone messages from looping infinitely --- CHANGELOG.txt | 1 + main/hud.c | 25 +++++++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index e20b100cd..2fe41608c 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -4,6 +4,7 @@ D1X-Rebirth Changelog -------- arch/sdl/jukebox.c, include/physfsx.h, main/menu.c, misc/physfsx.c: Created function PHYSFSX_isNewPath to check wether given path has already been added to Searchpath or not; Used PHYSFSX_isNewPath for menu browsing code instead it's own implementation; Using PHYSFSX_isNewPath for Jukebox directory, too to make sure Jukebox will not accidentially remove Game content depending on user selection; Also only keep Jukebox directory added until files are stored to prevent any other file present in this path can override or add anything to the game main/config.c: For fresh configuration set Redbook music as default for Mac, Builtin music for all others +main/hud.c: When checking for redundant messages in HUD display, compare new message to most recent one for locking and check whole list only for messages marked with HM_REDUNDANT. This will show all messages in correct order while keeping redundancy-prone messages from looping infinitely 20101113 -------- diff --git a/main/hud.c b/main/hud.c index 3c0360387..ec7d801d9 100644 --- a/main/hud.c +++ b/main/hud.c @@ -110,7 +110,7 @@ void HUD_render_message_frame() // Call to flash a message on the HUD. Returns true if message drawn. // (message might not be drawn if previous message was same) -int HUD_init_message_va(char * format, va_list args) +int HUD_init_message_va(int class_flag, char * format, va_list args) { int i, j; #ifndef macintosh @@ -125,16 +125,21 @@ int HUD_init_message_va(char * format, va_list args) vsprintf(message, format, args); #endif - // already in list - do not add again - for (i = 0; i < HUD_nmessages; i++) + + // check if message is already in list and bail out if so + if (HUD_nmessages > 0) { - if (!strnicmp(message, HUD_messages[i].message, sizeof(char)*HUD_MESSAGE_LENGTH)) + // if "normal" message, only check if it's the same at the most recent one, if marked as "redundant" check whole list + for (i = ((class_flag & HM_REDUNDANT)?0:HUD_nmessages-1); i < HUD_nmessages; i++) { - HUD_messages[i].time = F1_0*2; // keep redundant message in list - if (i >= HUD_nmessages-HUD_MAX_NUM_DISP) // if redundant message on display, update them all - for (i = (HUD_nmessages-HUD_MAX_NUM_DISP<0?0:HUD_nmessages-HUD_MAX_NUM_DISP), j = 1; i < HUD_nmessages; i++, j++) - HUD_messages[i].time = F1_0*(j*2); - return 0; + if (!strnicmp(message, HUD_messages[i].message, sizeof(char)*HUD_MESSAGE_LENGTH)) + { + HUD_messages[i].time = F1_0*2; // keep redundant message in list + if (i >= HUD_nmessages-HUD_MAX_NUM_DISP) // if redundant message on display, update them all + for (i = (HUD_nmessages-HUD_MAX_NUM_DISP<0?0:HUD_nmessages-HUD_MAX_NUM_DISP), j = 1; i < HUD_nmessages; i++, j++) + HUD_messages[i].time = F1_0*(j*2); + return 0; + } } } @@ -189,7 +194,7 @@ int HUD_init_message(int class_flag, char * format, ... ) return 0; va_start(args, format); - ret = HUD_init_message_va(format, args); + ret = HUD_init_message_va(class_flag, format, args); va_end(args); return ret;