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 "log.h"
26 #include "configuration/doomseekerconfig.h"
27 #include "configuration/queryspeed.h"
28 #include "pathfinder/pathfinder.h"
29 #include "pathfinder/wadpathfinder.h"
30 #include "plugins/engineplugin.h"
31 #include "strings.hpp"
32 #include "serverapi/tooltips/tooltipgenerator.h"
33 #include "serverapi/exefile.h"
34 #include "serverapi/gameclientrunner.h"
35 #include "serverapi/gameexeretriever.h"
36 #include "serverapi/message.h"
37 #include "serverapi/playerslist.h"
38 #include <QElapsedTimer>
39 #include <QTime>
40 #include <QUdpSocket>
41 #include <cassert>
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 
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  foreach (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  ExeFile* 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() != NULL)
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  assert(0 && "Server::readRequest(const QByteArray&) is not implemented.");
481  return RESPONSE_BAD;
482 }
483 
485 {
486  d->bIsRefreshing = true;
487 
488  emit begunRefreshing(ServerPtr(self()));
489  d->triesLeft = gConfig.doomseeker.querySpeed().attemptsPerServer;
490  // Limit the maximum number of tries
491  d->triesLeft = qMin(d->triesLeft, QuerySpeed::MAX_ATTEMPTS_PER_SERVER);
492  // Sanity.
493  d->triesLeft = qMax(d->triesLeft, 1);
494 }
495 
497 {
498  d->lastRefreshClock.start();
499  setResponse(response);
500  if (!d->bPingIsSet)
501  {
502  // Set the current ping, if plugin didn't do so already.
503  d->ping = d->pingClock.elapsed();
504  d->bPingIsSet = true;
505  }
506  d->bIsRefreshing = false;
507  d->iwad = d->iwad.toLower();
508  emit updated(self(), response);
509 }
510 
511 unsigned int Server::score(int team) const
512 {
513  return d->scores[team];
514 }
515 
516 unsigned int Server::scoreLimit() const
517 {
518  return d->scoreLimit;
519 }
520 
521 const QList<int>& Server::scores() const
522 {
523  return d->scores;
524 }
525 
527 {
528  return d->scores;
529 }
530 
531 QWeakPointer<Server> Server::self() const
532 {
533  return d->self;
534 }
535 
536 bool Server::sendRefreshQuery(QUdpSocket* socket)
537 {
538  if (d->triesLeft <= 0)
539  {
541  return false;
542  }
543  --d->triesLeft;
544 
545  QByteArray request = createSendRequest();
546  if (request.isEmpty())
547  {
549  return false;
550  }
551 
552  d->bPingIsSet = false;
553  d->pingClock.start();
554 
555  socket->writeDatagram(request, address(), port());
556 
557  return true;
558 }
559 
560 void Server::setCustom(bool custom)
561 {
562  d->custom = custom;
563 }
564 
565 void Server::setDmFlags(const QList<DMFlagsSection>& dmFlags)
566 {
567  d->dmFlags = dmFlags;
568 }
569 
570 void Server::setEmail(const QString& email)
571 {
572  d->email = email;
573 }
574 
576 {
577  d->gameMode = gameMode;
578 }
579 
580 void Server::setGameVersion(const QString& version)
581 {
582  d->version = version;
583 }
584 
585 void Server::setHostName(QHostInfo host)
586 {
587  d->host = host;
588  if(!d->bIsRefreshing)
589  emit updated(self(), lastResponse());
590 }
591 
592 void Server::setIwad(const QString& iwad)
593 {
594  d->iwad = iwad;
595 }
596 
597 void Server::setLocked(bool locked)
598 {
599  d->locked = locked;
600 }
601 
602 void Server::setLockedInGame(bool locked)
603 {
604  d->lockedInGame = locked;
605 }
606 
607 void Server::setMapList(const QStringList& mapList)
608 {
609  d->mapList = mapList;
610 }
611 
612 void Server::setMap(const QString& mapName)
613 {
614  d->mapName = mapName;
615 }
616 
617 void Server::setMaxClients(unsigned short maxClients)
618 {
619  d->maxClients = maxClients;
620 }
621 
622 void Server::setMaxPlayers(unsigned short maxPlayers)
623 {
624  d->maxPlayers = maxPlayers;
625 }
626 
627 void Server::setMotd(const QString& motd)
628 {
629  d->motd = motd;
630 }
631 
632 void Server::setName(const QString& serverName)
633 {
634  d->name = serverName;
635  // Don't let servers occupy more than one row with newline chars.
636  d->name.replace('\n', ' ').replace('\r', ' ');
637 }
638 
639 void Server::setPing(unsigned int ping)
640 {
641  d->ping = ping;
642 }
643 
645 {
646  d->bPingIsSet = b;
647 }
648 
649 void Server::setPort(unsigned short i)
650 {
651  d->port = i;
652 }
653 
654 void Server::setRandomMapRotation(bool randomMapRotation)
655 {
656  d->randomMapRotation = randomMapRotation;
657 }
658 
659 void Server::setResponse(Response response)
660 {
661  d->response = response;
662  if (response == RESPONSE_GOOD)
663  {
664  d->bKnown = true;
665  }
666  else if (response == RESPONSE_BAD || response == RESPONSE_BANNED || response == RESPONSE_TIMEOUT)
667  {
668  d->bKnown = false;
669  }
670 }
671 
672 void Server::setScores(const QList<int>& scores)
673 {
674  d->scores = scores;
675 }
676 
677 void Server::setScoreLimit(unsigned int serverScoreLimit)
678 {
679  d->scoreLimit = serverScoreLimit;
680 }
681 
682 void Server::setSecure(bool bSecure)
683 {
684  d->bSecure = bSecure;
685 }
686 
687 void Server::setSelf(const QWeakPointer<Server> &self)
688 {
689  d->self = self;
690 }
691 
692 void Server::setTestingServer(bool b)
693 {
694  d->testingServer = b;
695 }
696 
697 void Server::setTimeLeft(unsigned short serverTimeLeft)
698 {
699  d->timeLeft = serverTimeLeft;
700 }
701 
702 void Server::setTimeLimit(unsigned short serverTimeLimit)
703 {
704  d->timeLimit = serverTimeLimit;
705 }
706 
707 void Server::setSkill(unsigned char skill)
708 {
709  d->skill = skill;
710 }
711 
712 void Server::setWads(const QList<PWad>& wads)
713 {
714  d->wads = wads;
715 }
716 
717 void Server::setWebSite(const QString& webSite)
718 {
719  d->webSite = webSite;
720 }
721 
722 QRgb Server::teamColor(int team) const
723 {
724  switch(team)
725  {
726  case Player::TEAM_BLUE:
727  return qRgb(0, 0, 255);
728  case Player::TEAM_RED:
729  return qRgb(255, 0, 0);
730  case Player::TEAM_GREEN:
731  return qRgb(0, 255, 0);
732  case Player::TEAM_GOLD:
733  return qRgb(255, 255, 0);
734  default: break;
735  }
736  return qRgb(0, 255, 0);
737 }
738 
739 QString Server::teamName(int team) const
740 {
741  return team < MAX_TEAMS && team >= 0 ? teamNames[team] : "";
742 }
743 
744 unsigned short Server::timeLeft() const
745 {
746  return d->timeLeft;
747 }
748 
749 unsigned short Server::timeLimit() const
750 {
751  return d->timeLimit;
752 }
753 
755 {
756  if (d->lastRefreshClock.isValid())
757  {
758  return d->lastRefreshClock.elapsed();
759  }
760  else
761  {
762  return -1;
763  }
764 }
765 
767 {
768  return new TooltipGenerator(self());
769 }
770 
771 unsigned char Server::skill() const
772 {
773  return d->skill;
774 }
775 
776 const PWad& Server::wad(int index) const
777 {
778  return wads()[index];
779 }
780 
782 {
783  PathFinder pathFinder;
784  {
785  GameExeRetriever exeRetriever(*plugin()->gameExe());
786  Message msg;
787  pathFinder.addPrioritySearchDir(exeRetriever.pathToOfflineExe(msg));
788  }
789  {
790  QScopedPointer<ExeFile> exeFile(clientExe());
791  Message msg;
792  pathFinder.addPrioritySearchDir(exeFile->pathToExe(msg));
793  }
794  return pathFinder;
795 }
796 
797 const QList<PWad>& Server::wads() const
798 {
799  return d->wads;
800 }
801 
802 const QString& Server::webSite() const
803 {
804  return d->webSite;
805 }
806 
807 bool Server::isLan() const
808 {
809  return d->lan;
810 }
811 
812 void Server::setLan(bool b)
813 {
814  d->lan = b;
815 }
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:654
virtual QString teamName(int team) const
Name of team under given index.
Definition: server.cpp:739
void setSecure(bool bSecureServer)
Set isSecure().
Definition: server.cpp:682
void setProgramName(const QString &name)
Plugin setter for programName().
Definition: exefile.cpp:113
const QString & webSite() const
Website URL provided by this server.
Definition: server.cpp:802
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:771
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:575
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 setExeTypeName(const QString &name)
Plugin setter for exeTypeName().
Definition: exefile.cpp:108
void setPort(unsigned short i)
Set network port, should be called by Doomseeker only.
Definition: server.cpp:649
void setMapList(const QStringList &mapList)
Set map rotation list parsed from the response packet.
Definition: server.cpp:607
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:560
const QList< PWad > & wads() const
List of all PWADs loaded on this server.
Definition: server.cpp:797
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:697
int numTotalSlots() const
Actual number of free connection slots deduced from maxPlayers() and maxClients().
Definition: server.h:469
virtual EnginePlugin * plugin() const =0
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
void setConfigKey(const QString &keyName)
Plugin setter for configKey().
Definition: exefile.cpp:103
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:722
"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:531
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:511
void setWebSite(const QString &site)
Set web site URL parsed from the response packet.
Definition: server.cpp:717
void setGameVersion(const QString &version)
Set gameVersion().
Definition: server.cpp:580
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:592
void setEmail(const QString &mail)
Set email parsed from the response packet.
Definition: server.cpp:570
Response from the server was erroreneous.
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:622
void setTimeLimit(unsigned short timeLimit)
Set timeLimit().
Definition: server.cpp:702
virtual TooltipGenerator * tooltipGenerator() const
Creates an instance of TooltipGenerator.
Definition: server.cpp:766
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:776
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:749
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:521
unsigned short timeLeft() const
Amount of time until the round is over, expressed in minutes.
Definition: server.cpp:744
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.
Definition: server.cpp:183
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:597
Response readRefreshQueryResponse(const QByteArray &data)
Entry point for Refresher that pushes response packet for parsing.
Definition: server.cpp:473
Definition: dptr.h:31
void setPing(unsigned int currentPing)
Set ping().
Definition: server.cpp:639
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:781
void setSelf(const QWeakPointer< Server > &self)
Set "self" reference, should by called by Doomseeker only.
Definition: server.cpp:687
void setMaxClients(unsigned short i)
Set amount of slots for client parsed from the response packet.
Definition: server.cpp:617
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:807
void refreshStarts()
Called when server begins refreshing routine.
Definition: server.cpp:484
qint64 timeMsSinceLastRefresh() const
Milliseconds elapsed since last refresh.
Definition: server.cpp:754
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:612
void setDmFlags(const QList< DMFlagsSection > &dmFlags)
Set dmFlags().
Definition: server.cpp:565
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:496
void setScoreLimit(unsigned int scoreLimit)
Set scoreLimit().
Definition: server.cpp:677
void setName(const QString &name)
Set server&#39;s name parsed from the response packet.
Definition: server.cpp:632
Server didn&#39;t respond at all.
Definition: server.h:117
void setLockedInGame(bool locked)
Set isLockedInGame().
Definition: server.cpp:602
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:526
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:473
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:146
void setPingIsSet(bool b)
Plugins should set this to true to prevent default ping calculation.
Definition: server.cpp:644
void setMotd(const QString &message)
Set Message of the Day parsed from the response packet.
Definition: server.cpp:627
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:516
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:707
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:536