]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix #2433 "Bold messages appearing twice"
authorterencehill <piuntn@gmail.com>
Sat, 9 May 2020 12:51:59 +0000 (14:51 +0200)
committerterencehill <piuntn@gmail.com>
Sat, 9 May 2020 12:51:59 +0000 (14:51 +0200)
qcsrc/client/hud/panel/centerprint.qc

index 5d47ed85a06ade00a35caa5770d7ab4cbd0ef71d..446a64ec65649c7266c890f56fdc803f366dec72 100644 (file)
@@ -196,7 +196,7 @@ void HUD_CenterPrint ()
        }
 
        bool is_bold;
        }
 
        bool is_bold;
-       string centerprint_message;
+       string centerprint_message = strzone("");
        int entries;
        float height;
        vector fontsize;
        int entries;
        float height;
        vector fontsize;
@@ -216,7 +216,10 @@ void HUD_CenterPrint ()
                // if the notification starts with ^BOLD make it bold (e.g. frag messages);
                is_bold = (substring(centerprint_messages[j], 0, 5) == BOLD_OPERATOR);
                // remove ^BOLD so it doesn't get printed onscreen
                // if the notification starts with ^BOLD make it bold (e.g. frag messages);
                is_bold = (substring(centerprint_messages[j], 0, 5) == BOLD_OPERATOR);
                // remove ^BOLD so it doesn't get printed onscreen
-               centerprint_message = is_bold ? strzone(substring(centerprint_messages[j], 5, -1)) : strzone(centerprint_messages[j]);
+               if (is_bold)
+                       strcpy(centerprint_message, substring(centerprint_messages[j], 5, -1));
+               else
+                       strcpy(centerprint_message, centerprint_messages[j]);
 
                // entries = bound(1, floor(CENTERPRINT_MAX_ENTRIES * 4 * panel_size_y/panel_size_x), CENTERPRINT_MAX_ENTRIES);
                // height = panel_size_y/entries;
 
                // entries = bound(1, floor(CENTERPRINT_MAX_ENTRIES * 4 * panel_size_y/panel_size_x), CENTERPRINT_MAX_ENTRIES);
                // height = panel_size_y/entries;
@@ -340,6 +343,7 @@ void HUD_CenterPrint ()
                        if (pos.y < panel_pos.y) // check if the next message can be shown
                        {
                                drawfontscale = hud_scale;
                        if (pos.y < panel_pos.y) // check if the next message can be shown
                        {
                                drawfontscale = hud_scale;
+                               strfree(centerprint_message);
                                return;
                        }
                }
                                return;
                        }
                }
@@ -352,13 +356,13 @@ void HUD_CenterPrint ()
                        if(pos.y > panel_pos.y + panel_size.y - fontsize.y) // check if the next message can be shown
                        {
                                drawfontscale = hud_scale;
                        if(pos.y > panel_pos.y + panel_size.y - fontsize.y) // check if the next message can be shown
                        {
                                drawfontscale = hud_scale;
+                               strfree(centerprint_message);
                                return;
                        }
                }
                                return;
                        }
                }
-
-               // free up memory
-               strunzone(centerprint_message);
        }
        }
+       strfree(centerprint_message);
+
        drawfontscale = hud_scale;
        if (all_messages_expired)
        {
        drawfontscale = hud_scale;
        if (all_messages_expired)
        {