aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/titanic/true_talk/tt_parser.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/engines/titanic/true_talk/tt_parser.cpp b/engines/titanic/true_talk/tt_parser.cpp
index 1a5c2b97a6..8c8157370a 100644
--- a/engines/titanic/true_talk/tt_parser.cpp
+++ b/engines/titanic/true_talk/tt_parser.cpp
@@ -399,7 +399,7 @@ int TTparser::replaceNumbers(TTstring &line, int startIndex) {
return index;
bool flag1 = false, flag2 = false, flag3 = false;
- int total = 0, factor = 0;
+ int total = 0, factor = 0, endIndex = index;
do {
if (!(numEntry->_flags & NF_1)) {
@@ -421,8 +421,11 @@ int TTparser::replaceNumbers(TTstring &line, int startIndex) {
factor += numEntry->_value;
}
}
- } while (replaceNumbers2(line, &index));
+ endIndex = index;
+ } while ((numEntry = replaceNumbers2(line, &index)) != nullptr);
+
+ index = endIndex;
if (!flag2)
return index;
@@ -440,7 +443,7 @@ int TTparser::replaceNumbers(TTstring &line, int startIndex) {
line = CString::format("%s%s%s",
CString(line.c_str(), line.c_str() + startIndex).c_str(),
numStr.c_str(),
- (index == -1) ? "" : line.c_str() + index
+ (index == -1) ? "" : line.c_str() + index - 1
);
index = startIndex + numStr.size();