23 #include "serversummary.h" 25 #include "serverapi/server.h" 27 ServerSummary::ServerSummary(
const Server *server)
29 setAddress(server->
address().toString());
30 setPort(server->
port());
32 setName(server->
name());
35 ServerSummary ServerSummary::deserializeQVariant(
const QVariant &v)
37 QVariantMap m = v.toMap();
39 o.setAddress(m[
"address"].toString());
40 o.setGame(m[
"game"].toString());
41 o.setName(m[
"name"].toString());
42 o.setPort(m[
"port"].toUInt());
43 o.setTime(m[
"time"].toDateTime());
47 QVariant ServerSummary::serializeQVariant()
const 50 m.insert(
"address", d.address);
51 m.insert(
"game", d.game);
52 m.insert(
"name", d.name);
53 m.insert(
"port", d.port);
54 m.insert(
"time", d.time);
60 if (!isValid() || !other.isValid())
65 const float MAX_SIMILARITY = 3.0f;
67 if (address() == other.address() && port() == other.port() && game() == other.game())
71 if (name() == other.name())
75 return similarity / MAX_SIMILARITY;
QString engineName() const
Returns name of the engine for this server, for example: "Skulltag".
A representation of a server for a given game.
const QString & name() const
Server's name.
float similarity(const ServerSummary &other) const
Similarity to the 'other' server; between 0.0 and 1.0.
unsigned short port() const
Network port on which this server is hosted.
const QHostAddress & address() const
Address of this server.