Ejemplo n.º 1
0
        public static void ParseBaseline( )
        {
            entity_state_t nullstate = new entity_state_t(null);

            Int32[]        bits   = new[] { 0 };
            var            newnum = CL_ents.ParseEntityBits(bits);
            entity_state_t es     = Globals.cl_entities[newnum].baseline;

            CL_ents.ParseDelta(nullstate, es, newnum, bits[0]);
        }
Ejemplo n.º 2
0
        public static void ParseServerMessage( )
        {
            while (true)
            {
                if (Globals.net_message.readcount > Globals.net_message.cursize)
                {
                    Com.Error(Defines.ERR_FATAL, "CL_ParseServerMessage: Bad server message:");
                    break;
                }

                var cmd = MSG.ReadByte(Globals.net_message);
                if (cmd == -1)
                {
                    SHOWNET("END OF MESSAGE");
                    break;
                }

                if (Globals.cl_shownet.value >= 2)
                {
                    if (null == svc_strings[cmd])
                    {
                        Com.Printf(Globals.net_message.readcount - 1 + ":BAD CMD " + cmd + "\\n");
                    }
                    else
                    {
                        SHOWNET(svc_strings[cmd]);
                    }
                }

                switch (cmd)

                {
                default:
                    Com.Error(Defines.ERR_DROP, "CL_ParseServerMessage: Illegible server message\\n");
                    break;

                case Defines.svc_nop:
                    break;

                case Defines.svc_disconnect:
                    Com.Error(Defines.ERR_DISCONNECT, "Server disconnected\\n");
                    break;

                case Defines.svc_reconnect:
                    Com.Printf("Server disconnected, reconnecting\\n");
                    if (Globals.cls.download != null)
                    {
                        try
                        {
                            Globals.cls.download.Close();
                        }
                        catch (IOException e)
                        {
                        }

                        Globals.cls.download = null;
                    }

                    Globals.cls.state        = Defines.ca_connecting;
                    Globals.cls.connect_time = -99999;
                    break;

                case Defines.svc_print:
                    var i = MSG.ReadByte(Globals.net_message);
                    if (i == Defines.PRINT_CHAT)
                    {
                        S.StartLocalSound("misc/talk.wav");
                        Globals.con.ormask = 128;
                    }

                    Com.Printf(MSG.ReadString(Globals.net_message));
                    Globals.con.ormask = 0;
                    break;

                case Defines.svc_centerprint:
                    SCR.CenterPrint(MSG.ReadString(Globals.net_message));
                    break;

                case Defines.svc_stufftext:
                    var s = MSG.ReadString(Globals.net_message);
                    Com.DPrintf("stufftext: " + s + "\\n");
                    Cbuf.AddText(s);
                    break;

                case Defines.svc_serverdata:
                    Cbuf.Execute();
                    ParseServerData();
                    break;

                case Defines.svc_configstring:
                    ParseConfigString();
                    break;

                case Defines.svc_sound:
                    ParseStartSoundPacket();
                    break;

                case Defines.svc_spawnbaseline:
                    ParseBaseline();
                    break;

                case Defines.svc_temp_entity:
                    CL_tent.ParseTEnt();
                    break;

                case Defines.svc_muzzleflash:
                    CL_fx.ParseMuzzleFlash();
                    break;

                case Defines.svc_muzzleflash2:
                    CL_fx.ParseMuzzleFlash2();
                    break;

                case Defines.svc_download:
                    ParseDownload();
                    break;

                case Defines.svc_frame:
                    CL_ents.ParseFrame();
                    break;

                case Defines.svc_inventory:
                    CL_inv.ParseInventory();
                    break;

                case Defines.svc_layout:
                    Globals.cl.layout = MSG.ReadString(Globals.net_message);
                    break;

                case Defines.svc_playerinfo:
                case Defines.svc_packetentities:
                case Defines.svc_deltapacketentities:
                    Com.Error(Defines.ERR_DROP, "Out of place frame data");
                    break;
                }
            }

            CL_view.AddNetgraph();
            if (Globals.cls.demorecording && !Globals.cls.demowaiting)
            {
                CL.WriteDemoMessage();
            }
        }
Ejemplo n.º 3
0
        public static void RenderView(Single stereo_separation)
        {
            if (cls.state != ca_active)
            {
                return;
            }
            if (!cl.refresh_prepped)
            {
                return;
            }
            if (cl_timedemo.value != 0F)
            {
                if (cl.timedemo_start == 0)
                {
                    cl.timedemo_start = Timer.Milliseconds();
                }
                cl.timedemo_frames++;
            }

            if (cl.frame.valid && (cl.force_refdef || cl_paused.value == 0F))
            {
                cl.force_refdef = false;
                V.ClearScene();
                CL_ents.AddEntities();
                if (cl_testparticles.value != 0F)
                {
                    TestParticles();
                }
                if (cl_testentities.value != 0F)
                {
                    TestEntities();
                }
                if (cl_testlights.value != 0F)
                {
                    TestLights();
                }
                if (cl_testblend.value != 0F)
                {
                    cl.refdef.blend[0] = 1F;
                    cl.refdef.blend[1] = 0.5F;
                    cl.refdef.blend[2] = 0.25F;
                    cl.refdef.blend[3] = 0.5F;
                }

                if (stereo_separation != 0)
                {
                    Single[] tmp = new Single[3];
                    Math3D.VectorScale(cl.v_right, stereo_separation, tmp);
                    Math3D.VectorAdd(cl.refdef.vieworg, tmp, cl.refdef.vieworg);
                }

                cl.refdef.vieworg[0] += 1 / 16;
                cl.refdef.vieworg[1] += 1 / 16;
                cl.refdef.vieworg[2] += 1 / 16;
                cl.refdef.x           = scr_vrect.x;
                cl.refdef.y           = scr_vrect.y;
                cl.refdef.width       = scr_vrect.width;
                cl.refdef.height      = scr_vrect.height;
                cl.refdef.fov_y       = Math3D.CalcFov(cl.refdef.fov_x, cl.refdef.width, cl.refdef.height);
                cl.refdef.time        = cl.time * 0.001F;
                cl.refdef.areabits    = cl.frame.areabits;
                if (cl_add_entities.value == 0F)
                {
                    r_numentities = 0;
                }
                if (cl_add_particles.value == 0F)
                {
                    r_numparticles = 0;
                }
                if (cl_add_lights.value == 0F)
                {
                    r_numdlights = 0;
                }
                if (cl_add_blend.value == 0)
                {
                    Math3D.VectorClear(cl.refdef.blend);
                }

                cl.refdef.num_entities  = r_numentities;
                cl.refdef.entities      = r_entities;
                cl.refdef.num_particles = r_numparticles;
                cl.refdef.num_dlights   = r_numdlights;
                cl.refdef.dlights       = r_dlights;
                cl.refdef.lightstyles   = r_lightstyles;
                cl.refdef.rdflags       = cl.frame.playerstate.rdflags;
            }

            re.RenderFrame(cl.refdef);
            if (cl_stats.value != 0F)
            {
                Com.Printf("ent:%i  lt:%i  part:%i\\n", r_numentities, r_numdlights, r_numparticles);
            }
            if (log_stats.value != 0F && (log_stats_file != null))
            {
                try
                {
                    log_stats_file.Write(r_numentities + "," + r_numdlights + "," + r_numparticles);
                }
                catch (Exception e)
                {
                }
            }

            SCR.AddDirtyPoint(scr_vrect.x, scr_vrect.y);
            SCR.AddDirtyPoint(scr_vrect.x + scr_vrect.width - 1, scr_vrect.y + scr_vrect.height - 1);
            SCR.DrawCrosshair();
        }