From 0750f040190b5f1cd4cc97841dd74da90db184c4 Mon Sep 17 00:00:00 2001 From: erorcun Date: Tue, 20 Oct 2020 22:19:05 +0300 Subject: Messages, fix Font --- src/text/Messages.cpp | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) (limited to 'src/text/Messages.cpp') diff --git a/src/text/Messages.cpp b/src/text/Messages.cpp index 82ab294c..70225860 100644 --- a/src/text/Messages.cpp +++ b/src/text/Messages.cpp @@ -11,6 +11,8 @@ #include "Font.h" +// --MIAMI: file done + tMessage CMessages::BriefMessages[NUMBRIEFMESSAGES]; tPreviousBrief CMessages::PreviousBriefs[NUMPREVIOUSBRIEFS]; tBigMessage CMessages::BIGMessages[NUMBIGMESSAGES]; @@ -70,7 +72,7 @@ CMessages::WideStringCompare(wchar *str1, wchar *str2, uint16 size) return false; for (int32 i = 0; i < size; i++) { - if (FixupChar(str1[i]) == '\0') + if (FixupChar(str1[i]) == '\0' || i > size) break; if (FixupChar(str1[i]) != FixupChar(str2[i])) @@ -297,6 +299,7 @@ CMessages::AddBigMessage(wchar *msg, uint32 time, uint16 style) BIGMessages[style].m_Stack[0].m_nNumber[5] = -1; BIGMessages[style].m_Stack[0].m_pString = nil; } + void CMessages::AddBigMessageQ(wchar *msg, uint32 time, uint16 style) { @@ -327,10 +330,8 @@ CMessages::AddBigMessageQ(wchar *msg, uint32 time, uint16 style) void CMessages::AddToPreviousBriefArray(wchar *text, int32 n1, int32 n2, int32 n3, int32 n4, int32 n5, int32 n6, wchar *string) { - int32 i = 0; - while (i < NUMPREVIOUSBRIEFS) { - if (PreviousBriefs[i].m_pText == nil) - break; + int32 i; + for (i = 0; PreviousBriefs[i].m_pText && i < NUMPREVIOUSBRIEFS; i++) { if (PreviousBriefs[i].m_nNumber[0] == n1 && PreviousBriefs[i].m_nNumber[1] == n2 && PreviousBriefs[i].m_nNumber[2] == n3 @@ -340,8 +341,6 @@ CMessages::AddToPreviousBriefArray(wchar *text, int32 n1, int32 n2, int32 n3, in && PreviousBriefs[i].m_pText == text && PreviousBriefs[i].m_pString == string) return; - - i++; } if (i != 0) { @@ -374,6 +373,14 @@ CMessages::InsertNumberInString(wchar *str, int32 n1, int32 n2, int32 n3, int32 return; } + sprintf(numStr, "%d", n1); + size_t outLen = strlen(numStr); + AsciiToUnicode(numStr, wNumStr); + if (str[0] == 0) { + *outstr = '\0'; + return; + } + int32 size = GetWideStringLength(str); int32 i = 0; @@ -385,6 +392,11 @@ CMessages::InsertNumberInString(wchar *str, int32 n1, int32 n2, int32 n3, int32 #else if (str[c] == '~' && str[c + 1] == '1' && str[c + 2] == '~') { #endif + c += 3; + for (int j=0; j Date: Wed, 21 Oct 2020 03:55:35 +0300 Subject: Cross-platform fix and a little style change --- src/text/Messages.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/text/Messages.cpp') diff --git a/src/text/Messages.cpp b/src/text/Messages.cpp index 70225860..257a47ce 100644 --- a/src/text/Messages.cpp +++ b/src/text/Messages.cpp @@ -71,10 +71,7 @@ CMessages::WideStringCompare(wchar *str1, wchar *str2, uint16 size) if (len1 != len2 && (len1 < size || len2 < size)) return false; - for (int32 i = 0; i < size; i++) { - if (FixupChar(str1[i]) == '\0' || i > size) - break; - + for (int32 i = 0; FixupChar(str1[i]) != '\0' && i < size; i++) { if (FixupChar(str1[i]) != FixupChar(str2[i])) return false; } @@ -393,7 +390,7 @@ CMessages::InsertNumberInString(wchar *str, int32 n1, int32 n2, int32 n3, int32 if (str[c] == '~' && str[c + 1] == '1' && str[c + 2] == '~') { #endif c += 3; - for (int j=0; j Date: Wed, 21 Oct 2020 21:27:13 +0300 Subject: EmergencyPed, PedDebug, message fix --- src/text/Messages.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/text/Messages.cpp') diff --git a/src/text/Messages.cpp b/src/text/Messages.cpp index 257a47ce..2154384c 100644 --- a/src/text/Messages.cpp +++ b/src/text/Messages.cpp @@ -390,12 +390,11 @@ CMessages::InsertNumberInString(wchar *str, int32 n1, int32 n2, int32 n3, int32 if (str[c] == '~' && str[c + 1] == '1' && str[c + 2] == '~') { #endif c += 3; - for (int j = 0; j < outLen; j++) + for (int j = 0; j < outLen; ) *(outstr++) = wNumStr[j++]; i++; switch (i) { - case 0: sprintf(numStr, "%d", n1); break; case 1: sprintf(numStr, "%d", n2); break; case 2: sprintf(numStr, "%d", n3); break; case 3: sprintf(numStr, "%d", n4); break; -- cgit v1.2.3 From 1544683bdc62a4fc52d79cddb094c96e3285d4e0 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 23 Oct 2020 13:23:42 +0300 Subject: Missed nil --- src/text/Messages.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/text/Messages.cpp') diff --git a/src/text/Messages.cpp b/src/text/Messages.cpp index 2154384c..a2409289 100644 --- a/src/text/Messages.cpp +++ b/src/text/Messages.cpp @@ -804,7 +804,7 @@ CMessages::ClearThisBigPrint(wchar *str) } BIGMessages[style].m_Stack[i].m_pText = nil; } else { - BIGMessages[style].m_Stack[0].m_pText = 0; + BIGMessages[style].m_Stack[0].m_pText = nil; i = 0; while (i < 3) { if (BIGMessages[style].m_Stack[i + 1].m_pText == nil) -- cgit v1.2.3