From eaa206aa1727fa745168edbe04604569a97a2387 Mon Sep 17 00:00:00 2001 From: havoc Date: Wed, 18 Apr 2007 06:45:31 +0000 Subject: [PATCH] further optimized space skipping in DrawQ_String git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7122 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_draw.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/gl_draw.c b/gl_draw.c index 82b2bea7..164eebdd 100644 --- a/gl_draw.c +++ b/gl_draw.c @@ -672,7 +672,7 @@ static void DrawQ_GetTextColor(float color[4], int colorindex, float r, float g, float DrawQ_String(float startx, float starty, const char *text, int maxlen, float w, float h, float basered, float basegreen, float baseblue, float basealpha, int flags, int *outcolor, qboolean ignorecolorcodes) { int i, num, shadow, colorindex; - float x, y, s, t, u, v; + float x = startx, y, s, t, u, v; float *av, *at, *ac; float color[4]; int batchcount; @@ -713,24 +713,28 @@ float DrawQ_String(float startx, float starty, const char *text, int maxlen, flo } // because this loop increments x before it draws, we must bias x first x -= w; - for (i = 0;i < maxlen && text[i];) + for (i = 0;i < maxlen && text[i];i++, x += w) { + if (text[i] == ' ') + continue; if (text[i] == STRING_COLOR_TAG && !ignorecolorcodes && i + 1 < maxlen) { if (text[i+1] == STRING_COLOR_TAG) + { i++; + if (text[i] == ' ') + continue; + } else if (text[i+1] >= '0' && text[i+1] <= '9') { colorindex = text[i+1] - '0'; DrawQ_GetTextColor(color, colorindex, basered, basegreen, baseblue, basealpha, shadow); - i += 2; + i++; + x -= w; continue; } } - num = text[i++]; - x += w; - if (num == ' ') - continue; + num = text[i]; s = (num & 15)*0.0625f + (0.5f / 256.0f); t = (num >> 4)*0.0625f + (0.5f / 256.0f); u = 0.0625f - (1.0f / 256.0f); -- 2.39.2