Răsfoiți Sursa

Fix start game button for rmg without templates (#781)

Nordsoft91 3 ani în urmă
părinte
comite
4f1f9e3c5d
3 a modificat fișierele cu 12 adăugiri și 21 ștergeri
  1. 9 15
      client/lobby/CLobbyScreen.cpp
  2. 3 3
      lib/StartInfo.cpp
  3. 0 3
      lib/StartInfo.h

+ 9 - 15
client/lobby/CLobbyScreen.cpp

@@ -131,25 +131,19 @@ void CLobbyScreen::startScenario(bool allowOnlyAI)
 		CSH->sendStartGame(allowOnlyAI);
 		buttonStart->block(true);
 	}
-	catch(ExceptionMapMissing & e)
+	catch(std::exception & e)
 	{
-		(void)e;	// unused
-	}
-	catch(ExceptionNoHuman & e)
-	{
-		(void)e;	// unused
-		// You must position yourself prior to starting the game.
-		CInfoWindow::showInfoDialog(std::ref(CGI->generaltexth->allTexts[530]), CInfoWindow::TCompsInfo(), PlayerColor(1));
-	}
-	catch(ExceptionNoTemplate & e)
-	{
-		(void)e; // unused
-		// Could not create a random map that fits current choices.
-		CInfoWindow::showInfoDialog(std::ref(CGI->generaltexth->allTexts[751]), CInfoWindow::TCompsInfo(), PlayerColor(1));
+		logGlobal->error("Exception during startScenario: %s", e.what());
+		
+		if(std::string(e.what()) == "ExceptionNoHuman")
+			CInfoWindow::showInfoDialog(std::ref(CGI->generaltexth->allTexts[530]), CInfoWindow::TCompsInfo(), PlayerColor(1));
+		
+		if(std::string(e.what()) == "ExceptionNoTemplate")
+			CInfoWindow::showInfoDialog(std::ref(CGI->generaltexth->allTexts[751]), CInfoWindow::TCompsInfo(), PlayerColor(1));
 	}
 	catch(...)
 	{
-
+		logGlobal->error("Unknown exception");
 	}
 }
 

+ 3 - 3
lib/StartInfo.cpp

@@ -64,7 +64,7 @@ std::string StartInfo::getCampaignName() const
 void LobbyInfo::verifyStateBeforeStart(bool ignoreNoHuman) const
 {
 	if(!mi)
-		throw ExceptionMapMissing();
+		throw std::domain_error("ExceptionMapMissing");
 
 	//there must be at least one human player before game can be started
 	std::map<PlayerColor, PlayerSettings>::const_iterator i;
@@ -73,12 +73,12 @@ void LobbyInfo::verifyStateBeforeStart(bool ignoreNoHuman) const
 			break;
 
 	if(i == si->playerInfos.cend() && !ignoreNoHuman)
-		throw ExceptionNoHuman();
+		throw std::domain_error("ExceptionNoHuman");
 
 	if(si->mapGenOptions && si->mode == StartInfo::NEW_GAME)
 	{
 		if(!si->mapGenOptions->checkOptions())
-			throw ExceptionNoTemplate();
+			throw std::domain_error("ExceptionNoTemplate");
 	}
 }
 

+ 0 - 3
lib/StartInfo.h

@@ -187,6 +187,3 @@ struct DLL_LINKAGE LobbyInfo : public LobbyState
 	TeamID getPlayerTeamId(PlayerColor color);
 };
 
-class ExceptionMapMissing : public std::exception {};
-class ExceptionNoHuman : public std::exception {};
-class ExceptionNoTemplate : public std::exception {};