serverstructs.h
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // serverstructs.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) 2010 Braden "Blzut3" Obrzut <admin@maniacsvault.net>
22 //------------------------------------------------------------------------------
23 #ifndef __SERVER_STRUCTS_H_
24 #define __SERVER_STRUCTS_H_
25 
26 #include <QString>
27 #include <QList>
28 #include <QObject>
29 #include <QVariant>
30 #include <climits>
31 
32 #include "dptr.h"
33 #include "global.h"
34 
59 class MAIN_EXPORT DMFlag
60 {
61  public:
62  DMFlag();
63  DMFlag(const QString &internalName, unsigned value);
64  DMFlag(const QString &internalName, unsigned value, const QString &name);
65  virtual ~DMFlag();
66 
73  const QString &internalName() const;
74 
80  bool isValid() const;
81 
86  const QString &name() const;
87 
91  unsigned value() const;
92 
93  private:
94  DPtr<DMFlag> d;
95 };
96 
137 class MAIN_EXPORT DMFlagsSection
138 {
139  public:
146  static QList<DMFlagsSection> removedBySection(
147  const QList<DMFlagsSection> &original,
148  const QList<DMFlagsSection> &removals);
149 
150  DMFlagsSection();
151 
158  DMFlagsSection(const QString &internalName);
159 
166  DMFlagsSection(const QString &internalName, const QString &name);
167 
168  virtual ~DMFlagsSection();
169 
177  void add(const DMFlag& flag);
184  unsigned combineValues() const;
185 
190  DMFlagsSection copyEmpty() const;
191 
195  int count() const;
196 
202  const QString &internalName() const;
203 
207  bool isEmpty() const;
208 
213  const QString &name() const;
217  const DMFlag &operator[](int index) const;
218  DMFlag &operator[](int index);
219 
225  {
226  add(flag);
227  return *this;
228  }
229 
238  DMFlagsSection removed(const DMFlagsSection &removals) const;
239 
240  private:
242 };
243 
250 class MAIN_EXPORT GameCVar
251 {
252  public:
253  GameCVar();
254  GameCVar(const QString &name, const QString &command);
255  GameCVar(const QString &name, const QString &command, const QVariant &value);
256  virtual ~GameCVar();
257 
265  const QString &command() const;
266 
270  bool hasValue() const;
274  bool isValid() const;
275 
280  const QString &name() const;
281 
285  void setValue(const QVariant& value);
286 
290  const QVariant &value() const;
291  QString valueString() const { return value().toString(); }
292  bool valueBool() const { return value().toBool(); }
293  int valueInt() const { return value().toInt(); }
294 
295  private:
296  DPtr<GameCVar> d;
297 };
298 
308 class MAIN_EXPORT GameCVarProvider : public QObject
309 {
310  Q_OBJECT;
311 
312 public:
314  virtual ~GameCVarProvider();
315 
322  virtual QList<GameCVar> get(const QVariant &context);
323 
324 private:
325  Q_DISABLE_COPY(GameCVarProvider);
326 
328 };
329 
348 typedef int gamemode_id;
349 
363 class MAIN_EXPORT GameMode
364 {
365  public:
380  {
381  SGM_Cooperative = 900,
382  SGM_Deathmatch = 901,
383  SGM_TeamDeathmatch = 902,
384  SGM_CTF = 903,
388  SGM_Unknown = 904
389  };
390 
391  // Standard game mode set
392  // These should be used in order to keep the names uniform.
393  // These can't be static members as translations may not work.
394  static GameMode mkCooperative();
395  static GameMode mkDeathmatch();
396  static GameMode mkTeamDeathmatch();
397  static GameMode mkCaptureTheFlag();
398  static GameMode mkUnknown();
399 
414  static GameMode ffaGame(int index, const QString &name);
425  static GameMode teamGame(int index, const QString &name);
426 
430  GameMode();
431  virtual ~GameMode();
432 
436  gamemode_id index() const;
437 
443  const QString &name() const;
444 
448  bool isTeamGame() const;
452  bool isValid() const;
453 
454  private:
455  DPtr<GameMode> d;
456 
457  GameMode(gamemode_id index, const QString &name);
458 
459  void setTeamGame(bool b);
460 };
461 
470 class MAIN_EXPORT PWad
471 {
472  public:
473  PWad(const QString &name, bool optional=false);
474  virtual ~PWad();
475 
479  bool isOptional() const;
483  const QString& name() const;
484 
485  private:
486  DPtr<PWad> d;
487 };
488 
493 class Skill
494 {
495 public:
500  static const unsigned char UNDEFINED = CHAR_MAX;
501 };
502 
503 #endif
Creates GameCVar set.
PWAD hosted on a server.
Game difficulty setting.
A group of DMFlag objects that can be safely OR&#39;ed together to form a meaningful value.
A game setting that is a part of a group of settings that can be OR&#39;ed logically as a single integer...
Definition: serverstructs.h:59
DMFlagsSection & operator<<(const DMFlag &flag)
Stream input operator that appends DMFlag to the collection, same as add().
int gamemode_id
Unique identifier of a GameMode within the plugin.
Game mode representation.
StandardGameMode
These game modes are so common that Doomseeker represents them through internal values and static met...
A general game setting or variable (like fraglimit).