QTfrontend/game.cpp
changeset 141 ac3680be1f4b
parent 140 50ccde437ea1
child 142 1ff0b02fe367
equal deleted inserted replaced
140:50ccde437ea1 141:ac3680be1f4b
    88 {
    88 {
    89 	SendIPC(QString("eseed %1").arg(seed));
    89 	SendIPC(QString("eseed %1").arg(seed));
    90 	SendIPC(QString("etheme %1").arg(config->GetRandomTheme()));
    90 	SendIPC(QString("etheme %1").arg(config->GetRandomTheme()));
    91 	SENDIPC("TL");
    91 	SENDIPC("TL");
    92 	SendIPC(QString("e$gmflags %1").arg(gamecfg->getGameFlags()));
    92 	SendIPC(QString("e$gmflags %1").arg(gamecfg->getGameFlags()));
       
    93 
       
    94 	for (int i = 0; i < TeamCount; i++)
       
    95 	{
       
    96 		SENDIPC("eaddteam");
       
    97 		LocalCFG(teams[i]);
       
    98 		SendIPC(QString("ecolor %1").arg(65535 << i * 8));
       
    99 		for (int t = 0; t < hdNum[teams[i]]; t++)
       
   100 			SendIPC(QString("eadd hh%1 0").arg(t));
       
   101 	}
       
   102 }
       
   103 
       
   104 void HWGame::SendQuickConfig()
       
   105 {
       
   106 	SendIPC(QString("eseed %1").arg(seed));
       
   107 	SendIPC(QString("etheme %1").arg(config->GetRandomTheme()));
       
   108 	SENDIPC("TL");
       
   109 	SendIPC(QString("e$gmflags %1").arg(gamecfg->getGameFlags()));
    93 	SENDIPC("eaddteam");
   110 	SENDIPC("eaddteam");
    94 	LocalCFG(0);
   111 	LocalCFG(0);
    95 	SENDIPC("ecolor 65535");
   112 	SENDIPC("ecolor 65535");
    96 	SENDIPC("eadd hh0 0");
   113 	SENDIPC("eadd hh0 0");
    97 	SENDIPC("eadd hh1 0");
   114 	SENDIPC("eadd hh1 0");
   106 	SENDIPC("eadd hh3 1");
   123 	SENDIPC("eadd hh3 1");
   107 }
   124 }
   108 
   125 
   109 void HWGame::ParseMessage(const QByteArray & msg)
   126 void HWGame::ParseMessage(const QByteArray & msg)
   110 {
   127 {
   111 	switch(msg.data()[1])
   128 	switch(msg.data()[1]) {
   112 	{
   129 		case '?': {
   113 		case '?':
       
   114 		{
       
   115 			if (gameType == gtNet)
   130 			if (gameType == gtNet)
   116 				emit SendNet(QByteArray("\x01""?"));
   131 				emit SendNet(QByteArray("\x01""?"));
   117 			else
   132 			else
   118 				SENDIPC("!");
   133 				SENDIPC("!");
   119 			break;
   134 			break;
   120 		}
   135 		}
   121 		case 'C':
   136 		case 'C': {
   122 		{
   137 			switch (gameType) {
   123 			if (gameType == gtNet)
   138 				case gtLocal:
   124 			{
   139 				case gtQLocal: {
   125 				SENDIPC("TN");
       
   126 				emit SendNet(QByteArray("\x01""C"));
       
   127 			}
       
   128 			else
       
   129 			{
       
   130 				if (gameType == gtLocal)
       
   131 				 	SendConfig();
   140 				 	SendConfig();
       
   141 					break;
       
   142 				}
       
   143 				case gtDemo: break;
       
   144 				case gtNet: {
       
   145 					SENDIPC("TN");
       
   146 					emit SendNet(QByteArray("\x01""C"));
       
   147 					break;
       
   148 				}
   132 			}
   149 			}
   133 			break;
   150 			break;
   134 		}
   151 		}
   135 		case 'E':
   152 		case 'E': {
   136 		{
       
   137 			QMessageBox::critical(0,
   153 			QMessageBox::critical(0,
   138 					"Hedgewars: error message",
   154 					"Hedgewars: error message",
   139 					QString().append(msg.mid(2)).left(msg.size() - 6),
   155 					QString().append(msg.mid(2)).left(msg.size() - 6),
   140 					QMessageBox::Ok,
   156 					QMessageBox::Ok,
   141 					QMessageBox::NoButton,
   157 					QMessageBox::NoButton,
   142 					QMessageBox::NoButton);
   158 					QMessageBox::NoButton);
   143 			return;
   159 			return;
   144 		}
   160 		}
   145 		case '+':
   161 		case '+': {
   146 		{
       
   147 			if (gameType == gtNet)
   162 			if (gameType == gtNet)
   148 			{
   163 			{
   149 				emit SendNet(msg);
   164 				emit SendNet(msg);
   150 			}
   165 			}
   151 			break;
   166 			break;
   152 		}
   167 		}
   153 		default:
   168 		default: {
   154 		{
       
   155 			if (gameType == gtNet)
   169 			if (gameType == gtNet)
   156 			{
   170 			{
   157 				emit SendNet(msg);
   171 				emit SendNet(msg);
   158 			}
   172 			}
   159 			demo->append(msg);
   173 			demo->append(msg);
   319 	Start();
   333 	Start();
   320 }
   334 }
   321 
   335 
   322 void HWGame::StartQuick()
   336 void HWGame::StartQuick()
   323 {
   337 {
   324 	gameType = gtLocal;
   338 	gameType = gtQLocal;
   325 	seed = QUuid::createUuid().toString();
   339 	seed = QUuid::createUuid().toString();
   326 	Start();
   340 	Start();
   327 }
   341 }
   328 
   342 
   329 
   343