QTfrontend/game.cpp
changeset 21 dff476dcaaa3
parent 20 ccd2c45f043d
child 25 27aa8030322b
equal deleted inserted replaced
20:ccd2c45f043d 21:dff476dcaaa3
    52 				.arg(IPCServer->errorString()));
    52 				.arg(IPCServer->errorString()));
    53 	}
    53 	}
    54 	connect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection()));
    54 	connect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection()));
    55 	IPCSocket = 0;
    55 	IPCSocket = 0;
    56 	TeamCount = 0;
    56 	TeamCount = 0;
       
    57 	seed = "seed";
    57 }
    58 }
    58 
    59 
    59 void HWGame::NewConnection()
    60 void HWGame::NewConnection()
    60 {
    61 {
    61 	QTcpSocket * client = IPCServer->nextPendingConnection();
    62 	QTcpSocket * client = IPCServer->nextPendingConnection();
   160 		{
   161 		{
   161 			msgbufsize = 0;
   162 			msgbufsize = 0;
   162 			readbytes = IPCSocket->read((char *)&msgsize, 1);
   163 			readbytes = IPCSocket->read((char *)&msgsize, 1);
   163 		} else
   164 		} else
   164 		{
   165 		{
   165 			msgbufsize += readbytes = IPCSocket->read((char *)&msgbuf[msgbufsize], msgsize - msgbufsize);
   166 			msgbufsize += 
       
   167 			readbytes = IPCSocket->read((char *)&msgbuf[msgbufsize], msgsize - msgbufsize);
   166 			if (msgbufsize = msgsize)
   168 			if (msgbufsize = msgsize)
   167 			{
   169 			{
   168 				ParseMessage();
   170 				ParseMessage();
   169 				msgsize = 0;
   171 				msgsize = 0;
   170 			}
   172 			}
   171 		}
   173 		}
   172 	}
   174 	}
   173 }
   175 }
   174 
   176 
   175 void HWGame::Start(int Resolution)
   177 void HWGame::Start(int Resolution, bool Fullscreen)
   176 {
   178 {
   177 	if (TeamCount < 2) return;
   179 	if (TeamCount < 2) return;
   178 	QProcess * process;
   180 	QProcess * process;
   179 	QStringList arguments;
   181 	QStringList arguments;
       
   182 	seedgen.GenRNDStr(seed, 10);
   180 	process = new QProcess;
   183 	process = new QProcess;
   181 	arguments << resolutions[0][Resolution];
   184 	arguments << resolutions[0][Resolution];
   182 	arguments << resolutions[1][Resolution];
   185 	arguments << resolutions[1][Resolution];
   183 	arguments << "avematan";
   186 	arguments << "avematan";
   184 	arguments << "46631";
   187 	arguments << "46631";
   185 	arguments << "=seed=";
   188 	arguments << seed;
   186 	arguments << "1";
   189 	arguments << (Fullscreen ? "1" : "0");
   187 	process->start("hw", arguments);
   190 	process->start("hw", arguments);
   188 }
   191 }
   189 
   192 
   190 void HWGame::AddTeam(const QString teamname)
   193 void HWGame::AddTeam(const QString & teamname)
   191 {
   194 {
   192 	if (TeamCount == 5) return;
   195 	if (TeamCount == 5) return;
   193 	teams[TeamCount] = teamname;
   196 	teams[TeamCount] = teamname;
   194 	TeamCount++;
   197 	TeamCount++;
   195 }
   198 }