CVariable class for GoldSrc
Exemplo n.º 1
0
        public static void Init()
        {
            Version = new CVar("smod_version", "0.1");

            // load plugins

            Server.Print(License);
            Server.RegisterCommand("smod", smod);

            Verifier = new Verifier(Directory.GetCurrentDirectory(), Server.GameDirectory);

            try {
                var doc = new System.Xml.XmlDocument();
                doc.Load(Path.Combine(Server.ModDirectory, Path.Combine("cfg", "databases.xml")));
                try {
                    Database = DefaultDatabase.Load(Path.Combine(Server.ModDirectory, "SharpMod.Database.MySql.dll"));
                    Database.Load(doc);
                } catch (Exception e) {
                    Server.LogError("Database Interface failed to load, using default: {0}", e.Message);
                    Database = new DefaultDatabase();
                    Database.Load(doc);
                }
            } catch (Exception e) {
                Server.LogError("Failed to load cfg/databases.xml: {0}", e.Message);
            }

            Message.Init();
            MapCycle.Init();
        }
Exemplo n.º 2
0
        public static void Init()
        {
            Version = new CVar("smod_version", "0.1");

            // load plugins

            Server.Print(License);
            Server.RegisterCommand("smod", smod);

            Verifier = new Verifier(Directory.GetCurrentDirectory(), Server.GameDirectory);

            try {
                var doc = new System.Xml.XmlDocument();
                doc.Load(Path.Combine(Server.ModDirectory, Path.Combine("cfg", "databases.xml")));
                try {
                    Database = DefaultDatabase.Load(Path.Combine(Server.ModDirectory, "SharpMod.Database.MySql.dll"));
                    Database.Load(doc);
                } catch (Exception e) {
                    Server.LogError("Database Interface failed to load, using default: {0}", e.Message);
                    Database = new DefaultDatabase();
                    Database.Load(doc);
                }
            } catch (Exception e) {
                Server.LogError("Failed to load cfg/databases.xml: {0}", e.Message);
            }

            Message.Init();
            MapCycle.Init();
        }
Exemplo n.º 3
0
 /// <summary>
 /// This has to be called in order to make this work this class proplery.
 /// If you use this class in your plugin, just call it when the plugin is loaded.
 /// </summary>
 public static void Init()
 {
     if (protocol == null)
     {
         protocol = CVar.Get("dp_r_protocol");
     }
     if (id_provider == null)
     {
         id_provider = CVar.Get("dp_r_id_provider");
     }
     if (version == null)
     {
         version = CVar.Get("dp_version");
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Returns a list of all valid maps in the mapcycle.
        /// </summary>
        /// <returns>
        /// String array of all map names <see cref="System.String[]"/>
        /// </returns>
        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();
                }
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// This has to be called in order to make this work this class proplery.
 /// If you use this class in your plugin, just call it when the plugin is loaded.
 /// </summary>
 public static void Init()
 {
     if (protocol == null) protocol    = CVar.Get("dp_r_protocol");
     if (id_provider == null) id_provider = CVar.Get("dp_r_id_provider");
     if (version == null)     version     = CVar.Get("dp_version");
 }