KYRA: (LoK/Mac) - fix linebreak chars

Mac uses '\n' instead of '\r'. I have verified from disasm that it only uses '\n'. '\r' is not used at all.

Now, I know only 2 cases where it matters and these are hard coded cases: "That snake must\nbe poisonous!" and "The flask is now filled\nwith %s water.". So I could just hard code these differently.
But the scripts might have more of these linebreaks, so it makes sense to have it accurate...
This commit is contained in:
athrxx
2021-12-03 21:31:05 +01:00
parent e751768622
commit 6f2df10d03
4 changed files with 11 additions and 5 deletions
+3 -2
View File
@@ -79,6 +79,7 @@ Screen::Screen(KyraEngine_v1 *vm, OSystem *system, const ScreenDim *dimTable, co
_customDimTable = nullptr;
_curDim = nullptr;
_lineBreakChar = (_vm->gameFlags().platform == Common::kPlatformMacintosh) ? '\n' : '\r';
_yTransOffs = 0;
}
@@ -1420,7 +1421,7 @@ int Screen::getTextWidth(const char *str, bool nextWordOnly) {
if (c == 0 || (nextWordOnly && (c == 2 || c == 6 || c == 13 || c == 32 || c == 0x4081))) {
break;
} else if (c == '\r') {
} else if (c == _lineBreakChar) {
if (curLineLen > maxLineLen)
maxLineLen = curLineLen;
else
@@ -1479,7 +1480,7 @@ void Screen::printText(const char *str, int x, int y, uint8 color1, uint8 color2
if (c == 0) {
break;
} else if (c == '\r') {
} else if (c == _lineBreakChar) {
x = x_start;
y += (charHeight + _lineSpacing);
} else {
+2
View File
@@ -650,6 +650,8 @@ public:
const ScreenDim *_curDim;
char _lineBreakChar;
// shape handling
uint8 *encodeShape(int x, int y, int w, int h, int flags);
+4 -3
View File
@@ -35,6 +35,7 @@ TextDisplayer::TextDisplayer(KyraEngine_v1 *vm, Screen *screen) {
_talkMessageY = 0xC;
_talkMessageH = 0;
_talkMessagePrinted = false;
_lineBreakChar = (_vm->gameFlags().platform == Common::kPlatformMacintosh) ? '\n' : '\r';
memset(_talkSubstrings, 0, sizeof(_talkSubstrings));
memset(_talkBuffer, 0, sizeof(_talkBuffer));
}
@@ -76,7 +77,7 @@ int TextDisplayer::dropCRIntoString(char *str, int offs) {
str += offs;
while (*str) {
if (*str == ' ') {
*str = '\r';
*str = _lineBreakChar;
return pos;
}
++str;
@@ -96,7 +97,7 @@ char *TextDisplayer::preprocessString(const char *str) {
char *p = _talkBuffer;
while (*p) {
if (*p == '\r') {
if (*p == _lineBreakChar) {
return _talkBuffer;
}
++p;
@@ -131,7 +132,7 @@ int TextDisplayer::buildMessageSubstrings(const char *str) {
int currentLine = 0;
int pos = 0;
while (*str) {
if (*str == '\r') {
if (*str == _lineBreakChar) {
assert(currentLine < TALK_SUBSTRING_NUM);
_talkSubstrings[currentLine * TALK_SUBSTRING_LEN + pos] = '\0';
++currentLine;
+2
View File
@@ -74,6 +74,8 @@ protected:
char _talkSubstrings[TALK_SUBSTRING_LEN * TALK_SUBSTRING_NUM];
TalkCoords _talkCoords;
bool _talkMessagePrinted;
char _lineBreakChar;
};
} // End of namespace Kyra