[PATCH] New command "maplist"

Add a new command "maplist" which will list all the available maps in
the current search path. An optional argument specifies a prefix to
filter the maps listed.

Con_Init is moved to the end of the file to avoid unnecessary forward
declarations.

diff -urN b/common/console.c head/common/console.c
--- b/common/console.c	2006-02-08 18:16:21.000000000 +1030
+++ head/common/console.c	2006-02-08 18:19:39.000000000 +1030
@@ -206,38 +206,6 @@
     Con_Resize(&con_main);
 }
 
-
-/*
-================
-Con_Init
-================
-*/
-void
-Con_Init(void)
-{
-    debuglog = COM_CheckParm("-condebug");
-
-    con_main.text = Hunk_AllocName(CON_TEXTSIZE, "conmain");
-
-    con = &con_main;
-    con_linewidth = -1;
-    Con_CheckResize();
-
-    Con_Printf("Console initialized.\n");
-
-//
-// register our commands
-//
-    Cvar_RegisterVariable(&con_notifytime);
-
-    Cmd_AddCommand("toggleconsole", Con_ToggleConsole_f);
-    Cmd_AddCommand("messagemode", Con_MessageMode_f);
-    Cmd_AddCommand("messagemode2", Con_MessageMode2_f);
-    Cmd_AddCommand("clear", Con_Clear_f);
-    con_initialized = true;
-}
-
-
 /*
 ===============
 Con_Linefeed
@@ -768,3 +736,49 @@
 	free(showtree_list);
     }
 }
+
+
+void
+Con_Maplist_f()
+{
+    struct rb_string_root st_root = RB_STRING_ROOT;
+    char *pfx = NULL;
+
+    if (Cmd_Argc() == 2)
+	pfx = Cmd_Argv(1);
+
+    ST_AllocInit();
+    COM_ScanDir(&st_root, "maps", pfx, ".bsp", true);
+    Con_ShowTree(&st_root);
+}
+
+
+/*
+================
+Con_Init
+================
+*/
+void
+Con_Init(void)
+{
+    debuglog = COM_CheckParm("-condebug");
+
+    con_main.text = Hunk_AllocName(CON_TEXTSIZE, "conmain");
+
+    con = &con_main;
+    con_linewidth = -1;
+    Con_CheckResize();
+
+    Con_Printf("Console initialized.\n");
+
+    /* register our commands */
+    Cvar_RegisterVariable(&con_notifytime);
+
+    Cmd_AddCommand("toggleconsole", Con_ToggleConsole_f);
+    Cmd_AddCommand("messagemode", Con_MessageMode_f);
+    Cmd_AddCommand("messagemode2", Con_MessageMode2_f);
+    Cmd_AddCommand("clear", Con_Clear_f);
+    Cmd_AddCommand("maplist", Con_Maplist_f);
+
+    con_initialized = true;
+}
