From 8e69e9e462aa5c5b79c4561da8702b76279f5cc9 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 19 Aug 2019 00:16:02 +0300 Subject: STARTREK: Fix failed action texts --- engines/startrek/startrek.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'engines/startrek') diff --git a/engines/startrek/startrek.cpp b/engines/startrek/startrek.cpp index 2e4a5a0a88..d22c6100c3 100644 --- a/engines/startrek/startrek.cpp +++ b/engines/startrek/startrek.cpp @@ -628,18 +628,25 @@ Common::String StarTrekEngine::getLoadedText(int textIndex) { Common::String str; byte cur; - while (textIndex != 0) { + int curIndex = 0; + + while (!txtFile->eos()) { do { cur = txtFile->readByte(); - if (cur != '\0') - str += cur; + str += cur; } while (cur != '\0'); - textIndex--; - } - delete txtFile; + if (curIndex == textIndex) { + delete txtFile; + return str; + } - return str; + curIndex++; + str = ""; + } + + delete txtFile; + return ""; } } // End of namespace StarTrek -- cgit v1.2.3