blob: c4797eda75bb8803078b3bf7fc617f97f2b49434 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#include "commonactions.h"
QSqlQuery selectServerList(const QString &gamename,
const int &serverAge_s,
const bool &withSyncData)
{
// retrieve servers from database
QSqlQuery q;
QString selectString = "SELECT ip, queryport FROM serverlist "
"WHERE gamename = :gamename ";
if ( withSyncData )
{
// relies on sync data to be accurate (if checker is not enabled)
selectString += "AND (dt_updated > :timestamp OR dt_sync > :timestamp)";
}
else
{
// sync data may not be (sufficiently) accurate, only use data that we verified directly
selectString += "AND dt_updated > :timestamp";
}
// bind values and execute
q.prepare(selectString);
q.bindValue(":gamename", gamename);
q.bindValue(":timestamp", QDateTime::currentDateTime().addSecs(-serverAge_s ).toSecsSinceEpoch());
if ( ! q.exec() )
reportQuery(q);
return q;
}
|