author | nemo |
Wed, 02 Jan 2019 11:06:34 -0500 | |
changeset 14531 | bcb418530a1c |
parent 14498 | 4b678aad50e9 |
child 14550 | db646b3c0b95 |
permissions | -rw-r--r-- |
184 | 1 |
/* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
11046 | 3 |
* Copyright (c) 2004-2015 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 |
|
10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents:
9998
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
184 | 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> |
8346 | 26 |
#include <QDebug> |
5252 | 27 |
|
184 | 28 |
#include "team.h" |
29 |
#include "hwform.h" |
|
7258 | 30 |
#include "DataManager.h" |
8346 | 31 |
#include "gameuiconfig.h" |
314 | 32 |
|
1325 | 33 |
HWTeam::HWTeam(const QString & teamname) : |
6225
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
34 |
QObject(0) |
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
35 |
, m_difficulty(0) |
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
36 |
, m_numHedgehogs(4) |
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
37 |
, m_isNetTeam(false) |
14498
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
13708
diff
changeset
|
38 |
, m_isMissionTeam(false) |
184 | 39 |
{ |
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
|
40 |
m_name = teamname; |
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
|
41 |
OldTeamName = 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:
5907
diff
changeset
|
42 |
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
|
43 |
{ |
7131 | 44 |
m_hedgehogs.append(HWHog()); |
13080
23a498a2b5b8
Capitalize default hog names and server name
Wuzzy <Wuzzy2@mail.ru>
parents:
12670
diff
changeset
|
45 |
m_hedgehogs[i].Name = (QLineEdit::tr("Hedgehog %1").arg(i+1)); |
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
|
46 |
m_hedgehogs[i].Hat = "NoHat"; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
47 |
} |
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
|
48 |
m_grave = "Statue"; |
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
|
49 |
m_fort = "Plane"; |
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
|
50 |
m_voicepack = "Default"; |
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
|
51 |
m_flag = "hedgewars"; |
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 |
{ |
7131 | 54 |
m_binds.append(BindAction()); |
6024 | 55 |
m_binds[i].action = cbinds[i].action; |
8346 | 56 |
m_binds[i].strbind = QString(); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
57 |
} |
7145
1d1a14b39400
Fix a bug with wrong state of teams list when color isn't changed manually
unc0rr
parents:
7133
diff
changeset
|
58 |
m_color = 0; |
184 | 59 |
} |
60 |
||
353 | 61 |
HWTeam::HWTeam(const QStringList& strLst) : |
6225
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
62 |
QObject(0) |
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
63 |
, m_numHedgehogs(4) |
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
64 |
, m_isNetTeam(true) |
14498
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
13708
diff
changeset
|
65 |
, m_isMissionTeam(false) |
314 | 66 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
67 |
// net teams are configured from QStringList |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
68 |
if(strLst.size() != 23) throw HWTeamConstructException(); |
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
|
69 |
m_name = strLst[0]; |
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
|
70 |
m_grave = strLst[1]; |
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
|
71 |
m_fort = strLst[2]; |
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
|
72 |
m_voicepack = strLst[3]; |
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
|
73 |
m_flag = strLst[4]; |
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
|
74 |
m_owner = strLst[5]; |
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
|
75 |
m_difficulty = strLst[6].toUInt(); |
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
|
76 |
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
|
77 |
{ |
7131 | 78 |
m_hedgehogs.append(HWHog()); |
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
|
79 |
m_hedgehogs[i].Name=strLst[i * 2 + 7]; |
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
|
80 |
m_hedgehogs[i].Hat=strLst[i * 2 + 8]; |
2833
9c2accd92cc7
Check for empty hat, somehow claymore managed this, this should be a workaround pending figuring out how he did it.
nemo
parents:
2747
diff
changeset
|
81 |
// Somehow claymore managed an empty hat. Until we figure out how, this should avoid a repeat |
9c2accd92cc7
Check for empty hat, somehow claymore managed this, this should be a workaround pending figuring out how he did it.
nemo
parents:
2747
diff
changeset
|
82 |
// Checking net teams is probably pointless, but can't hurt. |
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
|
83 |
if (m_hedgehogs[i].Hat.isEmpty()) m_hedgehogs[i].Hat = "NoHat"; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
84 |
} |
7145
1d1a14b39400
Fix a bug with wrong state of teams list when color isn't changed manually
unc0rr
parents:
7133
diff
changeset
|
85 |
m_color = 0; |
314 | 86 |
} |
87 |
||
1907 | 88 |
HWTeam::HWTeam() : |
6225
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
89 |
QObject(0) |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
90 |
, m_difficulty(0) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
91 |
, m_numHedgehogs(4) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
92 |
, m_isNetTeam(false) |
14498
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
13708
diff
changeset
|
93 |
, m_isMissionTeam(false) |
184 | 94 |
{ |
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
|
95 |
m_name = QString("Team"); |
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
|
96 |
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
|
97 |
{ |
7131 | 98 |
m_hedgehogs.append(HWHog()); |
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
|
99 |
m_hedgehogs[i].Name.sprintf("hedgehog %d", i); |
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
|
100 |
m_hedgehogs[i].Hat = "NoHat"; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
101 |
} |
1840 | 102 |
|
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
|
103 |
m_grave = QString("Simple"); // default |
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
|
104 |
m_fort = QString("Island"); // default |
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
|
105 |
m_voicepack = "Default"; |
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
|
106 |
m_flag = "hedgewars"; |
1907 | 107 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
108 |
for(int i = 0; i < BINDS_NUMBER; i++) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
109 |
{ |
7131 | 110 |
m_binds.append(BindAction()); |
6024 | 111 |
m_binds[i].action = cbinds[i].action; |
8346 | 112 |
m_binds[i].strbind = QString(); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
113 |
} |
7145
1d1a14b39400
Fix a bug with wrong state of teams list when color isn't changed manually
unc0rr
parents:
7133
diff
changeset
|
114 |
m_color = 0; |
184 | 115 |
} |
116 |
||
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 |
HWTeam::HWTeam(const HWTeam & other) : |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
118 |
QObject(0) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
119 |
, OldTeamName(other.OldTeamName) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
120 |
, m_name(other.m_name) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
121 |
, m_grave(other.m_grave) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
122 |
, m_fort(other.m_fort) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
123 |
, m_flag(other.m_flag) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
124 |
, m_voicepack(other.m_voicepack) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
125 |
, m_hedgehogs(other.m_hedgehogs) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
126 |
, m_difficulty(other.m_difficulty) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
127 |
, m_binds(other.m_binds) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
128 |
, m_numHedgehogs(other.m_numHedgehogs) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
129 |
, m_color(other.m_color) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
130 |
, m_isNetTeam(other.m_isNetTeam) |
14498
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
13708
diff
changeset
|
131 |
, m_isMissionTeam(other.m_isMissionTeam) |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
132 |
, m_owner(other.m_owner) |
6225
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
133 |
// , AchievementProgress(other.AchievementProgress) |
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
|
134 |
{ |
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
|
135 |
|
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
|
136 |
} |
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
|
137 |
|
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
|
138 |
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
|
139 |
{ |
6225
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
140 |
if(this != &other) |
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
141 |
{ |
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
142 |
OldTeamName = other.OldTeamName; |
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
143 |
m_name = other.m_name; |
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
144 |
m_grave = other.m_grave; |
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
145 |
m_fort = other.m_fort; |
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
146 |
m_flag = other.m_flag; |
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
147 |
m_voicepack = other.m_voicepack; |
7254 | 148 |
m_hedgehogs = other.m_hedgehogs; |
6225
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
149 |
m_difficulty = other.m_difficulty; |
7254 | 150 |
m_binds = other.m_binds; |
6225
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
151 |
m_numHedgehogs = other.m_numHedgehogs; |
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
152 |
m_color = other.m_color; |
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
153 |
m_isNetTeam = other.m_isNetTeam; |
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
154 |
m_owner = other.m_owner; |
7145
1d1a14b39400
Fix a bug with wrong state of teams list when color isn't changed manually
unc0rr
parents:
7133
diff
changeset
|
155 |
m_color = other.m_color; |
14498
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
13708
diff
changeset
|
156 |
m_isMissionTeam = other.m_isMissionTeam; |
6225
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
157 |
} |
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
|
158 |
|
6225
505643d4c23d
disconnect when going back from lobby page (regression fix)
sheepluva
parents:
6223
diff
changeset
|
159 |
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
|
160 |
} |
184 | 161 |
|
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
|
162 |
bool HWTeam::loadFromFile() |
184 | 163 |
{ |
13284
b504131f7405
Fix team files and settings not saving properly, and remove FileEngine stuff from DLC
Wuzzy <Wuzzy2@mail.ru>
parents:
13080
diff
changeset
|
164 |
QSettings teamfile(QString(cfgdir->absolutePath() + "/Teams/%1.hwt").arg(DataManager::safeFileName(m_name)), QSettings::IniFormat, 0); |
3333 | 165 |
teamfile.setIniCodec("UTF-8"); |
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 |
m_name = teamfile.value("Team/Name", m_name).toString(); |
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
|
167 |
m_grave = teamfile.value("Team/Grave", "Statue").toString(); |
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
|
168 |
m_fort = teamfile.value("Team/Fort", "Plane").toString(); |
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
|
169 |
m_voicepack = teamfile.value("Team/Voicepack", "Default").toString(); |
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
|
170 |
m_flag = teamfile.value("Team/Flag", "hedgewars").toString(); |
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
|
171 |
m_difficulty = teamfile.value("Team/Difficulty", 0).toInt(); |
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
|
172 |
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
|
173 |
{ |
3333 | 174 |
QString hh = QString("Hedgehog%1/").arg(i); |
13080
23a498a2b5b8
Capitalize default hog names and server name
Wuzzy <Wuzzy2@mail.ru>
parents:
12670
diff
changeset
|
175 |
m_hedgehogs[i].Name = teamfile.value(hh + "Name", QString("Hedgehog %1").arg(i+1)).toString(); |
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
|
176 |
m_hedgehogs[i].Hat = teamfile.value(hh + "Hat", "NoHat").toString(); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
177 |
} |
3333 | 178 |
for(int i = 0; i < BINDS_NUMBER; i++) |
8346 | 179 |
m_binds[i].strbind = teamfile.value(QString("Binds/%1").arg(m_binds[i].action), QString()).toString(); |
3344 | 180 |
for(int i = 0; i < MAX_ACHIEVEMENTS; i++) |
181 |
if(achievements[i][0][0]) |
|
182 |
AchievementProgress[i] = teamfile.value(QString("Achievements/%1").arg(achievements[i][0]), 0).toUInt(); |
|
183 |
else |
|
184 |
break; |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
185 |
return true; |
184 | 186 |
} |
187 |
||
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
|
188 |
bool HWTeam::fileExists() |
3381 | 189 |
{ |
13284
b504131f7405
Fix team files and settings not saving properly, and remove FileEngine stuff from DLC
Wuzzy <Wuzzy2@mail.ru>
parents:
13080
diff
changeset
|
190 |
QFile f(QString(cfgdir->absolutePath() + "/Teams/%1.hwt").arg(DataManager::safeFileName(m_name))); |
3381 | 191 |
return f.exists(); |
192 |
} |
|
193 |
||
12670
967990d958bc
Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
194 |
// Returns true if the team name has been changed but a file with the same team name already exists. |
967990d958bc
Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
195 |
// So if this team would be saved, another team file would be overwritten, which is generally not |
967990d958bc
Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
196 |
// desired. |
967990d958bc
Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
197 |
bool HWTeam::wouldOverwriteOtherFile() |
967990d958bc
Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
198 |
{ |
967990d958bc
Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
199 |
return (m_name != OldTeamName) && fileExists(); |
967990d958bc
Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
200 |
} |
967990d958bc
Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
201 |
|
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
|
202 |
bool HWTeam::deleteFile() |
3159 | 203 |
{ |
204 |
if(m_isNetTeam) |
|
205 |
return false; |
|
13284
b504131f7405
Fix team files and settings not saving properly, and remove FileEngine stuff from DLC
Wuzzy <Wuzzy2@mail.ru>
parents:
13080
diff
changeset
|
206 |
QFile cfgfile(QString(cfgdir->absolutePath() + "/Teams/%1.hwt").arg(DataManager::safeFileName(m_name))); |
3159 | 207 |
cfgfile.remove(); |
208 |
return true; |
|
209 |
} |
|
210 |
||
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
|
211 |
bool HWTeam::saveToFile() |
184 | 212 |
{ |
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
|
213 |
if (OldTeamName != m_name) |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
214 |
{ |
13284
b504131f7405
Fix team files and settings not saving properly, and remove FileEngine stuff from DLC
Wuzzy <Wuzzy2@mail.ru>
parents:
13080
diff
changeset
|
215 |
QFile cfgfile(QString(cfgdir->absolutePath() + "/Teams/%1.hwt").arg(DataManager::safeFileName(OldTeamName))); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
216 |
cfgfile.remove(); |
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
|
217 |
OldTeamName = m_name; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
218 |
} |
8098 | 219 |
|
13284
b504131f7405
Fix team files and settings not saving properly, and remove FileEngine stuff from DLC
Wuzzy <Wuzzy2@mail.ru>
parents:
13080
diff
changeset
|
220 |
QString fileName = QString(cfgdir->absolutePath() + "/Teams/%1.hwt").arg(DataManager::safeFileName(m_name)); |
8508
f849b7b3af1d
- Ensure that team file exists before saving into it (same fix as for hedgewars.ini, due to bug in Qt)
unc0rr
parents:
8346
diff
changeset
|
221 |
DataManager::ensureFileExists(fileName); |
f849b7b3af1d
- Ensure that team file exists before saving into it (same fix as for hedgewars.ini, due to bug in Qt)
unc0rr
parents:
8346
diff
changeset
|
222 |
QSettings teamfile(fileName, QSettings::IniFormat, 0); |
3333 | 223 |
teamfile.setIniCodec("UTF-8"); |
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
|
224 |
teamfile.setValue("Team/Name", 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:
5907
diff
changeset
|
225 |
teamfile.setValue("Team/Grave", 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:
5907
diff
changeset
|
226 |
teamfile.setValue("Team/Fort", 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:
5907
diff
changeset
|
227 |
teamfile.setValue("Team/Voicepack", 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:
5907
diff
changeset
|
228 |
teamfile.setValue("Team/Flag", 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:
5907
diff
changeset
|
229 |
teamfile.setValue("Team/Difficulty", m_difficulty); |
8098 | 230 |
|
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
|
231 |
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
|
232 |
{ |
3333 | 233 |
QString hh = QString("Hedgehog%1/").arg(i); |
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
|
234 |
teamfile.setValue(hh + "Name", m_hedgehogs[i].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:
5907
diff
changeset
|
235 |
teamfile.setValue(hh + "Hat", m_hedgehogs[i].Hat); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
236 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
237 |
for(int i = 0; i < BINDS_NUMBER; i++) |
6024 | 238 |
teamfile.setValue(QString("Binds/%1").arg(m_binds[i].action), m_binds[i].strbind); |
3344 | 239 |
for(int i = 0; i < MAX_ACHIEVEMENTS; i++) |
240 |
if(achievements[i][0][0]) |
|
241 |
teamfile.setValue(QString("Achievements/%1").arg(achievements[i][0]), AchievementProgress[i]); |
|
242 |
else |
|
243 |
break; |
|
8098 | 244 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
245 |
return true; |
184 | 246 |
} |
247 |
||
9466 | 248 |
QStringList HWTeam::teamGameConfig(quint32 InitHealth) const |
184 | 249 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
250 |
QStringList sl; |
14498
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
13708
diff
changeset
|
251 |
QString cmdAddHog = "eaddhh"; |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
13708
diff
changeset
|
252 |
|
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
|
253 |
if (m_isNetTeam) |
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
|
254 |
{ |
7313
162bc562335b
Use toUtf8 instead TODO - find out 'sactly what the website is using for hashes.
nemo
parents:
7258
diff
changeset
|
255 |
sl.push_back(QString("eaddteam %3 %1 %2").arg(qcolor().rgb() & 0xffffff).arg(m_name).arg(QString(QCryptographicHash::hash(m_owner.toUtf8(), QCryptographicHash::Md5).toHex()))); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
256 |
sl.push_back("erdriven"); |
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
|
257 |
} |
14498
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
13708
diff
changeset
|
258 |
else |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
13708
diff
changeset
|
259 |
{ |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
13708
diff
changeset
|
260 |
if (m_isMissionTeam) |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
13708
diff
changeset
|
261 |
{ |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
13708
diff
changeset
|
262 |
sl.push_back(QString("esetmissteam %3 %1 %2").arg(qcolor().rgb() & 0xffffff).arg(m_name).arg(playerHash)); |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
13708
diff
changeset
|
263 |
cmdAddHog = "eaddmisshh"; |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
13708
diff
changeset
|
264 |
} |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
13708
diff
changeset
|
265 |
else |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
13708
diff
changeset
|
266 |
{ |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
13708
diff
changeset
|
267 |
sl.push_back(QString("eaddteam %3 %1 %2").arg(qcolor().rgb() & 0xffffff).arg(m_name).arg(playerHash)); |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
13708
diff
changeset
|
268 |
} |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
13708
diff
changeset
|
269 |
} |
606
9d800fdfd3bd
Add ammostores in frontend, should help further ammostores implemetation
unc0rr
parents:
605
diff
changeset
|
270 |
|
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
|
271 |
sl.push_back(QString("egrave " + 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:
5907
diff
changeset
|
272 |
sl.push_back(QString("efort " + 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:
5907
diff
changeset
|
273 |
sl.push_back(QString("evoicepack " + 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:
5907
diff
changeset
|
274 |
sl.push_back(QString("eflag " + m_flag)); |
341 | 275 |
|
9790 | 276 |
if(!m_owner.isEmpty()) |
9791
446e4919b738
Display team owner in teams widget (addresses issue 174)
unc0rr
parents:
9790
diff
changeset
|
277 |
sl.push_back(QString("eowner ") + m_owner); |
9790 | 278 |
|
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
|
279 |
for (int t = 0; t < m_numHedgehogs; t++) |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
280 |
{ |
14498
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
13708
diff
changeset
|
281 |
sl.push_back(QString(cmdAddHog + " %1 %2 %3") |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
282 |
.arg(QString::number(m_difficulty), |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
283 |
QString::number(InitHealth), |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
284 |
m_hedgehogs[t].Name)); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
285 |
sl.push_back(QString("ehat %1") |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
286 |
.arg(m_hedgehogs[t].Hat)); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
287 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2879
diff
changeset
|
288 |
return sl; |
184 | 289 |
} |
290 |
||
10400
47e2189eae44
This should make frontend aware of your own teams in game on rejoin
unc0rr
parents:
10108
diff
changeset
|
291 |
|
47e2189eae44
This should make frontend aware of your own teams in game on rejoin
unc0rr
parents:
10108
diff
changeset
|
292 |
void HWTeam::setNetTeam(bool isNetTeam) |
47e2189eae44
This should make frontend aware of your own teams in game on rejoin
unc0rr
parents:
10108
diff
changeset
|
293 |
{ |
47e2189eae44
This should make frontend aware of your own teams in game on rejoin
unc0rr
parents:
10108
diff
changeset
|
294 |
m_isNetTeam = isNetTeam; |
47e2189eae44
This should make frontend aware of your own teams in game on rejoin
unc0rr
parents:
10108
diff
changeset
|
295 |
} |
47e2189eae44
This should make frontend aware of your own teams in game on rejoin
unc0rr
parents:
10108
diff
changeset
|
296 |
|
352 | 297 |
bool HWTeam::isNetTeam() const |
298 |
{ |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
299 |
return m_isNetTeam; |
352 | 300 |
} |
301 |
||
14498
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
13708
diff
changeset
|
302 |
void HWTeam::setMissionTeam(bool isMissionTeam) |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
13708
diff
changeset
|
303 |
{ |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
13708
diff
changeset
|
304 |
m_isMissionTeam = isMissionTeam; |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
13708
diff
changeset
|
305 |
} |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
13708
diff
changeset
|
306 |
|
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
13708
diff
changeset
|
307 |
bool HWTeam::isMissionTeam() const |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
13708
diff
changeset
|
308 |
{ |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
13708
diff
changeset
|
309 |
return m_isMissionTeam; |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
13708
diff
changeset
|
310 |
} |
352 | 311 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
312 |
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
|
313 |
{ |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
314 |
return m_name==t1.m_name; |
184 | 315 |
} |
316 |
||
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
317 |
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
|
318 |
{ |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
319 |
return m_name<t1.m_name; // if names are equal - test if it is net team |
184 | 320 |
} |
1840 | 321 |
|
322 |
||
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
|
323 |
//// 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
|
324 |
|
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 |
// name |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
327 |
QString HWTeam::name() const |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
328 |
{ |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
329 |
return m_name; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
330 |
} |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
331 |
void HWTeam::setName(const QString & name) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
332 |
{ |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
333 |
m_name = name; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
334 |
} |
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
|
335 |
|
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
|
336 |
// single hedgehog |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
337 |
const HWHog & HWTeam::hedgehog(unsigned int idx) const |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
338 |
{ |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
339 |
return m_hedgehogs[idx]; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
340 |
} |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
341 |
void HWTeam::setHedgehog(unsigned int idx, HWHog hh) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
342 |
{ |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
343 |
m_hedgehogs[idx] = hh; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
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 |
// owner |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
347 |
QString HWTeam::owner() const |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
348 |
{ |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
349 |
return m_owner; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
350 |
} |
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
|
351 |
|
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
|
352 |
|
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
|
353 |
|
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
|
354 |
// difficulty |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
355 |
unsigned int HWTeam::difficulty() const |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
356 |
{ |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
357 |
return m_difficulty; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
358 |
} |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
359 |
void HWTeam::setDifficulty(unsigned int level) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
360 |
{ |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
361 |
m_difficulty = level; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
362 |
} |
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
|
363 |
|
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
|
364 |
// color |
7130 | 365 |
int HWTeam::color() const |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
366 |
{ |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
367 |
return m_color; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
368 |
} |
7130 | 369 |
|
370 |
QColor HWTeam::qcolor() const |
|
371 |
{ |
|
7258 | 372 |
return DataManager::instance().colorsModel()->item(m_color)->data().value<QColor>(); |
7130 | 373 |
} |
374 |
||
375 |
void HWTeam::setColor(int color) |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
376 |
{ |
7258 | 377 |
m_color = color % DataManager::instance().colorsModel()->rowCount(); |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
378 |
} |
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
|
379 |
|
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
|
380 |
|
6024 | 381 |
// binds |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
382 |
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
|
383 |
{ |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
384 |
return m_binds[idx].strbind; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
385 |
} |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
386 |
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
|
387 |
{ |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
388 |
m_binds[idx].strbind = key; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
389 |
} |
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
|
390 |
|
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
|
391 |
// flag |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
392 |
void HWTeam::setFlag(const QString & flag) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
393 |
{ |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
394 |
m_flag = flag; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
395 |
} |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
396 |
QString HWTeam::flag() const |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
397 |
{ |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
398 |
return m_flag; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
399 |
} |
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
|
400 |
|
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
|
401 |
// fort |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
402 |
void HWTeam::setFort(const QString & fort) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
403 |
{ |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
404 |
m_fort = fort; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
405 |
} |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
406 |
QString HWTeam::fort() const |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
407 |
{ |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
408 |
return m_fort; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
409 |
} |
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
|
410 |
|
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
|
411 |
// grave |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
412 |
void HWTeam::setGrave(const QString & grave) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
413 |
{ |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
414 |
m_grave = grave; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
415 |
} |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
416 |
QString HWTeam::grave() const |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
417 |
{ |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
418 |
return m_grave; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
419 |
} |
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
|
420 |
|
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
|
421 |
// voicepack - getter/setter |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
422 |
void HWTeam::setVoicepack(const QString & voicepack) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
423 |
{ |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
424 |
m_voicepack = voicepack; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
425 |
} |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
426 |
QString HWTeam::voicepack() const |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
427 |
{ |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
428 |
return m_voicepack; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
429 |
} |
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
|
430 |
|
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
|
431 |
// amount of hedgehogs |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
432 |
unsigned char HWTeam::numHedgehogs() const |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
433 |
{ |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
434 |
return m_numHedgehogs; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
435 |
} |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
436 |
void HWTeam::setNumHedgehogs(unsigned char num) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
437 |
{ |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
438 |
m_numHedgehogs = num; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6225
diff
changeset
|
439 |
} |
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
|
440 |