SharpMod.Server.LoadMapListFromMapcycle C# (CSharp) Method

LoadMapListFromMapcycle() public static method

Returns a list of all valid maps in the mapcycle.
public static LoadMapListFromMapcycle ( ) : string[]
return string[]
        public static string[] LoadMapListFromMapcycle()
        {
            StreamReader sr = null;
            List<string> list = new List<string>();
            try {
                string mapcyclefile = Path.Combine(Server.GameDirectory, CVar.GetStringValue("mapcyclefile"));
                sr = new StreamReader(File.Open(mapcyclefile, FileMode.Open));
                while (!sr.EndOfStream) {
                    string line = sr.ReadLine();
                    if (line.ToLower().EndsWith(".bsp")) {
                        string map = line.Substring(0, line.Length - 4);
                        if (Server.IsMapValid(map)) {
                            list.Add(map);
                        }
                    } else {
                        if (Server.IsMapValid(line)) {
                            list.Add(line);
                        }
                    }
                }
                return list.ToArray();
            } catch {
                try {
                    return list.ToArray();
                } catch {
                    return new string[] {};
                }
            } finally {
                if (sr != null) {
                    sr.Close();
                }
            }
        }