gamecreateparams.cpp
1 //------------------------------------------------------------------------------
2 // gamecreateparams.cpp
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) 2014 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #include "gamecreateparams.h"
24 
26 #include "gamedemo.h"
27 #include <QFileInfo>
28 
29 DClass<GameCreateParams>
30 {
31  public:
32  bool broadcastToLan;
33  bool broadcastToMaster;
34  QString connectPassword;
35  QStringList customParameters;
36  QList<GameCVar> cvars;
37  QString executablePath;
38  QString demoPath;
39  GameDemo demoRecord;
40  QList<DMFlagsSection> dmFlags;
41  QString email;
42  GameMode gameMode;
43  GameCreateParams::HostMode hostMode;
44  QString ingamePassword;
45  QString iwadPath;
46  QString map;
47  QStringList mapList;
48  int maxClients;
49  int maxPlayers;
50  QString motd;
51  QString name;
52  unsigned short port;
53  QList<bool> pwadsOptional;
54  QStringList pwadsPaths;
55  bool randomMapRotation;
56  QString rconPassword;
57  int skill;
58  QString url;
59 };
60 
61 DPointered(GameCreateParams)
62 
64 {
65  d->broadcastToLan = true;
66  d->broadcastToMaster = true;
67  d->randomMapRotation = false;
68  d->maxClients = 0;
69  d->maxPlayers = 0;
70  d->port = 0;
71  d->skill = 0;
72 }
73 
74 GameCreateParams::~GameCreateParams()
75 {
76 }
77 
78 const QString& GameCreateParams::connectPassword() const
79 {
80  return d->connectPassword;
81 }
82 
83 QStringList& GameCreateParams::customParameters()
84 {
85  return d->customParameters;
86 }
87 
88 const QStringList& GameCreateParams::customParameters() const
89 {
90  return d->customParameters;
91 }
92 
93 QList<GameCVar>& GameCreateParams::cvars()
94 {
95  return d->cvars;
96 }
97 
98 const QList<GameCVar>& GameCreateParams::cvars() const
99 {
100  return d->cvars;
101 }
102 
103 const QString& GameCreateParams::demoPath() const
104 {
105  return d->demoPath;
106 }
107 
109 {
110  return d->demoRecord;
111 }
112 
113 void GameCreateParams::setDemoRecord(const GameDemo &demo)
114 {
115  d->demoRecord = demo;
116 }
117 
118 QList<DMFlagsSection>& GameCreateParams::dmFlags()
119 {
120  return d->dmFlags;
121 }
122 
123 const QList<DMFlagsSection>& GameCreateParams::dmFlags() const
124 {
125  return d->dmFlags;
126 }
127 
128 const QString& GameCreateParams::email() const
129 {
130  return d->email;
131 }
132 
133 const QString& GameCreateParams::executablePath() const
134 {
135  return d->executablePath;
136 }
137 
138 const GameMode& GameCreateParams::gameMode() const
139 {
140  return d->gameMode;
141 }
142 
143 GameCreateParams::HostMode GameCreateParams::hostMode() const
144 {
145  return d->hostMode;
146 }
147 
148 bool GameCreateParams::isBroadcastToLan() const
149 {
150  return d->broadcastToLan;
151 }
152 
153 bool GameCreateParams::isBroadcastToMaster() const
154 {
155  return d->broadcastToMaster;
156 }
157 
158 bool GameCreateParams::isRandomMapRotation() const
159 {
160  return d->randomMapRotation;
161 }
162 
163 const QString& GameCreateParams::ingamePassword() const
164 {
165  return d->ingamePassword;
166 }
167 
168 const QString& GameCreateParams::iwadPath() const
169 {
170  return d->iwadPath;
171 }
172 
174 {
175  QFileInfo fi(iwadPath());
176  return fi.fileName();
177 }
178 
179 const QString& GameCreateParams::map() const
180 {
181  return d->map;
182 }
183 
184 const QStringList& GameCreateParams::mapList() const
185 {
186  return d->mapList;
187 }
188 
189 int GameCreateParams::maxClients() const
190 {
191  return d->maxClients;
192 }
193 
194 int GameCreateParams::maxPlayers() const
195 {
196  return d->maxPlayers;
197 }
198 
200 {
201  return qMax(maxClients(), maxPlayers());
202 }
203 
204 const QString& GameCreateParams::motd() const
205 {
206  return d->motd;
207 }
208 
209 const QString& GameCreateParams::name() const
210 {
211  return d->name;
212 }
213 
214 unsigned short GameCreateParams::port() const
215 {
216  return d->port;
217 }
218 
219 QList<bool>& GameCreateParams::pwadsOptional()
220 {
221  return d->pwadsOptional;
222 }
223 
224 const QList<bool>& GameCreateParams::pwadsOptional() const
225 {
226  return d->pwadsOptional;
227 }
228 
229 QStringList& GameCreateParams::pwadsPaths()
230 {
231  return d->pwadsPaths;
232 }
233 
234 const QStringList& GameCreateParams::pwadsPaths() const
235 {
236  return d->pwadsPaths;
237 }
238 
239 QStringList GameCreateParams::pwadsNames() const
240 {
241  QStringList result;
242  foreach (const QString &path, pwadsPaths())
243  {
244  QFileInfo fi(path);
245  result << fi.fileName();
246  }
247  return result;
248 }
249 
250 const QString& GameCreateParams::rconPassword() const
251 {
252  return d->rconPassword;
253 }
254 
255 void GameCreateParams::setBroadcastToLan(bool b)
256 {
257  d->broadcastToLan = b;
258 }
259 
260 void GameCreateParams::setBroadcastToMaster(bool b)
261 {
262  d->broadcastToMaster = b;
263 }
264 
265 void GameCreateParams::setConnectPassword(const QString& pass)
266 {
267  d->connectPassword = pass;
268 }
269 
270 void GameCreateParams::setCustomParameters(const QStringList& customParameters)
271 {
272  d->customParameters = customParameters;
273 }
274 
275 void GameCreateParams::setCvars(const QList<GameCVar>& cvars)
276 {
277  d->cvars = cvars;
278 }
279 
280 void GameCreateParams::setDemoPath(const QString& demoPath)
281 {
282  d->demoPath = demoPath;
283 }
284 
285 void GameCreateParams::setEmail(const QString& email)
286 {
287  d->email = email;
288 }
289 
290 void GameCreateParams::setExecutablePath(const QString& executablePath)
291 {
292  d->executablePath = executablePath;
293 }
294 
295 void GameCreateParams::setGameMode(const GameMode& mode)
296 {
297  d->gameMode = mode;
298 }
299 
300 void GameCreateParams::setHostMode(HostMode mode)
301 {
302  d->hostMode = mode;
303 }
304 
305 void GameCreateParams::setIngamePassword(const QString& pass)
306 {
307  d->ingamePassword = pass;
308 }
309 
310 void GameCreateParams::setIwadPath(const QString& iwadPath)
311 {
312  d->iwadPath = iwadPath;
313 }
314 
315 void GameCreateParams::setMap(const QString& map)
316 {
317  d->map = map;
318 }
319 
320 void GameCreateParams::setMapList(const QStringList& mapList)
321 {
322  d->mapList = mapList;
323 }
324 
325 void GameCreateParams::setMaxClients(int num)
326 {
327  d->maxClients = num;
328 }
329 
330 void GameCreateParams::setMaxPlayers(int num)
331 {
332  d->maxPlayers = num;
333 }
334 
335 void GameCreateParams::setMotd(const QString& motd)
336 {
337  d->motd = motd;
338 }
339 
340 void GameCreateParams::setName(const QString& name)
341 {
342  d->name = name;
343 }
344 
345 void GameCreateParams::setPort(unsigned short port)
346 {
347  d->port = port;
348 }
349 
350 void GameCreateParams::setPwadsOptional(const QList<bool>& pwadsOptional)
351 {
352  d->pwadsOptional = pwadsOptional;
353 }
354 
355 void GameCreateParams::setPwadsPaths(const QStringList& pwadsPaths)
356 {
357  d->pwadsPaths = pwadsPaths;
358 }
359 
360 void GameCreateParams::setRandomMapRotation(bool b)
361 {
362  d->randomMapRotation = b;
363 }
364 
365 void GameCreateParams::setRconPassword(const QString& pass)
366 {
367  d->rconPassword = pass;
368 }
369 
370 void GameCreateParams::setSkill(int skill)
371 {
372  d->skill = skill;
373 }
374 
375 void GameCreateParams::setUrl(const QString& url)
376 {
377  d->url = url;
378 }
379 
381 {
382  return d->skill;
383 }
384 
385 const QString& GameCreateParams::url() const
386 {
387  return d->url;
388 }
QStringList pwadsNames() const
Names of PWADs, derived from pwadsPaths().
const QString & connectPassword() const
Password that allows clients to connect to the server.
const QString & ingamePassword() const
Internal game password.
Game parametrization data used when creating new games.
QString iwadName() const
Name of IWAD, derived from iwadPath().
const QString & motd() const
Message of the Day.
int maxTotalClientSlots() const
Derived basing on maxClients() and maxPlayers() value; higher value wins.
const QString & executablePath() const
Path to the game executable.
const QString & demoPath() const
Use if running in HostMode::Demo mode or recording a demo.
const QString & url() const
URL for server's website or for WADs download.
Game mode representation.
const QString & map() const
Level name as in E1M1 or MAP01.
QList< GameCVar > & cvars()
Contents of this list will be passed as "+consoleCommand value" to the command line.
const QString & rconPassword() const
Password required to connect to remote admin console.
int skill() const
Difficulty level.
const GameDemo & demoRecord() const
Type of demo to record; applicable only in Offline game.
const QStringList & mapList() const
List of maps in cycle, as in MAP01, MAP02, MAP03, and so on.