|
@@ -28,6 +28,9 @@ along with this program. If not, see < http://www.gnu.org/licenses/ >.
|
|
|
#include "App.h"
|
|
|
#include "Settings.h"
|
|
|
|
|
|
+static QRegExp rxColoredPattern("&c[0-9a-fA-F]{3}");
|
|
|
+static QRegExp rxBrackets("\\{[^}]*\\}");
|
|
|
+
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
Client::Client(App *app, ActiveClient* ac):
|
|
|
QWClient(),
|
|
@@ -46,6 +49,7 @@ Client::Client(App *app, ActiveClient* ac):
|
|
|
myMaxClients(0),
|
|
|
myCmdScheduledTimer(new QTimer())
|
|
|
{
|
|
|
+ rxBrackets.setMinimal(true);
|
|
|
myKeepNickTimer->setSingleShot(true);
|
|
|
myFloodTimer->setSingleShot(true);
|
|
|
myQWBroadcastFloodTimer->setSingleShot(true);
|
|
@@ -82,13 +86,13 @@ void Client::say(const QString &msg, const QString &nickName)
|
|
|
|
|
|
cmd.append(msg);
|
|
|
|
|
|
- sendCmd(cmd.toAscii().data());
|
|
|
+ sendCmd(cmd.toLatin1().data());
|
|
|
}
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
void Client::setTeam(const QString &msg)
|
|
|
{
|
|
|
- sendCmd(QString("setinfo \"team\" \"" + msg + "\"").toAscii().data());
|
|
|
+ sendCmd(QString("setinfo \"team\" \"" + msg + "\"").toLatin1().data());
|
|
|
}
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
@@ -104,9 +108,9 @@ void Client::print(const QString &msg)
|
|
|
QString str;
|
|
|
|
|
|
str = "[" + QTime::currentTime().toString(Qt::ISODate) + "] " + QString(host()) + ":" + QString::number(port()) + "> " + msg;
|
|
|
- QByteArray b = str.toAscii();
|
|
|
+ QByteArray b = str.toLatin1();
|
|
|
Client::stripColor(b.data());
|
|
|
- str = QString::fromAscii(b.data());
|
|
|
+ str = QString::fromLatin1(b.data());
|
|
|
|
|
|
myApp->print(str);
|
|
|
}
|
|
@@ -468,14 +472,14 @@ void Client::run()
|
|
|
// Keep nick... Simply set name again after 30 secs
|
|
|
if(!myKeepNickTimer->isActive())
|
|
|
{
|
|
|
- setName(Settings::globalInstance()->botName().toAscii().data());
|
|
|
+ setName(Settings::globalInstance()->botName().toLatin1().data());
|
|
|
myKeepNickTimer->start(30000);
|
|
|
}
|
|
|
|
|
|
// Scheduled commands
|
|
|
if(!myCmdScheduled.isEmpty() && !myCmdScheduledTimer->isActive())
|
|
|
{
|
|
|
- sendCmd(myCmdScheduled.toAscii().data());
|
|
|
+ sendCmd(myCmdScheduled.toLatin1().data());
|
|
|
myCmdScheduled.clear();
|
|
|
}
|
|
|
|
|
@@ -540,12 +544,24 @@ void Client::spDetection()
|
|
|
}
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
+static QRegExp coloredTextStrings("(\\{&c[0-9a-fA-F]{3}).*?(\\{&c[0-9a-fA-F]{3})|(\\})");
|
|
|
QString Client::parseNameFun(const QString &string)
|
|
|
{
|
|
|
- QByteArray b(string.toAscii());
|
|
|
+ QByteArray b(string.toLatin1());
|
|
|
QWClient::stripColor(b.data());
|
|
|
+ QString text = QString::fromLatin1(b);
|
|
|
+ int pos = 0;
|
|
|
+ int index_adj;
|
|
|
+ while ((pos = rxBrackets.indexIn(text, pos)) != -1) {
|
|
|
+ QString match = rxBrackets.cap(0);
|
|
|
+ QString newtext = rxBrackets.cap(0).replace(rxColoredPattern, "");
|
|
|
+ newtext = newtext.mid(1, newtext.size()-2);
|
|
|
+ index_adj = match.length() - newtext.length();
|
|
|
+ text.replace(match, newtext);
|
|
|
+ pos += rxBrackets.matchedLength() - index_adj;
|
|
|
+ }
|
|
|
|
|
|
- return QString(b);
|
|
|
+ return text;
|
|
|
}
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|