From 5ea33b4f7f0b67b25f149aad8e7a406d22ee2115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joni=20V=C3=A4h=C3=A4m=C3=A4ki?= Date: Sat, 11 Jun 2011 18:25:25 +0300 Subject: [PATCH] GRIM: Allow SayLine messages of zero length. Fixes #199 --- engines/grim/actor.cpp | 52 +++++++++++++++++++----------------- engines/grim/lua_v1_text.cpp | 5 ++-- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/engines/grim/actor.cpp b/engines/grim/actor.cpp index 5cb25672f66..a8fe5f7e73c 100644 --- a/engines/grim/actor.cpp +++ b/engines/grim/actor.cpp @@ -888,34 +888,36 @@ void Actor::sayLine(const char *msg, const char *msgId, bool background) { _sayLineText = 0; } - GrimEngine::SpeechMode m = g_grim->getSpeechMode(); - if (!g_grim->_sayLineDefaults.getFont() || m == GrimEngine::VoiceOnly || background) - return; + if (msg[0] != 0) { + GrimEngine::SpeechMode m = g_grim->getSpeechMode(); + if (!g_grim->_sayLineDefaults.getFont() || m == GrimEngine::VoiceOnly || background) + return; - TextObject *textObject = new TextObject(false, true); - textObject->setDefaults(&g_grim->_sayLineDefaults); - textObject->setFGColor(_talkColor); - if (g_grim->getMode() == ENGINE_MODE_SMUSH) - g_grim->killTextObjects(); - if (m == GrimEngine::TextOnly || g_grim->getMode() == ENGINE_MODE_SMUSH) { - textObject->setDuration(500 + strlen(msg) * 15 * (11 - g_grim->getTextSpeed())); - } - if (g_grim->getMode() == ENGINE_MODE_SMUSH) { - textObject->setX(640 / 2); - textObject->setY(456); - } else { - if (_winX1 == 1000 || _winX2 == -1000 || _winY2 == -1000) { - textObject->setX(640 / 2); - textObject->setY(463); - } else { - textObject->setX((_winX1 + _winX2) / 2); - textObject->setY(_winY1); + TextObject *textObject = new TextObject(false, true); + textObject->setDefaults(&g_grim->_sayLineDefaults); + textObject->setFGColor(_talkColor); + if (g_grim->getMode() == ENGINE_MODE_SMUSH) + g_grim->killTextObjects(); + if (m == GrimEngine::TextOnly || g_grim->getMode() == ENGINE_MODE_SMUSH) { + textObject->setDuration(500 + strlen(msg) * 15 * (11 - g_grim->getTextSpeed())); } + if (g_grim->getMode() == ENGINE_MODE_SMUSH) { + textObject->setX(640 / 2); + textObject->setY(456); + } else { + if (_winX1 == 1000 || _winX2 == -1000 || _winY2 == -1000) { + textObject->setX(640 / 2); + textObject->setY(463); + } else { + textObject->setX((_winX1 + _winX2) / 2); + textObject->setY(_winY1); + } + } + textObject->setText(msg); + g_grim->registerTextObject(textObject); + if (g_grim->getMode() != ENGINE_MODE_SMUSH) + _sayLineText = textObject->getId(); } - textObject->setText(msg); - g_grim->registerTextObject(textObject); - if (g_grim->getMode() != ENGINE_MODE_SMUSH) - _sayLineText = textObject->getId(); } bool Actor::isTalking() { diff --git a/engines/grim/lua_v1_text.cpp b/engines/grim/lua_v1_text.cpp index 861693015e6..c59ec81d3ba 100644 --- a/engines/grim/lua_v1_text.cpp +++ b/engines/grim/lua_v1_text.cpp @@ -498,9 +498,8 @@ void L1_SayLine() { } paramObj = lua_getparam(paramId++); } - if (!msg.empty()) { - actor->sayLine(msg.c_str(), msgId, background); //background, vol, pan, x, y - } + + actor->sayLine(msg.c_str(), msgId, background); //background, vol, pan, x, y } } }