QTfrontend/hwform.cpp
changeset 660 7c155e849602
parent 659 5eafb20566f1
child 661 0523b15353a2
--- a/QTfrontend/hwform.cpp	Fri Dec 14 15:36:00 2007 +0000
+++ b/QTfrontend/hwform.cpp	Fri Dec 14 16:13:35 2007 +0000
@@ -365,7 +365,7 @@
 	ui.pageNetGame->pChatWidget->clear();
 	hwnet = new HWNewNet(config, ui.pageNetGame->pGameCFG, ui.pageNetGame->pNetTeamsWidget);
 
-	connect(hwnet, SIGNAL(GameStateChanged(GameState)), this, SLOT(NetGameStateChanged(GameState)));
+	connect(hwnet, SIGNAL(AskForRunGame()), this, SLOT(CreateNetGame()));
 	connect(hwnet, SIGNAL(EnteredGame()), this, SLOT(NetGameEnter()));
 	connect(hwnet, SIGNAL(AddNetTeam(const HWTeam&)), this, SLOT(AddNetTeam(const HWTeam&)));
 
@@ -445,8 +445,11 @@
     hwnet=0;
   }
   if(pnetserver) {
-    pRegisterServer->unregister();
-    pRegisterServer = 0;
+    if (pRegisterServer)
+    {
+      pRegisterServer->unregister();
+      pRegisterServer = 0;
+    }
 
     pnetserver->StopServer();
     delete pnetserver;
@@ -490,12 +493,6 @@
 	game->StartLocal();
 }
 
-void HWForm::NetGameStateChanged(GameState __attribute__((unused)) gameState)
-{
-  ui.pageNetGame->BtnGo->setText(QPushButton::tr("Go!"));
-  ui.pageNetGame->BtnGo->setEnabled(true);
-}
-
 void HWForm::GameStateChanged(GameState gameState)
 {
 	switch(gameState) {
@@ -510,6 +507,11 @@
 		default: ;
 	}
 
+	if (hwnet)
+	{
+		ui.pageNetGame->BtnGo->setText(QPushButton::tr("Go!"));
+		ui.pageNetGame->BtnGo->setEnabled(true);
+	}
 }
 
 void HWForm::AddStatText(const QString & msg)
@@ -589,3 +591,13 @@
 
 	game->StartTraining();
 }
+
+void HWForm::CreateNetGame()
+{
+	CreateGame(ui.pageNetGame->pGameCFG, ui.pageNetGame->pNetTeamsWidget);
+
+	connect(game, SIGNAL(SendNet(const QByteArray &)), hwnet, SLOT(SendNet(const QByteArray &)));
+	connect(hwnet, SIGNAL(FromNet(const QByteArray &)), game, SLOT(FromNet(const QByteArray &)));
+
+	game->StartNet();
+}