55 } |
56 } |
56 |
57 |
57 void HWGame::commonConfig() |
58 void HWGame::commonConfig() |
58 { |
59 { |
59 QByteArray buf; |
60 QByteArray buf; |
|
61 QString gt; |
|
62 switch (gameType) { |
|
63 case gtDemo: |
|
64 gt = "TD"; |
|
65 break; |
|
66 case gtNet: |
|
67 gt = "TN"; |
|
68 break; |
|
69 default: |
|
70 gt = "TL"; |
|
71 } |
|
72 HWProto::addStringToBuffer(buf, gt); |
|
73 qDebug() << "game type" << gt; |
60 HWProto::addStringListToBuffer(buf, gamecfg->getFullConfig()); |
74 HWProto::addStringListToBuffer(buf, gamecfg->getFullConfig()); |
61 HWProto::addStringToBuffer(buf, "TL"); |
75 qDebug() << "config" << gamecfg->getFullConfig(); |
|
76 |
|
77 if (m_pTeamSelWidget) |
|
78 { |
|
79 qDebug() << "adding teams from teamselwidget..."; |
|
80 QList<HWTeam> teams = QList<HWTeam>::fromStdList(m_pTeamSelWidget->getPlayingTeams()); |
|
81 for(QList<HWTeam>::iterator it = teams.begin(); it != teams.end(); ++it) |
|
82 { |
|
83 qDebug() << "a team..."; |
|
84 (*it).numHedgehogs = 4; |
|
85 HWProto::addStringListToBuffer(buf, |
|
86 (*it).TeamGameConfig(gamecfg->getInitHealth())); |
|
87 } |
|
88 } |
62 RawSendIPC(buf); |
89 RawSendIPC(buf); |
63 } |
90 } |
64 |
91 |
65 void HWGame::SendConfig() |
92 void HWGame::SendConfig() |
66 { |
93 { |
67 commonConfig(); |
94 commonConfig(); |
68 |
|
69 for (int i = 0; i < TeamCount; i++) |
|
70 { |
|
71 HWTeam team(teams[i]); |
|
72 team.LoadFromFile(); |
|
73 |
|
74 QColor clr = m_teamsParams[teams[i]].teamColor; |
|
75 QByteArray buf; |
|
76 QStringList sl = team.TeamGameConfig(clr.rgb()&0xFFFFFF, |
|
77 m_teamsParams[teams[i]].numHedgehogs, |
|
78 gamecfg->getInitHealth()); |
|
79 HWProto::addStringListToBuffer(buf, sl); |
|
80 RawSendIPC(buf); |
|
81 } |
|
82 } |
95 } |
83 |
96 |
84 void HWGame::SendQuickConfig() |
97 void HWGame::SendQuickConfig() |
85 { |
98 { |
86 commonConfig(); |
99 commonConfig(); |
87 |
100 |
88 QByteArray teamscfg; |
101 QByteArray teamscfg; |
89 HWTeam team1(0); |
102 HWTeam team1(0); |
90 team1.difficulty = 0; |
103 team1.difficulty = 0; |
|
104 team1.teamColor = QColor(65535); |
|
105 team1.numHedgehogs = 4; |
91 HWProto::addStringListToBuffer(teamscfg, |
106 HWProto::addStringListToBuffer(teamscfg, |
92 team1.TeamGameConfig(65535, 4, gamecfg->getInitHealth())); |
107 team1.TeamGameConfig(gamecfg->getInitHealth())); |
93 |
108 |
94 HWTeam team2(2); |
109 HWTeam team2(2); |
95 team2.difficulty = 4; |
110 team2.difficulty = 4; |
|
111 team2.teamColor = QColor(16776960); |
|
112 team2.numHedgehogs = 4; |
96 RawSendIPC(HWProto::addStringListToBuffer(teamscfg, |
113 RawSendIPC(HWProto::addStringListToBuffer(teamscfg, |
97 team2.TeamGameConfig(16776960, 4, gamecfg->getInitHealth()))); |
114 team2.TeamGameConfig(gamecfg->getInitHealth()))); |
|
115 } |
|
116 |
|
117 void HWGame::SendNetConfig() |
|
118 { |
|
119 commonConfig(); |
98 } |
120 } |
99 |
121 |
100 void HWGame::ParseMessage(const QByteArray & msg) |
122 void HWGame::ParseMessage(const QByteArray & msg) |
101 { |
123 { |
102 switch(msg.at(1)) { |
124 switch(msg.at(1)) { |
210 arguments << datadir->absolutePath(); |
233 arguments << datadir->absolutePath(); |
211 arguments << (config->isShowFPSEnabled() ? "1" : "0"); |
234 arguments << (config->isShowFPSEnabled() ? "1" : "0"); |
212 return arguments; |
235 return arguments; |
213 } |
236 } |
214 |
237 |
215 void HWGame::AddTeam(const QString & teamname, HWTeamTempParams teamParams) |
238 void HWGame::AddTeam(const QString & teamname) |
216 { |
239 { |
217 if (TeamCount == 5) return; |
240 if (TeamCount == 5) return; |
218 teams[TeamCount] = teamname; |
241 teams[TeamCount] = teamname; |
219 TeamCount++; |
242 TeamCount++; |
220 m_teamsParams[teamname]=teamParams; |
|
221 } |
243 } |
222 |
244 |
223 void HWGame::SaveDemo(const QString & filename) |
245 void HWGame::SaveDemo(const QString & filename) |
224 { |
246 { |
225 demo->replace(QByteArray("\x02TL"), QByteArray("\x02TD")); |
247 demo->replace(QByteArray("\x02TL"), QByteArray("\x02TD")); |
300 } |
321 } |
301 |
322 |
302 |
323 |
303 void HWGame::LocalCFG(const QString & teamname) |
324 void HWGame::LocalCFG(const QString & teamname) |
304 { |
325 { |
305 QByteArray teamcfg; |
326 qDebug("HWGame::LocalCFG is UNIMPLEMENTED"); |
|
327 /* QByteArray teamcfg; |
306 HWTeam team(teamname); |
328 HWTeam team(teamname); |
307 team.LoadFromFile(); |
329 team.LoadFromFile(); |
308 RawSendIPC(HWProto::addStringListToBuffer(teamcfg, |
330 RawSendIPC(HWProto::addStringListToBuffer(teamcfg, |
309 team.TeamGameConfig(16776960, 4, gamecfg->getInitHealth()))); |
331 team.TeamGameConfig(16776960, 4, gamecfg->getInitHealth()))); |
310 } |
332 */ |
311 |
333 } |
|
334 |