- Fix a bug in READY message handling
authorunc0rr
Fri, 24 Oct 2008 12:57:06 +0000
changeset 1404 2b6b6809c2e4
parent 1403 b8c921ed0f13
child 1405 ee4b28a1861d
- Fix a bug in READY message handling - Fix frontend to use new semantics
QTfrontend/hwform.cpp
QTfrontend/hwform.h
QTfrontend/newnetclient.cpp
QTfrontend/newnetclient.h
QTfrontend/pages.cpp
netserver/HWProto.hs
--- a/QTfrontend/hwform.cpp	Thu Oct 23 15:12:38 2008 +0000
+++ b/QTfrontend/hwform.cpp	Fri Oct 24 12:57:06 2008 +0000
@@ -102,7 +102,6 @@
 	connect(ui.pageNetServer->BtnStart,	SIGNAL(clicked()),	this, SLOT(NetStartServer()));
 
 	connect(ui.pageNetGame->BtnBack,	SIGNAL(clicked()),	this, SLOT(GoBack()));
-	connect(ui.pageNetGame->BtnGo, SIGNAL(clicked()), this, SLOT(NetStartGame()));
 	connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(setEnabledGameStart(bool)),
 		ui.pageNetGame->BtnGo, SLOT(setEnabled(bool)));
 	connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(SetupClicked()), this, SLOT(IntermediateSetup()));
@@ -451,6 +450,7 @@
 		ui.pageNetGame->pChatWidget, SLOT(nickAdded(const QString&)));
 	connect(hwnet, SIGNAL(nickRemoved(const QString&)),
 		ui.pageNetGame->pChatWidget, SLOT(nickRemoved(const QString&)));
+	connect(ui.pageNetGame->BtnGo, SIGNAL(clicked()), hwnet, SLOT(ToggleReady()));
 
 	connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(hhogsNumChanged(const HWTeam&)),
 		hwnet, SLOT(onHedgehogsNumChanged(const HWTeam&)));
@@ -560,13 +560,6 @@
 	GoToPage(ID_PAGE_NETGAME);
 }
 
-void HWForm::NetStartGame()
-{
-	ui.pageNetGame->BtnGo->setText(QPushButton::tr("Waiting"));
-	ui.pageNetGame->BtnGo->setEnabled(false);
-	hwnet->Ready();
-}
-
 void HWForm::AddNetTeam(const HWTeam& team)
 {
   ui.pageNetGame->pNetTeamsWidget->addTeam(team);
@@ -611,12 +604,6 @@
 			}
 		};
 	}
-
-	if (hwnet)
-	{
-		ui.pageNetGame->BtnGo->setText(QPushButton::tr("Go!"));
-		ui.pageNetGame->BtnGo->setEnabled(true);
-	}
 }
 
 void HWForm::AddStatText(const QString & msg)
--- a/QTfrontend/hwform.h	Thu Oct 23 15:12:38 2008 +0000
+++ b/QTfrontend/hwform.h	Fri Oct 24 12:57:06 2008 +0000
@@ -75,7 +75,6 @@
 	void NetDisconnect();
 	void NetConnected();
 	void NetGameEnter();
-	void NetStartGame();
 	void AddNetTeam(const HWTeam& team);
 	void StartMPGame();
 	void GameStateChanged(GameState gameState);
--- a/QTfrontend/newnetclient.cpp	Thu Oct 23 15:12:38 2008 +0000
+++ b/QTfrontend/newnetclient.cpp	Fri Oct 24 12:57:06 2008 +0000
@@ -113,9 +113,9 @@
 	RawSendNet(QString("REMOVE_TEAM") + delimeter + team.TeamName);
 }
 
-void HWNewNet::Ready()
+void HWNewNet::ToggleReady()
 {
-  RawSendNet(QString("READY"));
+  RawSendNet(QString("TOGGLE_READY"));
 }
 
 void HWNewNet::SendNet(const QByteArray & buf)
--- a/QTfrontend/newnetclient.h	Thu Oct 23 15:12:38 2008 +0000
+++ b/QTfrontend/newnetclient.h	Fri Oct 24 12:57:06 2008 +0000
@@ -41,7 +41,6 @@
   HWNewNet(GameUIConfig * config, GameCFGWidget* pGameCFGWidget, TeamSelWidget* pTeamSelWidget);
   void Connect(const QString & hostName, quint16 port, const QString & nick);
   void Disconnect();
-  void Ready();
   bool isRoomChief();
 
  private:
@@ -113,6 +112,7 @@
   void serverMessage(const QString &);
 
  public slots:
+  void ToggleReady();
   void chatLineToNet(const QString& str);
   void SendNet(const QByteArray & buf);
   void AddTeam(const HWTeam & team);
--- a/QTfrontend/pages.cpp	Thu Oct 23 15:12:38 2008 +0000
+++ b/QTfrontend/pages.cpp	Fri Oct 24 12:57:06 2008 +0000
@@ -537,8 +537,7 @@
 
 	BtnGo = new QPushButton(this);
 	BtnGo->setFont(*font14);
-	BtnGo->setText(QPushButton::tr("Go!"));
-	BtnGo->setEnabled(false);
+	BtnGo->setText(QPushButton::tr("Ready"));
 	pageLayout->addWidget(BtnGo, 2, 1);
 }
 
--- a/netserver/HWProto.hs	Thu Oct 23 15:12:38 2008 +0000
+++ b/netserver/HWProto.hs	Fri Oct 24 12:57:06 2008 +0000
@@ -241,7 +241,7 @@
 			(modifyClient client{isReady = True}, modifyRoom clRoom{readyPlayers = newReadyPlayers}, answerReady $ nick client)
 	where
 		clRoom = roomByName (room client) rooms
-		newReadyPlayers = (readyPlayers clRoom) + if isReady client then 1 else -1
+		newReadyPlayers = (readyPlayers clRoom) + if isReady client then -1 else 1
 
 handleCmd_inRoom client _ rooms ["ROUNDFINISHED"] =
 	if isMaster client then