engineplugin.h
1 //------------------------------------------------------------------------------
2 // engineplugin.h
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) 2011 Braden "Blzut3" Obrzut <admin@maniacsvault.net>
22 //------------------------------------------------------------------------------
23 
24 #ifndef __ENGINEPLUGIN_H__
25 #define __ENGINEPLUGIN_H__
26 
27 #include "global.h"
28 #include "serverapi/serverptr.h"
30 #include "serverapi/textprovider.h"
31 #include <QString>
32 #include <QStringList>
33 #include <QtContainerFwd>
34 #include <QVector>
35 
36 // Bump whenever the ABI changes in order to reject old plugins
37 #define DOOMSEEKER_ABI_VERSION 2
38 
39 #define DECLARE_PLUGIN(XEnginePlugin) \
40  friend PLUGIN_EXPORT EnginePlugin * doomSeekerInit(); \
41 public: \
42  static EnginePlugin *staticInstance() { return __Static_Instance; } \
43 private: \
44  static XEnginePlugin *__Static_Instance;
45 
46 #define INSTALL_PLUGIN(XEnginePlugin) \
47  XEnginePlugin *XEnginePlugin::__Static_Instance; \
48  extern "C" PLUGIN_EXPORT unsigned int doomSeekerABI() { return DOOMSEEKER_ABI_VERSION; } \
49  extern "C" PLUGIN_EXPORT EnginePlugin *doomSeekerInit() \
50  { \
51  XEnginePlugin::__Static_Instance = new XEnginePlugin(); \
52  return XEnginePlugin::staticInstance(); \
53  }
54 
55 class Broadcast;
56 class ConfigPage;
57 class CreateServerDialog;
59 class GameCVarProvider;
60 class GameCVar;
61 class GameExeFactory;
62 class GameHost;
63 class GameMode;
64 class IniSection;
65 class IRCNetworkEntity;
66 class MasterClient;
67 class Server;
68 class QHostAddress;
69 class QPixmap;
70 class QWidget;
71 class TextProvider;
72 
76 class MAIN_EXPORT EnginePlugin
77 {
78 protected:
85  {
87 
90 
105 
116 
255  EP_AllowsLogging
256  };
257 
259  virtual void setupConfig(IniSection &config);
260 
261 public:
266  class Data
267  {
268  public:
269  unsigned int abiVersion;
270  bool allowsConnectPassword;
271  bool allowsEmail;
272  bool allowsJoinPassword;
273  bool allowsMOTD;
274  bool allowsRConPassword;
275  bool allowsURL;
276  QString author;
278  QString defaultMaster;
279  quint16 defaultServerPort;
281  QPixmap *icon;
282  bool inGameFileDownloads;
283  QVector<IRCNetworkEntity> ircChannels;
284  MasterClient *masterClient;
285  QString name;
286  IniSection *pConfig;
287  quint8 refreshThreshold;
288  QString scheme;
289  bool supportsRandomMapRotation;
290  bool valid;
291  unsigned int version;
292  bool demoExtensionAutomatic;
293  QString demoExtension;
298  QScopedPointer<TextProvider> aboutProvider;
310  bool clientOnly;
321  QSharedPointer<GameExeFactory> gameExeFactory;
322  Broadcast *broadcast;
323 
324  QString clientExeName;
325  QString serverExeName;
326  QStringList gameFileSearchSuffixes;
327 
333  QSharedPointer<GameCVarProvider> difficulty;
334  bool hasMapList;
335  bool hasIwad;
336  bool allowsClientSlots;
337  bool allowsPlayerSlots;
338  bool allowsUpnp;
339  bool allowsUpnpPort;
340  bool allowsLogging;
341  QString canonicalName;
342 
343  Data();
344 
345  bool hasBroadcast() const
346  {
347  return broadcast != nullptr;
348  }
349 
350  bool hasMasterClient() const
351  {
352  return masterClient != nullptr;
353  }
354  };
355 
356  EnginePlugin();
357  virtual ~EnginePlugin();
358 
368  void init(const char *name, const char *const icon[], ...);
369 
373  virtual ConfigPage *configuration(QWidget *parent);
374 
392  virtual QList<CreateServerDialogPage *> createServerDialogPages(CreateServerDialog *pDialog)
393  {
394  Q_UNUSED(pDialog);
395  return QList<CreateServerDialogPage *>();
396  }
397 
398  const Data *data() const
399  {
400  return d;
401  }
402  const QPixmap &icon() const
403  {
404  return *d->icon;
405  }
406  void setConfig(IniSection &cfg);
407 
411  virtual QList<DMFlagsSection> dmFlags() const;
412 
413  GameExeFactory *gameExe();
414 
422  virtual GameHost *gameHost();
423 
431  virtual QList<GameMode> gameModes() const;
435  virtual QList<GameCVar> gameModifiers() const;
436 
441  virtual QList<GameCVar> limits(const GameMode &mode) const
442  {
443  Q_UNUSED(mode);
444  return QList<GameCVar>();
445  }
446 
450  void masterHost(QString &host, unsigned short &port) const;
451 
465  QString nameCanonical() const;
466 
474  virtual ServerPtr server(const QHostAddress &address, unsigned short port) const;
475 
492  virtual void start();
493 
494 protected:
499  virtual ServerPtr mkServer(const QHostAddress &address, unsigned short port) const = 0;
500  void initDefaultGameFiles();
501  void setGameExeFactory(QSharedPointer<GameExeFactory> factory);
502 
503 private:
504  Data *d;
505 
506  QStringList collectKnownPaths(const IniSection &ini) const;
507  void findGameFiles(IniSection &ini);
508 };
509 
510 extern "C" PLUGIN_EXPORT EnginePlugin *doomSeekerInit();
511 
512 #endif
Disables specifying amount of player slots in create game box.
Definition: engineplugin.h:197
bool createDMFlagsPagesAutomatic
Controls behavior of "Create Game" dialog.
Definition: engineplugin.h:309
Creates GameCVar set.
Informs that the game has no notion of an IWAD.
Definition: engineplugin.h:179
QPixmap * icon
icon of the engine
Definition: engineplugin.h:281
(const char*) Author of the plugin.
Definition: engineplugin.h:88
QScopedPointer< TextProvider > aboutProvider
Description of the plugin, intended to be displayed in the "About" dialog.
Definition: engineplugin.h:298
QSharedPointer< GameExeFactory > gameExeFactory
Factory of executable retrievers ExeFile objects.
Definition: engineplugin.h:321
Allows the player to join a server without downloading files through Wadseeker.
Definition: engineplugin.h:99
Tells the create game box that this game allows UPnP.
Definition: engineplugin.h:204
MasterClient object.
Definition: engineplugin.h:123
Signifies that servers can be created with a join password.
Definition: engineplugin.h:94
Signifies that a server can be created with a random map rotation.
Definition: engineplugin.h:101
File name for game&#39;s server executable if game has any.
Definition: engineplugin.h:143
LAN Broadcast object.
Definition: engineplugin.h:119
Returns executable file retrievers from plugins to Doomseeker.
A representation of a server for a given game.
Definition: server.h:93
(const char*) Default ip address and port ("address:port") for master server. Requires EP_HasMasterSe...
Definition: engineplugin.h:97
(bool)auto, (const char*)extension Sets the extension that will be used for demos (default is true an...
Definition: engineplugin.h:104
GameCVarProvider that returns difficulty levels ordered from easiest to hardest.
Definition: engineplugin.h:168
QSharedPointer< GameCVarProvider > difficulty
Difficulty levels provider for this game.
Definition: engineplugin.h:333
Signifies that servers can be created for remote console access.
Definition: engineplugin.h:95
Provides a description to be shown in the "About" menu.
Definition: engineplugin.h:222
Dialog window allowing user to create a game.
File name for game&#39;s client (main) executable.
Definition: engineplugin.h:132
Tells the create game box that this game allows to modify UPnP port.
Definition: engineplugin.h:218
Signifies that servers can have a message of the day.
Definition: engineplugin.h:96
Game mode representation.
Signifies that servers can provide a URL for potential wad downloads.
Definition: engineplugin.h:93
Signals the end of init parameters.
Definition: engineplugin.h:86
(quint8) The amount of time (in seconds) that must pass before a server can be requeried.
Definition: engineplugin.h:102
Base class to be used by plugins to define custom pages in Create Game dialog.
Signifies that servers can be created with a connection password.
Definition: engineplugin.h:91
Disables map list in create game box.
Definition: engineplugin.h:172
Signifies that servers can have an administrative contact email attached.
Definition: engineplugin.h:92
Data structure that describes and defines a connection to an IRC network or server.
INI section representation.
Definition: inisection.h:40
Indicates that client binary serves the purpose of the client and server.
Definition: engineplugin.h:115
Creates game servers, offline games or demo playbacks.
Definition: gamehost.h:69
virtual QList< GameCVar > limits(const GameMode &mode) const
Returns a list of limits (like fraglimit) supported by passed gamemode.
Definition: engineplugin.h:441
(unsigned int) Single version number for plugin.
Definition: engineplugin.h:89
(quint16) Default port for custom server creation.
Definition: engineplugin.h:98
virtual QList< CreateServerDialogPage * > createServerDialogPages(CreateServerDialog *pDialog)
Creates a list of custom Create Game dialog pages.
Definition: engineplugin.h:392
Abstract base for all MasterClients.
Definition: masterclient.h:49
Default search suffixes used to automatically find game files.
Definition: engineplugin.h:160
(const char*)server, (const char*)channel - Can be repeated. Default IRC channels.
Definition: engineplugin.h:100
(const char*) Overrides the URL scheme which Doomseeker sets for this plugin. By default it is the po...
Definition: engineplugin.h:103
A general game setting or variable (like fraglimit).
Plugin canonical name; should match filenames of the library and translation files.
Definition: engineplugin.h:249
QString defaultMaster
Default port on which servers for given engine are hosted.
Definition: engineplugin.h:278
Base class for configuration pages.
Definition: configpage.h:44
Disables specifying amount of client slots in create game box.
Definition: engineplugin.h:188