author | unc0rr |
Sun, 25 Nov 2012 22:17:11 +0400 | |
branch | flibqtfrontend |
changeset 8103 | c247346d296f |
parent 8100 | 0e6fadf81a2c |
child 8106 | 861d145b270e |
permissions | -rw-r--r-- |
184 | 1 |
/* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
6952 | 3 |
* Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com> |
184 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
17 |
*/ |
|
18 |
||
19 |
#include <QFile> |
|
20 |
#include <QTextStream> |
|
471 | 21 |
#include <QStringList> |
22 |
#include <QLineEdit> |
|
2874
3c7c2bf1ba38
A simple hat reservation mechanism. Can be worked around with a little effort, but to make it useful, you'd have to get everyone you played with to work around it too. Quite a bit of effort for a small reward feature.
nemo
parents:
2833
diff
changeset
|
23 |
#include <QCryptographicHash> |
3333 | 24 |
#include <QSettings> |
7130 | 25 |
#include <QStandardItemModel> |
8100 | 26 |
#include <QDebug> |
5252 | 27 |
|
184 | 28 |
#include "team.h" |
29 |
#include "hwform.h" |
|
7258 | 30 |
#include "DataManager.h" |
314 | 31 |
|
8103 | 32 |
HWTeam::HWTeam(const QString & teamname, QObject *parent) : |
33 |
QObject(parent) |
|
184 | 34 |
{ |
8103 | 35 |
flib_team team; |
36 |
bzero(&team, sizeof(team)); |
|
37 |
team.name = teamname.toUtf8().data(); |
|
38 |
team.grave = "Statue"; |
|
39 |
team.fort = "Plane"; |
|
40 |
team.voicepack = "Default"; |
|
41 |
team.flag = "hedgewars"; |
|
42 |
||
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:
5907
diff
changeset
|
43 |
for (int i = 0; i < HEDGEHOGS_PER_TEAM; i++) |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
44 |
{ |
8103 | 45 |
team.hogs[i].name = QLineEdit::tr("hedgehog %1").arg(i+1).toUtf8().data(); |
46 |
team.hogs[i].hat = "NoHat"; |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
47 |
} |
8103 | 48 |
|
49 |
m_oldTeamName = teamname; |
|
50 |
||
51 |
QVector<flib_binding> binds(BINDS_NUMBER); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
52 |
for(int i = 0; i < BINDS_NUMBER; i++) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
53 |
{ |
8103 | 54 |
binds[i].action = cbinds[i].action.toUtf8().data(); |
55 |
binds[i].binding = cbinds[i].strbind.toUtf8().data(); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
56 |
} |
8103 | 57 |
team.bindings = binds.data(); |
58 |
team.bindingCount = binds.size(); |
|
59 |
||
60 |
team.remoteDriven = false; |
|
61 |
team.hogsInGame = 4; |
|
62 |
||
63 |
m_team = flib_team_copy(&team); |
|
184 | 64 |
} |
65 |
||
8103 | 66 |
HWTeam::HWTeam(const QStringList& strLst, QObject *parent) : |
67 |
QObject(parent) |
|
314 | 68 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
69 |
// net teams are configured from QStringList |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
70 |
if(strLst.size() != 23) throw HWTeamConstructException(); |
8103 | 71 |
flib_team team; |
72 |
bzero(&team, sizeof(team)); |
|
73 |
team.name = strLst[0].toUtf8().data(); |
|
74 |
m_oldTeamName = strLst[0]; |
|
75 |
team.grave = strLst[1].toUtf8().data(); |
|
76 |
team.fort = strLst[2].toUtf8().data(); |
|
77 |
team.voicepack = strLst[3].toUtf8().data(); |
|
78 |
team.flag = strLst[4].toUtf8().data(); |
|
79 |
team.ownerName = strLst[5].toUtf8().data(); |
|
80 |
int difficulty = strLst[6].toUInt(); |
|
314 | 81 |
|
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:
5907
diff
changeset
|
82 |
for (int i = 0; i < HEDGEHOGS_PER_TEAM; i++) |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
83 |
{ |
8103 | 84 |
team.hogs[i].name = strLst[i * 2 + 7].toUtf8().data(); |
85 |
||
86 |
QString hat = strLst[i * 2 + 8]; |
|
87 |
if (hat.isEmpty()) |
|
88 |
team.hogs[i].hat = "NoHat"; |
|
89 |
else |
|
90 |
team.hogs[i].hat = hat.toUtf8().data(); |
|
91 |
||
92 |
team.hogs[i].difficulty = difficulty; |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
93 |
} |
1840 | 94 |
|
8103 | 95 |
m_oldTeamName = strLst[0]; |
1907 | 96 |
|
8103 | 97 |
QVector<flib_binding> binds(BINDS_NUMBER); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
98 |
for(int i = 0; i < BINDS_NUMBER; i++) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
99 |
{ |
8103 | 100 |
binds[i].action = cbinds[i].action.toUtf8().data(); |
101 |
binds[i].binding = cbinds[i].strbind.toUtf8().data(); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
102 |
} |
8103 | 103 |
team.bindings = binds.data(); |
104 |
team.bindingCount = binds.size(); |
|
105 |
||
106 |
team.remoteDriven = true; |
|
107 |
team.hogsInGame = 4; |
|
108 |
||
109 |
m_team = flib_team_copy(&team); |
|
184 | 110 |
} |
111 |
||
8103 | 112 |
|
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:
6060
diff
changeset
|
113 |
HWTeam::HWTeam(const HWTeam & other) : |
8103 | 114 |
QObject(other.parent()) |
115 |
, m_oldTeamName(other.m_oldTeamName) |
|
8100 | 116 |
, m_team(flib_team_copy(other.m_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:
6060
diff
changeset
|
117 |
{ |
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:
6060
diff
changeset
|
118 |
|
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:
6060
diff
changeset
|
119 |
} |
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:
6060
diff
changeset
|
120 |
|
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:
6060
diff
changeset
|
121 |
HWTeam & HWTeam::operator = (const HWTeam & other) |
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:
6060
diff
changeset
|
122 |
{ |
6225
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
123 |
if(this != &other) |
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
124 |
{ |
8103 | 125 |
m_oldTeamName = other.m_oldTeamName; |
126 |
m_team = flib_team_copy(other.m_team); |
|
6225
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
127 |
} |
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:
6060
diff
changeset
|
128 |
|
6225
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
129 |
return *this; |
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:
6060
diff
changeset
|
130 |
} |
184 | 131 |
|
8100 | 132 |
HWTeam::~HWTeam() |
133 |
{ |
|
134 |
if(m_team) |
|
135 |
flib_team_destroy(m_team); |
|
136 |
} |
|
137 |
||
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:
5907
diff
changeset
|
138 |
bool HWTeam::loadFromFile() |
184 | 139 |
{ |
8103 | 140 |
QString name = QString::fromUtf8(m_team->name); |
141 |
||
8100 | 142 |
if(m_team) |
143 |
flib_team_destroy(m_team); |
|
144 |
||
8103 | 145 |
m_team = flib_team_from_ini(QString("/config/Teams/%1.hwt").arg(name).toUtf8().data()); |
8100 | 146 |
|
147 |
return m_team != NULL; |
|
184 | 148 |
} |
149 |
||
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:
5907
diff
changeset
|
150 |
bool HWTeam::fileExists() |
3381 | 151 |
{ |
8103 | 152 |
QFile f(QString("physfs://config/Teams/%1.hwt").arg(name())); |
3381 | 153 |
return f.exists(); |
154 |
} |
|
155 |
||
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:
5907
diff
changeset
|
156 |
bool HWTeam::deleteFile() |
3159 | 157 |
{ |
8103 | 158 |
if(m_team->remoteDriven) |
3159 | 159 |
return false; |
8103 | 160 |
|
161 |
QFile cfgfile(QString("physfs://config/Teams/%1.hwt").arg(name())); |
|
3159 | 162 |
cfgfile.remove(); |
163 |
return true; |
|
164 |
} |
|
165 |
||
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:
5907
diff
changeset
|
166 |
bool HWTeam::saveToFile() |
184 | 167 |
{ |
8103 | 168 |
if (m_oldTeamName != name()) |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
169 |
{ |
8103 | 170 |
QFile cfgfile(QString("physfs://config/Teams/%1.hwt").arg(m_oldTeamName)); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
171 |
cfgfile.remove(); |
8103 | 172 |
m_oldTeamName = name(); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
173 |
} |
8103 | 174 |
|
175 |
return flib_team_to_ini(QString("physfs://config/Teams/%1.hwt").arg(name()).toUtf8(), m_team) == 0; |
|
184 | 176 |
} |
177 |
||
178 |
||
352 | 179 |
bool HWTeam::isNetTeam() const |
180 |
{ |
|
8103 | 181 |
return m_team->remoteDriven; |
352 | 182 |
} |
183 |
||
184 |
||
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
185 |
bool HWTeam::operator==(const HWTeam& t1) const |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
186 |
{ |
8103 | 187 |
return qstrcmp(m_team->name, t1.m_team->name) == 0; |
184 | 188 |
} |
189 |
||
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
190 |
bool HWTeam::operator<(const HWTeam& t1) const |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
191 |
{ |
8103 | 192 |
return qstrcmp(m_team->name, t1.m_team->name) < 0; // if names are equal - test if it is net team |
184 | 193 |
} |
1840 | 194 |
|
195 |
||
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:
5907
diff
changeset
|
196 |
//// Methods for member inspection+modification //// |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
5907
diff
changeset
|
197 |
|
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
5907
diff
changeset
|
198 |
|
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
5907
diff
changeset
|
199 |
// name |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
200 |
QString HWTeam::name() const |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
201 |
{ |
8103 | 202 |
return QString::fromUtf8(m_team->name); |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
203 |
} |
8103 | 204 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
205 |
void HWTeam::setName(const QString & name) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
206 |
{ |
8103 | 207 |
free(m_team->name); |
208 |
||
209 |
m_team->name = qstrdup(name.toUtf8().constData()); |
|
210 |
} |
|
211 |
||
212 |
QString HWTeam::hedgehogName(int index) const |
|
213 |
{ |
|
214 |
return QString::fromUtf8(m_team->hogs[index].name); |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
215 |
} |
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:
5907
diff
changeset
|
216 |
|
8103 | 217 |
QString HWTeam::hedgehogHat(int index) const |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
218 |
{ |
8103 | 219 |
return QString::fromUtf8(m_team->hogs[index].hat); |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
220 |
} |
8103 | 221 |
|
222 |
void HWTeam::setHedgehogName(int index, const QString & name) |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
223 |
{ |
8103 | 224 |
free(m_team->hogs[index].name); |
225 |
||
226 |
m_team->hogs[index].name = qstrdup(name.toUtf8().constData()); |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
227 |
} |
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:
5907
diff
changeset
|
228 |
|
8103 | 229 |
void HWTeam::setHedgehogHat(int index, const QString & hat) |
230 |
{ |
|
231 |
free(m_team->hogs[index].hat); |
|
232 |
||
233 |
m_team->hogs[index].hat = qstrdup(hat.toUtf8().constData()); |
|
234 |
} |
|
235 |
||
236 |
||
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:
5907
diff
changeset
|
237 |
// owner |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
238 |
QString HWTeam::owner() const |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
239 |
{ |
8103 | 240 |
return QString::fromUtf8(m_team->ownerName); |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
241 |
} |
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:
5907
diff
changeset
|
242 |
|
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
5907
diff
changeset
|
243 |
|
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
5907
diff
changeset
|
244 |
|
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
5907
diff
changeset
|
245 |
// difficulty |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
246 |
unsigned int HWTeam::difficulty() const |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
247 |
{ |
8103 | 248 |
return m_team->hogs[0].difficulty; |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
249 |
} |
8103 | 250 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
251 |
void HWTeam::setDifficulty(unsigned int level) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
252 |
{ |
8103 | 253 |
for(int i = 0; i < HEDGEHOGS_PER_TEAM; ++i) |
254 |
m_team->hogs[i].difficulty = level; |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
255 |
} |
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:
5907
diff
changeset
|
256 |
|
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
5907
diff
changeset
|
257 |
// color |
7130 | 258 |
int HWTeam::color() const |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
259 |
{ |
8103 | 260 |
return m_team->colorIndex; |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
261 |
} |
7130 | 262 |
|
263 |
QColor HWTeam::qcolor() const |
|
264 |
{ |
|
8103 | 265 |
return DataManager::instance().colorsModel()->item(m_team->colorIndex)->data().value<QColor>(); |
7130 | 266 |
} |
267 |
||
268 |
void HWTeam::setColor(int color) |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
269 |
{ |
8103 | 270 |
m_team->colorIndex = color % DataManager::instance().colorsModel()->rowCount(); |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
271 |
} |
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:
5907
diff
changeset
|
272 |
|
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
5907
diff
changeset
|
273 |
|
6024 | 274 |
// binds |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
275 |
QString HWTeam::keyBind(unsigned int idx) const |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
276 |
{ |
8103 | 277 |
return QString::fromUtf8(m_team->bindings[idx].binding); |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
278 |
} |
8103 | 279 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
280 |
void HWTeam::bindKey(unsigned int idx, const QString & key) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
281 |
{ |
8103 | 282 |
free(m_team->bindings[idx].binding); |
283 |
||
284 |
m_team->bindings[idx].binding = qstrdup(key.toUtf8().constData()); |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
285 |
} |
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:
5907
diff
changeset
|
286 |
|
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
5907
diff
changeset
|
287 |
// flag |
8103 | 288 |
void HWTeam::setFlag(const QString & flag) |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
289 |
{ |
8103 | 290 |
free(m_team->flag); |
291 |
||
292 |
m_team->flag = strdup(flag.toUtf8().constData()); |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
293 |
} |
8103 | 294 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
295 |
QString HWTeam::flag() const |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
296 |
{ |
8103 | 297 |
return QString::fromUtf8(m_team->flag); |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
298 |
} |
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:
5907
diff
changeset
|
299 |
|
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
5907
diff
changeset
|
300 |
// fort |
8103 | 301 |
void HWTeam::setFort(const QString & fort) |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
302 |
{ |
8103 | 303 |
free(m_team->fort); |
304 |
||
305 |
m_team->fort = strdup(fort.toUtf8().constData()); |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
306 |
} |
8103 | 307 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
308 |
QString HWTeam::fort() const |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
309 |
{ |
8103 | 310 |
return QString::fromUtf8(m_team->fort); |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
311 |
} |
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:
5907
diff
changeset
|
312 |
|
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
5907
diff
changeset
|
313 |
// grave |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
314 |
void HWTeam::setGrave(const QString & grave) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
315 |
{ |
8103 | 316 |
free(m_team->grave); |
317 |
||
318 |
m_team->grave = strdup(grave.toUtf8().constData()); |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
319 |
} |
8103 | 320 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
321 |
QString HWTeam::grave() const |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
322 |
{ |
8103 | 323 |
return QString::fromUtf8(m_team->grave); |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
324 |
} |
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:
5907
diff
changeset
|
325 |
|
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
5907
diff
changeset
|
326 |
// voicepack - getter/setter |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
327 |
void HWTeam::setVoicepack(const QString & voicepack) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
328 |
{ |
8103 | 329 |
free(m_team->voicepack); |
330 |
||
331 |
m_team->voicepack = strdup(voicepack.toUtf8().constData()); |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
332 |
} |
8103 | 333 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
334 |
QString HWTeam::voicepack() const |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
335 |
{ |
8103 | 336 |
return QString::fromUtf8(m_team->voicepack); |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
337 |
} |
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:
5907
diff
changeset
|
338 |
|
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
5907
diff
changeset
|
339 |
|
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
5907
diff
changeset
|
340 |
// campaignProgress - getter |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
341 |
unsigned int HWTeam::campaignProgress() const |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
342 |
{ |
8103 | 343 |
return m_team->campaignProgress; |
344 |
} |
|
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:
5907
diff
changeset
|
345 |
|
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
5907
diff
changeset
|
346 |
// amount of hedgehogs |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
347 |
unsigned char HWTeam::numHedgehogs() const |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
348 |
{ |
8103 | 349 |
return m_team->hogsInGame; |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
350 |
} |
8103 | 351 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
352 |
void HWTeam::setNumHedgehogs(unsigned char num) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
353 |
{ |
8103 | 354 |
m_team->hogsInGame = num; |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
355 |
} |
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:
5907
diff
changeset
|
356 |
|
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
5907
diff
changeset
|
357 |
// rounds+wins - incrementors |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
358 |
void HWTeam::incRounds() |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
359 |
{ |
8103 | 360 |
m_team->rounds++; |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
361 |
} |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
362 |
void HWTeam::incWins() |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
363 |
{ |
8103 | 364 |
m_team->wins++; |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
365 |
} |