mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-03 15:41:41 +00:00
SCI: Added a more generalized fix for bug #3306417
This commit is contained in:
parent
c713628721
commit
1ea96002b8
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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]);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user