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());
|
||||
connect(priceTagsCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setPriceTagFeature(int)));
|
||||
|
||||
priceTagSource0 = new QRadioButton;
|
||||
priceTagSource1 = new QRadioButton;
|
||||
priceTagSource1->setChecked(true);
|
||||
priceTagSource1->setEnabled(false);
|
||||
|
||||
/* Not necessary unless another price source comes into play
|
||||
switch(settingsCache->getPriceTagSource())
|
||||
{
|
||||
case AbstractPriceUpdater::DBPriceSource:
|
||||
priceTagSource1->setChecked(true);
|
||||
break;
|
||||
case AbstractPriceUpdater::BLPPriceSource:
|
||||
default:
|
||||
priceTagSource0->setChecked(true);
|
||||
break;
|
||||
priceTagSource1->setChecked(true);
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
||||
connect(priceTagSource0, 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)));
|
||||
|
||||
QGridLayout *generalGrid = new QGridLayout;
|
||||
generalGrid->addWidget(priceTagsCheckBox, 0, 0);
|
||||
generalGrid->addWidget(priceTagSource0, 1, 0);
|
||||
generalGrid->addWidget(priceTagSource1, 2, 0);
|
||||
generalGrid->addWidget(priceTagSource1, 1, 0);
|
||||
|
||||
generalGroupBox = new QGroupBox;
|
||||
generalGroupBox->setLayout(generalGrid);
|
||||
|
|
@ -603,8 +601,7 @@ DeckEditorSettingsPage::DeckEditorSettingsPage()
|
|||
void DeckEditorSettingsPage::retranslateUi()
|
||||
{
|
||||
priceTagsCheckBox->setText(tr("Enable &price tag feature"));
|
||||
priceTagSource0->setText(tr("using data from blacklotusproject.com"));
|
||||
priceTagSource1->setText(tr("using data from deckbrew.com"));
|
||||
priceTagSource1->setText(tr("Get prices from deckbrew.com"));
|
||||
generalGroupBox->setTitle(tr("General"));
|
||||
}
|
||||
|
||||
|
|
@ -613,11 +610,7 @@ void DeckEditorSettingsPage::radioPriceTagSourceClicked(bool checked)
|
|||
if(!checked)
|
||||
return;
|
||||
|
||||
int source=AbstractPriceUpdater::BLPPriceSource;
|
||||
if(priceTagSource0->isChecked())
|
||||
source=AbstractPriceUpdater::BLPPriceSource;
|
||||
if(priceTagSource1->isChecked())
|
||||
source=AbstractPriceUpdater::DBPriceSource;
|
||||
int source=AbstractPriceUpdater::DBPriceSource;
|
||||
|
||||
emit priceTagSourceChanged(source);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,82 +28,6 @@ AbstractPriceUpdater::AbstractPriceUpdater(const DeckList *_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
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -31,16 +31,6 @@ public:
|
|||
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
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
|
|||
|
|
@ -680,11 +680,8 @@ void TabDeckEditor::actUpdatePrices()
|
|||
switch(settingsCache->getPriceTagSource())
|
||||
{
|
||||
case AbstractPriceUpdater::DBPriceSource:
|
||||
up = new DBPriceUpdater(deckModel->getDeckList());
|
||||
break;
|
||||
case AbstractPriceUpdater::BLPPriceSource:
|
||||
default:
|
||||
up = new BLPPriceUpdater(deckModel->getDeckList());
|
||||
up = new DBPriceUpdater(deckModel->getDeckList());
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ port=4747
|
|||
; long delays (lag), you may want to try increasing this value; default is 1.
|
||||
number_pools=1
|
||||
|
||||
; When database is enabled, servatrice writes the server status in the "update" database table; this
|
||||
; When database is enabled, servatrice writes the server status in the "update" database table; this
|
||||
; setting defines every how many milliseconds servatrice will update its status; default is 15000 (15 secs)
|
||||
statusupdate=15000
|
||||
|
||||
|
|
@ -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
|
||||
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.
|
||||
; This setting defines the length in seconds of the considered interval; default is 10
|
||||
message_counting_interval=10
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#include <QTimer>
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <QString>
|
||||
#include <iostream>
|
||||
#include "servatrice.h"
|
||||
#include "servatrice_database_interface.h"
|
||||
|
|
@ -45,25 +46,25 @@ Servatrice_GameServer::Servatrice_GameServer(Servatrice *_server, int _numberPoo
|
|||
server->setThreaded(false);
|
||||
Servatrice_DatabaseInterface *newDatabaseInterface = new Servatrice_DatabaseInterface(0, server);
|
||||
Servatrice_ConnectionPool *newPool = new Servatrice_ConnectionPool(newDatabaseInterface);
|
||||
|
||||
|
||||
server->addDatabaseInterface(thread(), newDatabaseInterface);
|
||||
newDatabaseInterface->initDatabase(_sqlDatabase);
|
||||
|
||||
|
||||
connectionPools.append(newPool);
|
||||
} else
|
||||
for (int i = 0; i < _numberPools; ++i) {
|
||||
Servatrice_DatabaseInterface *newDatabaseInterface = new Servatrice_DatabaseInterface(i, server);
|
||||
Servatrice_ConnectionPool *newPool = new Servatrice_ConnectionPool(newDatabaseInterface);
|
||||
|
||||
|
||||
QThread *newThread = new QThread;
|
||||
newThread->setObjectName("pool_" + QString::number(i));
|
||||
newPool->moveToThread(newThread);
|
||||
newDatabaseInterface->moveToThread(newThread);
|
||||
server->addDatabaseInterface(newThread, newDatabaseInterface);
|
||||
|
||||
|
||||
newThread->start();
|
||||
QMetaObject::invokeMethod(newDatabaseInterface, "initDatabase", Qt::BlockingQueuedConnection, Q_ARG(QSqlDatabase, _sqlDatabase));
|
||||
|
||||
|
||||
connectionPools.append(newPool);
|
||||
}
|
||||
}
|
||||
|
|
@ -98,12 +99,12 @@ void Servatrice_GameServer::incomingConnection(qintptr socketDescriptor)
|
|||
}
|
||||
qDebug() << "Pool utilisation:" << debugStr;
|
||||
Servatrice_ConnectionPool *pool = connectionPools[poolIndex];
|
||||
|
||||
|
||||
ServerSocketInterface *ssi = new ServerSocketInterface(server, pool->getDatabaseInterface());
|
||||
ssi->moveToThread(pool->thread());
|
||||
pool->addClient();
|
||||
connect(ssi, SIGNAL(destroyed()), pool, SLOT(removeClient()));
|
||||
|
||||
|
||||
QMetaObject::invokeMethod(ssi, "initConnection", Qt::QueuedConnection, Q_ARG(int, socketDescriptor));
|
||||
}
|
||||
|
||||
|
|
@ -111,11 +112,11 @@ void Servatrice_IslServer::incomingConnection(int socketDescriptor)
|
|||
{
|
||||
QThread *thread = new QThread;
|
||||
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
|
||||
|
||||
|
||||
IslInterface *interface = new IslInterface(socketDescriptor, cert, privateKey, server);
|
||||
interface->moveToThread(thread);
|
||||
connect(interface, SIGNAL(destroyed()), thread, SLOT(quit()));
|
||||
|
||||
|
||||
thread->start();
|
||||
QMetaObject::invokeMethod(interface, "initServer", Qt::QueuedConnection);
|
||||
}
|
||||
|
|
@ -137,7 +138,7 @@ bool Servatrice::initServer()
|
|||
serverName = settingsCache->value("server/name", "My Cockatrice server").toString();
|
||||
serverId = settingsCache->value("server/id", 0).toInt();
|
||||
bool regServerOnly = settingsCache->value("authentication/regonly", 0).toBool();
|
||||
|
||||
|
||||
const QString authenticationMethodStr = settingsCache->value("authentication/method").toString();
|
||||
if (authenticationMethodStr == "sql") {
|
||||
qDebug() << "Authenticating method: sql";
|
||||
|
|
@ -148,22 +149,22 @@ bool Servatrice::initServer()
|
|||
} else {
|
||||
if (regServerOnly) {
|
||||
qDebug() << "Registration only server enabled but no authentication method defined: Error.";
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
qDebug() << "Authenticating method: none";
|
||||
authenticationMethod = AuthenticationNone;
|
||||
}
|
||||
|
||||
|
||||
QString dbTypeStr = settingsCache->value("database/type").toString();
|
||||
if (dbTypeStr == "mysql")
|
||||
databaseType = DatabaseMySql;
|
||||
else
|
||||
databaseType = DatabaseNone;
|
||||
|
||||
|
||||
servatriceDatabaseInterface = new Servatrice_DatabaseInterface(-1, this);
|
||||
setDatabaseInterface(servatriceDatabaseInterface);
|
||||
|
||||
|
||||
if (databaseType != DatabaseNone) {
|
||||
settingsCache->beginGroup("database");
|
||||
dbPrefix = settingsCache->value("prefix").toString();
|
||||
|
|
@ -173,13 +174,13 @@ bool Servatrice::initServer()
|
|||
settingsCache->value("user").toString(),
|
||||
settingsCache->value("password").toString());
|
||||
settingsCache->endGroup();
|
||||
|
||||
|
||||
updateServerList();
|
||||
|
||||
|
||||
qDebug() << "Clearing previous sessions...";
|
||||
servatriceDatabaseInterface->clearSessionTables();
|
||||
}
|
||||
|
||||
|
||||
const QString roomMethod = settingsCache->value("rooms/method").toString();
|
||||
if (roomMethod == "sql") {
|
||||
QSqlQuery query(servatriceDatabaseInterface->getDatabase());
|
||||
|
|
@ -193,7 +194,7 @@ bool Servatrice::initServer()
|
|||
QStringList gameTypes;
|
||||
while (query2.next())
|
||||
gameTypes.append(query2.value(0).toString());
|
||||
|
||||
|
||||
addRoom(new Server_Room(query.value(0).toInt(),
|
||||
query.value(1).toString(),
|
||||
query.value(2).toString(),
|
||||
|
|
@ -207,7 +208,7 @@ bool Servatrice::initServer()
|
|||
int size = settingsCache->beginReadArray("rooms/roomlist");
|
||||
for (int i = 0; i < size; ++i) {
|
||||
settingsCache->setArrayIndex(i);
|
||||
|
||||
|
||||
QStringList gameTypes;
|
||||
int size2 = settingsCache->beginReadArray("game_types");
|
||||
for (int j = 0; j < size2; ++j) {
|
||||
|
|
@ -215,7 +216,7 @@ bool Servatrice::initServer()
|
|||
gameTypes.append(settingsCache->value("name").toString());
|
||||
}
|
||||
settingsCache->endArray();
|
||||
|
||||
|
||||
Server_Room *newRoom = new Server_Room(
|
||||
i,
|
||||
settingsCache->value("name").toString(),
|
||||
|
|
@ -240,17 +241,17 @@ bool Servatrice::initServer()
|
|||
QStringList("Standard"),
|
||||
this
|
||||
);
|
||||
addRoom(newRoom);
|
||||
addRoom(newRoom);
|
||||
}
|
||||
|
||||
settingsCache->endArray();
|
||||
}
|
||||
|
||||
|
||||
updateLoginMessage();
|
||||
|
||||
|
||||
maxGameInactivityTime = settingsCache->value("game/max_game_inactivity_time", 120).toInt();
|
||||
maxPlayerInactivityTime = settingsCache->value("game/max_player_inactivity_time", 15).toInt();
|
||||
|
||||
|
||||
maxUsersPerAddress = settingsCache->value("security/max_users_per_address", 4).toInt();
|
||||
messageCountingInterval = settingsCache->value("security/message_counting_interval", 10).toInt();
|
||||
maxMessageCountPerInterval = settingsCache->value("security/max_message_count_per_interval", 10).toInt();
|
||||
|
|
@ -283,7 +284,7 @@ bool Servatrice::initServer()
|
|||
QSslKey key(&keyFile, QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey);
|
||||
if (key.isNull())
|
||||
throw QString("Invalid private key.");
|
||||
|
||||
|
||||
QMutableListIterator<ServerProperties> serverIterator(serverList);
|
||||
while (serverIterator.hasNext()) {
|
||||
const ServerProperties &prop = serverIterator.next();
|
||||
|
|
@ -291,22 +292,22 @@ bool Servatrice::initServer()
|
|||
serverIterator.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
QThread *thread = new QThread;
|
||||
thread->setObjectName("isl_" + QString::number(prop.id));
|
||||
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
|
||||
|
||||
|
||||
IslInterface *interface = new IslInterface(prop.id, prop.hostname, prop.address.toString(), prop.controlPort, prop.cert, cert, key, this);
|
||||
interface->moveToThread(thread);
|
||||
connect(interface, SIGNAL(destroyed()), thread, SLOT(quit()));
|
||||
|
||||
|
||||
thread->start();
|
||||
QMetaObject::invokeMethod(interface, "initClient", Qt::BlockingQueuedConnection);
|
||||
}
|
||||
|
||||
|
||||
const int networkPort = settingsCache->value("servernetwork/port", 14747).toInt();
|
||||
qDebug() << "Starting ISL server on port" << networkPort;
|
||||
|
||||
|
||||
islServer = new Servatrice_IslServer(this, cert, key, this);
|
||||
if (islServer->listen(QHostAddress::Any, networkPort))
|
||||
qDebug() << "ISL server listening.";
|
||||
|
|
@ -316,11 +317,11 @@ bool Servatrice::initServer()
|
|||
qDebug() << "ERROR --" << error;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
pingClock = new QTimer(this);
|
||||
connect(pingClock, SIGNAL(timeout()), this, SIGNAL(pingClockTimeout()));
|
||||
pingClock->start(1000);
|
||||
|
||||
|
||||
int statusUpdateTime = settingsCache->value("server/statusupdate", 15000).toInt();
|
||||
statusUpdateClock = new QTimer(this);
|
||||
connect(statusUpdateClock, SIGNAL(timeout()), this, SLOT(statusUpdate()));
|
||||
|
|
@ -328,7 +329,7 @@ bool Servatrice::initServer()
|
|||
qDebug() << "Starting status update clock, interval " << statusUpdateTime << " ms";
|
||||
statusUpdateClock->start(statusUpdateTime);
|
||||
}
|
||||
|
||||
|
||||
const int numberPools = settingsCache->value("server/number_pools", 1).toInt();
|
||||
gameServer = new Servatrice_GameServer(this, numberPools, servatriceDatabaseInterface->getDatabase(), this);
|
||||
gameServer->setMaxPendingConnections(1000);
|
||||
|
|
@ -351,10 +352,10 @@ void Servatrice::addDatabaseInterface(QThread *thread, Servatrice_DatabaseInterf
|
|||
void Servatrice::updateServerList()
|
||||
{
|
||||
qDebug() << "Updating server list...";
|
||||
|
||||
|
||||
serverListMutex.lock();
|
||||
serverList.clear();
|
||||
|
||||
|
||||
QSqlQuery query(servatriceDatabaseInterface->getDatabase());
|
||||
query.prepare("select id, ssl_cert, hostname, address, game_port, control_port from " + dbPrefix + "_servers order by id asc");
|
||||
servatriceDatabaseInterface->execSqlQuery(query);
|
||||
|
|
@ -363,7 +364,7 @@ void Servatrice::updateServerList()
|
|||
serverList.append(prop);
|
||||
qDebug() << QString("#%1 CERT=%2 NAME=%3 IP=%4:%5 CPORT=%6").arg(prop.id).arg(QString(prop.cert.digest().toHex())).arg(prop.hostname).arg(prop.address.toString()).arg(prop.gamePort).arg(prop.controlPort);
|
||||
}
|
||||
|
||||
|
||||
serverListMutex.unlock();
|
||||
}
|
||||
|
||||
|
|
@ -372,7 +373,7 @@ QList<ServerProperties> Servatrice::getServerList() const
|
|||
serverListMutex.lock();
|
||||
QList<ServerProperties> result = serverList;
|
||||
serverListMutex.unlock();
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -381,8 +382,9 @@ int Servatrice::getUsersWithAddress(const QHostAddress &address) const
|
|||
int result = 0;
|
||||
QReadLocker locker(&clientsLock);
|
||||
for (int i = 0; i < clients.size(); ++i)
|
||||
if (static_cast<ServerSocketInterface *>(clients[i])->getPeerAddress() == address)
|
||||
++result;
|
||||
if (static_cast<ServerSocketInterface *>(clients[i])->getPeerAddress() == address)
|
||||
++result;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -400,18 +402,18 @@ void Servatrice::updateLoginMessage()
|
|||
{
|
||||
if (!servatriceDatabaseInterface->checkSql())
|
||||
return;
|
||||
|
||||
|
||||
QSqlQuery query(servatriceDatabaseInterface->getDatabase());
|
||||
query.prepare("select message from " + dbPrefix + "_servermessages where id_server = :id_server order by timest desc limit 1");
|
||||
query.bindValue(":id_server", serverId);
|
||||
if (servatriceDatabaseInterface->execSqlQuery(query))
|
||||
if (query.next()) {
|
||||
const QString newLoginMessage = query.value(0).toString();
|
||||
|
||||
|
||||
loginMessageMutex.lock();
|
||||
loginMessage = newLoginMessage;
|
||||
loginMessageMutex.unlock();
|
||||
|
||||
|
||||
Event_ServerMessage event;
|
||||
event.set_message(newLoginMessage.toStdString());
|
||||
SessionEvent *se = Server_ProtocolHandler::prepareSessionEvent(event);
|
||||
|
|
@ -426,12 +428,12 @@ void Servatrice::statusUpdate()
|
|||
{
|
||||
if (!servatriceDatabaseInterface->checkSql())
|
||||
return;
|
||||
|
||||
|
||||
const int uc = getUsersCount(); // for correct mutex locking order
|
||||
const int gc = getGamesCount();
|
||||
|
||||
|
||||
uptime += statusUpdateClock->interval() / 1000;
|
||||
|
||||
|
||||
txBytesMutex.lock();
|
||||
quint64 tx = txBytes;
|
||||
txBytes = 0;
|
||||
|
|
@ -440,7 +442,7 @@ void Servatrice::statusUpdate()
|
|||
quint64 rx = rxBytes;
|
||||
rxBytes = 0;
|
||||
rxBytesMutex.unlock();
|
||||
|
||||
|
||||
QSqlQuery query(servatriceDatabaseInterface->getDatabase());
|
||||
query.prepare("insert into " + dbPrefix + "_uptime (id_server, timest, uptime, users_count, games_count, tx_bytes, rx_bytes) values(:id, NOW(), :uptime, :users_count, :games_count, :tx, :rx)");
|
||||
query.bindValue(":id", serverId);
|
||||
|
|
@ -481,7 +483,7 @@ void Servatrice::incRxBytes(quint64 num)
|
|||
void Servatrice::shutdownTimeout()
|
||||
{
|
||||
--shutdownMinutes;
|
||||
|
||||
|
||||
SessionEvent *se;
|
||||
if (shutdownMinutes) {
|
||||
Event_ServerShutdown event;
|
||||
|
|
@ -493,13 +495,13 @@ void Servatrice::shutdownTimeout()
|
|||
event.set_reason(Event_ConnectionClosed::SERVER_SHUTDOWN);
|
||||
se = Server_ProtocolHandler::prepareSessionEvent(event);
|
||||
}
|
||||
|
||||
|
||||
clientsLock.lockForRead();
|
||||
for (int i = 0; i < clients.size(); ++i)
|
||||
clients[i]->sendProtocolItem(*se);
|
||||
clientsLock.unlock();
|
||||
delete se;
|
||||
|
||||
|
||||
if (!shutdownMinutes)
|
||||
deleteLater();
|
||||
}
|
||||
|
|
@ -507,14 +509,14 @@ void Servatrice::shutdownTimeout()
|
|||
bool Servatrice::islConnectionExists(int serverId) const
|
||||
{
|
||||
// Only call with islLock locked at least for reading
|
||||
|
||||
|
||||
return islInterfaces.contains(serverId);
|
||||
}
|
||||
|
||||
void Servatrice::addIslInterface(int serverId, IslInterface *interface)
|
||||
{
|
||||
// Only call with islLock locked for writing
|
||||
|
||||
|
||||
islInterfaces.insert(serverId, interface);
|
||||
connect(interface, SIGNAL(externalUserJoined(ServerInfo_User)), this, SLOT(externalUserJoined(ServerInfo_User)));
|
||||
connect(interface, SIGNAL(externalUserLeft(QString)), this, SLOT(externalUserLeft(QString)));
|
||||
|
|
@ -531,7 +533,7 @@ void Servatrice::addIslInterface(int serverId, IslInterface *interface)
|
|||
void Servatrice::removeIslInterface(int serverId)
|
||||
{
|
||||
// Only call with islLock locked for writing
|
||||
|
||||
|
||||
// XXX we probably need to delete everything that belonged to it...
|
||||
islInterfaces.remove(serverId);
|
||||
}
|
||||
|
|
@ -539,7 +541,7 @@ void Servatrice::removeIslInterface(int serverId)
|
|||
void Servatrice::doSendIslMessage(const IslMessage &msg, int serverId)
|
||||
{
|
||||
QReadLocker locker(&islLock);
|
||||
|
||||
|
||||
if (serverId == -1) {
|
||||
QMapIterator<int, IslInterface *> islIterator(islInterfaces);
|
||||
while (islIterator.hasNext())
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue