127 } |
127 } |
128 } |
128 } |
129 |
129 |
130 void HWNewNet::OnConnect() |
130 void HWNewNet::OnConnect() |
131 { |
131 { |
132 RawSendNet(QString("NICK%1%2").arg(delimeter).arg(mynick)); |
132 RawSendNet(QString("NICK%1%2").arg(delimeter).arg(mynick)); |
133 RawSendNet(QString("PROTO%1%2").arg(delimeter).arg(*cProtoVer)); |
133 RawSendNet(QString("PROTO%1%2").arg(delimeter).arg(*cProtoVer)); |
134 RawSendNet(QString("CREATE%1%2").arg(delimeter).arg("myroom")); |
134 RawSendNet(QString("CREATE%1%2").arg(delimeter).arg("myroom")); |
135 RawSendNet(QString("JOIN%1%2").arg(delimeter).arg("myroom")); |
135 RawSendNet(QString("JOIN%1%2").arg(delimeter).arg("myroom")); |
136 } |
136 } |
137 |
137 |
138 void HWNewNet::OnDisconnect() |
138 void HWNewNet::OnDisconnect() |
139 { |
139 { |
140 //emit ChangeInTeams(QStringList()); |
140 //emit ChangeInTeams(QStringList()); |
246 for(int i = 1; i < lst.size(); ++i) |
246 for(int i = 1; i < lst.size(); ++i) |
247 emit nickAdded(lst[i]); |
247 emit nickAdded(lst[i]); |
248 return; |
248 return; |
249 } |
249 } |
250 |
250 |
251 if(lst[0]=="LEFT") { |
251 if(lst[0]=="LEFT") { |
252 if(lst.size() < 2) |
252 if(lst.size() < 2) |
253 { |
253 { |
254 qWarning("Net: Bad LEFT message"); |
254 qWarning("Net: Bad LEFT message"); |
255 return; |
255 return; |
256 } |
256 } |
257 emit nickRemoved(lst[1]); |
257 emit nickRemoved(lst[1]); |
258 return; |
258 return; |
259 } |
259 } |
260 |
260 |
261 if (lst[0] == "CONFIGASKED") { |
261 if (lst[0] == "CONFIGASKED") { // клиент знает CREATE он делал или JOIN |
262 isChief=true; |
262 isChief=true; |
263 ConfigAsked(); |
263 ConfigAsked(); |
264 return; |
264 return; |
265 } |
265 } |
266 |
266 |
267 if (lst[0] == "RUNGAME") { |
267 if (lst[0] == "RUNGAME") { |
268 RunGame(); |
268 RunGame(); |
269 return; |
269 return; |
270 } |
270 } |
356 } |
356 } |
357 |
357 |
358 |
358 |
359 // should be kinda game states, which don't allow "GAMEMSG:" at configure step, |
359 // should be kinda game states, which don't allow "GAMEMSG:" at configure step, |
360 // "CONNECTED" at round phase, etc. |
360 // "CONNECTED" at round phase, etc. |
361 if (lst[0] == "GAMEMSG:") { |
361 if (lst[0] == "GAMEMSG") { |
362 if(lst.size() < 2) |
362 if(lst.size() < 2) |
363 { |
363 { |
364 qWarning("Net: Bad LEFT message"); |
364 qWarning("Net: Bad GAMEMSG message"); |
365 return; |
365 return; |
366 } |
366 } |
367 QByteArray em = QByteArray::fromBase64(lst[1].toAscii()); |
367 QByteArray em = QByteArray::fromBase64(lst[1].toAscii()); |
368 emit FromNet(em); |
368 emit FromNet(em); |
369 return; |
369 return; |
373 } |
373 } |
374 |
374 |
375 |
375 |
376 void HWNewNet::ConfigAsked() |
376 void HWNewNet::ConfigAsked() |
377 { |
377 { |
378 QString map = m_pGameCFGWidget->getCurrentMap(); |
378 QString map = m_pGameCFGWidget->getCurrentMap(); |
379 if (map.size()) |
379 if (map.size()) |
380 onMapChanged(map); |
380 onMapChanged(map); |
381 |
381 |
382 onSeedChanged(m_pGameCFGWidget->getCurrentSeed()); |
382 onSeedChanged(m_pGameCFGWidget->getCurrentSeed()); |
383 onThemeChanged(m_pGameCFGWidget->getCurrentTheme()); |
383 onThemeChanged(m_pGameCFGWidget->getCurrentTheme()); |
384 onInitHealthChanged(m_pGameCFGWidget->getInitHealth()); |
384 onInitHealthChanged(m_pGameCFGWidget->getInitHealth()); |
385 onTurnTimeChanged(m_pGameCFGWidget->getTurnTime()); |
385 onTurnTimeChanged(m_pGameCFGWidget->getTurnTime()); |
386 onFortsModeChanged(m_pGameCFGWidget->getGameFlags() & 0x1); |
386 onFortsModeChanged(m_pGameCFGWidget->getGameFlags() & 0x1); |
387 // always initialize with default ammo (also avoiding complicated cross-class dependencies) |
387 // always initialize with default ammo (also avoiding complicated cross-class dependencies) |
388 onWeaponsNameChanged("Default", cDefaultAmmoStore->mid(10)); |
388 onWeaponsNameChanged("Default", cDefaultAmmoStore->mid(10)); |
389 } |
389 } |
390 |
390 |
391 void HWNewNet::RunGame() |
391 void HWNewNet::RunGame() |
392 { |
392 { |
393 emit AskForRunGame(); |
393 emit AskForRunGame(); |
394 } |
394 } |
395 |
395 |
396 void HWNewNet::onHedgehogsNumChanged(const HWTeam& team) |
396 void HWNewNet::onHedgehogsNumChanged(const HWTeam& team) |
397 { |
397 { |
398 RawSendNet(QString("HHNUM%1%2%1%3%1%4").arg(delimeter).arg(team.TeamName)\ |
398 RawSendNet(QString("HHNUM%1%2%1%3%1%4").arg(delimeter).arg(team.TeamName)\ |