350 { |
351 { |
351 configasks++; |
352 configasks++; |
352 if (configasks == playerscnt) |
353 if (configasks == playerscnt) |
353 { |
354 { |
354 quint32 color = 65535; |
355 quint32 color = 65535; |
355 for (int i = 0; i < teamsCount; i++) |
|
356 { |
|
357 QString msg; |
|
358 msg = MAGIC_CHAR "T" MAGIC_CHAR + teams[i].nick + MAGIC_CHAR + teams[i].hhs.join(MAGIC_CHAR); |
|
359 RawSendNet(QString("PRIVMSG %1 :%2").arg(channel, msg)); |
|
360 hwp_chanmsg(mynick, msg); |
|
361 QByteArray cache; |
|
362 #define ADD(a) { \ |
356 #define ADD(a) { \ |
363 QByteArray strmsg; \ |
357 QByteArray strmsg; \ |
364 strmsg.append(a); \ |
358 strmsg.append(a); \ |
365 quint8 sz = strmsg.size(); \ |
359 quint8 sz = strmsg.size(); \ |
366 cache.append(QByteArray((char *)&sz, 1)); \ |
360 cache.append(QByteArray((char *)&sz, 1)); \ |
367 cache.append(strmsg); \ |
361 cache.append(strmsg); \ |
368 } |
362 } |
|
363 { |
|
364 QByteArray cache; |
|
365 ADD("eseed " + seed); |
|
366 ADD("e$gmflags 0"); |
|
367 ADD("etheme steel"); |
|
368 QString _msg = MAGIC_CHAR MAGIC_CHAR + QString(cache.toBase64()); |
|
369 RawSendNet(QString("PRIVMSG %1 :%2").arg(channel, _msg)); |
|
370 hwp_chanmsg(mynick, _msg); |
|
371 } |
|
372 for (int i = 0; i < teamsCount; i++) |
|
373 { |
|
374 QString msg; |
|
375 msg = MAGIC_CHAR "T" MAGIC_CHAR + teams[i].nick + MAGIC_CHAR + teams[i].hhs.join(MAGIC_CHAR); |
|
376 RawSendNet(QString("PRIVMSG %1 :%2").arg(channel, msg)); |
|
377 hwp_chanmsg(mynick, msg); |
|
378 QByteArray cache; |
369 ADD(QString("ecolor %1").arg(color)); |
379 ADD(QString("ecolor %1").arg(color)); |
370 ADD("eadd hh0 0"); |
380 ADD("eadd hh0 0"); |
371 ADD("eadd hh1 0"); |
381 ADD("eadd hh1 0"); |
372 ADD("eadd hh2 0"); |
382 ADD("eadd hh2 0"); |
373 ADD("eadd hh3 0"); |
383 ADD("eadd hh3 0"); |
374 ADD("eadd hh4 0"); |
384 ADD("eadd hh4 0"); |
375 #undef ADD |
385 #undef ADD |
376 QString _msg = MAGIC_CHAR MAGIC_CHAR + QString(cache.toBase64()); |
386 QString _msg = MAGIC_CHAR MAGIC_CHAR + QString(cache.toBase64()); |
|
387 RawSendNet(QString("PRIVMSG %1 :%2").arg(channel, _msg)); |
377 hwp_chanmsg(mynick, _msg); |
388 hwp_chanmsg(mynick, _msg); |
378 RawSendNet(QString("PRIVMSG %1 :").arg(channel) + _msg); |
|
379 color <<= 8; |
389 color <<= 8; |
380 } |
390 } |
381 SENDCFGSTRNET("!"); |
391 SENDCFGSTRNET("!"); |
382 } |
392 } |
383 } |
393 } |
481 } |
491 } |
482 } |
492 } |
483 playerscnt = players.size(); |
493 playerscnt = players.size(); |
484 configasks = 0; |
494 configasks = 0; |
485 |
495 |
486 QString seed; |
|
487 seedgen.GenRNDStr(seed, 10); |
496 seedgen.GenRNDStr(seed, 10); |
488 QString msg = QString(MAGIC_CHAR"Start!"MAGIC_CHAR"%1").arg(seed); |
497 QString msg = QString(MAGIC_CHAR"Start!"); |
489 RawSendNet(QString("PRIVMSG %1 :%2").arg(channel, msg)); |
498 RawSendNet(QString("PRIVMSG %1 :%2").arg(channel, msg)); |
490 hwp_chanmsg(mynick, msg); |
499 hwp_chanmsg(mynick, msg); |
491 } |
500 } |
492 |
501 |
493 void HWNet::RunGame(const QString & seed) |
502 void HWNet::RunGame() |
494 { |
503 { |
495 HWGame * game = new HWGame(config, 0); |
504 HWGame * game = new HWGame(config, 0); |
496 connect(game, SIGNAL(SendNet(const QByteArray &)), this, SLOT(SendNet(const QByteArray &))); |
505 connect(game, SIGNAL(SendNet(const QByteArray &)), this, SLOT(SendNet(const QByteArray &))); |
497 connect(this, SIGNAL(FromNet(const QByteArray &)), game, SLOT(FromNet(const QByteArray &))); |
506 connect(this, SIGNAL(FromNet(const QByteArray &)), game, SLOT(FromNet(const QByteArray &))); |
498 connect(this, SIGNAL(LocalCFG(const QString &)), game, SLOT(LocalCFG(const QString &))); |
507 connect(this, SIGNAL(LocalCFG(const QString &)), game, SLOT(LocalCFG(const QString &))); |
499 game->StartNet(seed); |
508 game->StartNet(); |
500 } |
509 } |