diff options
Diffstat (limited to 'engines/titanic/pet_control')
-rw-r--r-- | engines/titanic/pet_control/pet_conversations.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_text.cpp | 16 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_text.h | 2 |
3 files changed, 11 insertions, 9 deletions
diff --git a/engines/titanic/pet_control/pet_conversations.cpp b/engines/titanic/pet_control/pet_conversations.cpp index b534136eaf..03cdefbd34 100644 --- a/engines/titanic/pet_control/pet_conversations.cpp +++ b/engines/titanic/pet_control/pet_conversations.cpp @@ -120,7 +120,7 @@ void CPetConversations::draw(CScreenManager *screenManager) { if (startIndex >= 0) { int npcNum = _log.getNPCNum(1, startIndex); if (npcNum > 0 && npcNum < 10) - _npcNum = npcNum; + _npcNum = npcNum - 1; } _logChanged = false; diff --git a/engines/titanic/pet_control/pet_text.cpp b/engines/titanic/pet_control/pet_text.cpp index 78dceb7a31..97bb0be02d 100644 --- a/engines/titanic/pet_control/pet_text.cpp +++ b/engines/titanic/pet_control/pet_text.cpp @@ -173,7 +173,7 @@ void CPetText::draw(CScreenManager *screenManager) { tempRect.grow(-2); int oldFontNumber = screenManager->setFontNumber(_fontNumber); - screenManager->writeString(SURFACE_BACKBUFFER, tempRect, _scrollTop, _lines, _textCursor); + _linesStart = screenManager->writeString(SURFACE_BACKBUFFER, tempRect, _scrollTop, _lines, _textCursor); screenManager->setFontNumber(oldFontNumber); } @@ -450,7 +450,7 @@ void CPetText::hideCursor() { } } -int CPetText::getNPCNum(uint npcId, uint startIndex) { +int CPetText::getNPCNum(uint ident, uint startIndex) { if (!_stringsMerged) { mergeStrings(); if (!_stringsMerged) @@ -461,18 +461,20 @@ int CPetText::getNPCNum(uint npcId, uint startIndex) { if (startIndex < 5 || startIndex >= size) return -1; - // Loop through string - for (const char *strP = _lines.c_str(); size >= 5; ++strP, --size) { + // Loop backwards from the starting index to find an NPC ident sequence + for (const char *strP = _lines.c_str() + startIndex; + strP >= (_lines.c_str() + 5); --strP) { if (*strP == 26) { byte id = *(strP - 2); - if (id == npcId) + if (id == ident) return *(strP - 1); + strP -= 3; } else if (*strP == 27) { - strP += 4; + strP -= 4; } } - return - 1; + return -1; } void CPetText::setFontNumber(int fontNumber) { diff --git a/engines/titanic/pet_control/pet_text.h b/engines/titanic/pet_control/pet_text.h index 0a6bb2d03d..a48ab91117 100644 --- a/engines/titanic/pet_control/pet_text.h +++ b/engines/titanic/pet_control/pet_text.h @@ -247,7 +247,7 @@ public: * Get an NPC Number embedded within on-screen text. * Used by the PET log to encode which NPC spoke */ - int getNPCNum(uint npcId, uint startIndex); + int getNPCNum(uint ident, uint startIndex); /** * Replaces any occurances of line colors that appear in the |