From 41afb2a9962aafb2cfd91a89f057ad14c8cb4c4f Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Wed, 19 Apr 2006 14:18:34 +0000 Subject: Fixed a potential bug when calculating the width of conversation option in FF. This bug appears to have been present in the original as well, though the chances of triggering it are small. (We did in at least one place, before adding the number prefix to the string.) svn-id: r22036 --- engines/simon/string.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/engines/simon/string.cpp b/engines/simon/string.cpp index 7c962637d5..cffebd0c67 100644 --- a/engines/simon/string.cpp +++ b/engines/simon/string.cpp @@ -129,13 +129,17 @@ void SimonEngine::printInteractText(uint16 num, const char *string) { char *convertedString2 = convertedString; const char *string2 = string; uint16 height = 15; - uint16 w = 620; + uint16 w = 0xFFFF; uint16 b, pixels, x; + // It doesn't really matter what 'w' is to begin with, as long as it's + // something that cannot be generated by getPixelLength(). The original + // used 620, which was a potential problem. + while (1) { string2 = getPixelLength(string, 620, pixels); if (*string2 == 0x00) { - if (w == 620) + if (w == 0xFFFF) w = pixels; strcpy(convertedString2, string); break; @@ -145,7 +149,7 @@ void SimonEngine::printInteractText(uint16 num, const char *string) { pixels -= charWidth[chr]; string2--; } - if (w == 620) + if (w == 0xFFFF) w = pixels; b = string2 - string; strncpy(convertedString2, string, b); -- cgit v1.2.3