29 #include "serverapi/polymorphism.h"
34 #include <QHostAddress>
92 class MAIN_EXPORT
Server :
public QObject
96 friend class ServerPointer;
157 Server(
const QHostAddress &address,
unsigned short port);
158 virtual ~
Server()
override;
182 virtual bool hasRcon()
const {
return false; }
186 virtual QList<GameCVar> modifiers()
const;
200 virtual QRgb teamColor(
int team)
const;
206 virtual QString teamName(
int team)
const;
262 void addPlayer(
const Player &player);
266 const QHostAddress &address()
const;
270 QString addressWithPort()
const;
275 QStringList allWadNames()
const;
280 bool anyWadnameContains(
const QString &text,
281 Qt::CaseSensitivity cs = Qt::CaseInsensitive)
const;
288 void clearPlayersList();
293 QString customDetails();
295 const QString &country()
const;
300 const QList<DMFlagsSection> &dmFlags()
const;
304 const QString &email()
const;
313 QString engineName()
const;
322 const QString &gameVersion()
const;
336 QString hostName(
bool forceAddress =
false)
const;
340 const QPixmap &icon()
const;
347 bool isCustom()
const;
351 bool isEmpty()
const;
362 bool isKnown()
const;
367 bool isLockedAnywhere()
const;
371 bool isLocked()
const;
375 bool isLockedInGame()
const;
380 bool isRandomMapRotation()
const;
384 bool isRefreshing()
const;
394 bool isSecure()
const;
399 bool isSpecial()
const;
404 bool isTestingServer()
const;
409 const QString &iwad()
const;
415 Response lastResponse()
const;
428 const QString &map()
const;
432 const QStringList &mapList()
const;
437 unsigned short maxClients()
const;
441 unsigned short maxPlayers()
const;
445 const QString &motd()
const;
449 const QString &name()
const;
453 int numFreeClientSlots()
const;
457 int numFreeJoinSlots()
const;
463 int numFreeSpectatorSlots()
const;
470 int numTotalSlots()
const
472 return maxPlayers() > maxClients() ? maxPlayers() : maxClients();
481 unsigned int ping()
const;
485 const Player &player(
int index)
const;
493 unsigned short port()
const;
499 Response readRefreshQueryResponse(
const QByteArray &data);
504 void refreshStarts();
509 void refreshStops(Response response);
514 unsigned int score(
int team = 0)
const;
518 const QList<int> &scores()
const;
524 unsigned int scoreLimit()
const;
535 QWeakPointer<Server>
self()
const;
543 bool sendRefreshQuery(QUdpSocket *socket);
558 void setCountry(
const QString &country);
563 void setCustom(
bool custom);
567 void setEmail(
const QString &mail);
571 void setGameMode(
const GameMode &gameMode);
575 void setMap(
const QString &name);
579 void setMapList(
const QStringList &mapList);
583 void setMaxClients(
unsigned short i);
587 void setMaxPlayers(
unsigned short i);
591 void setMotd(
const QString &message);
595 void setName(
const QString &name);
599 void setPort(
unsigned short i);
603 void setRandomMapRotation(
bool b);
609 void setSelf(
const QWeakPointer<Server> &
self);
613 void setSkill(
unsigned char newSkill);
617 void setWebSite(
const QString &site);
622 void setAdditionalWebSites(
const QStringList &list);
627 unsigned short timeLeft()
const;
631 unsigned short timeLimit()
const;
645 qint64 timeMsSinceLastRefresh()
const;
654 unsigned char skill()
const;
658 const PWad &wad(
int index)
const;
662 const QList<PWad> &wads()
const;
666 const QString &webSite()
const;
671 const QStringList &additionalWebSites()
const;
676 QStringList allWebSites()
const;
691 void begunRefreshing(ServerPtr server);
703 void updated(ServerPtr server,
int response);
706 POLYMORPHIC_SETTER_DECLARE(QString,
Server, customDetails, ())
707 QString customDetails_default();
716 Response readRequest(const QByteArray &data);
717 POLYMORPHIC_SETTER_DECLARE(Response,
Server, readRequest, (const QByteArray &data))
724 QByteArray createSendRequest();
725 POLYMORPHIC_SETTER_DECLARE(QByteArray, Server, createSendRequest, ())
730 void addWad(const
PWad &wad);
739 QList<
int> &scoresMutable();
747 void setGameVersion(const QString &version);
751 void setIwad(const QString &iwad);
755 void setLocked(
bool locked);
759 void setLockedInGame(
bool locked);
766 void setPing(
unsigned int currentPing);
774 void setPingIsSet(
bool b);
776 void setTestingServer(
bool b);
780 void setTimeLeft(
unsigned short timeLeft);
784 void setTimeLimit(
unsigned short timeLimit);
788 void setScoreLimit(
unsigned int scoreLimit);
792 void setSecure(
bool bSecureServer);
795 Q_DISABLE_COPY(Server)
797 static QString teamNames[];
803 QByteArray createSendRequest_default();
804 Response readRequest_default(const QByteArray &data);
806 void setResponse(Response response);
807 void setScores(const QList<
int> &scores);
808 void setWads(const QList<
PWad> &wads);
811 void setHostName(QHostInfo host);
814 Q_DECLARE_METATYPE(ServerPtr)
815 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
817 Q_DECLARE_METATYPE(ServerCPtr)