diff options
| -rw-r--r-- | src/CRSMConfig.hpp | 4 | ||||
| -rw-r--r-- | src/Util.cpp | 37 | ||||
| -rw-r--r-- | src/Util.hpp | 1 | ||||
| -rw-r--r-- | src/crsm.cpp | 3 |
4 files changed, 44 insertions, 1 deletions
diff --git a/src/CRSMConfig.hpp b/src/CRSMConfig.hpp index 04c92ce..db2c4a8 100644 --- a/src/CRSMConfig.hpp +++ b/src/CRSMConfig.hpp @@ -51,6 +51,8 @@ public: Boolean Use = false; String Server = "irc.euirc.net"; String Nick = "CRSM"; + String User = ""; + Integer Port = 6667; String Password = ""; String RealName = "Dedicated Clonk server powered by CRSM"; String Channel = "#crsm"; @@ -124,6 +126,8 @@ public: ConfigVal(IRC.Use), ConfigVal(IRC.Server), ConfigVal(IRC.Nick), + ConfigVal(IRC.User), + ConfigVal(IRC.Port), ConfigVal(IRC.Password), ConfigVal(IRC.RealName), ConfigVal(IRC.Channel), diff --git a/src/Util.cpp b/src/Util.cpp index 3658802..41500da 100644 --- a/src/Util.cpp +++ b/src/Util.cpp @@ -151,4 +151,41 @@ namespace Util { } return string; } + + int indexOfEscaped(const QString& string, const QChar subject, int startPos, const QChar escapeChar) + { + if(string.isEmpty()) + { + return -1; + } + if(startPos < 0) + { + startPos += string.length(); + } + bool escaped = false; + for(int pos = startPos; pos < string.length(); ++pos) + { + QChar c = string.at(pos); + if(!escaped) + { + if(c == escapeChar) + { + escaped = true; + continue; + } + else + { + if(c == subject) + { + return pos; + } + } + } + else + { + escaped = false; + } + } + return -1; + } } diff --git a/src/Util.hpp b/src/Util.hpp index 8f5ff86..f90e108 100644 --- a/src/Util.hpp +++ b/src/Util.hpp @@ -14,4 +14,5 @@ namespace Util { QString joinEscape(const QStringList& list, const QChar joinChar, const QChar escapeChar = '\\'); QStringList splitEscaped(const QString& joined, const QChar splitChar, const QChar escapeChar = '\\'); QString& unescapeClonkString(QString&& string); + int indexOfEscaped(const QString& string, const QChar subject, int startPos = 0, const QChar escapeChar = '\\'); } diff --git a/src/crsm.cpp b/src/crsm.cpp index 15c4ff8..607fd00 100644 --- a/src/crsm.cpp +++ b/src/crsm.cpp @@ -1569,7 +1569,8 @@ void CRSM::kick(const QString& pcName, const QString& reason) void CRSM::prepareAndConnectIrc() { connection = new IrcConnection(Config.IRC.Server); - connection->setUserName(Config.IRC.Nick); + connection->setPort(Config.IRC.Port); + connection->setUserName(Config.IRC.User.isEmpty() ? Config.IRC.Nick : Config.IRC.User); connection->setNickName(Config.IRC.Nick); connection->setRealName(Config.IRC.RealName); connection->setReconnectDelay(Config.IRC.ReconnectDelay); |
