Browse Source

Backward compatibility with mods

nordsoft 2 years ago
parent
commit
b1bfc2239f

+ 1 - 1
client/CServerHandler.cpp

@@ -551,7 +551,7 @@ void CServerHandler::sendStartGame(bool allowOnlyAI) const
 	catch (const std::exception & e)
 	{
 		showServerError( std::string("Unable to start map! Reason: ") + e.what());
-		return;
+		throw e;
 	}
 
 	LobbyStartGame lsg;

+ 26 - 16
client/mainmenu/CMainMenu.cpp

@@ -590,16 +590,18 @@ CLoadingScreen::CLoadingScreen()
 	CCS->musich->stopMusic(5000);
 	
 	const auto & conf = CMainMenuConfig::get().getConfig()["loading"];
-	
-	const int posx = conf["x"].Integer(), posy = conf["y"].Integer();
-	const int blockSize = conf["size"].Integer();
-	const int blocksAmount = conf["amount"].Integer();
-			
-	for(int i = 0; i < blocksAmount; ++i)
+	if(conf.isStruct())
 	{
-		progressBlocks.push_back(std::make_shared<CAnimImage>(conf["name"].String(), i, 0, posx + i * blockSize, posy));
-		progressBlocks.back()->deactivate();
-		progressBlocks.back()->visible = false;
+		const int posx = conf["x"].Integer(), posy = conf["y"].Integer();
+		const int blockSize = conf["size"].Integer();
+		const int blocksAmount = conf["amount"].Integer();
+		
+		for(int i = 0; i < blocksAmount; ++i)
+		{
+			progressBlocks.push_back(std::make_shared<CAnimImage>(conf["name"].String(), i, 0, posx + i * blockSize, posy));
+			progressBlocks.back()->deactivate();
+			progressBlocks.back()->visible = false;
+		}
 	}
 }
 
@@ -628,14 +630,22 @@ void CLoadingScreen::showAll(Canvas & to)
 
 std::string CLoadingScreen::getBackground()
 {
-	const auto & conf = CMainMenuConfig::get().getConfig()["loading"]["background"].Vector();
+	std::string fname = "loadbar";
+	const auto & conf = CMainMenuConfig::get().getConfig()["loading"];
 
-	if(conf.empty())
-	{
-		return "loadbar";
-	}
-	else
+	if(conf.isStruct())
 	{
-		return RandomGeneratorUtil::nextItem(conf, CRandomGenerator::getDefault())->String();
+		if(conf["background"].isVector())
+			return RandomGeneratorUtil::nextItem(conf["background"].Vector(), CRandomGenerator::getDefault())->String();
+		
+		if(conf["background"].isString())
+			return conf["background"].String();
+		
+		return fname;
 	}
+	
+	if(conf.isVector() and !conf.Vector().empty())
+		return RandomGeneratorUtil::nextItem(conf.Vector(), CRandomGenerator::getDefault())->String();
+	
+	return fname;
 }

BIN
mapeditor/icons/lock-closed.png


BIN
mapeditor/icons/lock-open.png