blob: 5423fbf525ab84a08c200c1ca38ea03d4f06e362 (
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
32
33
34
35
36
37
38
39
|
#include "listenclienthandler.h"
QByteArray ListenClientHandler::compileServerlist (const QString &gamename,
const int &serverAge_s,
const bool &cmp)
{
// retrieve servers from database (both direct and sync)
QSqlQuery q = selectServerList( gamename, serverAge_s, true);
// output array
QByteArray compiledList;
QDataStream dsList(&compiledList,QIODevice::WriteOnly);
// iterate through resulting queries and add to compile list
while (q.next())
{
QString ip = q.value(0).toString();
unsigned short port = q.value(1).value<unsigned short>();
// add server to list (compressed/cmp or plaintext)
if (cmp)
{
// QHostAddress.toIPv4Address() provides the correct ABCD format, append EF port bytes
dsList << QHostAddress(ip).toIPv4Address() << port;
}
else // plaintext output
{
// ip in database is plaintext already
compiledList += QStringLiteral("\\ip\\%1:%2").arg(ip, QString::number(port));
}
} // while next
// terminator after list
compiledList.append("\\final\\");
// list compiled
return compiledList;
}
|