Ejemplo n.º 1
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");
        }