added mutex for RNG, moved game command implementation from S_PH to S_Player in preparation for forwarding of game commands via tunneling interface

This commit is contained in:
Max-Wilhelm Bruker 2012-03-17 22:26:12 +01:00
parent 671214c60e
commit 9706ecd98a
11 changed files with 1090 additions and 1092 deletions

View file

@ -29,6 +29,7 @@
#include "server_logger.h"
#include "main.h"
#include "passwordhasher.h"
#include "decklist.h"
#include "pb/game_replay.pb.h"
#include "pb/event_replay_added.pb.h"
#include "pb/event_server_message.pb.h"
@ -815,6 +816,27 @@ void Servatrice::storeGameInformation(int secondsElapsed, const QSet<QString> &a
query3.execBatch();
}
DeckList *Servatrice::getDeckFromDatabase(int deckId, const QString &userName)
{
checkSql();
QMutexLocker locker(&dbMutex);
QSqlQuery query;
query.prepare("select content from " + dbPrefix + "_decklist_files where id = :id and user = :user");
query.bindValue(":id", deckId);
query.bindValue(":user", userName);
execSqlQuery(query);
if (!query.next())
throw Response::RespNameNotFound;
QXmlStreamReader deckReader(query.value(0).toString());
DeckList *deck = new DeckList;
deck->loadFromXml(&deckReader);
return deck;
}
void Servatrice::scheduleShutdown(const QString &reason, int minutes)
{
shutdownReason = reason;