author | sheepluva |
Thu, 24 Nov 2011 19:15:29 +0100 | |
changeset 6418 | f1a3c3aab5b4 |
parent 6225 | 505643d4c23d |
child 6616 | f77bb02b669f |
permissions | -rw-r--r-- |
184 | 1 |
/* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
4976 | 3 |
* Copyright (c) 2005-2011 Andrey Korotaev <unC0Rr@gmail.com> |
486 | 4 |
* Copyright (c) 2007 Igor Ulyanov <iulyanov@gmail.com> |
184 | 5 |
* |
6 |
* This program is free software; you can redistribute it and/or modify |
|
7 |
* it under the terms of the GNU General Public License as published by |
|
8 |
* the Free Software Foundation; version 2 of the License |
|
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
18 |
*/ |
|
19 |
||
20 |
#ifndef TEAM_H |
|
21 |
#define TEAM_H |
|
22 |
||
207 | 23 |
#include <QColor> |
184 | 24 |
#include <QString> |
25 |
#include "binds.h" |
|
3344 | 26 |
#include "achievements.h" |
6015
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
27 |
#include "hwconsts.h" |
184 | 28 |
|
29 |
class HWForm; |
|
30 |
class GameUIConfig; |
|
31 |
||
314 | 32 |
class HWTeamConstructException |
33 |
{ |
|
34 |
}; |
|
35 |
||
6015
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
36 |
// structure for customization and statistics of a single hedgehog |
3344 | 37 |
struct HWHog |
38 |
{ |
|
39 |
QString Name; |
|
40 |
QString Hat; |
|
41 |
int Rounds, Kills, Deaths, Suicides; |
|
42 |
}; |
|
43 |
||
6015
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
44 |
// class representing a team |
6223
cc3eb9b7230f
It doesn't make much sense to make checks like 'if(game)' if you never set game to 0. Using smart pointers instead. Does it fix segfaults? Probably.
unc0rr
parents:
6024
diff
changeset
|
45 |
class HWTeam : public QObject |
184 | 46 |
{ |
6225
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
47 |
Q_OBJECT |
6223
cc3eb9b7230f
It doesn't make much sense to make checks like 'if(game)' if you never set game to 0. Using smart pointers instead. Does it fix segfaults? Probably.
unc0rr
parents:
6024
diff
changeset
|
48 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2747
diff
changeset
|
49 |
public: |
6015
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
50 |
|
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
51 |
// constructors |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2747
diff
changeset
|
52 |
HWTeam(const QString & teamname); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2747
diff
changeset
|
53 |
HWTeam(const QStringList& strLst); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2747
diff
changeset
|
54 |
HWTeam(); |
6225
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
55 |
HWTeam(const HWTeam & other); |
184 | 56 |
|
6015
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
57 |
// file operations |
6024 | 58 |
static HWTeam loadFromFile(const QString & teamName); |
6015
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
59 |
bool loadFromFile(); |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
60 |
bool deleteFile(); |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
61 |
bool saveToFile(); |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
62 |
bool fileExists(); |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
63 |
|
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
64 |
// attribute getters |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
65 |
unsigned int campaignProgress() const; |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
66 |
QColor color() const; |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
67 |
unsigned int difficulty() const; |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
68 |
QString flag() const; |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
69 |
QString fort() const; |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
70 |
QString grave() const; |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
71 |
const HWHog & hedgehog(unsigned int idx) const; |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
72 |
bool isNetTeam() const; |
6024 | 73 |
QString keyBind(unsigned int idx) const; |
6015
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
74 |
QString name() const; |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
75 |
unsigned char numHedgehogs() const; |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
76 |
QString owner() const; |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
77 |
QString voicepack() const; |
352 | 78 |
|
6015
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
79 |
// attribute setters |
6024 | 80 |
void bindKey(unsigned int idx, const QString & key); |
6015
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
81 |
void setColor(const QColor & color); |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
82 |
void setDifficulty(unsigned int level); |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
83 |
void setFlag(const QString & flag); |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
84 |
void setFort(const QString & fort); |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
85 |
void setGrave(const QString & grave); |
6024 | 86 |
void setHedgehog(unsigned int idx, HWHog hh); |
6015
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
87 |
void setName(const QString & name); |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
88 |
void setNumHedgehogs(unsigned char num); |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
89 |
void setVoicepack(const QString & voicepack); |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
90 |
|
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
91 |
// increments for statistical info |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
92 |
void incRounds(); |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
93 |
void incWins(); |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
94 |
|
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
95 |
// convert team info into strings for further computation |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
96 |
QStringList teamGameConfig(quint32 InitHealth) const; |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
97 |
|
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
98 |
// comparison operators |
6225
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
99 |
bool operator == (const HWTeam& t1) const; |
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
100 |
bool operator < (const HWTeam& t1) const; |
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
101 |
HWTeam & operator = (const HWTeam & other); |
6015
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
102 |
|
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
103 |
|
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
104 |
private: |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
105 |
|
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
106 |
QString OldTeamName; |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
107 |
|
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
108 |
// class members that contain the general team info and settings |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
109 |
QString m_name; |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
110 |
QString m_grave; |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
111 |
QString m_fort; |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
112 |
QString m_flag; |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
113 |
QString m_voicepack; |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
114 |
HWHog m_hedgehogs[HEDGEHOGS_PER_TEAM]; |
6225
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
115 |
quint8 m_difficulty; |
6024 | 116 |
BindAction m_binds[BINDS_NUMBER]; |
341 | 117 |
|
6015
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
118 |
// class members that contain info for the current game setup |
6225
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
119 |
quint8 m_numHedgehogs; |
6015
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
120 |
QColor m_color; |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
121 |
bool m_isNetTeam; |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
122 |
QString m_owner; |
184 | 123 |
|
6015
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
124 |
// class members that contain statistics, etc. |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
125 |
unsigned int m_campaignProgress; |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
126 |
unsigned int m_rounds; |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
127 |
unsigned int m_wins; |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
4976
diff
changeset
|
128 |
unsigned int AchievementProgress[MAX_ACHIEVEMENTS]; |
184 | 129 |
}; |
130 |
||
131 |
#endif |