server.cpp
1 //------------------------------------------------------------------------------
2 // server.cpp
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2009 Braden "Blzut3" Obrzut <admin@maniacsvault.net>
22 //------------------------------------------------------------------------------
23 #include "server.h"
24 
25 #include "configuration/doomseekerconfig.h"
26 #include "configuration/queryspeed.h"
27 #include "log.h"
28 #include "pathfinder/pathfinder.h"
29 #include "pathfinder/wadpathfinder.h"
30 #include "plugins/engineplugin.h"
31 #include "serverapi/exefile.h"
32 #include "serverapi/gameclientrunner.h"
33 #include "serverapi/gameexeretriever.h"
34 #include "serverapi/message.h"
35 #include "serverapi/playerslist.h"
36 #include "serverapi/tooltips/tooltipgenerator.h"
37 #include "strings.hpp"
38 #include <cassert>
39 #include <QElapsedTimer>
40 #include <QTime>
41 #include <QUdpSocket>
42 
44 
45 DClass<Server>
46 {
47 public:
48  PrivData()
49  {
50  gameMode = GameMode::mkCooperative();
51  }
52 
59  bool bKnown;
60 
69  bool bPingIsSet;
70 
71  bool bSecure;
73  unsigned int ping;
74  bool custom;
75  QList<DMFlagsSection> dmFlags;
76  QString email;
77  QElapsedTimer lastRefreshClock;
78  QString iwad;
79  bool lan;
80  bool locked;
81  bool lockedInGame;
82  QStringList mapList;
83  QString mapName;
84  unsigned short maxClients;
85  unsigned short maxPlayers;
86  QString motd;
87  QString name;
88  QTime pingClock;
90  bool randomMapRotation;
91  Server::Response response;
92  QList<int> scores;
93  unsigned int scoreLimit;
94  unsigned short timeLeft;
95  unsigned short timeLimit;
96  unsigned char skill;
97  bool testingServer;
98  QString version;
99  QList<PWad> wads;
100  QString webSite;
101 
107  bool bIsRefreshing;
108  QHostAddress address;
109  QHostInfo host;
110  unsigned short port;
114  int triesLeft;
115  QWeakPointer<Server> self;
116 
117  QString (Server::*customDetails)();
118  QByteArray (Server::*createSendRequest)();
119  Server::Response (Server::*readRequest)(const QByteArray &);
120 };
121 
122 DPointeredNoCopy(Server)
123 
124 
126 QString Server::teamNames[] =
127 {
128  "Blue",
129  "Red",
130  "Green",
131  "Gold"
132 };
133 
134 Server::Server(const QHostAddress &address, unsigned short port)
135  : QObject()
136 {
137  d->address = address;
138  d->port = port;
139  d->bIsRefreshing = false;
140  d->lan = false;
141  d->locked = false;
142  d->lockedInGame = false;
143  d->testingServer = false;
144  d->triesLeft = 0;
145  d->maxClients = 0;
146  d->maxPlayers = 0;
147  d->name = tr("<< ERROR >>");
148  d->response = RESPONSE_NO_RESPONSE_YET;
149  d->scoreLimit = 0;
150  d->timeLeft = 0;
151  d->timeLimit = 0;
152  d->ping = 999;
153  for (int i = 0; i < MAX_TEAMS; ++i)
154  {
155  d->scores << 0;
156  }
157  d->bSecure = false;
158  d->randomMapRotation = false;
159  d->skill = 3;
160  d->bKnown = false;
161  d->custom = false;
162  d->lastRefreshClock.invalidate();
163 
164  set_customDetails(&Server::customDetails_default);
165  set_createSendRequest(&Server::createSendRequest_default);
166  set_readRequest(&Server::readRequest_default);
167 
168  if (gConfig.doomseeker.bLookupHosts)
169  {
170  lookupHost();
171  }
172 }
173 
174 Server::~Server()
175 {
176  clearDMFlags();
177 }
178 
179 POLYMORPHIC_DEFINE(QString, Server, customDetails, (), ())
180 POLYMORPHIC_DEFINE(QByteArray, Server, createSendRequest, (), ())
181 POLYMORPHIC_DEFINE(Server::Response, Server, readRequest, (const QByteArray &data), (data))
182 
183 void Server::addPlayer(const Player &player)
184 {
185  d->players << player;
186 }
187 
188 void Server::addWad(const PWad &wad)
189 {
190  d->wads << wad;
191 }
192 
193 const QHostAddress &Server::address() const
194 {
195  return d->address;
196 }
197 
198 QString Server::addressWithPort() const
199 {
200  return QString("%1:%2").arg(address().toString()).arg(port());
201 }
202 
203 QStringList Server::allWadNames() const
204 {
205  QStringList result;
206  if (!d->iwad.trimmed().isEmpty())
207  {
208  result << d->iwad;
209  }
210  for (const PWad &wad : d->wads)
211  {
212  result << wad.name();
213  }
214  return result;
215 }
216 
217 bool Server::anyWadnameContains(const QString &text, Qt::CaseSensitivity cs) const
218 {
219  if (d->iwad.contains(text, cs))
220  {
221  return true;
222  }
223 
224  for (int j = 0; j < numWads(); ++j)
225  {
226  const PWad &pwad = wad(j);
227  if (pwad.name().contains(text, cs))
228  {
229  return true;
230  }
231  }
232  return false;
233 }
234 
235 void Server::clearDMFlags()
236 {
237  d->dmFlags.clear();
238 }
239 
240 QByteArray Server::createSendRequest_default()
241 {
242  assert(0 && "Server::createSendRequest() is not implemented");
243  return QByteArray();
244 }
245 
247 {
248  d->players.clear();
249 }
250 
252 {
253  d->wads.clear();
254 }
255 
257 {
258  auto f = new ExeFile();
259  // TODO: Figure out a way so that plugins don't have to reset following
260  // values if they don't change:
261  f->setProgramName(plugin()->data()->name);
262  f->setExeTypeName(tr("client"));
263  f->setConfigKey("BinaryPath");
264  return f;
265 }
266 
267 QString Server::customDetails_default()
268 {
269  return "";
270 }
271 
272 const QList<DMFlagsSection> &Server::dmFlags() const
273 {
274  return d->dmFlags;
275 }
276 
277 const QString &Server::email() const
278 {
279  return d->email;
280 }
281 
282 QString Server::engineName() const
283 {
284  if (plugin() != nullptr)
285  {
286  return plugin()->data()->name;
287  }
288  else
289  {
290  return tr("Undefined");
291  }
292 }
293 
295 {
296  return d->gameMode;
297 }
298 
300 {
301  return new GameClientRunner(self());
302 }
303 
304 const QString &Server::gameVersion() const
305 {
306  return d->version;
307 }
308 
309 QString Server::hostName(bool forceAddress) const
310 {
311  if (!forceAddress && gConfig.doomseeker.bLookupHosts &&
312  d->host.error() == QHostInfo::NoError && d->host.lookupId() != -1)
313  {
314  return QString("%1:%2").arg(d->host.hostName()).arg(port());
315  }
316  return QString("%1:%2").arg(address().toString()).arg(port());
317 }
318 
319 const QPixmap &Server::icon() const
320 {
321  return plugin()->icon();
322 }
323 
324 bool Server::isCustom() const
325 {
326  return d->custom;
327 }
328 
329 bool Server::isEmpty() const
330 {
331  return d->players.numClients() == 0;
332 }
333 
334 bool Server::isFull() const
335 {
336  return d->players.numClients() == maxClients();
337 }
338 
339 bool Server::isKnown() const
340 {
341  return d->bKnown;
342 }
343 
345 {
346  return isLocked() || isLockedInGame();
347 }
348 
349 bool Server::isLocked() const
350 {
351  return d->locked;
352 }
353 
355 {
356  return d->lockedInGame;
357 }
358 
360 {
361  return d->randomMapRotation;
362 }
363 
365 {
366  return d->bIsRefreshing;
367 }
368 
369 bool Server::isSecure() const
370 {
371  return d->bSecure;
372 }
373 
374 bool Server::isSpecial() const
375 {
376  return isLan() || isCustom();
377 }
378 
380 {
381  return d->testingServer;
382 }
383 
384 const QString &Server::iwad() const
385 {
386  return d->iwad;
387 }
388 
390 {
391  return d->response;
392 }
393 
395 {
396  QHostInfo::lookupHost(address().toString(), this,
397  SLOT(setHostName(QHostInfo)));
398 }
399 
400 const QStringList &Server::mapList() const
401 {
402  return d->mapList;
403 }
404 
405 const QString &Server::map() const
406 {
407  return d->mapName;
408 }
409 
410 unsigned short Server::maxClients() const
411 {
412  return d->maxClients;
413 }
414 
415 unsigned short Server::maxPlayers() const
416 {
417  return d->maxPlayers;
418 }
419 
420 QList<GameCVar> Server::modifiers() const
421 {
422  return QList<GameCVar>();
423 }
424 
425 const QString &Server::motd() const
426 {
427  return d->motd;
428 }
429 
430 const QString &Server::name() const
431 {
432  return d->name;
433 }
434 
436 {
437  int returnValue = numTotalSlots() - d->players.numClients();
438  return (returnValue < 0) ? 0 : returnValue;
439 }
440 
442 {
443  int returnValue = d->maxPlayers - d->players.numClients();
444  return (returnValue < 0) ? 0 : returnValue;
445 }
446 
448 {
449  int returnValue = numFreeClientSlots() - numFreeJoinSlots();
450  return (returnValue < 0) ? 0 : returnValue;
451 }
452 
453 unsigned int Server::ping() const
454 {
455  return d->ping;
456 }
457 
458 const Player &Server::player(int index) const
459 {
460  return d->players[index];
461 }
462 
464 {
465  return d->players;
466 }
467 
468 unsigned short Server::port() const
469 {
470  return d->port;
471 }
472 
474 {
475  return readRequest(data);
476 }
477 
478 Server::Response Server::readRequest_default(const QByteArray &data)
479 {
480  Q_UNUSED(data);
481  assert(0 && "Server::readRequest(const QByteArray&) is not implemented.");
482  return RESPONSE_BAD;
483 }
484 
486 {
487  d->bIsRefreshing = true;
488 
489  emit begunRefreshing(ServerPtr(self()));
490  d->triesLeft = gConfig.doomseeker.querySpeed().attemptsPerServer;
491  // Limit the maximum number of tries
492  d->triesLeft = qMin(d->triesLeft, QuerySpeed::MAX_ATTEMPTS_PER_SERVER);
493  // Sanity.
494  d->triesLeft = qMax(d->triesLeft, 1);
495 }
496 
498 {
499  d->lastRefreshClock.start();
500  setResponse(response);
501  if (!d->bPingIsSet)
502  {
503  // Set the current ping, if plugin didn't do so already.
504  d->ping = d->pingClock.elapsed();
505  d->bPingIsSet = true;
506  }
507  d->bIsRefreshing = false;
508  d->iwad = d->iwad.toLower();
509  emit updated(self(), response);
510 }
511 
512 unsigned int Server::score(int team) const
513 {
514  return d->scores[team];
515 }
516 
517 unsigned int Server::scoreLimit() const
518 {
519  return d->scoreLimit;
520 }
521 
522 const QList<int> &Server::scores() const
523 {
524  return d->scores;
525 }
526 
528 {
529  return d->scores;
530 }
531 
532 QWeakPointer<Server> Server::self() const
533 {
534  return d->self;
535 }
536 
537 bool Server::sendRefreshQuery(QUdpSocket *socket)
538 {
539  if (d->triesLeft <= 0)
540  {
542  return false;
543  }
544  --d->triesLeft;
545 
546  QByteArray request = createSendRequest();
547  if (request.isEmpty())
548  {
550  return false;
551  }
552 
553  d->bPingIsSet = false;
554  d->pingClock.start();
555 
556  socket->writeDatagram(request, address(), port());
557 
558  return true;
559 }
560 
561 void Server::setCustom(bool custom)
562 {
563  d->custom = custom;
564 }
565 
566 void Server::setDmFlags(const QList<DMFlagsSection> &dmFlags)
567 {
568  d->dmFlags = dmFlags;
569 }
570 
571 void Server::setEmail(const QString &email)
572 {
573  d->email = email;
574 }
575 
577 {
578  d->gameMode = gameMode;
579 }
580 
581 void Server::setGameVersion(const QString &version)
582 {
583  d->version = version;
584 }
585 
586 void Server::setHostName(QHostInfo host)
587 {
588  d->host = host;
589  if (!d->bIsRefreshing)
590  emit updated(self(), lastResponse());
591 }
592 
593 void Server::setIwad(const QString &iwad)
594 {
595  d->iwad = iwad;
596 }
597 
598 void Server::setLocked(bool locked)
599 {
600  d->locked = locked;
601 }
602 
603 void Server::setLockedInGame(bool locked)
604 {
605  d->lockedInGame = locked;
606 }
607 
608 void Server::setMapList(const QStringList &mapList)
609 {
610  d->mapList = mapList;
611 }
612 
613 void Server::setMap(const QString &mapName)
614 {
615  d->mapName = mapName;
616 }
617 
618 void Server::setMaxClients(unsigned short maxClients)
619 {
620  d->maxClients = maxClients;
621 }
622 
623 void Server::setMaxPlayers(unsigned short maxPlayers)
624 {
625  d->maxPlayers = maxPlayers;
626 }
627 
628 void Server::setMotd(const QString &motd)
629 {
630  d->motd = motd;
631 }
632 
633 void Server::setName(const QString &serverName)
634 {
635  d->name = serverName;
636  // Don't let servers occupy more than one row with newline chars.
637  d->name.replace('\n', ' ').replace('\r', ' ');
638 }
639 
640 void Server::setPing(unsigned int ping)
641 {
642  d->ping = ping;
643 }
644 
646 {
647  d->bPingIsSet = b;
648 }
649 
650 void Server::setPort(unsigned short i)
651 {
652  d->port = i;
653 }
654 
655 void Server::setRandomMapRotation(bool randomMapRotation)
656 {
657  d->randomMapRotation = randomMapRotation;
658 }
659 
660 void Server::setResponse(Response response)
661 {
662  d->response = response;
663  if (response == RESPONSE_GOOD)
664  {
665  d->bKnown = true;
666  }
667  else if (response == RESPONSE_BAD || response == RESPONSE_BANNED || response == RESPONSE_TIMEOUT)
668  {
669  d->bKnown = false;
670  }
671 }
672 
673 void Server::setScores(const QList<int> &scores)
674 {
675  d->scores = scores;
676 }
677 
678 void Server::setScoreLimit(unsigned int serverScoreLimit)
679 {
680  d->scoreLimit = serverScoreLimit;
681 }
682 
683 void Server::setSecure(bool bSecure)
684 {
685  d->bSecure = bSecure;
686 }
687 
688 void Server::setSelf(const QWeakPointer<Server> &self)
689 {
690  d->self = self;
691 }
692 
693 void Server::setTestingServer(bool b)
694 {
695  d->testingServer = b;
696 }
697 
698 void Server::setTimeLeft(unsigned short serverTimeLeft)
699 {
700  d->timeLeft = serverTimeLeft;
701 }
702 
703 void Server::setTimeLimit(unsigned short serverTimeLimit)
704 {
705  d->timeLimit = serverTimeLimit;
706 }
707 
708 void Server::setSkill(unsigned char skill)
709 {
710  d->skill = skill;
711 }
712 
713 void Server::setWads(const QList<PWad> &wads)
714 {
715  d->wads = wads;
716 }
717 
718 void Server::setWebSite(const QString &webSite)
719 {
720  d->webSite = webSite;
721 }
722 
723 QRgb Server::teamColor(int team) const
724 {
725  switch (team)
726  {
727  case Player::TEAM_BLUE:
728  return qRgb(0, 0, 255);
729  case Player::TEAM_RED:
730  return qRgb(255, 0, 0);
731  case Player::TEAM_GREEN:
732  return qRgb(0, 255, 0);
733  case Player::TEAM_GOLD:
734  return qRgb(255, 255, 0);
735  default: break;
736  }
737  return qRgb(0, 255, 0);
738 }
739 
740 QString Server::teamName(int team) const
741 {
742  return team < MAX_TEAMS && team >= 0 ? teamNames[team] : "";
743 }
744 
745 unsigned short Server::timeLeft() const
746 {
747  return d->timeLeft;
748 }
749 
750 unsigned short Server::timeLimit() const
751 {
752  return d->timeLimit;
753 }
754 
756 {
757  if (d->lastRefreshClock.isValid())
758  {
759  return d->lastRefreshClock.elapsed();
760  }
761  else
762  {
763  return -1;
764  }
765 }
766 
768 {
769  return new TooltipGenerator(self());
770 }
771 
772 unsigned char Server::skill() const
773 {
774  return d->skill;
775 }
776 
777 const PWad &Server::wad(int index) const
778 {
779  return wads()[index];
780 }
781 
783 {
784  PathFinder pathFinder;
785  #ifdef Q_OS_WIN32
786  {
787  GameExeRetriever exeRetriever(*plugin()->gameExe());
788  Message msg;
789  pathFinder.addPrioritySearchDir(exeRetriever.pathToOfflineExe(msg));
790  }
791  #endif
792  if (isTestingServer())
793  {
794  QScopedPointer<ExeFile> exeFile(clientExe());
795  Message msg;
796  pathFinder.addPrioritySearchDir(exeFile->pathToExe(msg));
797  }
798  return pathFinder;
799 }
800 
801 const QList<PWad> &Server::wads() const
802 {
803  return d->wads;
804 }
805 
806 const QString &Server::webSite() const
807 {
808  return d->webSite;
809 }
810 
811 bool Server::isLan() const
812 {
813  return d->lan;
814 }
815 
816 void Server::setLan(bool b)
817 {
818  d->lan = b;
819 }
const QStringList & mapList() const
List of all levels that are in map rotation on this server.
Definition: server.cpp:400
const QPixmap & icon() const
Icon for this server.
Definition: server.cpp:319
void setRandomMapRotation(bool b)
Set random map rotation status parsed from the response packet.
Definition: server.cpp:655
virtual QString teamName(int team) const
Name of team under given index.
Definition: server.cpp:740
void setSecure(bool bSecureServer)
Set isSecure().
Definition: server.cpp:683
const QString & webSite() const
Website URL provided by this server.
Definition: server.cpp:806
bool isLockedInGame() const
"Join" passworded or not.
Definition: server.cpp:354
Performs a case-insensitive (OS independent) file searches.
Definition: pathfinder.h:81
bool isRefreshing() const
Is the server being refreshed at the current moment?
Definition: server.cpp:364
int numFreeClientSlots() const
Amount of free connection slots.
Definition: server.cpp:435
void lookupHost()
Prompts the server to reverse resolve its address to a hostname.
Definition: server.cpp:394
virtual GameClientRunner * gameRunner()
Creates an instance of GameClientRunner&#39;s derivative class.
Definition: server.cpp:299
unsigned char skill() const
Game skill level, starting from zero.
Definition: server.cpp:772
QString addressWithPort() const
Returns "address:port" string.
Definition: server.cpp:198
PWAD hosted on a server.
void setGameMode(const GameMode &gameMode)
Set game mode parsed from the response packet.
Definition: server.cpp:576
bool anyWadnameContains(const QString &text, Qt::CaseSensitivity cs=Qt::CaseInsensitive) const
True if name of any WAD of this server contains given text.
Definition: server.cpp:217
const QString & motd() const
Message of the Day.
Definition: server.cpp:425
void setPort(unsigned short i)
Set network port, should be called by Doomseeker only.
Definition: server.cpp:650
void setMapList(const QStringList &mapList)
Set map rotation list parsed from the response packet.
Definition: server.cpp:608
Message object used to pass messages throughout the Doomseeker&#39;s system.
Definition: message.h:63
Player is banned from that server.
Definition: server.h:132
A convenience wrapper class for GameExeFactory.
void setCustom(bool custom)
Set whether this server is custom, should be called by Doomseeker only.
Definition: server.cpp:561
const QList< PWad > & wads() const
List of all PWADs loaded on this server.
Definition: server.cpp:801
unsigned int ping() const
Ping from local host to this server.
Definition: server.cpp:453
void setTimeLeft(unsigned short timeLeft)
Set timeLeft().
Definition: server.cpp:698
int numTotalSlots() const
Actual number of free connection slots deduced from maxPlayers() and maxClients().
Definition: server.h:469
QString hostName(bool forceAddress=false) const
A string that is either the "ipaddress:port" or "hostname:port".
Definition: server.cpp:309
QString engineName() const
Returns name of the engine for this server, for example: "Skulltag".
Definition: server.cpp:282
unsigned short maxPlayers() const
Amount of play slots for this server.
Definition: server.cpp:415
A representation of a server for a given game.
Definition: server.h:93
const QString & gameVersion() const
Version of the server program (1.0, 0.98-beta, and so on).
Definition: server.cpp:304
virtual QRgb teamColor(int team) const
Color of team under given index.
Definition: server.cpp:723
"Dummy" response for servers that weren&#39;t refreshed yet.
Definition: server.h:136
virtual QList< GameCVar > modifiers() const
What kind of game modifiers are enabled on this server?
Definition: server.cpp:420
virtual ExeFile * clientExe()
Client executable retriever.
Definition: server.cpp:256
int numFreeJoinSlots() const
Amount of free play slots.
Definition: server.cpp:441
QWeakPointer< Server > self() const
Reference to this server made available ONLY after the server is fully created.
Definition: server.cpp:532
void clearWads()
Clear PWADs list.
Definition: server.cpp:251
unsigned int score(int team=0) const
Total score of a given team, by default team 0 is used.
Definition: server.cpp:512
void setWebSite(const QString &site)
Set web site URL parsed from the response packet.
Definition: server.cpp:718
void setGameVersion(const QString &version)
Set gameVersion().
Definition: server.cpp:581
bool isSecure() const
Secure as in &#39;secure for players&#39;, not &#39;passworded&#39;.
Definition: server.cpp:369
void setIwad(const QString &iwad)
Set iwad().
Definition: server.cpp:593
void setEmail(const QString &mail)
Set email parsed from the response packet.
Definition: server.cpp:571
Response from the server was erroneous.
Definition: server.h:128
QByteArray createSendRequest()
[Pure Virtual] Prepares challenge data.
void setMaxPlayers(unsigned short i)
Set amount of slots for players parsed from the response packet.
Definition: server.cpp:623
void setTimeLimit(unsigned short timeLimit)
Set timeLimit().
Definition: server.cpp:703
virtual TooltipGenerator * tooltipGenerator() const
Creates an instance of TooltipGenerator.
Definition: server.cpp:767
Response lastResponse() const
Last response status deduced by parsing of the server response packet.
Definition: server.cpp:389
const QString & name() const
Server&#39;s name.
Definition: server.cpp:430
Server(const QHostAddress &address, unsigned short port)
Spawn server with given address and port.
Definition: server.cpp:134
bool isSpecial() const
Special servers are custom servers or LAN servers.
Definition: server.cpp:374
const PWad & wad(int index) const
PWAD under given index on the PWADs list.
Definition: server.cpp:777
Data structure that holds information about players in a server.
Definition: player.h:37
void begunRefreshing(ServerPtr server)
Emitted when refresh process begins for the current server.
const GameMode & gameMode() const
GameMode that is currently running on this server.
Definition: server.cpp:294
bool isTestingServer() const
Does this server run a testing version of the game?
Definition: server.cpp:379
unsigned short timeLimit() const
Round time limit, expressed in minutes.
Definition: server.cpp:750
bool isLocked() const
"Connect" passworded or not.
Definition: server.cpp:349
Game mode representation.
QStringList allWadNames() const
IWAD + PWADs.
Definition: server.cpp:203
const QList< int > & scores() const
Scores for all teams.
Definition: server.cpp:522
unsigned short timeLeft() const
Amount of time until the round is over, expressed in minutes.
Definition: server.cpp:745
const QString & iwad() const
IWAD used by this server.
Definition: server.cpp:384
void addPlayer(const Player &player)
Add new Player to this server&#39;s PlayersList.
void addWad(const PWad &wad)
Add PWAD to the list of this server&#39;s PWADs.
Definition: server.cpp:188
const QString & email() const
Email address provided by this server.
Definition: server.cpp:277
void setLocked(bool locked)
Set isLocked().
Definition: server.cpp:598
Response readRefreshQueryResponse(const QByteArray &data)
Entry point for Refresher that pushes response packet for parsing.
Definition: server.cpp:473
Definition: dptr.h:31
virtual EnginePlugin * plugin() const =0
void setPing(unsigned int currentPing)
Set ping().
Definition: server.cpp:640
Response was parsed properly and Server information is available.
Definition: server.h:113
const PlayersList & players() const
List of players that are on this server currently.
Definition: server.cpp:463
virtual PathFinder wadPathFinder()
Instantiate and return PathFinder configured to search for WADs for this server.
Definition: server.cpp:782
void setSelf(const QWeakPointer< Server > &self)
Set "self" reference, should by called by Doomseeker only.
Definition: server.cpp:688
void setMaxClients(unsigned short i)
Set amount of slots for client parsed from the response packet.
Definition: server.cpp:618
void clearPlayersList()
Removes all players from PlayersList.
Definition: server.cpp:246
const QList< DMFlagsSection > & dmFlags() const
dmflags used by this server.
Definition: server.cpp:272
bool isLan() const
Does this server come from LAN.
Definition: server.cpp:811
void refreshStarts()
Called when server begins refreshing routine.
Definition: server.cpp:485
qint64 timeMsSinceLastRefresh() const
Milliseconds elapsed since last refresh.
Definition: server.cpp:755
bool isEmpty() const
Are there any players on this server?
Definition: server.cpp:329
void setMap(const QString &name)
Set current level parsed from the response packet.
Definition: server.cpp:613
void setDmFlags(const QList< DMFlagsSection > &dmFlags)
Set dmFlags().
Definition: server.cpp:566
bool isFull() const
Is this server full?
Definition: server.cpp:334
void updated(ServerPtr server, int response)
Emitted when a refresh has been completed.
bool isRandomMapRotation() const
Is random maplist rotation enabled?
Definition: server.cpp:359
void refreshStops(Response response)
Called when server finishes refreshing routine.
Definition: server.cpp:497
void setScoreLimit(unsigned int scoreLimit)
Set scoreLimit().
Definition: server.cpp:678
void setName(const QString &name)
Set server&#39;s name parsed from the response packet.
Definition: server.cpp:633
Server didn&#39;t respond at all.
Definition: server.h:117
void setLockedInGame(bool locked)
Set isLockedInGame().
Definition: server.cpp:603
const Player & player(int index) const
Player at given index of PlayersList.
Definition: server.cpp:458
int numFreeSpectatorSlots() const
Amount of free spectator slots.
Definition: server.cpp:447
QList< int > & scoresMutable()
Mutable reference to the scores list, available for contents modification.
Definition: server.cpp:527
bool isKnown() const
Is information for this server available?
Definition: server.cpp:339
Creates command line that launches the client executable of the game and connects it to a server...
Response
Type of response that is extracted by parsing the packet that came from the Server.
Definition: server.h:107
int numWads() const
Number of PWADs loaded on this server.
Definition: server.h:476
bool isLockedAnywhere() const
True if any "isLocked()" returns true.
Definition: server.cpp:344
Access to external program executables (game clients, servers, and so on).
Definition: exefile.h:48
void addPrioritySearchDir(const QString &dir)
Definition: pathfinder.cpp:150
void setPingIsSet(bool b)
Plugins should set this to true to prevent default ping calculation.
Definition: server.cpp:645
void setMotd(const QString &message)
Set Message of the Day parsed from the response packet.
Definition: server.cpp:628
unsigned short port() const
Network port on which this server is hosted.
Definition: server.cpp:468
unsigned short maxClients() const
Amount of connection slots for this server, as reported by the server.
Definition: server.cpp:410
bool isCustom() const
Is this a custom server defined by the user?
Definition: server.cpp:324
unsigned int scoreLimit() const
Current score limit.
Definition: server.cpp:517
QString customDetails()
[Virtual] Allows a plugin to provide custom server details.
Response readRequest(const QByteArray &data)
[Pure Virtual] Reads response packet.
const QHostAddress & address() const
Address of this server.
Definition: server.cpp:193
const QString & map() const
Name of the current level.
Definition: server.cpp:405
void setSkill(unsigned char newSkill)
Set skill level parsed from the response packet.
Definition: server.cpp:708
const QString & name() const
File name of the WAD.
bool sendRefreshQuery(QUdpSocket *socket)
Method called by the refreshing thread; sends the challenge query through refresher&#39;s socket...
Definition: server.cpp:537