QTfrontend/game.cpp
changeset 28 59f7db859b8a
parent 26 e32fa14529f8
child 31 99888245a4e8
equal deleted inserted replaced
27:c374fe590272 28:59f7db859b8a
    47 	vid_Fullscreen = Fullscreen;
    47 	vid_Fullscreen = Fullscreen;
    48 	IPCServer = new QTcpServer(this);
    48 	IPCServer = new QTcpServer(this);
    49 	IPCServer->setMaxPendingConnections(1);
    49 	IPCServer->setMaxPendingConnections(1);
    50 	if (!IPCServer->listen(QHostAddress("127.0.0.1"), IPC_PORT))
    50 	if (!IPCServer->listen(QHostAddress("127.0.0.1"), IPC_PORT))
    51 	{
    51 	{
    52 		QMessageBox::critical(this, tr("Error"),
    52 		QMessageBox::critical(0, tr("Error"),
    53 				tr("Unable to start the server: %1.")
    53 				tr("Unable to start the server: %1.")
    54 				.arg(IPCServer->errorString()));
    54 				.arg(IPCServer->errorString()));
    55 	}
    55 	}
    56 	connect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection()));
    56 	connect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection()));
    57 	IPCSocket = 0;
    57 	IPCSocket = 0;
   119 	SENDIPC("ecolor 65535");
   119 	SENDIPC("ecolor 65535");
   120 	SENDIPC("eadd hh0 0");
   120 	SENDIPC("eadd hh0 0");
   121 	SENDIPC("eadd hh1 0");
   121 	SENDIPC("eadd hh1 0");
   122 	SENDIPC("eadd hh2 0");
   122 	SENDIPC("eadd hh2 0");
   123 	SENDIPC("eadd hh3 0");
   123 	SENDIPC("eadd hh3 0");
       
   124 	SENDIPC("eadd hh4 0");
   124 	SENDIPC("eaddteam");
   125 	SENDIPC("eaddteam");
   125 	SendTeamConfig(1);
   126 	SendTeamConfig(1);
   126 	SENDIPC("ecolor 16776960");
   127 	SENDIPC("ecolor 16776960");
   127 	SENDIPC("eadd hh0 1");
   128 	SENDIPC("eadd hh0 1");
   128 	SENDIPC("eadd hh1 1");
   129 	SENDIPC("eadd hh1 1");
   129 	SENDIPC("eadd hh2 1");
   130 	SENDIPC("eadd hh2 1");
   130 	SENDIPC("eadd hh3 1");
   131 	SENDIPC("eadd hh3 1");
       
   132 	SENDIPC("eadd hh4 1");
   131 }
   133 }
   132 
   134 
   133 void HWGame::ParseMessage()
   135 void HWGame::ParseMessage()
   134 {
   136 {
   135 	switch(msgbuf[0])
   137 	switch(msgbuf[0])
   167 	}
   169 	}
   168 }
   170 }
   169 
   171 
   170 void HWGame::SendIPC(const QByteArray & buf)
   172 void HWGame::SendIPC(const QByteArray & buf)
   171 {
   173 {
   172 	if (buf.size() > 255) return;
   174 	if (buf.size() > MAXMSGCHARS) return;
   173 	quint8 len = buf.size();
   175 	quint8 len = buf.size();
   174 	IPCSocket->write((char *)&len, 1);
   176 	IPCSocket->write((char *)&len, 1);
   175 	IPCSocket->write(buf);
   177 	IPCSocket->write(buf);
   176 	demo->append(len);
   178 	demo->append(len);
   177 	demo->append(buf);
   179 	demo->append(buf);
   247 		themesfile.close();
   249 		themesfile.close();
   248 	}
   250 	}
   249 	quint32 len = themes.size();
   251 	quint32 len = themes.size();
   250 	if (len == 0)
   252 	if (len == 0)
   251 	{
   253 	{
   252 		QMessageBox::critical(this, "Error", "Cannot access themes.cfg or bad data", "OK");
   254 		QMessageBox::critical(0, "Error", "Cannot access themes.cfg or bad data", "OK");
   253 		return "avematan";
   255 		return "avematan";
   254 	}
   256 	}
   255 	if (seed.isEmpty())
   257 	if (seed.isEmpty())
   256 	{
   258 	{
   257 		QMessageBox::critical(this, "Error", "seed not defined", "OK");
   259 		QMessageBox::critical(0, "Error", "seed not defined", "OK");
   258 		return "avematan";
   260 		return "avematan";
   259 	}
   261 	}
   260 	quint32 k = 0;
   262 	quint32 k = 0;
   261 	for (int i = 0; i < seed.length(); i++)
   263 	for (int i = 0; i < seed.length(); i++)
   262 	{
   264 	{
   268 void HWGame::SaveDemo(const QString & filename)
   270 void HWGame::SaveDemo(const QString & filename)
   269 {
   271 {
   270 	QFile demofile(filename);
   272 	QFile demofile(filename);
   271 	if (!demofile.open(QIODevice::WriteOnly))
   273 	if (!demofile.open(QIODevice::WriteOnly))
   272 	{
   274 	{
   273 		QMessageBox::critical(this,
   275 		QMessageBox::critical(0,
   274 				tr("Error"),
   276 				tr("Error"),
   275 				tr("Cannot save demo to file %s").arg(filename),
   277 				tr("Cannot save demo to file %s").arg(filename),
   276 				tr("Quit"));
   278 				tr("Quit"));
   277 		return ;
   279 		return ;
   278 	}
   280 	}
   286 {
   288 {
   287 	gameType = gtDemo;
   289 	gameType = gtDemo;
   288 	QFile demofile(demofilename);
   290 	QFile demofile(demofilename);
   289 	if (!demofile.open(QIODevice::ReadOnly))
   291 	if (!demofile.open(QIODevice::ReadOnly))
   290 	{
   292 	{
   291 		QMessageBox::critical(this,
   293 		QMessageBox::critical(0,
   292 				tr("Error"),
   294 				tr("Error"),
   293 				tr("Cannot open demofile %s").arg(demofilename),
   295 				tr("Cannot open demofile %s").arg(demofilename),
   294 				tr("Quit"));
   296 				tr("Quit"));
   295 		return ;
   297 		return ;
   296 	}
   298 	}
   310 
   312 
   311 	// cut seed
   313 	// cut seed
   312 	quint32 index = toSendBuf->indexOf(10);
   314 	quint32 index = toSendBuf->indexOf(10);
   313 	if (!index)
   315 	if (!index)
   314 	{
   316 	{
   315 		QMessageBox::critical(this,
   317 		QMessageBox::critical(0,
   316 				tr("Error"),
   318 				tr("Error"),
   317 				tr("Corrupted demo file %s").arg(demofilename),
   319 				tr("Corrupted demo file %s").arg(demofilename),
   318 				tr("Quit"));
   320 				tr("Quit"));
   319 		return ;
   321 		return ;
   320 	}
   322 	}