Ejemplo n.º 1
0
        public static void SetGamedir(String dir)
        {
            searchpath_t next;

            if (dir.IndexOf("..") != -1 || dir.IndexOf("/") != -1 || dir.IndexOf("\\\\") != -1 || dir.IndexOf(":") != -1)
            {
                Com.Printf("Gamedir should be a single filename, not a path\\n");
                return;
            }

            while (fs_searchpaths != fs_base_searchpaths)
            {
                if (fs_searchpaths.pack != null)
                {
                    try
                    {
                        fs_searchpaths.pack.handle.Close();
                    }
                    catch (IOException e)
                    {
                        Com.DPrintf(e.Message + '\\');
                    }

                    fs_searchpaths.pack.files.Clear();
                    fs_searchpaths.pack.files = null;
                    fs_searchpaths.pack       = null;
                }

                next           = fs_searchpaths.next;
                fs_searchpaths = null;
                fs_searchpaths = next;
            }

            if ((Globals.dedicated != null) && (Globals.dedicated.value == 0F))
            {
                Cbuf.AddText("vid_restart\\nsnd_restart\\n");
            }
            fs_gamedir = fs_basedir.string_renamed + '/' + dir;
            if (dir.Equals(Globals.BASEDIRNAME) || (dir.Length == 0))
            {
                Cvar.FullSet("gamedir", "", CVAR_SERVERINFO | CVAR_NOSET);
                Cvar.FullSet("game", "", CVAR_LATCH | CVAR_SERVERINFO);
            }
            else
            {
                Cvar.FullSet("gamedir", dir, CVAR_SERVERINFO | CVAR_NOSET);
                if (fs_cddir.string_renamed != null && fs_cddir.string_renamed.Length > 0)
                {
                    AddGameDirectory(fs_cddir.string_renamed + '/' + dir);
                }
                AddGameDirectory(fs_basedir.string_renamed + '/' + dir);
            }
        }
Ejemplo n.º 2
0
        public static bool AddLateCommands( )
        {
            int  i;
            int  j    = 0;
            bool ret  = false;
            int  s    = 0;
            int  argc = Com.Argc();

            for (i = 1; i < argc; i++)
            {
                s += Com.Argv(i).Length;
            }

            if (s == 0)
            {
                return(false);
            }
            string text = "";

            for (i = 1; i < argc; i++)
            {
                text += Com.Argv(i);
                if (i != argc - 1)
                {
                    text += " ";
                }
            }

            string build = "";

            for (i = 0; i < text.Length; i++)
            {
                if (text[i] == '+')
                {
                    i++;
                    build += text.Substring(i, j);
                    build += "\\n";
                    i      = j - 1;
                }
            }

            ret = (build.Length != 0);
            if (ret)
            {
                Cbuf.AddText(build);
            }
            text  = null;
            build = null;
            return(ret);
        }
Ejemplo n.º 3
0
        public static void InsertText(string text)
        {
            int templen = 0;

            templen = Globals.cmd_text.cursize;
            if (templen != 0)
            {
                System.Array.Copy(Globals.cmd_text.data, 0, tmp, 0, templen);
                SZ.Clear(Globals.cmd_text);
            }

            Cbuf.AddText(text);
            if (templen != 0)
            {
                SZ.Write(Globals.cmd_text, tmp, templen);
            }
        }
Ejemplo n.º 4
0
        public static void AddEarlyCommands(bool clear)
        {
            for (int i = 0; i < Com.Argc(); i++)
            {
                string s = Com.Argv(i);
                if (!s.Equals("+set"))
                {
                    continue;
                }
                Cbuf.AddText("set " + Com.Argv(i + 1) + " " + Com.Argv(i + 2) + "\\n");
                if (clear)
                {
                    Com.ClearArgv(i);
                    Com.ClearArgv(i + 1);
                    Com.ClearArgv(i + 2);
                }

                i += 2;
            }
        }
Ejemplo n.º 5
0
        public static void ExecuteText(int exec_when, string text)
        {
            switch (exec_when)
            {
            case Defines.EXEC_NOW:
                Cmd.ExecuteString(text);
                break;

            case Defines.EXEC_INSERT:
                Cbuf.InsertText(text);
                break;

            case Defines.EXEC_APPEND:
                Cbuf.AddText(text);
                break;

            default:
                Com.Error(Defines.ERR_FATAL, "Cbuf_ExecuteText: bad exec_when");
                break;
            }
        }
Ejemplo n.º 6
0
        static void Reconfigure(Boolean clear)
        {
            var dir = Cvar.Get("cddir", "", CVAR_ARCHIVE).string_renamed;

            Cbuf.AddText("exec default.cfg\\n");
            Cbuf.AddText("bind MWHEELUP weapnext\\n");
            Cbuf.AddText("bind MWHEELDOWN weapprev\\n");
            Cbuf.AddText("bind w +forward\\n");
            Cbuf.AddText("bind s +back\\n");
            Cbuf.AddText("bind a +moveleft\\n");
            Cbuf.AddText("bind d +moveright\\n");
            Cbuf.Execute();
            Cvar.Set("vid_fullscreen", "0");
            Cbuf.AddText("exec config.cfg\\n");
            Cbuf.AddEarlyCommands(clear);
            Cbuf.Execute();
            if (!("".Equals(dir)))
            {
                Cvar.Set("cddir", dir);
            }
        }
Ejemplo n.º 7
0
        public static void ExecAutoexec( )
        {
            var    dir = fs_userdir;
            String name;

            if (dir != null && dir.Length > 0)
            {
                name = dir + "/autoexec.cfg";
            }
            else
            {
                name = fs_basedir.string_renamed + '/' + Globals.BASEDIRNAME + "/autoexec.cfg";
            }

            var canthave = Defines.SFF_SUBDIR | Defines.SFF_HIDDEN | Defines.SFF_SYSTEM;

            if (CoreSys.FindAll(name) != null)
            {
                Cbuf.AddText("exec autoexec.cfg\\n");
            }
        }
Ejemplo n.º 8
0
        public static void Init(String[] args)
        {
            try
            {
                Com.InitArgv(args);
                Cbuf.Init();
                Cmd.Init();
                Cvar.Init();
                Key.Init();
                Cbuf.AddEarlyCommands(false);
                Cbuf.Execute();
                if (Globals.dedicated.value != 1F)
                {
                    Program.Q2Dialog.SetStatus("initializing filesystem...");
                }
                FS.InitFilesystem();
                if (Globals.dedicated.value != 1F)
                {
                    Program.Q2Dialog.SetStatus("loading config...");
                }
                Reconfigure(false);
                FS.SetCDDir();
                FS.MarkBaseSearchPaths();
                if (Globals.dedicated.value != 1F)
                {
                    Program.Q2Dialog.TestQ2Data();
                }
                Reconfigure(true);
                Cmd.AddCommand("error", Com.Error_f);
                Globals.host_speeds    = Cvar.Get("host_speeds", "0", 0);
                Globals.log_stats      = Cvar.Get("log_stats", "0", 0);
                Globals.developer      = Cvar.Get("developer", "0", CVAR_ARCHIVE);
                Globals.timescale      = Cvar.Get("timescale", "0", 0);
                Globals.fixedtime      = Cvar.Get("fixedtime", "0", 0);
                Globals.logfile_active = Cvar.Get("logfile", "0", 0);
                Globals.showtrace      = Cvar.Get("showtrace", "0", 0);
                Globals.dedicated      = Cvar.Get("dedicated", "0", CVAR_NOSET);
                var s = Com.Sprintf("%4.2f %s %s %s", Globals.VERSION, CPUSTRING, Globals.__DATE__, BUILDSTRING);
                Cvar.Get("version", s, CVAR_SERVERINFO | CVAR_NOSET);
                if (Globals.dedicated.value != 1F)
                {
                    Program.Q2Dialog.SetStatus("initializing network subsystem...");
                }
                NET.Init();
                Netchan.Netchan_Init();
                if (Globals.dedicated.value != 1F)
                {
                    Program.Q2Dialog.SetStatus("initializing server subsystem...");
                }
                SV_MAIN.SV_Init();
                if (Globals.dedicated.value != 1F)
                {
                    Program.Q2Dialog.SetStatus("initializing client subsystem...");
                }
                CL.Init();
                if (!Cbuf.AddLateCommands())
                {
                    if (Globals.dedicated.value == 0)
                    {
                        Cbuf.AddText("d1\\n");
                    }
                    else
                    {
                        Cbuf.AddText("dedicated_start\\n");
                    }
                    Cbuf.Execute();
                }
                else
                {
                    SCR.EndLoadingPlaque();
                }

                Com.Printf("====== Quake2 Initialized ======\\n\\n");
                CL.WriteConfiguration();
                if (Globals.dedicated.value != 1F)
                {
                    Program.Q2Dialog.Dispose();
                }
            }
            catch (longjmpException e)
            {
                CoreSys.Error("Error during initialization");
            }
        }