From ac227d67326379463e4ce62335869ecaf464ace6 Mon Sep 17 00:00:00 2001
From: Marco Hladik <marco@icculus.org>
Date: Sun, 24 Mar 2019 16:27:36 +0100
Subject: [PATCH] Menu: Added support for fallback_dir, used by Condition Zero

---
 Source/menu-fn/defs.h           |  1 +
 Source/menu-fn/m_customgame.cpp | 12 +++++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/Source/menu-fn/defs.h b/Source/menu-fn/defs.h
index 9b6ed4f5..26c843ec 100644
--- a/Source/menu-fn/defs.h
+++ b/Source/menu-fn/defs.h
@@ -56,6 +56,7 @@ typedef struct
 	string gamedll;
 	string startmap;
 	string trainingmap;
+	string fallback_dir;
 } gameinfo_t;
 
 var int gameinfo_current = -1;
diff --git a/Source/menu-fn/m_customgame.cpp b/Source/menu-fn/m_customgame.cpp
index 6322df95..2bd22fb7 100644
--- a/Source/menu-fn/m_customgame.cpp
+++ b/Source/menu-fn/m_customgame.cpp
@@ -32,6 +32,7 @@ void game_printinfo(int i)
 	print("==================================\n");
 	print(sprintf("game: %s\n", games[i].game));
 	print(sprintf("gamedir: %s\n", games[i].gamedir));
+	print(sprintf("fallback_dir: %s\n", games[i].fallback_dir));
 	print(sprintf("url_info: %s\n", games[i].url_info));
 	print(sprintf("url_dl: %s\n", games[i].url_dl));
 	print(sprintf("version: %s\n", games[i].version));
@@ -107,6 +108,9 @@ void games_init(void)
 				case "gamedir":
 					games[gameidx].gamedir = argv(i + 1);
 					break;
+				case "fallback_dir":
+					games[gameidx].fallback_dir = argv(i + 1);
+					break;
 				case "url_info":
 					games[gameidx].url_info = argv(i + 1);
 					break;
@@ -184,7 +188,13 @@ void customgame_btnactivate_start(void)
 	int nextgame = customgame_lbMods.GetSelected();
 
 	games_set(nextgame);
-	localcmd(sprintf("gamedir \"%s\"\n", games[nextgame].gamedir));
+
+	if (games[nextgame].fallback_dir) {
+		localcmd(sprintf("gamedir \"%s;%s\"\n", games[nextgame].fallback_dir, games[nextgame].gamedir));
+	} else {
+		localcmd(sprintf("gamedir \"%s\"\n", games[nextgame].gamedir));
+	}
+
 	localcmd("snd_restart\nwait\nvid_reload\nmenu_restart\nmenu_customgame\n");
 	// TODO: Re-init important menu bits and bobs.
 	cvar_init();