Skip to content
This repository has been archived by the owner on Aug 26, 2020. It is now read-only.

Commit

Permalink
- Catches network/server failures on KOS lookups and plays a new "inc…
Browse files Browse the repository at this point in the history
…omplete"

  lookup sound.  The new sound is configurable on KOS tab in options, and
  defaults to the sound of a bottle-cap being dropped.

- Red-by-last checking now properly distinguishes between new, unlisted,
  pilots who are in red corps and people that are red by their previous
  player corp membership.

- Minor variable refactoring.
  • Loading branch information
3vi1 committed Mar 25, 2017
1 parent 22b3735 commit 1de5e26
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 43 deletions.
10 changes: 10 additions & 0 deletions docs/RELEASES
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
0.7.7 - Catches network/server failures on KOS lookups and plays a new "incomplete"
lookup sound. The new sound is configurable on KOS tab in options, and
defaults to the sound of a bottle-cap being dropped.

Red-by-last checking now properly distinguishes between new, unlisted,
pilots who are in red corps and people that are red by their previous
player corp membership.

Minor variable refactoring.

0.7.6 - Stop "x4" from setting off alarms in X-4. x[2-9] are no longer considered
potential system abbreviations.

Expand Down
50 changes: 29 additions & 21 deletions src/asyncinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@ void AsyncInfo::gotKosCheckReply()

//qDebug() << "gotKosCheckReply = " << b;

if(b.length() == 0)
{
emit kosCheckFailed(checkNames);
this->deleteLater();
return;
}

QList<KosEntry> entries;
QJsonDocument jsonResponse = QJsonDocument::fromJson(b);
QJsonObject jsonObject = jsonResponse.object();
Expand Down Expand Up @@ -271,28 +278,29 @@ void AsyncInfo::rblInfoRetrieved()

//qDebug() << "AsyncInfo::rblInfoRetrieved() - " << b;

if(b.length() > 0)
if(b.length() == 0)
{
emit kosCheckFailed(checkNames);
this->deleteLater();
return;
}

QXmlQuery query;
query.setFocus(b);
query.setQuery("//*:row/concat(@corporationID,',',@corporationName/string())");
QStringList results;
query.evaluateTo(&results);

m_corpNum = 0;
foreach(QString result, results)
{
QXmlQuery query;
query.setFocus(b);
/* query.setQuery("//[REMOVE_ME]*:characterName/string()");
QString name;
query.evaluateTo(&name);
name = name.trimmed();
*/
query.setQuery("//*:row/concat(@corporationID,',',@corporationName/string())");
QStringList results;
query.evaluateTo(&results);

foreach(QString result, results)
m_corpNum++;
QStringList entry = result.split(',');
if(entry[0].toInt() > 2000000)
{
QStringList entry = result.split(',');
if(entry[0].toInt() > 2000000)
{
// Found last NPC corp
kosCheck(entry[1], SLOT(gotKosCheckCorpReply()), "corp");
return;
}
// Found last NPC corp
kosCheck(entry[1], SLOT(gotKosCheckCorpReply()), "corp");
return;
}
}

Expand Down Expand Up @@ -342,7 +350,7 @@ void AsyncInfo::gotKosCheckCorpReply()
kosEntry.alliance.ticker = allianceObj["ticker"].toString();
}

emit rblResultReady(checkNames, kosEntry.corp.kos | kosEntry.alliance.kos);
emit rblResultReady(checkNames, kosEntry.corp.kos | kosEntry.alliance.kos, m_corpNum);
}
else
{
Expand Down
4 changes: 3 additions & 1 deletion src/asyncinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ class AsyncInfo : public QObject
signals:
void resultReady(PilotEntry* pilotEntry);
void kosResultReady(const QString& name, const QList<KosEntry>& entries);
void rblResultReady(const QString& name, bool kos);
void kosCheckFailed(const QString& name);
void rblResultReady(const QString& name, bool kos, int corpNum = 0);


public slots:
Expand All @@ -126,6 +127,7 @@ public slots:
QNetworkReply* kosReply;

QString checkNames = "";
int m_corpNum = 0;

void requestId(const QString& name, const char* slot);
void kosCheck(const QString &reqNames, const char* slot, QString queryType = "multi");
Expand Down
24 changes: 21 additions & 3 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,8 @@ void MainWindow::clipboardUpdated()
AsyncInfo* kosInfo = new AsyncInfo(manager, this);
connect(kosInfo, &AsyncInfo::kosResultReady,
this, &MainWindow::gotKosReply);
connect(kosInfo, &AsyncInfo::kosCheckFailed,
this, &MainWindow::gotKosError);
kosInfo->kosCheck(checkString);
}
}
Expand All @@ -431,9 +433,9 @@ void MainWindow::doRedByLastCheck(const QString& name, int id)
rblInfo->rblCheck(name, id);
}

void MainWindow::gotRblReply(QString name, bool rbl)
void MainWindow::gotRblReply(QString name, bool rbl, int corpNum)
{
qDebug() << "MainWindow::gotRblReply - " << name << ": " << rbl;
qDebug() << "MainWindow::gotRblReply - " << name << ": " << rbl << ". CorpNum = " << corpNum;

if(rbl)
{
Expand All @@ -444,7 +446,15 @@ void MainWindow::gotRblReply(QString name, bool rbl)
info.sender = "Khasm Kaotiqa";
info.logInfo = &impLogInfo;
info.dateTime = QDateTime::currentDateTimeUtc();
info.text = name + " is RED BY LAST!";

if(corpNum > 1)
{
info.text = name + " is RED BY LAST!";
}
else
{
info.text = name + " is IN A RED CORP!";
}
addMessage(info);
}

Expand All @@ -463,6 +473,14 @@ void MainWindow::gotRblReply(QString name, bool rbl)
}
}

void MainWindow::gotKosError(const QString& pilotNames)
{
QSet<QString> pilots = pilotNames.split(',').toSet();

pilotsBeingChecked -= pilots.count();
audio.playLocalFile(options.getSoundIncompleteKos());
}

void MainWindow::gotKosReply(const QString& pilotNames, const QList<KosEntry>& entries)
{
QSet<QString> pilots = pilotNames.split(',').toSet();
Expand Down
3 changes: 2 additions & 1 deletion src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ public slots:
void fileChanged(const QString &absoluteFilePath);
void gotAutoPeriodChange(int msecs);
void gotAvatar(PilotEntry* pilotEntry);
void gotKosError(const QString &pilotName);
void gotKosReply(const QString &pilotName, const QList<KosEntry>& entries);
void gotRblReply(QString name, bool rbl);
void gotRblReply(QString name, bool rbl, int corpNum = 0);
void gotEssReply(const QList<KosEntry>& entries);
void gotMapRefreshChange(int msecs);
void gotNewPilot(const QString& pilotName);
Expand Down
45 changes: 35 additions & 10 deletions src/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Options::Options(QWidget *parent) :
continue;

ui->alarmCombo->addItem(fileInfo.fileName());
ui->comboIncomplete->addItem(fileInfo.fileName());
ui->clipKosCombo->addItem(fileInfo.fileName());
ui->clipNotKosCombo->addItem(fileInfo.fileName());
ui->statusCombo->addItem(fileInfo.fileName());
Expand Down Expand Up @@ -96,11 +97,12 @@ void Options::cacheSettings()
_essAndKos = ui->essBox->isChecked();
_showAvatar = ui->checkAvatar->isChecked();

_soundAlarm = ui->alarmCombo->currentText();
_soundStatus = ui->statusCombo->currentText();
_soundIsKos = ui->clipKosCombo->currentText();
_soundNoKos = ui->clipNotKosCombo->currentText();
_soundEss = ui->essCombo->currentText();
m_soundAlarm = ui->alarmCombo->currentText();
m_soundStatus = ui->statusCombo->currentText();
m_soundIncomplete = ui->comboIncomplete->currentText();
m_soundIsKos = ui->clipKosCombo->currentText();
m_soundNoKos = ui->clipNotKosCombo->currentText();
m_soundEss = ui->essCombo->currentText();

_logPath = ui->logsEdit->text();
_mapPath = ui->mapEdit->text();
Expand Down Expand Up @@ -134,11 +136,12 @@ void Options::restoreSettings()
ui->checkKosDouble->setChecked(_kosDouble);
ui->checkAvatar->setChecked(_showAvatar);

ui->alarmCombo->setCurrentIndex(ui->alarmCombo->findText(_soundAlarm));
ui->statusCombo->setCurrentIndex(ui->statusCombo->findText(_soundStatus));
ui->clipKosCombo->setCurrentIndex(ui->clipKosCombo->findText(_soundIsKos));
ui->clipNotKosCombo->setCurrentIndex(ui->clipNotKosCombo->findText(_soundNoKos));
ui->essCombo->setCurrentIndex(ui->essCombo->findText(_soundEss));
ui->alarmCombo->setCurrentIndex(ui->alarmCombo->findText(m_soundAlarm));
ui->statusCombo->setCurrentIndex(ui->statusCombo->findText(m_soundStatus));
ui->comboIncomplete->setCurrentIndex(ui->comboIncomplete->findText(m_soundIncomplete));
ui->clipKosCombo->setCurrentIndex(ui->clipKosCombo->findText(m_soundIsKos));
ui->clipNotKosCombo->setCurrentIndex(ui->clipNotKosCombo->findText(m_soundNoKos));
ui->essCombo->setCurrentIndex(ui->essCombo->findText(m_soundEss));

/* Works on Linux, but not on Windows...
ui->alarmCombo->setCurrentText(_soundAlarm);
Expand Down Expand Up @@ -201,6 +204,11 @@ void Options::loadSettings(QSettings& settings)
settings.value("soundEss", "sci-fi-alarm.wav").toString()
)
);
ui->comboIncomplete->setCurrentIndex(
ui->clipKosCombo->findText(
settings.value("soundIncomplete", "bottle-cap-drop.wav").toString()
)
);
ui->clipKosCombo->setCurrentIndex(
ui->clipKosCombo->findText(
settings.value("soundIsKos", "140-bpm-wobble-c-in-c.wav").toString()
Expand Down Expand Up @@ -231,6 +239,11 @@ void Options::loadSettings(QSettings& settings)
ui->essCombo->findText("sci-fi-alarm.wav")
);
}
if(ui->comboIncomplete->currentText() == "") {
ui->comboIncomplete->setCurrentIndex(
ui->comboIncomplete->findText("bottle-cap-drop.wav")
);
}
if(ui->clipKosCombo->currentText() == "") {
ui->clipKosCombo->setCurrentIndex(
ui->clipKosCombo->findText("140-bpm-wobble-c-in-c.wav")
Expand Down Expand Up @@ -402,6 +415,7 @@ void Options::saveSettings(QSettings& settings)

settings.setValue("soundAlarm", getSoundAlarm());
settings.setValue("soundStatus", getSoundStatus());
settings.setValue("soundIncomplete", getSoundIncompleteKos());
settings.setValue("soundIsKos", getSoundIsKos());
settings.setValue("soundNoKos", getSoundNoKos());
settings.setValue("soundEss", getSoundEss());
Expand Down Expand Up @@ -573,6 +587,11 @@ QString Options::getSoundEss()
return ui->essCombo->currentText();
}

QString Options::getSoundIncompleteKos()
{
return ui->comboIncomplete->currentText();
}

QString Options::getSoundIsKos()
{
return ui->clipKosCombo->currentText();
Expand Down Expand Up @@ -669,6 +688,11 @@ void Options::on_clipNotKosTestButton_clicked()
audio->playLocalFile(getSoundNoKos());
}

void Options::on_incompleteTestButton_clicked()
{
audio->playLocalFile(getSoundIncompleteKos());
}

void Options::on_ruleInsertButton_clicked()
{
ruleModel->insertRule(ui->tableView->selectionModel()->selectedIndexes());
Expand Down Expand Up @@ -783,3 +807,4 @@ bool Options::getKosOnDouble()
{
return _kosDouble;
}

14 changes: 9 additions & 5 deletions src/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class Options : public QDialog
QString getSoundAlarm();
QString getSoundEss();
QString getSoundStatus();
QString getSoundIncompleteKos();
QString getSoundIsKos();
QString getSoundNoKos();

Expand Down Expand Up @@ -137,6 +138,8 @@ private slots:

void on_bridgeEdit_editingFinished();

void on_incompleteTestButton_clicked();

private:
Ui::Options *ui;

Expand Down Expand Up @@ -178,11 +181,12 @@ private slots:

QList<Rule> _rules;

QString _soundAlarm;
QString _soundEss;
QString _soundIsKos;
QString _soundNoKos;
QString _soundStatus;
QString m_soundAlarm;
QString m_soundEss;
QString m_soundIncomplete;
QString m_soundIsKos;
QString m_soundNoKos;
QString m_soundStatus;

};

Expand Down
41 changes: 39 additions & 2 deletions src/options.ui
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<enum>QTabWidget::Rounded</enum>
</property>
<property name="currentIndex">
<number>2</number>
<number>1</number>
</property>
<widget class="QWidget" name="alerts_tab">
<attribute name="title">
Expand Down Expand Up @@ -301,7 +301,7 @@
<attribute name="title">
<string>KOS Checking</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_8">
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="sizePolicy">
Expand Down Expand Up @@ -450,6 +450,43 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_34">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Failed to get Reply:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="1" colspan="2">
<widget class="QComboBox" name="comboIncomplete">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QToolButton" name="incompleteTestButton">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/graphics/volume-icon.png</normaloff>:/graphics/volume-icon.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="map_tab">
Expand Down

0 comments on commit 1de5e26

Please sign in to comment.