CVariable class for GoldSrc
コード例 #1
0
ファイル: SharpMod.cs プロジェクト: voed/sharpmod
        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();
        }
コード例 #2
0
ファイル: SharpMod.cs プロジェクト: txdv/sharpmod
        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();
        }
コード例 #3
0
ファイル: DProto.cs プロジェクト: voed/sharpmod
 /// <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");
     }
 }
コード例 #4
0
ファイル: Server.cs プロジェクト: voed/sharpmod
        /// <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();
                }
            }
        }
コード例 #5
0
ファイル: DProto.cs プロジェクト: txdv/sharpmod
 /// <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");
 }