diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sci/engine/kgraphics.cpp | 21 | ||||
-rw-r--r-- | engines/sci/engine/kstring.cpp | 15 |
2 files changed, 20 insertions, 16 deletions
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index 75f8c25ed2..6c96266922 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -360,10 +360,29 @@ reg_t kTextSize(EngineState *s, int argc, reg_t *argv) { } else #endif g_sci->_gfxText16->kernelTextSize(g_sci->strSplit(text.c_str(), sep).c_str(), font_nr, maxwidth, &textWidth, &textHeight); - + + // One of the game texts in LB2 German contains loads of spaces in + // its end. We trim the text here, otherwise the graphics code will + // attempt to draw a very large window (larger than the screen) to + // show the text, and crash. + // Fixes bug #3306417. + if (textWidth >= g_sci->_gfxScreen->getDisplayWidth() || + textHeight >= g_sci->_gfxScreen->getDisplayHeight()) { + // TODO: Is this needed for SCI32 as well? + if (g_sci->_gfxText16) { + warning("kTextSize: string would be too big to fit on screen. Trimming it"); + text.trim(); + // Copy over the trimmed string... + s->_segMan->strcpy(argv[1], text.c_str()); + // ...and recalculate bounding box dimensions + g_sci->_gfxText16->kernelTextSize(g_sci->strSplit(text.c_str(), sep).c_str(), font_nr, maxwidth, &textWidth, &textHeight); + } + } + debugC(kDebugLevelStrings, "GetTextSize '%s' -> %dx%d", text.c_str(), textWidth, textHeight); dest[2] = make_reg(0, textHeight); dest[3] = make_reg(0, textWidth); + return s->r_acc; } diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp index add5b7b52d..c3c10bd2a2 100644 --- a/engines/sci/engine/kstring.cpp +++ b/engines/sci/engine/kstring.cpp @@ -67,21 +67,6 @@ reg_t kStrCpy(EngineState *s, int argc, reg_t *argv) { else s->_segMan->memcpy(argv[0], argv[1], -length); } else { - if (g_sci->getGameId() == GID_LAURABOW2 && g_sci->getLanguage() == Common::DE_DEU && - s->currentRoomNumber() == 360) { - // One of the game texts in LB2 German contains loads of spaces in - // its end. We trim the text here, otherwise the graphics code will - // attempt to draw a very large window (larger than the screen) to - // show the text, and crash. - // Fixes bug #3306417. - SegmentRef src = s->_segMan->dereference(argv[1]); - if (src.maxSize == 7992) { // the problematic resource. Trim it. - Common::String text = s->_segMan->getString(argv[1]); - text.trim(); - s->_segMan->strcpy(argv[1], text.c_str()); - } - } - s->_segMan->strcpy(argv[0], argv[1]); } |