[Scummvm-cvs-logs] scummvm master -> f713094c6427e22c442b9b98be0f79d383d32b23

m-kiewitz m_kiewitz at users.sourceforge.net
Sun Jun 14 21:14:35 CEST 2015


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
f713094c64 SHERLOCK: SS: fix talkInterf to handle int. chars


Commit: f713094c6427e22c442b9b98be0f79d383d32b23
    https://github.com/scummvm/scummvm/commit/f713094c6427e22c442b9b98be0f79d383d32b23
Author: Martin Kiewitz (m_kiewitz at users.sourceforge.net)
Date: 2015-06-14T21:14:17+02:00

Commit Message:
SHERLOCK: SS: fix talkInterf to handle int. chars

so that line wrapping works properly for international versions

Changed paths:
    engines/sherlock/scalpel/scalpel_talk.cpp
    engines/sherlock/talk.cpp
    engines/sherlock/talk.h



diff --git a/engines/sherlock/scalpel/scalpel_talk.cpp b/engines/sherlock/scalpel/scalpel_talk.cpp
index c514ab1..c86720f 100644
--- a/engines/sherlock/scalpel/scalpel_talk.cpp
+++ b/engines/sherlock/scalpel/scalpel_talk.cpp
@@ -214,10 +214,10 @@ void ScalpelTalk::talkInterface(const byte *&str) {
 		width += screen.charWidth(str[idx]);
 		++idx;
 		++_charCount;
-	} while (width < 298 && str[idx] && str[idx] != '{' && str[idx] < _opcodes[0]);
+	} while (width < 298 && str[idx] && str[idx] != '{' && (!isOpcode(str[idx])));
 
 	if (str[idx] || width >= 298) {
-		if (str[idx] < _opcodes[0] && str[idx] != '{') {
+		if ((!isOpcode(str[idx])) && str[idx] != '{') {
 			--idx;
 			--_charCount;
 		}
@@ -261,7 +261,7 @@ void ScalpelTalk::talkInterface(const byte *&str) {
 	str += idx;
 
 	// If line wrap occurred, then move to after the separating space between the words
-	if (str[0] < _opcodes[0] && str[0] != '{')
+	if ((!isOpcode(str[0])) && str[0] != '{')
 		++str;
 
 	_yp += 9;
diff --git a/engines/sherlock/talk.cpp b/engines/sherlock/talk.cpp
index a349d71..6b122b4 100644
--- a/engines/sherlock/talk.cpp
+++ b/engines/sherlock/talk.cpp
@@ -1059,7 +1059,7 @@ void Talk::doScript(const Common::String &script) {
 			// Start of comment, so skip over it
 			while (*str++ != '}')
 				;
-		} else if (c >= _opcodes[0] && c < (_opcodes[0] + 99) && _opcodeTable[c - _opcodes[0]]) {
+		} else if (isOpcode(c)) {
 			// Handle control code
 			switch ((this->*_opcodeTable[c - _opcodes[0]])(str)) {
 			case RET_EXIT:
@@ -1200,6 +1200,14 @@ int Talk::waitForMore(int delay) {
 	return key2;
 }
 
+inline bool Talk::isOpcode(byte checkCharacter) {
+	if ((checkCharacter < _opcodes[0]) || (checkCharacter >= (_opcodes[0] + 99)))
+		return false; // outside of range
+	if (_opcodeTable[checkCharacter - _opcodes[0]])
+		return true;
+	return false;
+}
+
 void Talk::popStack() {
 	if (!_scriptStack.empty()) {
 		ScriptStackEntry scriptEntry = _scriptStack.pop();
diff --git a/engines/sherlock/talk.h b/engines/sherlock/talk.h
index 6695e4e..563f780 100644
--- a/engines/sherlock/talk.h
+++ b/engines/sherlock/talk.h
@@ -207,6 +207,7 @@ private:
 	 * the amount of text that's been displayed
 	 */
 	int waitForMore(int delay);
+
 protected:
 	SherlockEngine *_vm;
 	OpcodeMethod *_opcodeTable;
@@ -255,6 +256,11 @@ protected:
 	OpcodeReturn cmdWalkToCAnimation(const byte *&str);
 protected:
 	/**
+	 * Checks, if a character is an opcode
+	 */
+	inline bool isOpcode(byte checkCharacter);
+
+	/**
 	 * Display the talk interface window
 	 */
 	virtual void talkInterface(const byte *&str) = 0;






More information about the Scummvm-git-logs mailing list