Merge branch 'experimental' of git://cockatrice.git.sourceforge.net/gitroot/cockatrice/cockatrice

This commit is contained in:
Max-Wilhelm Bruker 2011-07-20 16:18:57 +02:00
commit 6b7c5eefd3
9 changed files with 50 additions and 33 deletions

View file

@ -394,8 +394,10 @@ CardDragItem *CardItem::createDragItem(int _id, const QPointF &_pos, const QPoin
{
deleteDragItem();
dragItem = new CardDragItem(this, _id, _pos, faceDown);
dragItem->setVisible(false);
scene()->addItem(dragItem);
dragItem->updatePosition(_scenePos);
dragItem->setVisible(true);
return dragItem;
}

View file

@ -92,7 +92,7 @@ bool UserListTWI::operator<(const QTreeWidgetItem &other) const
return data(0, Qt::UserRole).toInt() > other.data(0, Qt::UserRole).toInt();
// Sort by name
return data(2, Qt::UserRole).toString().toLower() < other.data(2, Qt::UserRole).toString().toLower();
return QString::localeAwareCompare(data(2, Qt::UserRole).toString(), other.data(2, Qt::UserRole).toString()) < 0;
}
UserList::UserList(TabSupervisor *_tabSupervisor, AbstractClient *_client, UserListType _type, QWidget *parent)

View file

@ -57,8 +57,10 @@ AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString
return authState;
if (authState == PasswordRight) {
if (users.contains(name))
if (users.contains(name)) {
qDebug("Login denied: would overwrite old session");
return WouldOverwriteOldSession;
}
} else if (authState == UnknownUser) {
// Change user name so that no two users have the same names,
// don't interfere with registered user names though.

View file

@ -56,7 +56,7 @@ Server_Game::~Server_Game()
room->removeGame(this);
delete creatorInfo;
qDebug("Server_Game destructor");
qDebug() << "Server_Game destructor: gameId=" << gameId;
}
void Server_Game::pingClockTimeout()

View file

@ -58,8 +58,8 @@ void Server_ProtocolHandler::prepareDestroy()
while (i.hasNext())
delete i.next().value();
QMapIterator<QString, ServerInfo_User *> j(ignoreList);
while (i.hasNext())
delete i.next().value();
while (j.hasNext())
delete j.next().value();
}
void Server_ProtocolHandler::playerRemovedFromGame(Server_Game *game)
@ -207,25 +207,26 @@ void Server_ProtocolHandler::processCommandContainer(CommandContainer *cont)
gameListMutex.lock();
GameEventContainer *gQPublic = cont->getGameEventQueuePublic();
if (gQPublic) {
Server_Game *game = games.value(gQPublic->getGameId()).first;
Server_Player *player = games.value(gQPublic->getGameId()).second;
GameEventContainer *gQPrivate = cont->getGameEventQueuePrivate();
GameEventContainer *gQOmniscient = cont->getGameEventQueueOmniscient();
if (gQPrivate) {
int privatePlayerId = cont->getPrivatePlayerId();
Server_Player *privatePlayer;
if (privatePlayerId == -1)
privatePlayer = player;
else
privatePlayer = game->getPlayer(privatePlayerId);
if (gQOmniscient) {
game->sendGameEventContainer(gQPublic, privatePlayer, true);
game->sendGameEventContainerOmniscient(gQOmniscient, privatePlayer);
QPair<Server_Game *, Server_Player *> gamePlayerPair = games.value(gQPublic->getGameId());
if (gamePlayerPair.first) {
GameEventContainer *gQPrivate = cont->getGameEventQueuePrivate();
GameEventContainer *gQOmniscient = cont->getGameEventQueueOmniscient();
if (gQPrivate) {
int privatePlayerId = cont->getPrivatePlayerId();
Server_Player *privatePlayer;
if (privatePlayerId == -1)
privatePlayer = gamePlayerPair.second;
else
privatePlayer = gamePlayerPair.first->getPlayer(privatePlayerId);
if (gQOmniscient) {
gamePlayerPair.first->sendGameEventContainer(gQPublic, privatePlayer, true);
gamePlayerPair.first->sendGameEventContainerOmniscient(gQOmniscient, privatePlayer);
} else
gamePlayerPair.first->sendGameEventContainer(gQPublic, privatePlayer);
privatePlayer->sendProtocolItem(gQPrivate);
} else
game->sendGameEventContainer(gQPublic, privatePlayer);
privatePlayer->sendProtocolItem(gQPrivate);
} else
game->sendGameEventContainer(gQPublic);
gamePlayerPair.first->sendGameEventContainer(gQPublic);
}
}
gameListMutex.unlock();

View file

@ -172,6 +172,10 @@
<name>M11</name>
<longname>Magic 2011</longname>
</set>
<set import="1">
<name>M12</name>
<longname>Magic 2012</longname>
</set>
<set import="1">
<name>COM</name>
<longname>Magic: The Gathering-Commander</longname>

View file

@ -37,9 +37,8 @@ void Servatrice_TcpServer::incomingConnection(int socketDescriptor)
} else {
QTcpSocket *socket = new QTcpSocket;
socket->setSocketDescriptor(socketDescriptor);
logger->logMessage(QString("incoming connection: %1").arg(socket->peerAddress().toString()));
new ServerSocketInterface(server, socket);
ServerSocketInterface *ssi = new ServerSocketInterface(server, socket);
logger->logMessage(QString("incoming connection: %1").arg(socket->peerAddress().toString()), ssi);
}
}
@ -188,18 +187,27 @@ AuthenticationResult Servatrice::checkUserPassword(Server_ProtocolHandler *handl
QSqlQuery query;
query.prepare("select a.password, time_to_sec(timediff(now(), date_add(b.time_from, interval b.minutes minute))) < 0, b.minutes <=> 0 from " + dbPrefix + "_users a left join " + dbPrefix + "_bans b on b.id_user = a.id and b.time_from = (select max(c.time_from) from " + dbPrefix + "_bans c where c.id_user = a.id) where a.name = :name and a.active = 1");
query.bindValue(":name", user);
if (!execSqlQuery(query))
if (!execSqlQuery(query)) {
qDebug("Login denied: SQL error");
return PasswordWrong;
}
if (query.next()) {
if (query.value(1).toInt() || query.value(2).toInt())
if (query.value(1).toInt() || query.value(2).toInt()) {
qDebug("Login denied: banned");
return PasswordWrong;
if (query.value(0).toString() == password)
}
if (query.value(0).toString() == password) {
qDebug("Login accepted: password right");
return PasswordRight;
else
} else {
qDebug("Login denied: password wrong");
return PasswordWrong;
} else
}
} else {
qDebug("Login accepted: unknown user");
return UnknownUser;
}
} else
return UnknownUser;
}

View file

@ -39,7 +39,7 @@ void ServerLogger::logMessage(QString message, ServerSocketInterface *ssi)
bufferMutex.lock();
QString ssiString;
if (ssi)
ssiString = QString::number((qulonglong) ssi) + " ";
ssiString = QString::number((qulonglong) ssi, 16) + " ";
buffer.append(QDateTime::currentDateTime().toString() + " " + QString::number((qulonglong) QThread::currentThread(), 16) + " " + ssiString + message);
bufferMutex.unlock();

View file

@ -60,7 +60,7 @@ ServerSocketInterface::ServerSocketInterface(Servatrice *_server, QTcpSocket *_s
ServerSocketInterface::~ServerSocketInterface()
{
logger->logMessage("ServerSocketInterface destructor");
logger->logMessage("ServerSocketInterface destructor", this);
prepareDestroy();