29 #include "serverapi/polymorphism.h"
33 #include <QHostAddress>
93 class MAIN_EXPORT
Server :
public QObject
97 friend class ServerPointer;
158 Server(
const QHostAddress &address,
unsigned short port);
159 virtual ~
Server()
override;
183 virtual bool hasRcon()
const {
return false; }
187 virtual QList<GameCVar> modifiers()
const;
201 virtual QRgb teamColor(
int team)
const;
207 virtual QString teamName(
int team)
const;
263 void addPlayer(
const Player &player);
267 const QHostAddress &address()
const;
271 QString addressWithPort()
const;
276 QStringList allWadNames()
const;
281 bool anyWadnameContains(
const QString &text,
282 Qt::CaseSensitivity cs = Qt::CaseInsensitive)
const;
289 void clearPlayersList();
294 QString customDetails();
299 const QList<DMFlagsSection> &dmFlags()
const;
303 const QString &email()
const;
312 QString engineName()
const;
321 const QString &gameVersion()
const;
335 QString hostName(
bool forceAddress =
false)
const;
339 const QPixmap &icon()
const;
346 bool isCustom()
const;
350 bool isEmpty()
const;
361 bool isKnown()
const;
366 bool isLockedAnywhere()
const;
370 bool isLocked()
const;
374 bool isLockedInGame()
const;
379 bool isRandomMapRotation()
const;
383 bool isRefreshing()
const;
393 bool isSecure()
const;
398 bool isSpecial()
const;
403 bool isTestingServer()
const;
408 const QString &iwad()
const;
414 Response lastResponse()
const;
427 const QString &map()
const;
431 const QStringList &mapList()
const;
438 unsigned short maxClients()
const;
442 unsigned short maxPlayers()
const;
446 const QString &motd()
const;
450 const QString &name()
const;
454 int numFreeClientSlots()
const;
458 int numFreeJoinSlots()
const;
464 int numFreeSpectatorSlots()
const;
469 int numTotalSlots()
const
471 return maxPlayers() > maxClients() ? maxPlayers() : maxClients();
480 unsigned int ping()
const;
484 const Player &player(
int index)
const;
492 unsigned short port()
const;
498 Response readRefreshQueryResponse(
const QByteArray &data);
503 void refreshStarts();
508 void refreshStops(Response response);
513 unsigned int score(
int team = 0)
const;
517 const QList<int> &scores()
const;
523 unsigned int scoreLimit()
const;
534 QWeakPointer<Server>
self()
const;
542 bool sendRefreshQuery(QUdpSocket *socket);
548 void setCustom(
bool custom);
552 void setEmail(
const QString &mail);
556 void setGameMode(
const GameMode &gameMode);
560 void setMap(
const QString &name);
564 void setMapList(
const QStringList &mapList);
568 void setMaxClients(
unsigned short i);
572 void setMaxPlayers(
unsigned short i);
576 void setMotd(
const QString &message);
580 void setName(
const QString &name);
584 void setPort(
unsigned short i);
588 void setRandomMapRotation(
bool b);
594 void setSelf(
const QWeakPointer<Server> &
self);
598 void setSkill(
unsigned char newSkill);
602 void setWebSite(
const QString &site);
607 void setAdditionalWebSites(
const QStringList &list);
612 unsigned short timeLeft()
const;
616 unsigned short timeLimit()
const;
630 qint64 timeMsSinceLastRefresh()
const;
639 unsigned char skill()
const;
643 const PWad &wad(
int index)
const;
647 const QList<PWad> &wads()
const;
651 const QString &webSite()
const;
656 const QStringList &additionalWebSites()
const;
661 QStringList allWebSites()
const;
676 void begunRefreshing(ServerPtr server);
688 void updated(ServerPtr server,
int response);
691 POLYMORPHIC_SETTER_DECLARE(QString,
Server, customDetails, ())
692 QString customDetails_default();
701 Response readRequest(const QByteArray &data);
702 POLYMORPHIC_SETTER_DECLARE(Response,
Server, readRequest, (const QByteArray &data))
709 QByteArray createSendRequest();
710 POLYMORPHIC_SETTER_DECLARE(QByteArray, Server, createSendRequest, ())
715 void addWad(const
PWad &wad);
724 QList<
int> &scoresMutable();
732 void setGameVersion(const QString &version);
736 void setIwad(const QString &iwad);
740 void setLocked(
bool locked);
744 void setLockedInGame(
bool locked);
751 void setPing(
unsigned int currentPing);
759 void setPingIsSet(
bool b);
761 void setTestingServer(
bool b);
765 void setTimeLeft(
unsigned short timeLeft);
769 void setTimeLimit(
unsigned short timeLimit);
773 void setScoreLimit(
unsigned int scoreLimit);
777 void setSecure(
bool bSecureServer);
780 Q_DISABLE_COPY(Server)
782 static QString teamNames[];
788 QByteArray createSendRequest_default();
789 Response readRequest_default(const QByteArray &data);
791 void setResponse(Response response);
792 void setScores(const QList<
int> &scores);
793 void setWads(const QList<
PWad> &wads);
796 void setHostName(QHostInfo host);
799 Q_DECLARE_METATYPE(ServerPtr)
800 Q_DECLARE_METATYPE(ServerCPtr)