|
From: <cn...@us...> - 2021-02-18 22:46:19
|
Revision: 1149
http://sourceforge.net/p/seq/svn/1149
Author: cn187
Date: 2021-02-18 22:46:17 +0000 (Thu, 18 Feb 2021)
Log Message:
-----------
Message formatting fixes
- Fix special messages not showing up correctly
- Fix typo introduced in Qt4 port that caused formatted messages not to
show correctly (oops).
Modified Paths:
--------------
showeq/branches/cn187_devel/src/eqstr.cpp
showeq/branches/cn187_devel/src/messageshell.cpp
Modified: showeq/branches/cn187_devel/src/eqstr.cpp
===================================================================
--- showeq/branches/cn187_devel/src/eqstr.cpp 2021-02-18 17:46:04 UTC (rev 1148)
+++ showeq/branches/cn187_devel/src/eqstr.cpp 2021-02-18 22:46:17 UTC (rev 1149)
@@ -207,7 +207,7 @@
}
// replace template argument with subst string
- if (substFormatStringRes.isEmpty())
+ if (!substFormatStringRes.isEmpty())
formatString.replace(curPos, rxt.matchedLength(), substFormatStringRes);
else
curPos += rxt.matchedLength(); // if no replacement string, skip over
Modified: showeq/branches/cn187_devel/src/messageshell.cpp
===================================================================
--- showeq/branches/cn187_devel/src/messageshell.cpp 2021-02-18 17:46:04 UTC (rev 1148)
+++ showeq/branches/cn187_devel/src/messageshell.cpp 2021-02-18 22:46:17 UTC (rev 1149)
@@ -253,20 +253,21 @@
target = m_spawnShell->findID(tSpawn, smsg->target);
// calculate the message position
- const char* message = smsg->source + strlen(smsg->source) + 1
- + sizeof(smsg->unknown0xxx);
-
- if (target)
- m_messages->addMessage(chatColor2MessageType(smsg->messageColor),
- QString("Special: '%1' -> '%2' - %3")
- .arg(smsg->source)
- .arg(target->name())
- .arg(message));
- else
- m_messages->addMessage(chatColor2MessageType(smsg->messageColor),
- QString("Special: '%1' - %2")
- .arg(smsg->source)
- .arg(message));
+ // const char* message = smsg->source + strlen(smsg->source) + 1
+ // + sizeof(smsg->unknown0xxx);
+ // NOTE: gcc 8 (and maybe others) over-optimizes the above strlen call on the
+ // variable-sized source array (possibly because it isn't the last member
+ // of the struct), and as a result, strlen always returns 0 unless compiler
+ // optimizations are disabled. So we work around this by creating a QString
+ // and using its size
+ const char* message = smsg->source + QString(smsg->source).length() + 1
+ + sizeof(smsg->unknown0xxx);
+
+ if (target) m_messages->addMessage(chatColor2MessageType(smsg->messageColor),
+ QString("Special: '%1' -> '%2' - %3") .arg(smsg->source)
+ .arg(target->name()) .arg(message)); else
+ m_messages->addMessage(chatColor2MessageType(smsg->messageColor),
+ QString("Special: '%1' - %2") .arg(smsg->source) .arg(message));
}
void MessageShell::guildMOTD(const uint8_t* data, size_t, uint8_t dir)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|