Ejemplo n.º 1
0
        private void InitialiseVCR(QuakeParameters parms)
        {
            if (CommandLine.HasParam("-playback"))
            {
                if (CommandLine.Argc != 2)
                {
                    Utilities.Error("No other parameters allowed with -playback\n");
                }

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

                this.VcrReader = new(file, Encoding.ASCII);
                var signature = this.VcrReader.ReadInt32( );  //Sys_FileRead(vcrFile, &i, sizeof(int));
                if (signature != HostDef.VCR_SIGNATURE)
                {
                    Utilities.Error("Invalid signature in vcr file\n");
                }

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

                for (var i = 1; i < argv.Length; i++)
                {
                    argv[i] = Utilities.ReadString(this.VcrReader);
                }

                CommandLine.Args = argv;
                parms.argv       = argv;
            }

            var n = CommandLine.CheckParm("-record");

            if (n != 0)
            {
                Stream file = FileSystem.OpenWrite("quake.vcr");   // vcrFile = Sys_FileOpenWrite("quake.vcr");
                this.VcrWriter = new(file, Encoding.ASCII);

                this.VcrWriter.Write(HostDef.VCR_SIGNATURE);   //  Sys_FileWrite(vcrFile, &i, sizeof(int));
                this.VcrWriter.Write(CommandLine.Argc - 1);
                for (var i = 1; i < CommandLine.Argc; i++)
                {
                    if (i == n)
                    {
                        Utilities.WriteString(this.VcrWriter, "-playback");
                        continue;
                    }
                    Utilities.WriteString(this.VcrWriter, CommandLine.Argv(i));
                }
            }
        }
Ejemplo n.º 2
0
        private static Int32 Main(String[] args)
        {
            if (File.Exists(DumpFilePath))
            {
                File.Delete(DumpFilePath);
            }

            var parms = new QuakeParameters( );

            parms.basedir = AppDomain.CurrentDomain.BaseDirectory; //Application.StartupPath;

            var args2 = new String[args.Length + 1];

            args2[0] = String.Empty;
            args.CopyTo(args2, 1);

            Common = new Common( );
            Common.InitArgv(args2);

            Input = new Input( );

            parms.argv = new String[CommandLine.Argc];
            CommandLine.Args.CopyTo(parms.argv, 0);

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

            var size = new Size(1280, 720);

            using (var form = CreateInstance(size, false))
            {
                form.Host.Console.DPrint("Host.Init\n");
                form.Host.Initialise(parms);
                Instance.CursorVisible = false; //Hides mouse cursor during main menu on start up
                form.Run( );
            }
            // host.Shutdown();
#if !DEBUG
        }
Ejemplo n.º 3
0
        // COM_InitFilesystem
        public static void InitFileSystem(QuakeParameters hostParams)
        {
            //
            // -basedir <path>
            // Overrides the system supplied base directory (under GAMENAME)
            //
            var basedir = String.Empty;
            var i       = CommandLine.CheckParm("-basedir");

            if ((i > 0) && (i < CommandLine._Argv.Length - 1))
            {
                basedir = CommandLine._Argv[i + 1];
            }
            else
            {
                basedir = hostParams.basedir;
                QuakeParameter.globalbasedir = basedir;
            }

            if (!String.IsNullOrEmpty(basedir))
            {
                basedir = basedir.TrimEnd('\\', '/');
            }

            //
            // -cachedir <path>
            // Overrides the system supplied cache directory (NULL or /qcache)
            // -cachedir - will disable caching.
            //
            i = CommandLine.CheckParm("-cachedir");
            if ((i > 0) && (i < CommandLine._Argv.Length - 1))
            {
                if (CommandLine._Argv[i + 1][0] == '-')
                {
                    _CacheDir = String.Empty;
                }
                else
                {
                    _CacheDir = CommandLine._Argv[i + 1];
                }
            }
            else if (!String.IsNullOrEmpty(hostParams.cachedir))
            {
                _CacheDir = hostParams.cachedir;
            }
            else
            {
                _CacheDir = String.Empty;
            }

            //
            // start up with GAMENAME by default (id1)
            //
            AddGameDirectory(basedir + "/" + QDef.GAMENAME);
            QuakeParameter.globalgameid = QDef.GAMENAME;

            if (CommandLine.HasParam("-rogue"))
            {
                AddGameDirectory(basedir + "/rogue");
                QuakeParameter.globalgameid = "rogue";
            }

            if (CommandLine.HasParam("-hipnotic"))
            {
                AddGameDirectory(basedir + "/hipnotic");
                QuakeParameter.globalgameid = "hipnotic";
            }
            //
            // -game <gamedir>
            // Adds basedir/gamedir as an override game
            //
            i = CommandLine.CheckParm("-game");
            if ((i > 0) && (i < CommandLine._Argv.Length - 1))
            {
                _IsModified = true;
                AddGameDirectory(basedir + "/" + CommandLine._Argv[i + 1]);
            }

            //
            // -path <dir or packfile> [<dir or packfile>] ...
            // Fully specifies the exact serach path, overriding the generated one
            //
            i = CommandLine.CheckParm("-path");
            if (i > 0)
            {
                _IsModified = true;
                _SearchPaths.Clear( );
                while (++i < CommandLine._Argv.Length)
                {
                    if (String.IsNullOrEmpty(CommandLine._Argv[i]) || CommandLine._Argv[i][0] == '+' || CommandLine._Argv[i][0] == '-')
                    {
                        break;
                    }

                    _SearchPaths.Insert(0, new SearchPath(CommandLine._Argv[i]));
                }
            }
        }
Ejemplo n.º 4
0
        public void Initialise(QuakeParameters parms)
        {
            Parameters = parms;

            //Command.SetupWrapper( ); // Temporary workaround - change soon!
            Cache.Initialise(1024 * 1024 * 512);   // debug

            Commands.Add("flush", Cache.Flush);

            //CommandBuffer.Initialise( );
            // Command.Initialise( );
            View.Initialise( );
            ChaseView.Initialise( );
            InitialiseVCR(parms);
            MainWindow.Common.Initialise(MainWindow, parms.basedir, parms.argv);
            InitialiseLocal( );

            InitialiseWAD();

            Keyboard.Initialise( );
            Console.Initialise( );
            Menus.Initialise(this);
            Programs.Initialise( );
            ProgramsBuiltIn.Initialise( );
            Model.Initialise(this);
            Network.Initialise( );
            Server.Initialise( );

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

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

            if (Client.cls.state != cactive_t.ca_dedicated)
            {
                BasePal = FileSystem.LoadFile("gfx/palette.lmp");
                if (BasePal == null)
                {
                    Utilities.Error("Couldn't load gfx/palette.lmp");
                }
                ColorMap = FileSystem.LoadFile("gfx/colormap.lmp");
                if (ColorMap == null)
                {
                    Utilities.Error("Couldn't load gfx/colormap.lmp");
                }

                // on non win32, mouse comes before video for security reasons
                MainWindow.Input.Initialise(this);
                Video.Initialise(BasePal);
                DrawingContext.Initialise( );
                Screen.Initialise( );
                RenderContext.Initialise( );
                Sound.Initialise( );
                CDAudio.Initialise( );
                Hud.Initialise( );
                Client.Initialise( );
            }
            else
            {
                DedicatedServer.Initialise( );
            }

            Commands.Buffer.Insert("exec quake.rc\n");

            IsInitialised = true;

            Console.DPrint("========Quake Initialized=========\n");
        }
Ejemplo n.º 5
0
        public void Initialise(QuakeParameters parms)
        {
            this.Parameters = parms;

            //Command.SetupWrapper( ); // Temporary workaround - change soon!
            this.Cache.Initialise(1024 * 1024 * 512);   // debug

            this.Commands.Add("flush", this.Cache.Flush);

            //CommandBuffer.Initialise( );
            // Command.Initialise( );
            this.View.Initialise( );
            this.ChaseView.Initialise( );
            this.InitialiseVCR(parms);
            MainWindow.Common.Initialise(this.MainWindow, parms.basedir, parms.argv);
            this.InitialiseLocal( );

            // Search wads
            foreach (var wadFile in FileSystem.Search("*.wad"))
            {
                if (wadFile == "radiant.wad")
                {
                    continue;
                }

                if (wadFile == "gfx.wad")
                {
                    continue;
                }

                var data = FileSystem.LoadFile(wadFile);

                if (data == null)
                {
                    continue;
                }

                var wad = new Wad( );
                wad.LoadWadFile(wadFile, data);

                this.WadFiles.Add(wadFile, wad);

                var textures = wad._Lumps.Values
                               .Select(s => Encoding.ASCII.GetString(s.name).Replace("\0", ""))
                               .ToArray( );

                foreach (var texture in textures)
                {
                    if (!this.WadTextures.ContainsKey(texture))
                    {
                        this.WadTextures.Add(texture, wadFile);
                    }
                }
            }

            this.GfxWad.LoadWadFile("gfx.wad");
            this.Keyboard.Initialise( );
            this.Console.Initialise( );
            this.Menu.Initialise( );
            this.Programs.Initialise( );
            this.ProgramsBuiltIn.Initialise( );
            this.Model.Initialise( );
            this.Network.Initialise( );
            this.Server.Initialise( );

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

            this.RenderContext.InitTextures( );         // needed even for dedicated servers

            if (this.Client.cls.state != cactive_t.ca_dedicated)
            {
                this.BasePal = FileSystem.LoadFile("gfx/palette.lmp");
                if (this.BasePal == null)
                {
                    Utilities.Error("Couldn't load gfx/palette.lmp");
                }

                this.ColorMap = FileSystem.LoadFile("gfx/colormap.lmp");
                if (this.ColorMap == null)
                {
                    Utilities.Error("Couldn't load gfx/colormap.lmp");
                }

                // on non win32, mouse comes before video for security reasons
                MainWindow.Input.Initialise(this);
                this.Video.Initialise(this.BasePal);
                this.DrawingContext.Initialise( );
                this.Screen.Initialise( );
                this.RenderContext.Initialise( );
                this.Sound.Initialise( );
                this.CDAudio.Initialise( );
                this.Hud.Initialise( );
                this.Client.Initialise( );
            }
            else
            {
                this.DedicatedServer.Initialise( );
            }

            this.Commands.Buffer.Insert("exec quake.rc\n");

            this.IsInitialised = true;

            this.Console.DPrint("========Quake Initialized=========\n");
        }