engineplugin.h
1 //------------------------------------------------------------------------------
2 // engineplugin.h
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) 2011 "Blzut3" <admin@maniacsvault.net>
22 //------------------------------------------------------------------------------
23 
24 #ifndef __ENGINEPLUGIN_H__
25 #define __ENGINEPLUGIN_H__
26 
27 #include <QtContainerFwd>
28 #include <QString>
29 #include <QStringList>
30 #include <QVector>
31 #include "global.h"
33 #include "serverapi/serverptr.h"
34 
35 // Bump whenever the ABI changes in order to reject old plugins
36 #define DOOMSEEKER_ABI_VERSION 2
37 
38 #define DECLARE_PLUGIN(XEnginePlugin) \
39  friend PLUGIN_EXPORT EnginePlugin *doomSeekerInit(); \
40  public: \
41  static EnginePlugin *staticInstance() { return __Static_Instance; } \
42  private: \
43  static XEnginePlugin *__Static_Instance;
44 
45 #define INSTALL_PLUGIN(XEnginePlugin) \
46  XEnginePlugin *XEnginePlugin::__Static_Instance; \
47  extern "C" PLUGIN_EXPORT unsigned int doomSeekerABI() { return DOOMSEEKER_ABI_VERSION; } \
48  extern "C" PLUGIN_EXPORT EnginePlugin *doomSeekerInit() \
49  { \
50  XEnginePlugin::__Static_Instance = new XEnginePlugin(); \
51  return XEnginePlugin::staticInstance(); \
52  }
53 
54 class Broadcast;
55 class ConfigPage;
56 class CreateServerDialog;
58 class GameCVarProvider;
59 class GameCVar;
60 class GameExeFactory;
61 class GameHost;
62 class GameMode;
63 class IniSection;
64 class IRCNetworkEntity;
65 class MasterClient;
66 class Server;
67 class QHostAddress;
68 class QPixmap;
69 class QWidget;
70 
74 class MAIN_EXPORT EnginePlugin
75 {
76  protected:
83  {
85 
88 
103 
114 
216  EP_AllowsUpnpPort
217  };
218 
220  virtual void setupConfig(IniSection &config);
221 
222  public:
227  class Data
228  {
229  public:
230  unsigned int abiVersion;
231  bool allowsConnectPassword;
232  bool allowsEmail;
233  bool allowsJoinPassword;
234  bool allowsMOTD;
235  bool allowsRConPassword;
236  bool allowsURL;
237  QString author;
239  QString defaultMaster;
240  quint16 defaultServerPort;
242  QPixmap *icon;
243  bool inGameFileDownloads;
244  QVector<IRCNetworkEntity> ircChannels;
245  MasterClient *masterClient;
246  QString name;
247  IniSection *pConfig;
248  quint8 refreshThreshold;
249  QString scheme;
250  bool supportsRandomMapRotation;
251  bool valid;
252  unsigned int version;
253  bool demoExtensionAutomatic;
254  QString demoExtension;
266  bool clientOnly;
277  QSharedPointer<GameExeFactory> gameExeFactory;
278  Broadcast *broadcast;
279 
280  QString clientExeName;
281  QString serverExeName;
282  QStringList gameFileSearchSuffixes;
283 
289  QSharedPointer<GameCVarProvider> difficulty;
290  bool hasMapList;
291  bool hasIwad;
292  bool allowsClientSlots;
293  bool allowsPlayerSlots;
294  bool allowsUpnp;
295  bool allowsUpnpPort;
296 
297  Data();
298 
299  bool hasBroadcast() const
300  {
301  return broadcast != NULL;
302  }
303 
304  bool hasMasterClient() const
305  {
306  return masterClient != NULL;
307  }
308  };
309 
310  EnginePlugin();
311  virtual ~EnginePlugin();
312 
322  void init(const char* name, const char* const icon[], ...);
323 
327  virtual ConfigPage* configuration(QWidget *parent);
328 
346  virtual QList<CreateServerDialogPage*> createServerDialogPages(
347  CreateServerDialog* pDialog)
348  {
349  return QList<CreateServerDialogPage*>();
350  }
351 
352  const Data *data() const { return d; }
353  const QPixmap &icon() const { return *d->icon; }
354  void setConfig(IniSection &cfg);
355 
359  virtual QList<DMFlagsSection> dmFlags() const;
360 
361  GameExeFactory *gameExe();
362 
370  virtual GameHost* gameHost();
371 
379  virtual QList<GameMode> gameModes() const;
383  virtual QList<GameCVar> gameModifiers() const;
384 
389  virtual QList<GameCVar> limits(const GameMode& mode) const { return QList<GameCVar>(); }
390 
394  void masterHost(QString &host, unsigned short &port) const;
395 
406  QString nameCanonical() const;
407 
415  virtual ServerPtr server(const QHostAddress &address, unsigned short port) const;
416 
433  virtual void start();
434 
435  protected:
440  virtual ServerPtr mkServer(const QHostAddress &address, unsigned short port) const = 0;
441  void initDefaultGameFiles();
442  void setGameExeFactory(QSharedPointer<GameExeFactory> factory);
443 
444  private:
445  Data *d;
446 
447  QStringList collectKnownPaths(const IniSection &ini) const;
448  void findGameFiles(IniSection &ini);
449 };
450 
451 extern "C" PLUGIN_EXPORT EnginePlugin *doomSeekerInit();
452 
453 #endif
Disables specifying amount of player slots in create game box.
Definition: engineplugin.h:195
bool createDMFlagsPagesAutomatic
Controls behavior of "Create Game" dialog.
Definition: engineplugin.h:265
Creates GameCVar set.
Informs that the game has no notion of an IWAD.
Definition: engineplugin.h:177
QPixmap * icon
icon of the engine
Definition: engineplugin.h:242
(const char*) Author of the plugin.
Definition: engineplugin.h:86
QSharedPointer< GameExeFactory > gameExeFactory
Factory of executable retrievers ExeFile objects.
Definition: engineplugin.h:277
Allows the player to join a server without downloading files through Wadseeker.
Definition: engineplugin.h:97
Tells the create game box that this game allows UPnP.
Definition: engineplugin.h:202
MasterClient object.
Definition: engineplugin.h:121
Signifies that servers can be created with a join password.
Definition: engineplugin.h:92
Signifies that a server can be created with a random map rotation.
Definition: engineplugin.h:99
File name for game&#39;s server executable if game has any.
Definition: engineplugin.h:141
LAN Broadcast object.
Definition: engineplugin.h:117
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:95
(bool)auto, (const char*)extension Sets the extension taht will be used for demos (default is true an...
Definition: engineplugin.h:102
virtual QList< CreateServerDialogPage * > createServerDialogPages(CreateServerDialog *pDialog)
Creates a list of custom Create Game dialog pages.
Definition: engineplugin.h:346
GameCVarProvider that returns difficulty levels ordered from easiest to hardest.
Definition: engineplugin.h:166
QSharedPointer< GameCVarProvider > difficulty
Difficulty levels provider for this game.
Definition: engineplugin.h:289
Signifies that servers can be created for remote console access.
Definition: engineplugin.h:93
Dialog window allowing user to host a game.
File name for game&#39;s client (main) executable.
Definition: engineplugin.h:130
Signifies that servers can have a message of the day.
Definition: engineplugin.h:94
Game mode representation.
Signifies that servers can provide a URL for potential wad downloads.
Definition: engineplugin.h:91
Signals the end of init parameters.
Definition: engineplugin.h:84
(quint8) The amount of time (in seconds) that must pass before a server can be requeried.
Definition: engineplugin.h:100
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:89
Disables map list in create game box.
Definition: engineplugin.h:170
Signifies that servers can have an administrative contact email attached.
Definition: engineplugin.h:90
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:113
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:389
(unsigned int) Single version number for plugin.
Definition: engineplugin.h:87
(quint16) Default port for custom server creation.
Definition: engineplugin.h:96
Abstract base for all MasterClients.
Definition: masterclient.h:49
Default search suffixes used to automatically find game files.
Definition: engineplugin.h:158
(const char*)server, (const char*)channel - Can be repeated. Default IRC channels.
Definition: engineplugin.h:98
(const char*) Overrides the URL scheme which Doomseeker sets for this plugin. By default it is the po...
Definition: engineplugin.h:101
A general game setting or variable (like fraglimit).
QString defaultMaster
Default port on which servers for given engine are hosted.
Definition: engineplugin.h:239
Base class for configuration pages.
Definition: configpage.h:43
Disables specifying amount of client slots in create game box.
Definition: engineplugin.h:186