From 5808e4f940b6515a2cf61ba39f8b15b40a315f49 Mon Sep 17 00:00:00 2001 From: Denis Kasak Date: Fri, 12 Jun 2009 10:37:46 +0000 Subject: Made DraciFont::drawString() return early if the string is too long to fit on the screen. svn-id: r41475 --- engines/draci/draci.cpp | 6 +++++- engines/draci/font.cpp | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'engines/draci') 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; } -- cgit v1.2.3