serverstructs.h
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // serverstructs.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) 2010 "Blzut3" <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 
31 #include "dptr.h"
32 #include "global.h"
33 
58 class MAIN_EXPORT DMFlag
59 {
60  public:
61  DMFlag();
62  DMFlag(const QString &internalName, unsigned value);
63  DMFlag(const QString &internalName, unsigned value, const QString &name);
64  virtual ~DMFlag();
65 
72  const QString &internalName() const;
73 
79  bool isValid() const;
80 
85  const QString &name() const;
86 
90  unsigned value() const;
91 
92  private:
93  DPtr<DMFlag> d;
94 };
95 
136 class MAIN_EXPORT DMFlagsSection
137 {
138  public:
145  static QList<DMFlagsSection> removedBySection(
146  const QList<DMFlagsSection> &original,
147  const QList<DMFlagsSection> &removals);
148 
149  DMFlagsSection();
150 
157  DMFlagsSection(const QString &internalName);
158 
165  DMFlagsSection(const QString &internalName, const QString &name);
166 
167  virtual ~DMFlagsSection();
168 
176  void add(const DMFlag& flag);
183  unsigned combineValues() const;
184 
189  DMFlagsSection copyEmpty() const;
190 
194  int count() const;
195 
201  const QString &internalName() const;
202 
206  bool isEmpty() const;
207 
212  const QString &name() const;
216  const DMFlag &operator[](int index) const;
217  DMFlag &operator[](int index);
218 
224  {
225  add(flag);
226  return *this;
227  }
228 
237  DMFlagsSection removed(const DMFlagsSection &removals) const;
238 
239  private:
241 };
242 
249 class MAIN_EXPORT GameCVar
250 {
251  public:
252  GameCVar();
253  GameCVar(const QString &name, const QString &command);
254  GameCVar(const QString &name, const QString &command, const QVariant &value);
255  virtual ~GameCVar();
256 
264  const QString &command() const;
265 
269  bool hasValue() const;
273  bool isValid() const;
274 
279  const QString &name() const;
280 
284  void setValue(const QVariant& value);
285 
289  const QVariant &value() const;
290  QString valueString() const { return value().toString(); }
291  bool valueBool() const { return value().toBool(); }
292  int valueInt() const { return value().toInt(); }
293 
294  private:
295  DPtr<GameCVar> d;
296 };
297 
307 class MAIN_EXPORT GameCVarProvider : public QObject
308 {
309  Q_OBJECT;
310 
311 public:
313  virtual ~GameCVarProvider();
314 
321  virtual QList<GameCVar> get(const QVariant &context);
322 
323 private:
324  Q_DISABLE_COPY(GameCVarProvider);
325 
327 };
328 
342 class MAIN_EXPORT GameMode
343 {
344  public:
359  {
360  SGM_Cooperative = 900,
361  SGM_Deathmatch = 901,
362  SGM_TeamDeathmatch = 902,
363  SGM_CTF = 903,
367  SGM_Unknown = 904
368  };
369 
370  // Standard game mode set
371  // These should be used in order to keep the names uniform.
372  // These can't be static members as translations may not work.
373  static GameMode mkCooperative();
374  static GameMode mkDeathmatch();
375  static GameMode mkTeamDeathmatch();
376  static GameMode mkCaptureTheFlag();
377  static GameMode mkUnknown();
378 
393  static GameMode ffaGame(int index, const QString &name);
404  static GameMode teamGame(int index, const QString &name);
405 
409  GameMode();
410  virtual ~GameMode();
411 
415  int index() const;
416 
422  const QString &name() const;
423 
427  bool isTeamGame() const;
431  bool isValid() const;
432 
433  private:
434  DPtr<GameMode> d;
435 
436  GameMode(int index, const QString &name);
437 
438  void setTeamGame(bool b);
439 };
440 
449 class MAIN_EXPORT PWad
450 {
451  public:
452  PWad(const QString &name, bool optional=false);
453  virtual ~PWad();
454 
458  bool isOptional() const;
462  const QString& name() const;
463 
464  private:
465  DPtr<PWad> d;
466 };
467 
468 #endif
Creates GameCVar set.
PWAD hosted on a server.
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:58
DMFlagsSection & operator<<(const DMFlag &flag)
Stream input operator that appends DMFlag to the collection, same as add().
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).