QTfrontend/game.cpp
changeset 306 7b61834edcf6
parent 297 279e10ec31b4
child 312 c36d0b34ac3d
equal deleted inserted replaced
305:1c1cd66ffcdc 306:7b61834edcf6
    42 }
    42 }
    43 
    43 
    44 void HWGame::onClientDisconnect()
    44 void HWGame::onClientDisconnect()
    45 {
    45 {
    46 	SaveDemo(cfgdir->absolutePath() + "/Demos/LastRound.hwd_" + cProtoVer);
    46 	SaveDemo(cfgdir->absolutePath() + "/Demos/LastRound.hwd_" + cProtoVer);
       
    47 	emit GameStateChanged(gsFinished);
    47 }
    48 }
    48 
    49 
    49 void HWGame::SendTeamConfig(int index)
    50 void HWGame::SendTeamConfig(int index)
    50 {
    51 {
    51 	LocalCFG(teams[index]);
    52 	LocalCFG(teams[index]);
    97 	RawSendIPC(HWProto::addStringListToBuffer(teamscfg, team2.TeamGameConfig(16776960, 4)));
    98 	RawSendIPC(HWProto::addStringListToBuffer(teamscfg, team2.TeamGameConfig(16776960, 4)));
    98 }
    99 }
    99 
   100 
   100 void HWGame::ParseMessage(const QByteArray & msg)
   101 void HWGame::ParseMessage(const QByteArray & msg)
   101 {
   102 {
   102 	switch(msg.data()[1]) {
   103 	switch(msg.at(1)) {
   103 		case '?': {
   104 		case '?': {
   104 			if (gameType == gtNet)
   105 			if (gameType == gtNet)
   105 				emit SendNet(QByteArray("\x01""?"));
   106 				emit SendNet(QByteArray("\x01""?"));
   106 			else
   107 			else
   107 				SendIPC("!");
   108 				SendIPC("!");
   153 			{
   154 			{
   154 				emit SendNet(msg);
   155 				emit SendNet(msg);
   155 			}
   156 			}
   156 			break;
   157 			break;
   157 		}
   158 		}
       
   159 		case 'i': {
       
   160 			emit GameStats(msg.at(2), QString::fromUtf8(msg.mid(3)));
       
   161 			break;
       
   162 		}
   158 		default: {
   163 		default: {
   159 			if (gameType == gtNet)
   164 			if (gameType == gtNet)
   160 			{
   165 			{
   161 				emit SendNet(msg);
   166 				emit SendNet(msg);
   162 			}
   167 			}
   255 	demofile.close();
   260 	demofile.close();
   256 
   261 
   257 	// run engine
   262 	// run engine
   258 	demo = new QByteArray;
   263 	demo = new QByteArray;
   259 	Start();
   264 	Start();
       
   265 	emit GameStateChanged(gsStarted);
   260 }
   266 }
   261 
   267 
   262 void HWGame::StartNet()
   268 void HWGame::StartNet()
   263 {
   269 {
   264 	gameType = gtNet;
   270 	gameType = gtNet;
   265 	demo = new QByteArray;
   271 	demo = new QByteArray;
   266 	Start();
   272 	Start();
       
   273 	emit GameStateChanged(gsStarted);
   267 }
   274 }
   268 
   275 
   269 void HWGame::StartLocal()
   276 void HWGame::StartLocal()
   270 {
   277 {
   271 	gameType = gtLocal;
   278 	gameType = gtLocal;
   272 	if (TeamCount < 2) return;
   279 	if (TeamCount < 2) return;
   273 	seed = gamecfg->getCurrentSeed();
   280 	seed = gamecfg->getCurrentSeed();
   274 	demo = new QByteArray;
   281 	demo = new QByteArray;
   275 	Start();
   282 	Start();
       
   283 	emit GameStateChanged(gsStarted);
   276 }
   284 }
   277 
   285 
   278 void HWGame::StartQuick()
   286 void HWGame::StartQuick()
   279 {
   287 {
   280 	gameType = gtQLocal;
   288 	gameType = gtQLocal;
   281 	seed = gamecfg->getCurrentSeed();
   289 	seed = gamecfg->getCurrentSeed();
   282 	demo = new QByteArray;
   290 	demo = new QByteArray;
   283 	Start();
   291 	Start();
       
   292 	emit GameStateChanged(gsStarted);
   284 }
   293 }
   285 
   294 
   286 
   295 
   287 void HWGame::LocalCFG(const QString & teamname)
   296 void HWGame::LocalCFG(const QString & teamname)
   288 {
   297 {