]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
centerprint no longer counts color codes when centering lines
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 27 May 2006 19:58:53 +0000 (19:58 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 27 May 2006 19:58:53 +0000 (19:58 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6394 d7cf8633-e32d-0410-b094-e92efae38249

cl_screen.c

index 56fb1ff1f37bbc59836e3f409832f54e9cfc0ff2..19f068426386568f535e4c694cb336015a08d361 100644 (file)
@@ -125,11 +125,19 @@ void SCR_DrawCenterString (void)
        color = -1;
        do
        {
-       // scan the width of the line
+               // scan the number of characters on the line, not counting color codes
+               int chars = 0;
                for (l=0 ; l<vid_conwidth.integer/8 ; l++)
+               {
                        if (start[l] == '\n' || !start[l])
                                break;
-               x = (vid_conwidth.integer - l*8)/2;
+                       // color codes add no visible characters, so don't count them
+                       if (start[l] == '^' && (start[l+1] >= '0' && start[l+1] <= '9'))
+                               l++;
+                       else
+                               chars++;
+               }
+               x = (vid_conwidth.integer - chars*8)/2;
                if (l > 0)
                {
                        if (remaining < l)