示例#1
0
文件: MainForm.cs 项目: Scrama/Quarp
        static int Main(string[] args)
        {
#if !DEBUG
            try
            {
#endif
            // select display device
            _DisplayDevice = DisplayDevice.Default;

            if (File.Exists(DumpFilePath))
            {
                File.Delete(DumpFilePath);
            }

            quakeparms_t parms = new quakeparms_t();

            parms.basedir = Application.StartupPath;

            string[] args2 = new string[args.Length + 1];
            args2[0] = String.Empty;
            args.CopyTo(args2, 1);

            Common.InitArgv(args2);

            parms.argv = new string[Common.Argc];
            Common.Args.CopyTo(parms.argv, 0);

            if (Common.HasParam("-dedicated"))
            {
                throw new QuakeException("Dedicated server mode not supported!");
            }

            Size size         = new Size(640, 480);
            GraphicsMode mode = new GraphicsMode();
            bool fullScreen   = false;
            using (MainForm form = MainForm.CreateInstance(size, mode, fullScreen))
            {
                Con.DPrint("Host.Init\n");
                Host.Init(parms);

                form.Run();
            }
            Host.Shutdown();
#if !DEBUG
        }

        catch (QuakeSystemError se)
        {
            HandleException(se);
        }
        catch (Exception ex)
        {
            HandleException(ex);
        }
#endif
            return(0);    // all Ok
        }
示例#2
0
        public static void Init(quakeparms_t parms)
        {
            _Params = parms;

            Cache.Init(1024 * 1024 * 16); // debug
            Cbuf.Init();
            Cmd.Init();
            View.Init();
            Chase.Init();
            InitVCR(parms);
            Common.Init(parms.basedir, parms.argv);
            InitLocal();
            Wad.LoadWadFile("gfx.wad");
            Key.Init();
            Con.Init();
            Menu.Init();
            Progs.Init();
            Mod.Init();
            Net.Init();
            Server.Init();

            //Con.Print("Exe: "__TIME__" "__DATE__"\n");
            //Con.Print("%4.1f megabyte heap\n",parms->memsize/ (1024*1024.0));

            Render.InitTextures();              // needed even for dedicated servers

            if (Client.cls.state != cactive_t.ca_dedicated)
            {
                _BasePal = Common.LoadFile("gfx/palette.lmp");
                if (_BasePal == null)
                {
                    Sys.Error("Couldn't load gfx/palette.lmp");
                }
                _ColorMap = Common.LoadFile("gfx/colormap.lmp");
                if (_ColorMap == null)
                {
                    Sys.Error("Couldn't load gfx/colormap.lmp");
                }

                // on non win32, mouse comes before video for security reasons
                Input.Init();
                Vid.Init(_BasePal);
                Drawer.Init();
                Scr.Init();
                Render.Init();
                Sound.Init();
                CDAudio.Init();
                Sbar.Init();
                Client.Init();
            }

            Cbuf.InsertText("exec quake.rc\n");

            _IsInitialized = true;

            Con.DPrint("========Quake Initialized=========\n");
        }
示例#3
0
        static void InitVCR(quakeparms_t parms)
        {
            if (Common.HasParam("-playback"))
            {
                if (Common.Argc != 2)
                {
                    Sys.Error("No other parameters allowed with -playback\n");
                }

                Stream file = Sys.FileOpenRead("quake.vcr");
                if (file == null)
                {
                    Sys.Error("playback file not found\n");
                }

                _VcrReader = new BinaryReader(file, Encoding.ASCII);
                int signature = _VcrReader.ReadInt32();  //Sys_FileRead(vcrFile, &i, sizeof(int));
                if (signature != Host.VCR_SIGNATURE)
                {
                    Sys.Error("Invalid signature in vcr file\n");
                }

                int      argc = _VcrReader.ReadInt32(); // Sys_FileRead(vcrFile, &com_argc, sizeof(int));
                string[] argv = new string[argc + 1];
                argv[0] = parms.argv[0];

                for (int i = 1; i < argv.Length; i++)
                {
                    argv[i] = Sys.ReadString(_VcrReader);
                }
                Common.Args = argv;
                parms.argv  = argv;
            }

            int n = Common.CheckParm("-record");

            if (n != 0)
            {
                Stream file = Sys.FileOpenWrite("quake.vcr"); // vcrFile = Sys_FileOpenWrite("quake.vcr");
                _VcrWriter = new BinaryWriter(file, Encoding.ASCII);

                _VcrWriter.Write(VCR_SIGNATURE); //  Sys_FileWrite(vcrFile, &i, sizeof(int));
                _VcrWriter.Write(Common.Argc - 1);
                for (int i = 1; i < Common.Argc; i++)
                {
                    if (i == n)
                    {
                        Sys.WriteString(_VcrWriter, "-playback");
                        continue;
                    }
                    Sys.WriteString(_VcrWriter, Common.Argv(i));
                }
            }
        }