Don't show game stats in case of interrupted by command '/quit' game
authorunc0rr
Sat, 13 Jan 2007 22:32:08 +0000
changeset 324 f4c109c82a0c
parent 323 ea947f2c3d2f
child 325 17c860483407
Don't show game stats in case of interrupted by command '/quit' game
QTfrontend/game.cpp
QTfrontend/game.h
QTfrontend/hwform.cpp
hedgewars/CCHandlers.inc
hedgewars/GSHandlers.inc
--- a/QTfrontend/game.cpp	Sat Jan 13 22:12:30 2007 +0000
+++ b/QTfrontend/game.cpp	Sat Jan 13 22:32:08 2007 +0000
@@ -44,7 +44,7 @@
 void HWGame::onClientDisconnect()
 {
 	SaveDemo(cfgdir->absolutePath() + "/Demos/LastRound.hwd_" + cProtoVer);
-	emit GameStateChanged(gsFinished);
+	emit GameStateChanged(gsStopped);
 }
 
 void HWGame::SendTeamConfig(int index)
@@ -157,6 +157,14 @@
 			emit GameStats(msg.at(2), QString::fromUtf8(msg.mid(3)));
 			break;
 		}
+		case 'Q': {
+			emit GameStateChanged(gsInterrupted);
+			break;
+		}
+		case 'q': {
+			emit GameStateChanged(gsFinished);
+			break;
+		}
 		default: {
 			if (gameType == gtNet)
 			{
--- a/QTfrontend/game.h	Sat Jan 13 22:12:30 2007 +0000
+++ b/QTfrontend/game.h	Sat Jan 13 22:32:08 2007 +0000
@@ -34,7 +34,9 @@
 enum GameState {
 	gsNotStarted = 0,
 	gsStarted  = 1,
-	gsFinished = 2
+	gsInterrupted = 2,
+	gsFinished = 3,
+	gsStopped = 4
 };
 
 
--- a/QTfrontend/hwform.cpp	Sat Jan 13 22:12:30 2007 +0000
+++ b/QTfrontend/hwform.cpp	Sat Jan 13 22:32:08 2007 +0000
@@ -159,7 +159,7 @@
 	if (id == ID_PAGE_MULTIPLAYER || id == ID_PAGE_NETCFG) {
 		QStringList tmNames=config->GetTeamsList();
 		TeamSelWidget* curTeamSelWidget;
-		id == ID_PAGE_MULTIPLAYER ? curTeamSelWidget=ui.pageMultiplayer->teamsSelect : 
+		id == ID_PAGE_MULTIPLAYER ? curTeamSelWidget=ui.pageMultiplayer->teamsSelect :
 		  curTeamSelWidget=ui.pageNetGame->pNetTeamsWidget;
 		QList<HWTeam> teamsList;
 		for(QStringList::iterator it=tmNames.begin(); it!=tmNames.end(); it++) {
@@ -337,11 +337,18 @@
 
 void HWForm::GameStateChanged(GameState gameState)
 {
-	if (gameState == gsStarted)
-	{
-		GoToPage(ID_PAGE_GAMESTATS);
-		ui.pageGameStats->labelGameStats->setText("");
+	switch(gameState) {
+		case gsStarted: {
+			ui.pageGameStats->labelGameStats->setText("");
+			break;
+		}
+		case gsFinished: {
+			GoToPage(ID_PAGE_GAMESTATS);
+			break;
+		}
+		default: ;
 	}
+
 }
 
 void HWForm::AddStatText(const QString & msg)
--- a/hedgewars/CCHandlers.inc	Sat Jan 13 22:12:30 2007 +0000
+++ b/hedgewars/CCHandlers.inc	Sat Jan 13 22:32:08 2007 +0000
@@ -18,7 +18,7 @@
 
 function CheckNoTeamOrHH: boolean;
 begin
-Result:= (CurrentTeam=nil) or (CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear = nil);
+Result:= (CurrentTeam = nil) or (CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear = nil);
 {$IFDEF DEBUGFILE}
 if Result then
    if CurrentTeam = nil then AddFileLog('CONSOLE: CurTeam = nil')
@@ -28,6 +28,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 procedure chQuit(var s: shortstring);
 begin
+SendIPC('Q');
 GameState:= gsExit
 end;
 
--- a/hedgewars/GSHandlers.inc	Sat Jan 13 22:12:30 2007 +0000
+++ b/hedgewars/GSHandlers.inc	Sat Jan 13 22:32:08 2007 +0000
@@ -344,6 +344,7 @@
                    if Gear.Timer = 0 then
                       begin
                       SendIPC('N');
+                      SendIPC('q');
                       GameState:= gsExit
                       end
                    end;