aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorDenis Kasak2009-06-12 10:37:46 +0000
committerDenis Kasak2009-06-12 10:37:46 +0000
commit5808e4f940b6515a2cf61ba39f8b15b40a315f49 (patch)
tree9ba9ff10341a6bb9175b3f7d8c07356717adf644 /engines
parent837f76f61f9e6c7d5c2788c673e8a93fa9700482 (diff)
downloadscummvm-rg350-5808e4f940b6515a2cf61ba39f8b15b40a315f49.tar.gz
scummvm-rg350-5808e4f940b6515a2cf61ba39f8b15b40a315f49.tar.bz2
scummvm-rg350-5808e4f940b6515a2cf61ba39f8b15b40a315f49.zip
Made DraciFont::drawString() return early if the string is too long to fit on the screen.
svn-id: r41475
Diffstat (limited to 'engines')
-rw-r--r--engines/draci/draci.cpp6
-rw-r--r--engines/draci/font.cpp6
2 files changed, 11 insertions, 1 deletions
diff --git a/engines/draci/draci.cpp b/engines/draci/draci.cpp
index 58f5261193..13e5ffae6a 100644
--- a/engines/draci/draci.cpp
+++ b/engines/draci/draci.cpp
@@ -136,8 +136,12 @@ int DraciEngine::go() {
testString = "I'm smaller than the font above me.";
font.drawString(surf, testString,
(320 - font.getStringWidth(testString, 1)) / 2, 150, 1);
- _system->unlockScreen();
+ // Overflow handling test
+ testString = "Checking overflooooooooooooooooooooooooow...";
+ font.drawString(surf, testString, 50, 170, 1);
+
+ _system->unlockScreen();
_system->updateScreen();
// Draw and animate the dragon
diff --git a/engines/draci/font.cpp b/engines/draci/font.cpp
index 9f91e466ea..4ef1b578db 100644
--- a/engines/draci/font.cpp
+++ b/engines/draci/font.cpp
@@ -166,6 +166,12 @@ void DraciFont::drawString(Graphics::Surface *dst, Common::String &str,
uint len = str.size();
for (unsigned int i = 0; i < len; ++i) {
+
+ // Return early if there's no more space on the screen
+ if (curx >= dst->w) {
+ return;
+ }
+
drawChar(dst, str[i], curx, y);
curx += getCharWidth(str[i]) + spacing;
}