mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-12 21:10:01 -08:00
removing blp from settings
This commit is contained in:
parent
0be45e3969
commit
98a1d38c4f
7 changed files with 641 additions and 719 deletions
|
|
@ -567,29 +567,27 @@ DeckEditorSettingsPage::DeckEditorSettingsPage()
|
||||||
priceTagsCheckBox->setChecked(settingsCache->getPriceTagFeature());
|
priceTagsCheckBox->setChecked(settingsCache->getPriceTagFeature());
|
||||||
connect(priceTagsCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setPriceTagFeature(int)));
|
connect(priceTagsCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setPriceTagFeature(int)));
|
||||||
|
|
||||||
priceTagSource0 = new QRadioButton;
|
|
||||||
priceTagSource1 = new QRadioButton;
|
priceTagSource1 = new QRadioButton;
|
||||||
|
priceTagSource1->setChecked(true);
|
||||||
|
priceTagSource1->setEnabled(false);
|
||||||
|
|
||||||
|
/* Not necessary unless another price source comes into play
|
||||||
switch(settingsCache->getPriceTagSource())
|
switch(settingsCache->getPriceTagSource())
|
||||||
{
|
{
|
||||||
case AbstractPriceUpdater::DBPriceSource:
|
case AbstractPriceUpdater::DBPriceSource:
|
||||||
|
default:
|
||||||
priceTagSource1->setChecked(true);
|
priceTagSource1->setChecked(true);
|
||||||
break;
|
break;
|
||||||
case AbstractPriceUpdater::BLPPriceSource:
|
|
||||||
default:
|
|
||||||
priceTagSource0->setChecked(true);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
connect(priceTagSource0, SIGNAL(toggled(bool)), this, SLOT(radioPriceTagSourceClicked(bool)));
|
|
||||||
connect(priceTagSource1, SIGNAL(toggled(bool)), this, SLOT(radioPriceTagSourceClicked(bool)));
|
connect(priceTagSource1, SIGNAL(toggled(bool)), this, SLOT(radioPriceTagSourceClicked(bool)));
|
||||||
|
|
||||||
connect(this, SIGNAL(priceTagSourceChanged(int)), settingsCache, SLOT(setPriceTagSource(int)));
|
connect(this, SIGNAL(priceTagSourceChanged(int)), settingsCache, SLOT(setPriceTagSource(int)));
|
||||||
|
|
||||||
QGridLayout *generalGrid = new QGridLayout;
|
QGridLayout *generalGrid = new QGridLayout;
|
||||||
generalGrid->addWidget(priceTagsCheckBox, 0, 0);
|
generalGrid->addWidget(priceTagsCheckBox, 0, 0);
|
||||||
generalGrid->addWidget(priceTagSource0, 1, 0);
|
generalGrid->addWidget(priceTagSource1, 1, 0);
|
||||||
generalGrid->addWidget(priceTagSource1, 2, 0);
|
|
||||||
|
|
||||||
generalGroupBox = new QGroupBox;
|
generalGroupBox = new QGroupBox;
|
||||||
generalGroupBox->setLayout(generalGrid);
|
generalGroupBox->setLayout(generalGrid);
|
||||||
|
|
@ -603,8 +601,7 @@ DeckEditorSettingsPage::DeckEditorSettingsPage()
|
||||||
void DeckEditorSettingsPage::retranslateUi()
|
void DeckEditorSettingsPage::retranslateUi()
|
||||||
{
|
{
|
||||||
priceTagsCheckBox->setText(tr("Enable &price tag feature"));
|
priceTagsCheckBox->setText(tr("Enable &price tag feature"));
|
||||||
priceTagSource0->setText(tr("using data from blacklotusproject.com"));
|
priceTagSource1->setText(tr("Get prices from deckbrew.com"));
|
||||||
priceTagSource1->setText(tr("using data from deckbrew.com"));
|
|
||||||
generalGroupBox->setTitle(tr("General"));
|
generalGroupBox->setTitle(tr("General"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -613,11 +610,7 @@ void DeckEditorSettingsPage::radioPriceTagSourceClicked(bool checked)
|
||||||
if(!checked)
|
if(!checked)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int source=AbstractPriceUpdater::BLPPriceSource;
|
int source=AbstractPriceUpdater::DBPriceSource;
|
||||||
if(priceTagSource0->isChecked())
|
|
||||||
source=AbstractPriceUpdater::BLPPriceSource;
|
|
||||||
if(priceTagSource1->isChecked())
|
|
||||||
source=AbstractPriceUpdater::DBPriceSource;
|
|
||||||
|
|
||||||
emit priceTagSourceChanged(source);
|
emit priceTagSourceChanged(source);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,82 +28,6 @@ AbstractPriceUpdater::AbstractPriceUpdater(const DeckList *_deck)
|
||||||
deck = _deck;
|
deck = _deck;
|
||||||
}
|
}
|
||||||
|
|
||||||
// blacklotusproject.com
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor.
|
|
||||||
*
|
|
||||||
* @param _deck deck.
|
|
||||||
*/
|
|
||||||
BLPPriceUpdater::BLPPriceUpdater(const DeckList *_deck)
|
|
||||||
: AbstractPriceUpdater(_deck)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the prices of the cards in deckList.
|
|
||||||
*/
|
|
||||||
void BLPPriceUpdater::updatePrices()
|
|
||||||
{
|
|
||||||
QString q = "http://blacklotusproject.com/json/?cards=";
|
|
||||||
QStringList cards = deck->getCardList();
|
|
||||||
for (int i = 0; i < cards.size(); ++i) {
|
|
||||||
q += cards[i].toLower() + "|";
|
|
||||||
}
|
|
||||||
QUrl url(q.replace(' ', '+'));
|
|
||||||
|
|
||||||
QNetworkReply *reply = nam->get(QNetworkRequest(url));
|
|
||||||
connect(reply, SIGNAL(finished()), this, SLOT(downloadFinished()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the download of the json file with the prices is finished.
|
|
||||||
*/
|
|
||||||
void BLPPriceUpdater::downloadFinished()
|
|
||||||
{
|
|
||||||
QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
|
|
||||||
bool ok;
|
|
||||||
QVariantMap resultMap = QtJson::Json::parse(QString(reply->readAll()), ok).toMap();
|
|
||||||
if (!ok) {
|
|
||||||
reply->deleteLater();
|
|
||||||
deleteLater();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QMap<QString, float> cardsPrice;
|
|
||||||
|
|
||||||
QListIterator<QVariant> it(resultMap.value("cards").toList());
|
|
||||||
while (it.hasNext()) {
|
|
||||||
QVariantMap map = it.next().toMap();
|
|
||||||
QString name = map.value("name").toString().toLower();
|
|
||||||
float price = map.value("price").toString().toFloat();
|
|
||||||
QString set = map.value("set_code").toString();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Make sure Masters Edition (MED) isn't the set, as it doesn't
|
|
||||||
* physically exist. Also check the price to see that the cheapest set
|
|
||||||
* ends up as the final price.
|
|
||||||
*/
|
|
||||||
if (set != "MED" && (!cardsPrice.contains(name) || cardsPrice.value(name) > price))
|
|
||||||
cardsPrice.insert(name, price);
|
|
||||||
}
|
|
||||||
|
|
||||||
InnerDecklistNode *listRoot = deck->getRoot();
|
|
||||||
for (int i = 0; i < listRoot->size(); i++) {
|
|
||||||
InnerDecklistNode *currentZone = dynamic_cast<InnerDecklistNode *>(listRoot->at(i));
|
|
||||||
for (int j = 0; j < currentZone->size(); j++) {
|
|
||||||
DecklistCardNode *currentCard = dynamic_cast<DecklistCardNode *>(currentZone->at(j));
|
|
||||||
if (!currentCard)
|
|
||||||
continue;
|
|
||||||
currentCard->setPrice(cardsPrice[currentCard->getName().toLower()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
reply->deleteLater();
|
|
||||||
deleteLater();
|
|
||||||
emit finishedUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
// deckbrew.com
|
// deckbrew.com
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -31,16 +31,6 @@ public:
|
||||||
virtual void updatePrices() = 0;
|
virtual void updatePrices() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class BLPPriceUpdater : public AbstractPriceUpdater
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
protected:
|
|
||||||
virtual void downloadFinished();
|
|
||||||
public:
|
|
||||||
BLPPriceUpdater(const DeckList *deck);
|
|
||||||
virtual void updatePrices();
|
|
||||||
};
|
|
||||||
|
|
||||||
class DBPriceUpdater : public AbstractPriceUpdater
|
class DBPriceUpdater : public AbstractPriceUpdater
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
|
||||||
|
|
@ -680,11 +680,8 @@ void TabDeckEditor::actUpdatePrices()
|
||||||
switch(settingsCache->getPriceTagSource())
|
switch(settingsCache->getPriceTagSource())
|
||||||
{
|
{
|
||||||
case AbstractPriceUpdater::DBPriceSource:
|
case AbstractPriceUpdater::DBPriceSource:
|
||||||
up = new DBPriceUpdater(deckModel->getDeckList());
|
|
||||||
break;
|
|
||||||
case AbstractPriceUpdater::BLPPriceSource:
|
|
||||||
default:
|
default:
|
||||||
up = new BLPPriceUpdater(deckModel->getDeckList());
|
up = new DBPriceUpdater(deckModel->getDeckList());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -125,6 +125,11 @@ max_game_inactivity_time=120
|
||||||
; Maximum number of users that can connect from the same IP address; useful to avoid bots, default is 4
|
; Maximum number of users that can connect from the same IP address; useful to avoid bots, default is 4
|
||||||
max_users_per_address=4
|
max_users_per_address=4
|
||||||
|
|
||||||
|
; You may want to allow an unlimited number of users from a trusted source. This setting can contain a
|
||||||
|
; comma-separed list of IP addresses which will allow an unlimited number of connections from each of the
|
||||||
|
; IP addresses listed (ignoring the max_users_per_address). Default is "127.0.0.1,::1"; example: "192.73.233.244,81.4.100.74"
|
||||||
|
trusted_sources="127.0.0.1,::1"
|
||||||
|
|
||||||
; Servatrice can avoid users from flooding rooms with large number messages in an interval of time.
|
; Servatrice can avoid users from flooding rooms with large number messages in an interval of time.
|
||||||
; This setting defines the length in seconds of the considered interval; default is 10
|
; This setting defines the length in seconds of the considered interval; default is 10
|
||||||
message_counting_interval=10
|
message_counting_interval=10
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QString>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "servatrice.h"
|
#include "servatrice.h"
|
||||||
#include "servatrice_database_interface.h"
|
#include "servatrice_database_interface.h"
|
||||||
|
|
@ -383,6 +384,7 @@ int Servatrice::getUsersWithAddress(const QHostAddress &address) const
|
||||||
for (int i = 0; i < clients.size(); ++i)
|
for (int i = 0; i < clients.size(); ++i)
|
||||||
if (static_cast<ServerSocketInterface *>(clients[i])->getPeerAddress() == address)
|
if (static_cast<ServerSocketInterface *>(clients[i])->getPeerAddress() == address)
|
||||||
++result;
|
++result;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@
|
||||||
#include <QHostAddress>
|
#include <QHostAddress>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
#include <QString>
|
||||||
|
#include "settingscache.h"
|
||||||
#include "serversocketinterface.h"
|
#include "serversocketinterface.h"
|
||||||
#include "servatrice.h"
|
#include "servatrice.h"
|
||||||
#include "servatrice_database_interface.h"
|
#include "servatrice_database_interface.h"
|
||||||
|
|
@ -117,6 +119,12 @@ bool ServerSocketInterface::initSession()
|
||||||
delete identSe;
|
delete identSe;
|
||||||
|
|
||||||
int maxUsers = servatrice->getMaxUsersPerAddress();
|
int maxUsers = servatrice->getMaxUsersPerAddress();
|
||||||
|
|
||||||
|
//allow unlimited number of connections from the trusted sources
|
||||||
|
QString trustedSources = settingsCache->value("server/trusted_sources","127.0.0.1,::1").toString();
|
||||||
|
if (trustedSources.contains(socket->peerAddress().toString(),Qt::CaseInsensitive))
|
||||||
|
return true;
|
||||||
|
|
||||||
if ((maxUsers > 0) && (servatrice->getUsersWithAddress(socket->peerAddress()) >= maxUsers)) {
|
if ((maxUsers > 0) && (servatrice->getUsersWithAddress(socket->peerAddress()) >= maxUsers)) {
|
||||||
Event_ConnectionClosed event;
|
Event_ConnectionClosed event;
|
||||||
event.set_reason(Event_ConnectionClosed::TOO_MANY_CONNECTIONS);
|
event.set_reason(Event_ConnectionClosed::TOO_MANY_CONNECTIONS);
|
||||||
|
|
@ -707,7 +715,10 @@ Response::ResponseCode ServerSocketInterface::cmdBanFromServer(const Command_Ban
|
||||||
|
|
||||||
QString userName = QString::fromStdString(cmd.user_name());
|
QString userName = QString::fromStdString(cmd.user_name());
|
||||||
QString address = QString::fromStdString(cmd.address());
|
QString address = QString::fromStdString(cmd.address());
|
||||||
|
QString trustedSources = settingsCache->value("server/trusted_sources","127.0.0.1,::1").toString();
|
||||||
int minutes = cmd.minutes();
|
int minutes = cmd.minutes();
|
||||||
|
if (trustedSources.contains(address,Qt::CaseInsensitive))
|
||||||
|
address = "";
|
||||||
|
|
||||||
QSqlQuery query(sqlInterface->getDatabase());
|
QSqlQuery query(sqlInterface->getDatabase());
|
||||||
query.prepare("insert into " + servatrice->getDbPrefix() + "_bans (user_name, ip_address, id_admin, time_from, minutes, reason, visible_reason) values(:user_name, :ip_address, :id_admin, NOW(), :minutes, :reason, :visible_reason)");
|
query.prepare("insert into " + servatrice->getDbPrefix() + "_bans (user_name, ip_address, id_admin, time_from, minutes, reason, visible_reason) values(:user_name, :ip_address, :id_admin, NOW(), :minutes, :reason, :visible_reason)");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue