Ejemplo n.º 1
0
        /// <summary>
        /// SCR_BeginLoadingPlaque
        /// </summary>
        public static void BeginLoadingPlaque()
        {
            Sound.StopAllSounds(true);

            if (Client.cls.state != cactive_t.ca_connected)
            {
                return;
            }
            if (Client.cls.signon != Client.SIGNONS)
            {
                return;
            }

            // redraw with no console and the loading plaque
            Con.ClearNotify();
            CenterTimeOff = 0;
            _ConCurrent   = 0;

            _DrawLoading   = true;
            Scr.FullUpdate = 0;
            Sbar.Changed();
            UpdateScreen();
            _DrawLoading = false;

            Scr.IsDisabledForLoading = true;
            _DisabledTime            = Host.RealTime;
            Scr.FullUpdate           = 0;
        }
Ejemplo n.º 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 != ClientActivityState.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");
        }
Ejemplo n.º 3
0
        /// <summary>
        /// SCR_SetUpToDrawConsole
        /// </summary>
        static void SetUpToDrawConsole()
        {
            Con.CheckResize();

            if (_DrawLoading)
            {
                return;     // never a console with loading plaque
            }

            // decide on the height of the console
            Con.ForcedUp = (Client.Cl.worldmodel == null) || (Client.Cls.signon != Client.SIGNONS);

            if (Con.ForcedUp)
            {
                _ConLines   = _VidDef.height; // full screen
                _ConCurrent = _ConLines;
            }
            else if (Key.Destination == keydest_t.key_console)
            {
                _ConLines = _VidDef.height / 2; // half screen
            }
            else
            {
                _ConLines = 0; // none visible
            }

            if (_ConLines < _ConCurrent)
            {
                _ConCurrent -= (int)(_ConSpeed.Value * Host.FrameTime);
                if (_ConLines > _ConCurrent)
                {
                    _ConCurrent = _ConLines;
                }
            }
            else if (_ConLines > _ConCurrent)
            {
                _ConCurrent += (int)(_ConSpeed.Value * Host.FrameTime);
                if (_ConLines < _ConCurrent)
                {
                    _ConCurrent = _ConLines;
                }
            }

            if (_ClearConsole++ < _VidDef.numpages)
            {
                Sbar.Changed();
            }
            else if (ClearNotify++ < _VidDef.numpages)
            {
                //????????????
            }
            else
            {
                Con.NotifyLines = 0;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// GL_EndRendering
        /// </summary>
        public static void EndRendering()
        {
            MainForm form = MainForm.Instance;

            if (form == null)
            {
                return;
            }

            if (!SkipUpdate || BlockDrawing)
            {
                form.SwapBuffers();
            }

            // handle the mouse state
            if (!Vid.WindowedMouse)
            {
                if (_IsMouseWindowed)
                {
                    Input.DeactivateMouse();
                    Input.ShowMouse();
                    _IsMouseWindowed = false;
                }
            }
            else
            {
                _IsMouseWindowed = true;
                if (Key.Destination == keydest_t.key_game && !Input.IsMouseActive &&
                    Client.cls.state != cactive_t.ca_disconnected) // && ActiveApp)
                {
                    Input.ActivateMouse();
                    Input.HideMouse();
                }
                else if (Input.IsMouseActive && Key.Destination != keydest_t.key_game)
                {
                    Input.DeactivateMouse();
                    Input.ShowMouse();
                }
            }

            if (FullSbarDraw)
            {
                Sbar.Changed();
            }
        }
Ejemplo n.º 5
0
        // Draw_FadeScreen
        public static void FadeScreen()
        {
            GL.Enable(EnableCap.Blend);
            GL.Disable(EnableCap.Texture2D);
            GL.Color4(0, 0, 0, 0.8f);
            GL.Begin(BeginMode.Quads);

            GL.Vertex2(0f, 0f);
            GL.Vertex2(Scr.vid.width, 0f);
            GL.Vertex2((float)Scr.vid.width, (float)Scr.vid.height);
            GL.Vertex2(0f, Scr.vid.height);

            GL.End();
            GL.Color4(1f, 1f, 1f, 1f);
            GL.Enable(EnableCap.Texture2D);
            GL.Disable(EnableCap.Blend);

            Sbar.Changed();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Sbar_IntermissionOverlay
        /// called each frame after the level has been completed
        /// </summary>
        public static void IntermissionOverlay()
        {
            Scr.CopyEverithing = true;
            Scr.FullUpdate     = 0;

            if (Client.Cl.gametype == Protocol.GAME_DEATHMATCH)
            {
                Sbar.DeathmatchOverlay();
                return;
            }

            glpic_t pic = Drawer.CachePic("gfx/complete.lmp");

            Drawer.DrawPic(64, 24, pic);

            pic = Drawer.CachePic("gfx/inter.lmp");
            Drawer.DrawTransPic(0, 56, pic);

            // time
            int dig = Client.Cl.completed_time / 60;

            IntermissionNumber(160, 64, dig, 3, 0);
            int num = Client.Cl.completed_time - dig * 60;

            Drawer.DrawTransPic(234, 64, _Colon);
            Drawer.DrawTransPic(246, 64, _Nums[0, num / 10]);
            Drawer.DrawTransPic(266, 64, _Nums[0, num % 10]);

            IntermissionNumber(160, 104, Client.Cl.stats[QStats.STAT_SECRETS], 3, 0);
            Drawer.DrawTransPic(232, 104, _Slash);
            IntermissionNumber(240, 104, Client.Cl.stats[QStats.STAT_TOTALSECRETS], 3, 0);

            IntermissionNumber(160, 144, Client.Cl.stats[QStats.STAT_MONSTERS], 3, 0);
            Drawer.DrawTransPic(232, 144, _Slash);
            IntermissionNumber(240, 144, Client.Cl.stats[QStats.STAT_TOTALMONSTERS], 3, 0);
        }
Ejemplo n.º 7
0
        // SCR_CalcRefdef
        //
        // Must be called whenever vid changes
        // Internal use only
        private static void CalcRefdef()
        {
            Scr.FullUpdate        = 0; // force a background redraw
            _VidDef.recalc_refdef = false;

            // force the status bar to redraw
            Sbar.Changed();

            // bound viewsize
            if (_ViewSize.Value < 30)
            {
                Cvar.Set("viewsize", "30");
            }
            if (_ViewSize.Value > 120)
            {
                Cvar.Set("viewsize", "120");
            }

            // bound field of view
            if (_Fov.Value < 10)
            {
                Cvar.Set("fov", "10");
            }
            if (_Fov.Value > 170)
            {
                Cvar.Set("fov", "170");
            }

            // intermission is always full screen
            float size;

            if (Client.cl.intermission > 0)
            {
                size = 120;
            }
            else
            {
                size = _ViewSize.Value;
            }

            if (size >= 120)
            {
                Sbar.Lines = 0; // no status bar at all
            }
            else if (size >= 110)
            {
                Sbar.Lines = 24; // no inventory
            }
            else
            {
                Sbar.Lines = 24 + 16 + 8;
            }

            bool full = false;

            if (_ViewSize.Value >= 100.0)
            {
                full = true;
                size = 100.0f;
            }
            else
            {
                size = _ViewSize.Value;
            }

            if (Client.cl.intermission > 0)
            {
                full       = true;
                size       = 100;
                Sbar.Lines = 0;
            }
            size /= 100.0f;

            int h = _VidDef.height - Sbar.Lines;

            refdef_t rdef = Render.RefDef;

            rdef.vrect.width = (int)(_VidDef.width * size);
            if (rdef.vrect.width < 96)
            {
                size             = 96.0f / rdef.vrect.width;
                rdef.vrect.width = 96;  // min for icons
            }

            rdef.vrect.height = (int)(_VidDef.height * size);
            if (rdef.vrect.height > _VidDef.height - Sbar.Lines)
            {
                rdef.vrect.height = _VidDef.height - Sbar.Lines;
            }
            if (rdef.vrect.height > _VidDef.height)
            {
                rdef.vrect.height = _VidDef.height;
            }
            rdef.vrect.x = (_VidDef.width - rdef.vrect.width) / 2;
            if (full)
            {
                rdef.vrect.y = 0;
            }
            else
            {
                rdef.vrect.y = (h - rdef.vrect.height) / 2;
            }

            rdef.fov_x = _Fov.Value;
            rdef.fov_y = CalcFov(rdef.fov_x, rdef.vrect.width, rdef.vrect.height);

            _VRect = rdef.vrect;
        }
Ejemplo n.º 8
0
        // void SCR_UpdateScreen (void);
        // This is called every frame, and can also be called explicitly to flush
        // text to the screen.
        //
        // WARNING: be very careful calling this from elsewhere, because the refresh
        // needs almost the entire 256k of stack space!
        public static void UpdateScreen()
        {
            if (BlockDrawing || !_IsInitialized || _InUpdate)
            {
                return;
            }

            _InUpdate = true;
            try
            {
                if (MainForm.Instance != null)
                {
                    if ((MainForm.Instance.VSync == VSyncMode.On) != Vid.Wait)
                    {
                        MainForm.Instance.VSync = (Vid.Wait ? VSyncMode.On : VSyncMode.Off);
                    }
                }

                _VidDef.numpages = 2 + (int)_glTripleBuffer.Value;

                CopyTop         = false;
                _CopyEverything = false;

                if (IsDisabledForLoading)
                {
                    if ((Host.RealTime - _DisabledTime) > 60)
                    {
                        IsDisabledForLoading = false;
                        Con.Print("Load failed.\n");
                    }
                    else
                    {
                        return;
                    }
                }

                if (!Con.IsInitialized)
                {
                    return;     // not initialized yet
                }
                BeginRendering();

                //
                // determine size of refresh window
                //
                if (_OldFov != _Fov.Value)
                {
                    _OldFov = _Fov.Value;
                    _VidDef.recalc_refdef = true;
                }

                if (_OldScreenSize != _ViewSize.Value)
                {
                    _OldScreenSize        = _ViewSize.Value;
                    _VidDef.recalc_refdef = true;
                }

                if (_VidDef.recalc_refdef)
                {
                    CalcRefdef();
                }

                //
                // do 3D refresh drawing, and then update the screen
                //
                SetUpToDrawConsole();

                View.RenderView();

                Set2D();

                //
                // draw any areas not covered by the refresh
                //
                Scr.TileClear();

                if (_DrawDialog)
                {
                    Sbar.Draw();
                    Drawer.FadeScreen();
                    DrawNotifyString();
                    _CopyEverything = true;
                }
                else if (_DrawLoading)
                {
                    DrawLoading();
                    Sbar.Draw();
                }
                else if (Client.cl.intermission == 1 && Key.Destination == keydest_t.key_game)
                {
                    Sbar.IntermissionOverlay();
                }
                else if (Client.cl.intermission == 2 && Key.Destination == keydest_t.key_game)
                {
                    Sbar.FinaleOverlay();
                    CheckDrawCenterString();
                }
                else
                {
                    if (View.Crosshair > 0)
                    {
                        Drawer.DrawCharacter(_VRect.x + _VRect.width / 2, _VRect.y + _VRect.height / 2, '+');
                    }

                    DrawRam();
                    DrawNet();
                    DrawTurtle();
                    DrawPause();
                    CheckDrawCenterString();
                    Sbar.Draw();
                    DrawConsole();
                    Menu.Draw();
                }

                View.UpdatePalette();
                EndRendering();
            }
            finally
            {
                _InUpdate = false;
            }
        }
Ejemplo n.º 9
0
        private static float _LastMsg;                 // static float lastmsg from CL_KeepaliveMessage

        /// <summary>
        /// CL_ParseServerMessage
        /// </summary>
        private static void ParseServerMessage()
        {
            //
            // if recording demos, copy the message out
            //
            if (_ShowNet.Value == 1)
            {
                Con.Print("{0} ", Net.Message.Length);
            }
            else if (_ShowNet.Value == 2)
            {
                Con.Print("------------------\n");
            }

            cl.onground = false;        // unless the server says otherwise

            //
            // parse the message
            //
            Net.Reader.Reset();
            int i;

            while (true)
            {
                if (Net.Reader.IsBadRead)
                {
                    Host.Error("CL_ParseServerMessage: Bad server message");
                }

                int cmd = Net.Reader.ReadByte();
                if (cmd == -1)
                {
                    ShowNet("END OF MESSAGE");
                    return;     // end of message
                }

                // if the high bit of the command byte is set, it is a fast update
                if ((cmd & 128) != 0)
                {
                    ShowNet("fast update");
                    ParseUpdate(cmd & 127);
                    continue;
                }

                ShowNet(_SvcStrings[cmd]);

                // other commands
                switch (cmd)
                {
                default:
                    Host.Error("CL_ParseServerMessage: Illegible server message\n");
                    break;

                case Protocol.svc_nop:
                    break;

                case Protocol.svc_time:
                    cl.mtime[1] = cl.mtime[0];
                    cl.mtime[0] = Net.Reader.ReadFloat();
                    break;

                case Protocol.svc_clientdata:
                    i = Net.Reader.ReadShort();
                    ParseClientData(i);
                    break;

                case Protocol.svc_version:
                    i = Net.Reader.ReadLong();
                    if (i != Protocol.PROTOCOL_VERSION)
                    {
                        Host.Error("CL_ParseServerMessage: Server is protocol {0} instead of {1}\n", i, Protocol.PROTOCOL_VERSION);
                    }
                    break;

                case Protocol.svc_disconnect:
                    Host.EndGame("Server disconnected\n");
                    break;

                case Protocol.svc_print:
                    Con.Print(Net.Reader.ReadString());
                    break;

                case Protocol.svc_centerprint:
                    Scr.CenterPrint(Net.Reader.ReadString());
                    break;

                case Protocol.svc_stufftext:
                    Cbuf.AddText(Net.Reader.ReadString());
                    break;

                case Protocol.svc_damage:
                    View.ParseDamage();
                    break;

                case Protocol.svc_serverinfo:
                    ParseServerInfo();
                    Scr.vid.recalc_refdef = true;       // leave intermission full screen
                    break;

                case Protocol.svc_setangle:
                    cl.viewangles.X = Net.Reader.ReadAngle();
                    cl.viewangles.Y = Net.Reader.ReadAngle();
                    cl.viewangles.Z = Net.Reader.ReadAngle();
                    break;

                case Protocol.svc_setview:
                    cl.viewentity = Net.Reader.ReadShort();
                    break;

                case Protocol.svc_lightstyle:
                    i = Net.Reader.ReadByte();
                    if (i >= QDef.MAX_LIGHTSTYLES)
                    {
                        Sys.Error("svc_lightstyle > MAX_LIGHTSTYLES");
                    }
                    _LightStyle[i].map = Net.Reader.ReadString();
                    break;

                case Protocol.svc_sound:
                    ParseStartSoundPacket();
                    break;

                case Protocol.svc_stopsound:
                    i = Net.Reader.ReadShort();
                    Sound.StopSound(i >> 3, i & 7);
                    break;

                case Protocol.svc_updatename:
                    Sbar.Changed();
                    i = Net.Reader.ReadByte();
                    if (i >= cl.maxclients)
                    {
                        Host.Error("CL_ParseServerMessage: svc_updatename > MAX_SCOREBOARD");
                    }
                    cl.scores[i].name = Net.Reader.ReadString();
                    break;

                case Protocol.svc_updatefrags:
                    Sbar.Changed();
                    i = Net.Reader.ReadByte();
                    if (i >= cl.maxclients)
                    {
                        Host.Error("CL_ParseServerMessage: svc_updatefrags > MAX_SCOREBOARD");
                    }
                    cl.scores[i].frags = Net.Reader.ReadShort();
                    break;

                case Protocol.svc_updatecolors:
                    Sbar.Changed();
                    i = Net.Reader.ReadByte();
                    if (i >= cl.maxclients)
                    {
                        Host.Error("CL_ParseServerMessage: svc_updatecolors > MAX_SCOREBOARD");
                    }
                    cl.scores[i].colors = Net.Reader.ReadByte();
                    NewTranslation(i);
                    break;

                case Protocol.svc_particle:
                    Render.ParseParticleEffect();
                    break;

                case Protocol.svc_spawnbaseline:
                    i = Net.Reader.ReadShort();
                    // must use CL_EntityNum() to force cl.num_entities up
                    ParseBaseline(EntityNum(i));
                    break;

                case Protocol.svc_spawnstatic:
                    ParseStatic();
                    break;

                case Protocol.svc_temp_entity:
                    ParseTempEntity();
                    break;

                case Protocol.svc_setpause:
                {
                    cl.paused = Net.Reader.ReadByte() != 0;

                    if (cl.paused)
                    {
                        CDAudio.Pause();
                    }
                    else
                    {
                        CDAudio.Resume();
                    }
                }
                break;

                case Protocol.svc_signonnum:
                    i = Net.Reader.ReadByte();
                    if (i <= cls.signon)
                    {
                        Host.Error("Received signon {0} when at {1}", i, cls.signon);
                    }
                    cls.signon = i;
                    SignonReply();
                    break;

                case Protocol.svc_killedmonster:
                    cl.stats[QStats.STAT_MONSTERS]++;
                    break;

                case Protocol.svc_foundsecret:
                    cl.stats[QStats.STAT_SECRETS]++;
                    break;

                case Protocol.svc_updatestat:
                    i = Net.Reader.ReadByte();
                    if (i < 0 || i >= QStats.MAX_CL_STATS)
                    {
                        Sys.Error("svc_updatestat: {0} is invalid", i);
                    }
                    cl.stats[i] = Net.Reader.ReadLong();
                    break;

                case Protocol.svc_spawnstaticsound:
                    ParseStaticSound();
                    break;

                case Protocol.svc_cdtrack:
                    cl.cdtrack   = Net.Reader.ReadByte();
                    cl.looptrack = Net.Reader.ReadByte();
                    if ((cls.demoplayback || cls.demorecording) && (cls.forcetrack != -1))
                    {
                        CDAudio.Play((byte)cls.forcetrack, true);
                    }
                    else
                    {
                        CDAudio.Play((byte)cl.cdtrack, true);
                    }
                    break;

                case Protocol.svc_intermission:
                    cl.intermission       = 1;
                    cl.completed_time     = (int)cl.time;
                    Scr.vid.recalc_refdef = true;       // go to full screen
                    break;

                case Protocol.svc_finale:
                    cl.intermission       = 2;
                    cl.completed_time     = (int)cl.time;
                    Scr.vid.recalc_refdef = true;       // go to full screen
                    Scr.CenterPrint(Net.Reader.ReadString());
                    break;

                case Protocol.svc_cutscene:
                    cl.intermission       = 3;
                    cl.completed_time     = (int)cl.time;
                    Scr.vid.recalc_refdef = true;       // go to full screen
                    Scr.CenterPrint(Net.Reader.ReadString());
                    break;

                case Protocol.svc_sellscreen:
                    Cmd.ExecuteString("help", cmd_source_t.src_command);
                    break;
                }
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// CL_ParseClientdata
        /// Server information pertaining to this client only
        /// </summary>
        private static void ParseClientData(int bits)
        {
            if ((bits & Protocol.SU_VIEWHEIGHT) != 0)
            {
                cl.viewheight = Net.Reader.ReadChar();
            }
            else
            {
                cl.viewheight = Protocol.DEFAULT_VIEWHEIGHT;
            }

            if ((bits & Protocol.SU_IDEALPITCH) != 0)
            {
                cl.idealpitch = Net.Reader.ReadChar();
            }
            else
            {
                cl.idealpitch = 0;
            }

            cl.mvelocity[1] = cl.mvelocity[0];
            for (int i = 0; i < 3; i++)
            {
                if ((bits & (Protocol.SU_PUNCH1 << i)) != 0)
                {
                    Mathlib.SetComp(ref cl.punchangle, i, Net.Reader.ReadChar());
                }
                else
                {
                    Mathlib.SetComp(ref cl.punchangle, i, 0);
                }
                if ((bits & (Protocol.SU_VELOCITY1 << i)) != 0)
                {
                    Mathlib.SetComp(ref cl.mvelocity[0], i, Net.Reader.ReadChar() * 16);
                }
                else
                {
                    Mathlib.SetComp(ref cl.mvelocity[0], i, 0);
                }
            }

            // [always sent]	if (bits & SU_ITEMS)
            int i2 = Net.Reader.ReadLong();

            if (cl.items != i2)
            {   // set flash times
                Sbar.Changed();
                for (int j = 0; j < 32; j++)
                {
                    if ((i2 & (1 << j)) != 0 && (cl.items & (1 << j)) == 0)
                    {
                        cl.item_gettime[j] = (float)cl.time;
                    }
                }
                cl.items = i2;
            }

            cl.onground = (bits & Protocol.SU_ONGROUND) != 0;
            cl.inwater  = (bits & Protocol.SU_INWATER) != 0;

            if ((bits & Protocol.SU_WEAPONFRAME) != 0)
            {
                cl.stats[QStats.STAT_WEAPONFRAME] = Net.Reader.ReadByte();
            }
            else
            {
                cl.stats[QStats.STAT_WEAPONFRAME] = 0;
            }

            if ((bits & Protocol.SU_ARMOR) != 0)
            {
                i2 = Net.Reader.ReadByte();
            }
            else
            {
                i2 = 0;
            }
            if (cl.stats[QStats.STAT_ARMOR] != i2)
            {
                cl.stats[QStats.STAT_ARMOR] = i2;
                Sbar.Changed();
            }

            if ((bits & Protocol.SU_WEAPON) != 0)
            {
                i2 = Net.Reader.ReadByte();
            }
            else
            {
                i2 = 0;
            }
            if (cl.stats[QStats.STAT_WEAPON] != i2)
            {
                cl.stats[QStats.STAT_WEAPON] = i2;
                Sbar.Changed();
            }

            i2 = Net.Reader.ReadShort();
            if (cl.stats[QStats.STAT_HEALTH] != i2)
            {
                cl.stats[QStats.STAT_HEALTH] = i2;
                Sbar.Changed();
            }

            i2 = Net.Reader.ReadByte();
            if (cl.stats[QStats.STAT_AMMO] != i2)
            {
                cl.stats[QStats.STAT_AMMO] = i2;
                Sbar.Changed();
            }

            for (i2 = 0; i2 < 4; i2++)
            {
                int j = Net.Reader.ReadByte();
                if (cl.stats[QStats.STAT_SHELLS + i2] != j)
                {
                    cl.stats[QStats.STAT_SHELLS + i2] = j;
                    Sbar.Changed();
                }
            }

            i2 = Net.Reader.ReadByte();

            if (Common.GameKind == GameKind.StandardQuake)
            {
                if (cl.stats[QStats.STAT_ACTIVEWEAPON] != i2)
                {
                    cl.stats[QStats.STAT_ACTIVEWEAPON] = i2;
                    Sbar.Changed();
                }
            }
            else
            {
                if (cl.stats[QStats.STAT_ACTIVEWEAPON] != (1 << i2))
                {
                    cl.stats[QStats.STAT_ACTIVEWEAPON] = (1 << i2);
                    Sbar.Changed();
                }
            }
        }