87 emit HaveRecord(rtNeither, demo); |
87 emit HaveRecord(rtNeither, demo); |
88 } |
88 } |
89 SetGameState(gsStopped); |
89 SetGameState(gsStopped); |
90 } |
90 } |
91 |
91 |
92 void HWGame::addKeyBindings(QByteArray * buf) |
|
93 { |
|
94 for(int i = 0; i < BINDS_NUMBER; i++) |
|
95 { |
|
96 QString value = config->value(QString("Binds/%1").arg(cbinds[i].action), cbinds[i].strbind).toString(); |
|
97 if (value.isEmpty() || value == "default") continue; |
|
98 |
|
99 QString bind = QString("edbind " + value + " " + cbinds[i].action); |
|
100 HWProto::addStringToBuffer(*buf, bind); |
|
101 } |
|
102 } |
|
103 |
|
104 void HWGame::commonConfig() |
92 void HWGame::commonConfig() |
105 { |
93 { |
106 QByteArray buf; |
94 QByteArray buf; |
107 QString gt; |
95 QString gt; |
108 switch (gameType) |
96 switch (gameType) |
130 HWProto::addStringToBuffer(buf, QString("eammprob %1").arg(ammostr.mid(cAmmoNumber, cAmmoNumber))); |
116 HWProto::addStringToBuffer(buf, QString("eammprob %1").arg(ammostr.mid(cAmmoNumber, cAmmoNumber))); |
131 HWProto::addStringToBuffer(buf, QString("eammdelay %1").arg(ammostr.mid(2 * cAmmoNumber, cAmmoNumber))); |
117 HWProto::addStringToBuffer(buf, QString("eammdelay %1").arg(ammostr.mid(2 * cAmmoNumber, cAmmoNumber))); |
132 HWProto::addStringToBuffer(buf, QString("eammreinf %1").arg(ammostr.mid(3 * cAmmoNumber, cAmmoNumber))); |
118 HWProto::addStringToBuffer(buf, QString("eammreinf %1").arg(ammostr.mid(3 * cAmmoNumber, cAmmoNumber))); |
133 if(gamecfg->schemeData(15).toBool() || !gamecfg->schemeData(21).toBool()) HWProto::addStringToBuffer(buf, QString("eammstore")); |
119 if(gamecfg->schemeData(15).toBool() || !gamecfg->schemeData(21).toBool()) HWProto::addStringToBuffer(buf, QString("eammstore")); |
134 HWProto::addStringListToBuffer(buf, |
120 HWProto::addStringListToBuffer(buf, |
135 team.teamGameConfig(gamecfg->getInitHealth(), config)); |
121 team.teamGameConfig(gamecfg->getInitHealth())); |
136 ; |
122 ; |
137 } |
123 } |
138 } |
124 } |
139 |
125 |
140 RawSendIPC(buf); |
126 RawSendIPC(buf); |
147 |
133 |
148 void HWGame::SendQuickConfig() |
134 void HWGame::SendQuickConfig() |
149 { |
135 { |
150 QByteArray teamscfg; |
136 QByteArray teamscfg; |
151 ThemeModel * themeModel = DataManager::instance().themeModel(); |
137 ThemeModel * themeModel = DataManager::instance().themeModel(); |
152 |
|
153 addKeyBindings(&teamscfg); |
|
154 |
138 |
155 HWProto::addStringToBuffer(teamscfg, "TL"); |
139 HWProto::addStringToBuffer(teamscfg, "TL"); |
156 HWProto::addStringToBuffer(teamscfg, QString("etheme %1") |
140 HWProto::addStringToBuffer(teamscfg, QString("etheme %1") |
157 .arg((themeModel->rowCount() > 0) ? themeModel->index(rand() % themeModel->rowCount()).data(ThemeModel::ActualNameRole).toString() : "steel")); |
141 .arg((themeModel->rowCount() > 0) ? themeModel->index(rand() % themeModel->rowCount()).data(ThemeModel::ActualNameRole).toString() : "steel")); |
158 HWProto::addStringToBuffer(teamscfg, "eseed " + QUuid::createUuid().toString()); |
142 HWProto::addStringToBuffer(teamscfg, "eseed " + QUuid::createUuid().toString()); |
163 team1.setDifficulty(0); |
147 team1.setDifficulty(0); |
164 team1.setColor(0); |
148 team1.setColor(0); |
165 team1.setNumHedgehogs(4); |
149 team1.setNumHedgehogs(4); |
166 HWNamegen::teamRandomNames(team1,true); |
150 HWNamegen::teamRandomNames(team1,true); |
167 HWProto::addStringListToBuffer(teamscfg, |
151 HWProto::addStringListToBuffer(teamscfg, |
168 team1.teamGameConfig(100, config)); |
152 team1.teamGameConfig(100)); |
169 |
153 |
170 HWTeam team2; |
154 HWTeam team2; |
171 team2.setDifficulty(4); |
155 team2.setDifficulty(4); |
172 team2.setColor(1); |
156 team2.setColor(1); |
173 team2.setNumHedgehogs(4); |
157 team2.setNumHedgehogs(4); |
174 do |
158 do |
175 HWNamegen::teamRandomNames(team2,true); |
159 HWNamegen::teamRandomNames(team2,true); |
176 while(!team2.name().compare(team1.name()) || !team2.hedgehog(0).Hat.compare(team1.hedgehog(0).Hat)); |
160 while(!team2.name().compare(team1.name()) || !team2.hedgehog(0).Hat.compare(team1.hedgehog(0).Hat)); |
177 HWProto::addStringListToBuffer(teamscfg, |
161 HWProto::addStringListToBuffer(teamscfg, |
178 team2.teamGameConfig(100, config)); |
162 team2.teamGameConfig(100)); |
179 |
163 |
180 HWProto::addStringToBuffer(teamscfg, QString("eammloadt %1").arg(cDefaultAmmoStore->mid(0, cAmmoNumber))); |
164 HWProto::addStringToBuffer(teamscfg, QString("eammloadt %1").arg(cDefaultAmmoStore->mid(0, cAmmoNumber))); |
181 HWProto::addStringToBuffer(teamscfg, QString("eammprob %1").arg(cDefaultAmmoStore->mid(cAmmoNumber, cAmmoNumber))); |
165 HWProto::addStringToBuffer(teamscfg, QString("eammprob %1").arg(cDefaultAmmoStore->mid(cAmmoNumber, cAmmoNumber))); |
182 HWProto::addStringToBuffer(teamscfg, QString("eammdelay %1").arg(cDefaultAmmoStore->mid(2 * cAmmoNumber, cAmmoNumber))); |
166 HWProto::addStringToBuffer(teamscfg, QString("eammdelay %1").arg(cDefaultAmmoStore->mid(2 * cAmmoNumber, cAmmoNumber))); |
183 HWProto::addStringToBuffer(teamscfg, QString("eammreinf %1").arg(cDefaultAmmoStore->mid(3 * cAmmoNumber, cAmmoNumber))); |
167 HWProto::addStringToBuffer(teamscfg, QString("eammreinf %1").arg(cDefaultAmmoStore->mid(3 * cAmmoNumber, cAmmoNumber))); |
192 QByteArray traincfg; |
176 QByteArray traincfg; |
193 HWProto::addStringToBuffer(traincfg, "TL"); |
177 HWProto::addStringToBuffer(traincfg, "TL"); |
194 HWProto::addStringToBuffer(traincfg, "eseed " + QUuid::createUuid().toString()); |
178 HWProto::addStringToBuffer(traincfg, "eseed " + QUuid::createUuid().toString()); |
195 HWProto::addStringToBuffer(traincfg, "escript " + training); |
179 HWProto::addStringToBuffer(traincfg, "escript " + training); |
196 |
180 |
197 addKeyBindings(&traincfg); |
|
198 |
|
199 RawSendIPC(traincfg); |
181 RawSendIPC(traincfg); |
200 } |
182 } |
201 |
183 |
202 void HWGame::SendCampaignConfig() |
184 void HWGame::SendCampaignConfig() |
203 { |
185 { |
204 QByteArray campaigncfg; |
186 QByteArray campaigncfg; |
205 HWProto::addStringToBuffer(campaigncfg, "TL"); |
187 HWProto::addStringToBuffer(campaigncfg, "TL"); |
206 HWProto::addStringToBuffer(campaigncfg, "eseed " + QUuid::createUuid().toString()); |
188 HWProto::addStringToBuffer(campaigncfg, "eseed " + QUuid::createUuid().toString()); |
207 |
189 |
208 HWProto::addStringToBuffer(campaigncfg, "escript " + campaignScript); |
190 HWProto::addStringToBuffer(campaigncfg, "escript " + campaignScript); |
209 |
|
210 addKeyBindings(&campaigncfg); |
|
211 |
191 |
212 RawSendIPC(campaigncfg); |
192 RawSendIPC(campaigncfg); |
213 } |
193 } |
214 |
194 |
215 void HWGame::SendNetConfig() |
195 void HWGame::SendNetConfig() |