[Scummvm-cvs-logs] SF.net SVN: scummvm:[48575] scummvm/branches/branch-1-1-0
spalek at users.sourceforge.net
spalek at users.sourceforge.net
Tue Apr 6 21:20:43 CEST 2010
Revision: 48575
http://scummvm.svn.sourceforge.net/scummvm/?rev=48575&view=rev
Author: spalek
Date: 2010-04-06 19:20:43 +0000 (Tue, 06 Apr 2010)
Log Message:
-----------
back-ported bugfix r48462 for Dragon History
Modified Paths:
--------------
scummvm/branches/branch-1-1-0/engines/draci/font.cpp
Property Changed:
----------------
scummvm/branches/branch-1-1-0/
scummvm/branches/branch-1-1-0/engines/draci/script.cpp
scummvm/branches/branch-1-1-0/engines/draci/script.h
Property changes on: scummvm/branches/branch-1-1-0
___________________________________________________________________
Modified: svn:mergeinfo
- /scummvm/branches/gsoc2009-draci:41389-44325
/scummvm/trunk:48460
+ /scummvm/branches/gsoc2009-draci:41389-44325
/scummvm/trunk:48460,48462
Modified: scummvm/branches/branch-1-1-0/engines/draci/font.cpp
===================================================================
--- scummvm/branches/branch-1-1-0/engines/draci/font.cpp 2010-04-06 19:17:55 UTC (rev 48574)
+++ scummvm/branches/branch-1-1-0/engines/draci/font.cpp 2010-04-06 19:20:43 UTC (rev 48575)
@@ -108,7 +108,12 @@
}
uint8 Font::getCharWidth(uint8 chr) const {
- return _charWidths[chr - kCharIndexOffset];
+ // Safe-guard against incorrect strings containing localized characters
+ // with inaccessible codes. These strings do not exist in the original
+ // Czech version, but they do in the (never properly reviewed) English
+ // version.
+ return chr >= kCharIndexOffset && chr < kCharIndexOffset + kCharNum
+ ? _charWidths[chr - kCharIndexOffset] : 0;
}
/**
@@ -126,10 +131,14 @@
assert(ty >= 0);
byte *ptr = (byte *)dst->getBasePtr(tx, ty);
- uint8 charIndex = chr - kCharIndexOffset;
- int charOffset = charIndex * _fontHeight * _maxCharWidth;
- uint8 currentWidth = _charWidths[charIndex];
+ const uint8 currentWidth = getCharWidth(chr);
+ if (currentWidth == 0) {
+ return;
+ }
+ const uint8 charIndex = chr - kCharIndexOffset;
+ const int charOffset = charIndex * _fontHeight * _maxCharWidth;
+
// Determine how many pixels to draw horizontally (to prevent overflow)
int xSpaceLeft = dst->w - tx - 1;
int xPixelsToDraw = (currentWidth < xSpaceLeft) ? currentWidth : xSpaceLeft;
@@ -256,9 +265,7 @@
for (uint i = 0, tmp = 0; i < len; ++i) {
if (str[i] != '|') {
- uint8 charIndex = str[i] - kCharIndexOffset;
- tmp += _charWidths[charIndex];
- tmp += spacing;
+ tmp += getCharWidth(str[i]) + spacing;
}
// Newline char encountered, skip it and store the new length if it is greater.
@@ -291,9 +298,7 @@
break;
// Add width of the current char
- uint8 charIndex = str[i] - kCharIndexOffset;
- width += _charWidths[charIndex];
- width += spacing;
+ width += getCharWidth(str[i]) + spacing;
}
return width;
Property changes on: scummvm/branches/branch-1-1-0/engines/draci/script.cpp
___________________________________________________________________
Modified: svn:mergeinfo
- /scummvm/trunk/engines/draci/script.cpp:48460
+ /scummvm/trunk/engines/draci/script.cpp:48460,48462
Property changes on: scummvm/branches/branch-1-1-0/engines/draci/script.h
___________________________________________________________________
Modified: svn:mergeinfo
- /scummvm/trunk/engines/draci/script.h:48460
+ /scummvm/trunk/engines/draci/script.h:48460,48462
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list