From 34e1826e6f60d3e147e6773ec7af3c38d6ffcb6a Mon Sep 17 00:00:00 2001
From: jsalmon3 <>
Date: Sun, 1 Dec 2002 21:06:35 +0000
Subject: [PATCH] Fixed bug #646385: Custom Single Player .cm Crash

---
 doc/ChangeLog.html |  1 +
 src/ui/menus.cpp   | 22 ++++++++++++++--------
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/doc/ChangeLog.html b/doc/ChangeLog.html
index 26d53d3f8..1abfedd11 100644
--- a/doc/ChangeLog.html
+++ b/doc/ChangeLog.html
@@ -994,6 +994,7 @@
     <LI>Fixed bug #618086: bugs when without network (from Nehal Mistry).
     <LI>Can specify port when entering IP Address in format: 
 	"x.x.x.x:port" (from Nehal Mistry).
+    <LI>Fixed bug #646385: Custom Single Player .cm Crash (from Jimmy Salmon).
     <LI>+++
     </UL>
 </UL>
diff --git a/src/ui/menus.cpp b/src/ui/menus.cpp
index fcd33e285..2596caf87 100644
--- a/src/ui/menus.cpp
+++ b/src/ui/menus.cpp
@@ -2400,15 +2400,21 @@ local void ScenSelectMenu(void)
     GetInfoFromSelectPath();
 
     menu = FindMenu("menu-custom-game");
-    for (n = j = 0; j < PlayerMax; j++) {
-	t = ScenSelectPudInfo->PlayerType[j];
-	if (t == PlayerPerson || t == PlayerComputer) {
-	    n++;
-	}
-    }
-    menu->items[12].d.pulldown.noptions = n;
-    if (menu->items[12].d.pulldown.curopt >= n) {
+    // FIXME: This check is only needed until GetCmInfo works
+    if (!ScenSelectPudInfo) {
+	menu->items[12].d.pulldown.noptions = PlayerMax-1;
 	menu->items[12].d.pulldown.curopt = 0;
+    } else {
+	for (n = j = 0; j < PlayerMax; ++j) {
+	    t = ScenSelectPudInfo->PlayerType[j];
+	    if (t == PlayerPerson || t == PlayerComputer) {
+		n++;
+	    }
+	}
+	menu->items[12].d.pulldown.noptions = n;
+	if (menu->items[12].d.pulldown.curopt >= n) {
+	    menu->items[12].d.pulldown.curopt = 0;
+	}
     }
 }