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