aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/startrek/startrek.cpp21
1 files changed, 14 insertions, 7 deletions
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