From 668774c12e516381e2c6bc679ca918bd45b1898a Mon Sep 17 00:00:00 2001 From: helixhorned Date: Fri, 24 Feb 2012 19:51:37 +0000 Subject: [PATCH] Fix user quotes colored with a 2-digit number being wrongly x-aligned. Such game text was shown starting from about the center of the screen. The reason for the bug was this code: t += 1 + isdigit(*(t+2)); The sequence points here are at the beginning and end of this assignment expression, and the updating of t may happen anywhere between these (C99 6.5.16 #3). Please don't write such code. When in doubt, and assignment and reference to the same object should be split! git-svn-id: https://svn.eduke32.com/eduke32@2380 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/game.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index a750b65b6..654cb3a44 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -328,7 +328,7 @@ int32_t G_PrintGameText(int32_t f, int32_t tile, int32_t x, int32_t y, const { int32_t ac; char centre; - int32_t squishtext = ((f&2) != 0); + const int32_t squishtext = ((f&2) != 0); int32_t shift = 16, widthx = 320; int32_t ox, oy, origx = x, origy = y; @@ -341,7 +341,8 @@ int32_t G_PrintGameText(int32_t f, int32_t tile, int32_t x, int32_t y, const shift = 0; } - if ((centre = (x == (widthx>>1)))) + centre = (x == (widthx>>1)); + if (centre) { const char *oldt = t; int32_t newx = 0; @@ -358,7 +359,10 @@ int32_t G_PrintGameText(int32_t f, int32_t tile, int32_t x, int32_t y, const if (*t == '^' && isdigit(*(t+1))) { - t += 1 + isdigit(*(t+2)); + t++; + if (isdigit(*(t+1))) + t++; +// t += 1 + isdigit(*(t+2)); // This code is wrong, see C99 6.5.16 #3 continue; } @@ -366,7 +370,8 @@ int32_t G_PrintGameText(int32_t f, int32_t tile, int32_t x, int32_t y, const if (ac < tile || ac > (tile + 93)) break; - newx += i = ((((f & 8) ? 8 : tilesizx[ac]) - squishtext) * z)>>16; + i = ((((f & 8) ? 8 : tilesizx[ac]) - squishtext) * z)>>16; + newx += i; if (*t >= '0' && *t <= '9') newx -= i - ((8 * z)>>16);