From: terencehill Date: Sun, 26 Jun 2011 16:12:46 +0000 (+0200) Subject: Trim trailing and leading newlines from every msg before adding it to the list X-Git-Tag: xonotic-v0.5.0~179 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b976036e4a483665096dab67d0c614e9f0b39843;p=xonotic%2Fxonotic-data.pk3dir.git Trim trailing and leading newlines from every msg before adding it to the list --- diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index e49fd4911..7b699c44b 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -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;