[Scummvm-git-logs] scummvm master -> 1a0c320616a052d6c64308cb1ace0d2b099df95f

sev- sev at scummvm.org
Fri Nov 6 18:35:38 UTC 2020


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

Summary:
145617ce69 SCUMM: Hacks for alternative Korean line-break
1a0c320616 SCUMM: Fix deepcode warning


Commit: 145617ce6920d3c201ebe82fcdef06f52e99fb50
    https://github.com/scummvm/scummvm/commit/145617ce6920d3c201ebe82fcdef06f52e99fb50
Author: wonst719 (wonst719 at gmail.com)
Date: 2020-11-06T19:35:34+01:00

Commit Message:
SCUMM: Hacks for alternative Korean line-break

Changed paths:
    engines/scumm/charset.cpp
    engines/scumm/charset.h


diff --git a/engines/scumm/charset.cpp b/engines/scumm/charset.cpp
index 36e297b30d..aa4d48c232 100644
--- a/engines/scumm/charset.cpp
+++ b/engines/scumm/charset.cpp
@@ -541,6 +541,9 @@ int CharsetRenderer::getStringWidth(int arg, const byte *text) {
 }
 
 void CharsetRenderer::addLinebreaks(int a, byte *str, int pos, int maxwidth) {
+	int lastKoreanLineBreak = -1;
+	char tmpStrBuf[512];
+	int origPos = pos;
 	int lastspace = -1;
 	int curw = 1;
 	int chr;
@@ -605,6 +608,11 @@ void CharsetRenderer::addLinebreaks(int a, byte *str, int pos, int maxwidth) {
 		if (chr == _vm->_newLineCharacter)
 			lastspace = pos - 1;
 
+		if (_vm->_useCJKMode && isScummvmKorTarget()) {
+			if (_center == false && chr == '(' && pos - 3 >= origPos && checkKSCode(str[pos -3], str[pos -2]))
+				lastKoreanLineBreak = pos - 1;
+		}
+
 		if (_vm->_useCJKMode) {
 			if (_vm->_game.platform == Common::kPlatformFMTowns) {
 				if (checkSJISCode(chr))
@@ -615,6 +623,13 @@ void CharsetRenderer::addLinebreaks(int a, byte *str, int pos, int maxwidth) {
 			} else if (chr & 0x80) {
 				pos++;
 				curw += _vm->_2byteWidth;
+				if (isScummvmKorTarget() && checkKSCode(chr, str[pos])) {
+					if (_center == false
+						&& !(pos - 4 >= origPos && str[pos - 3] == '`' && str[pos - 4] == ' ')	// prevents hanging quotation mark at the end of line
+						&& !(pos - 4 >= origPos && str[pos - 3] == '\'' && str[pos - 4] == ' ')	// prevents hanging single quotation mark at the end of line
+						&& !(pos -3 >= origPos && str[pos -3] == '('))	// prevents hanging parenthesis at the end of line
+						lastKoreanLineBreak = pos - 2;
+				}
 				// Original keeps glyph width and character dimensions separately
 				if (_vm->_language == Common::KO_KOR || _vm->_language == Common::ZH_TWN) {
 					curw++;
@@ -625,13 +640,32 @@ void CharsetRenderer::addLinebreaks(int a, byte *str, int pos, int maxwidth) {
 		} else {
 			curw += getCharWidth(chr);
 		}
-		if (lastspace == -1)
-			continue;
+		if (lastspace == -1) {
+			if (!isScummvmKorTarget() || lastKoreanLineBreak == -1) {
+				continue;
+			}
+		}
 		if (curw > maxwidth) {
-			str[lastspace] = 0xD;
-			curw = 1;
-			pos = lastspace + 1;
-			lastspace = -1;
+			if (!isScummvmKorTarget()) {
+				str[lastspace] = 0xD;
+				curw = 1;
+				pos = lastspace + 1;
+				lastspace = -1;
+			} else if (lastspace >= lastKoreanLineBreak) {
+				str[lastspace] = 0xD;
+				curw = 1;
+				pos = lastspace + 1;
+				lastspace = -1;
+				lastKoreanLineBreak = -1;
+			} else {
+				strcpy(tmpStrBuf, (char*)(str + lastKoreanLineBreak));
+				strcpy((char*)(str + lastKoreanLineBreak + 1), tmpStrBuf);
+				str[lastKoreanLineBreak] = 0xD;
+				curw = 1;
+				pos = lastKoreanLineBreak + 1;
+				lastspace = -1;
+				lastKoreanLineBreak = -1;
+			}
 		}
 	}
 
diff --git a/engines/scumm/charset.h b/engines/scumm/charset.h
index 688843cd75..71d1965a07 100644
--- a/engines/scumm/charset.h
+++ b/engines/scumm/charset.h
@@ -35,6 +35,18 @@ class ScummEngine;
 class NutRenderer;
 struct VirtScreen;
 
+static inline bool checkKSCode(byte hi, byte lo) {
+	//hi : xx
+	//lo : yy
+	if ((0xA1 > lo) || (0xFE < lo)) {
+		return false;
+	}
+	if ((hi >= 0xB0) && (hi <= 0xC8)) {
+		return true;
+	}
+	return false;
+}
+
 static inline bool checkSJISCode(byte c) {
 	if ((c >= 0x80 && c <= 0x9f) || (c >= 0xe0 && c <= 0xfd))
 		return true;


Commit: 1a0c320616a052d6c64308cb1ace0d2b099df95f
    https://github.com/scummvm/scummvm/commit/1a0c320616a052d6c64308cb1ace0d2b099df95f
Author: wonst719 (wonst719 at gmail.com)
Date: 2020-11-06T19:35:34+01:00

Commit Message:
SCUMM: Fix deepcode warning

- use memcpy() instead of strcpy() to insert linebreak character

Changed paths:
    engines/scumm/charset.cpp


diff --git a/engines/scumm/charset.cpp b/engines/scumm/charset.cpp
index aa4d48c232..a8d57f8b52 100644
--- a/engines/scumm/charset.cpp
+++ b/engines/scumm/charset.cpp
@@ -542,7 +542,6 @@ int CharsetRenderer::getStringWidth(int arg, const byte *text) {
 
 void CharsetRenderer::addLinebreaks(int a, byte *str, int pos, int maxwidth) {
 	int lastKoreanLineBreak = -1;
-	char tmpStrBuf[512];
 	int origPos = pos;
 	int lastspace = -1;
 	int curw = 1;
@@ -550,6 +549,8 @@ void CharsetRenderer::addLinebreaks(int a, byte *str, int pos, int maxwidth) {
 	int oldID = getCurID();
 	int code = (_vm->_game.heversion >= 80) ? 127 : 64;
 
+	int strLength = _vm->resStrLen(str);
+
 	while ((chr = str[pos++]) != 0) {
 		if (_vm->_game.heversion >= 72) {
 			if (chr == code) {
@@ -658,8 +659,8 @@ void CharsetRenderer::addLinebreaks(int a, byte *str, int pos, int maxwidth) {
 				lastspace = -1;
 				lastKoreanLineBreak = -1;
 			} else {
-				strcpy(tmpStrBuf, (char*)(str + lastKoreanLineBreak));
-				strcpy((char*)(str + lastKoreanLineBreak + 1), tmpStrBuf);
+				byte* breakPtr = str + lastKoreanLineBreak;
+				memmove(breakPtr + 1, breakPtr, strLength - lastKoreanLineBreak + 1);
 				str[lastKoreanLineBreak] = 0xD;
 				curw = 1;
 				pos = lastKoreanLineBreak + 1;




More information about the Scummvm-git-logs mailing list