aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2016-03-20 16:53:26 +0100
committerColin Snover2016-06-21 08:14:11 -0500
commit97c11e7d5fd1f23efc742abd2cb702cb8ce74361 (patch)
tree30da684fa38ff7cf0f86da4f2dd89e215a57d70a /engines/sci
parentdcc6234d816f7aab8f7ce0f473a7edf626dd03c6 (diff)
downloadscummvm-rg350-97c11e7d5fd1f23efc742abd2cb702cb8ce74361.tar.gz
scummvm-rg350-97c11e7d5fd1f23efc742abd2cb702cb8ce74361.tar.bz2
scummvm-rg350-97c11e7d5fd1f23efc742abd2cb702cb8ce74361.zip
SCI32: Fix getTextWidth on consecutive control codes
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/graphics/text32.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/engines/sci/graphics/text32.cpp b/engines/sci/graphics/text32.cpp
index d1c223d5d5..62664c1aa2 100644
--- a/engines/sci/graphics/text32.cpp
+++ b/engines/sci/graphics/text32.cpp
@@ -498,7 +498,7 @@ int16 GfxText32::getTextWidth(const uint index, uint length) const {
--length;
fontId = fontId * 10 + currentChar - '0';
- } while (length > 0 && currentChar >= '0' && currentChar <= '9');
+ } while (length > 0 && *text >= '0' && *text <= '9');
if (length > 0) {
font = _cache->getFont(fontId);
@@ -506,7 +506,11 @@ int16 GfxText32::getTextWidth(const uint index, uint length) const {
}
// Forward through any more unknown control character data
- while (length > 0 && currentChar != '|') {
+ while (length > 0 && *text != '|') {
+ ++text;
+ --length;
+ }
+ if (length > 0) {
++text;
--length;
}
@@ -514,8 +518,10 @@ int16 GfxText32::getTextWidth(const uint index, uint length) const {
width += font->getCharWidth(currentChar);
}
- currentChar = *text++;
- --length;
+ if (length > 0) {
+ currentChar = *text++;
+ --length;
+ }
}
return width;