launcher/demo.cpp

changeset 56
bdbbde5f754e
parent 51
5e4bd3b212ce
child 63
d10a6be4d99e
--- a/launcher/demo.cpp	Sun Jun 07 19:56:40 2015 +0300
+++ b/launcher/demo.cpp	Mon Jun 22 01:44:30 2015 +0300
@@ -106,19 +106,10 @@
 // -------------------------------------------------------------------------------------------------
 //
 
-static QString findWAD (QString name)
+static QString findWad (QString name)
 {
 	QStringList wadpaths = Config::get ("wadpaths").toStringList();
 
-	if (wadpaths.empty())
-	{
-		error (tr ("No WAD paths configured!"));
-
-		// Cannot just return an empty string here since that'd trigger another error prompt - skip
-		// ahead and exit.
-		exit (1);
-	}
-
 	for (int i = 0; i < wadpaths.size(); ++i)
 	{
 		QString fullpath = QString ("%1/%2").arg (wadpaths[i]).arg (name);
@@ -128,6 +119,11 @@
 			return fullpath;
 	}
 
+	// WAD names are case-sensitive under non-Windows and they can appear in uppercase
+	// so we need to test that too.
+	if (name != name.toUpper())
+		return findWad (name.toUpper());
+
 	return "";
 }
 
@@ -318,17 +314,25 @@
 
 	QString iwadpath;
 	QStringList pwadpaths;
+	bool doneAssimilation = false;
 
 	// Find the WADs
 	for (int i = 0; i < wads.size(); ++i)
 	{
 		const QString& wad = wads[i];
-		QString path = findWAD (wad);
+		QString path = findWad (wad);
+
+		if (path.isEmpty() and not doneAssimilation and Config::get ("autoassimilate").toBool())
+		{
+			QStringList wadpaths = Config::get ("wadpaths").toStringList();
 
-		// WAD names are case-sensitive under non-Windows and they can appear in uppercase
-		// so we need to test that too.
-		if (path.isEmpty())
-			path = findWAD (wad.toUpper());
+			// If there are no wad paths, try assimilate from other sources.
+			assimilateWadPaths (wadpaths);
+			Config::set ("wadpaths", wadpaths);
+
+			// Try find the wad again
+			path = findWad (wad);
+		}
 
 		if (path.isEmpty())
 		{

mercurial