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

@@ -451,27 +451,6 @@ Response::ResponseCode ServerSocketInterface::cmdDeckUpload(const Command_DeckUp
return Response::RespOk;
}
DeckList *ServerSocketInterface::getDeckFromDatabase(int deckId)
{
servatrice->checkSql();
QMutexLocker locker(&servatrice->dbMutex);
QSqlQuery query;
query.prepare("select content from " + servatrice->getDbPrefix() + "_decklist_files where id = :id and user = :user");
query.bindValue(":id", deckId);
query.bindValue(":user", QString::fromStdString(userInfo->name()));
servatrice->execSqlQuery(query);
if (!query.next())
throw Response::RespNameNotFound;
QXmlStreamReader deckReader(query.value(0).toString());
DeckList *deck = new DeckList;
deck->loadFromXml(&deckReader);
return deck;
}
Response::ResponseCode ServerSocketInterface::cmdDeckDownload(const Command_DeckDownload &cmd, ResponseContainer &rc)
{
if (authState != PasswordRight)
@@ -479,7 +458,7 @@ Response::ResponseCode ServerSocketInterface::cmdDeckDownload(const Command_Deck
DeckList *deck;
try {
deck = getDeckFromDatabase(cmd.deck_id());
deck = servatrice->getDeckFromDatabase(cmd.deck_id(), QString::fromStdString(userInfo->name()));
} catch(Response::ResponseCode r) {
return r;
}