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 
52 class MAIN_EXPORT DMFlag
53 {
54  public:
55  DMFlag();
56  DMFlag(QString name, unsigned value);
57  virtual ~DMFlag();
58 
64  bool isValid() const;
65 
69  const QString& name() const;
73  unsigned value() const;
74 
75  private:
76  DPtr<DMFlag> d;
77 };
78 
86 class MAIN_EXPORT DMFlagsSection
87 {
88  public:
90  DMFlagsSection(const QString& name);
91  virtual ~DMFlagsSection();
92 
100  void add(const DMFlag& flag);
107  unsigned combineValues() const;
111  int count() const;
112  bool isEmpty() const;
117  const QString &name() const;
121  const DMFlag &operator[](int index) const;
122  DMFlag &operator[](int index);
123 
129  {
130  add(flag);
131  return *this;
132  }
133 
134  private:
136 };
137 
144 class MAIN_EXPORT GameCVar
145 {
146  public:
147  GameCVar();
148  GameCVar(const QString &name, const QString &command);
149  virtual ~GameCVar();
150 
158  const QString &command() const;
159 
163  bool hasValue() const;
167  bool isValid() const;
168 
173  const QString &name() const;
174 
178  void setValue(const QVariant& value);
179 
183  const QVariant &value() const;
184  QString valueString() const { return value().toString(); }
185  bool valueBool() const { return value().toBool(); }
186  int valueInt() const { return value().toInt(); }
187 
188  private:
189  DPtr<GameCVar> d;
190 };
191 
205 class MAIN_EXPORT GameMode
206 {
207  public:
222  {
223  SGM_Cooperative = 900,
224  SGM_Deathmatch = 901,
225  SGM_TeamDeathmatch = 902,
226  SGM_CTF = 903,
230  SGM_Unknown = 904
231  };
232 
233  // Standard game mode set
234  // These should be used in order to keep the names uniform.
235  // These can't be static members as translations may not work.
236  static GameMode mkCooperative();
237  static GameMode mkDeathmatch();
238  static GameMode mkTeamDeathmatch();
239  static GameMode mkCaptureTheFlag();
240  static GameMode mkUnknown();
241 
256  static GameMode ffaGame(int index, const QString &name);
267  static GameMode teamGame(int index, const QString &name);
268 
272  GameMode();
273  virtual ~GameMode();
274 
278  int index() const;
279 
285  const QString &name() const;
286 
290  bool isTeamGame() const;
294  bool isValid() const;
295 
296  private:
297  DPtr<GameMode> d;
298 
299  GameMode(int index, const QString &name);
300 
301  void setTeamGame(bool b);
302 };
303 
312 class MAIN_EXPORT PWad
313 {
314  public:
315  PWad(const QString &name, bool optional=false);
316  virtual ~PWad();
317 
321  bool isOptional() const;
325  const QString& name() const;
326 
327  private:
328  DPtr<PWad> d;
329 };
330 
331 #endif
PWAD hosted on a server.
A group of DMFlag objects that can be safely OR'ed together to form a meaningful value.
Definition: serverstructs.h:86
A game setting that is a part of a group of settings that can be OR'ed logically as a single integer...
Definition: serverstructs.h:52
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).