]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Trim trailing and leading newlines from every msg before adding it to the list
authorterencehill <piuntn@gmail.com>
Sun, 26 Jun 2011 16:12:46 +0000 (18:12 +0200)
committerterencehill <piuntn@gmail.com>
Sun, 26 Jun 2011 16:12:46 +0000 (18:12 +0200)
qcsrc/client/hud.qc

index e49fd49117ea91153d7fa1433c501f2b00cd2227..7b699c44b284fa121bddb7d8905954c522b76565 100644 (file)
@@ -4360,6 +4360,26 @@ void centerprint_generic(float new_id, string strMessage, float duration, float
 {
        float i, j;
 
+       if(strMessage == "" && new_id == 0)
+               return;
+
+       // strip trailing newlines
+       j = strlen(strMessage) - 1;
+       while(substring(strMessage, j, 1) == "\n" && j >= 0)
+               --j;
+       if (j < strlen(strMessage) - 1)
+               strMessage = substring(strMessage, 0, j + 1);
+
+       if(strMessage == "" && new_id == 0)
+               return;
+
+       // strip leading newlines
+       j = 0;
+       while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
+               ++j;
+       if (j > 0)
+               strMessage = substring(strMessage, j, strlen(strMessage) - j);
+
        if(strMessage == "" && new_id == 0)
                return;