Exemplo n.º 1
0
        public static void PrepRefresh()
        {
            string mapname;
            int    i;
            string name;
            float  rotate;

            float[] axis = new float[3];
            if ((i = Globals.cl.configstrings[Defines.CS_MODELS + 1].Length) == 0)
            {
                return;
            }
            SCR.AddDirtyPoint(0, 0);
            SCR.AddDirtyPoint(Globals.viddef.GetWidth() - 1, Globals.viddef.GetHeight() - 1);
            mapname = Globals.cl.configstrings[Defines.CS_MODELS + 1].Substring(5, i - 4);
            Com.Printf("Map: " + mapname + "\\r");
            SCR.UpdateScreen();
            Globals.re.BeginRegistration(mapname);
            Com.Printf("                                     \\r");
            Com.Printf("pics\\r");
            SCR.UpdateScreen();
            SCR.TouchPics();
            Com.Printf("                                     \\r");
            CL_tent.RegisterTEntModels();
            num_cl_weaponmodels = 1;
            cl_weaponmodels[0]  = "weapon.md2";
            for (i = 1; i < Defines.MAX_MODELS && Globals.cl.configstrings[Defines.CS_MODELS + i].Length != 0; i++)
            {
                name = new string (Globals.cl.configstrings[Defines.CS_MODELS + i]);
                if (name.Length > 37)
                {
                    name = name.Substring(0, 36);
                }
                if (name[0] != '*')
                {
                    Com.Printf(name + "\\r");
                }
                SCR.UpdateScreen();
                CoreSys.SendKeyEvents();
                if (name[0] == '#')
                {
                    if (num_cl_weaponmodels < Defines.MAX_CLIENTWEAPONMODELS)
                    {
                        cl_weaponmodels[num_cl_weaponmodels] = Globals.cl.configstrings[Defines.CS_MODELS + i].Substring(1);
                        num_cl_weaponmodels++;
                    }
                }
                else
                {
                    Globals.cl.model_draw[i] = Globals.re.RegisterModel(Globals.cl.configstrings[Defines.CS_MODELS + i]);
                    if (name[0] == '*')
                    {
                        Globals.cl.model_clip[i] = CM.InlineModel(Globals.cl.configstrings[Defines.CS_MODELS + i]);
                    }
                    else
                    {
                        Globals.cl.model_clip[i] = null;
                    }
                }

                if (name[0] != '*')
                {
                    Com.Printf("                                     \\r");
                }
            }

            Com.Printf("images\\r");
            SCR.UpdateScreen();
            for (i = 1; i < Defines.MAX_IMAGES && Globals.cl.configstrings[Defines.CS_IMAGES + i].Length > 0; i++)
            {
                Globals.cl.image_precache[i] = Globals.re.RegisterPic(Globals.cl.configstrings[Defines.CS_IMAGES + i]);
                CoreSys.SendKeyEvents();
            }

            Com.Printf("                                     \\r");
            for (i = 0; i < Defines.MAX_CLIENTS; i++)
            {
                if (Globals.cl.configstrings[Defines.CS_PLAYERSKINS + i].Length == 0)
                {
                    continue;
                }
                Com.Printf("client " + i + '\\');
                SCR.UpdateScreen();
                CoreSys.SendKeyEvents();
                CL_parse.ParseClientinfo(i);
                Com.Printf("                                     \\r");
            }

            CL_parse.LoadClientinfo(Globals.cl.baseclientinfo, "unnamed\\\\male/grunt");
            Com.Printf("sky\\r");
            SCR.UpdateScreen();
            rotate = float.Parse(Globals.cl.configstrings[Defines.CS_SKYROTATE]);
            StringTokenizer st = new StringTokenizer(Globals.cl.configstrings[Defines.CS_SKYAXIS]);

            st.MoveNext();
            axis[0] = float.Parse(st.Current);
            st.MoveNext();
            axis[1] = float.Parse(st.Current);
            st.MoveNext();
            axis[2] = float.Parse(st.Current);
            Globals.re.SetSky(Globals.cl.configstrings[Defines.CS_SKY], rotate, axis);
            Com.Printf("                                     \\r");
            Globals.re.EndRegistration();
            Con.ClearNotify();
            SCR.UpdateScreen();
            Globals.cl.refresh_prepped = true;
            Globals.cl.force_refdef    = true;
        }
Exemplo n.º 2
0
        public static void ParseFrame( )
        {
            Int32   cmd;
            Int32   len;
            frame_t old;

            Globals.cl.frame.Reset();
            Globals.cl.frame.serverframe = MSG.ReadLong(Globals.net_message);
            Globals.cl.frame.deltaframe  = MSG.ReadLong(Globals.net_message);
            Globals.cl.frame.servertime  = Globals.cl.frame.serverframe * 100;
            if (Globals.cls.serverProtocol != 26)
            {
                Globals.cl.surpressCount = MSG.ReadByte(Globals.net_message);
            }
            if (Globals.cl_shownet.value == 3)
            {
                Com.Printf("   frame:" + Globals.cl.frame.serverframe + "  delta:" + Globals.cl.frame.deltaframe + "\\n");
            }
            if (Globals.cl.frame.deltaframe <= 0)
            {
                Globals.cl.frame.valid = true;
                old = null;
                Globals.cls.demowaiting = false;
            }
            else
            {
                old = Globals.cl.frames[Globals.cl.frame.deltaframe & Defines.UPDATE_MASK];
                if (!old.valid)
                {
                    Com.Printf("Delta from invalid frame (not supposed to happen!).\\n");
                }

                if (old.serverframe != Globals.cl.frame.deltaframe)
                {
                    Com.Printf("Delta frame too old.\\n");
                }
                else if (Globals.cl.parse_entities - old.parse_entities > Defines.MAX_PARSE_ENTITIES - 128)
                {
                    Com.Printf("Delta parse_entities too old.\\n");
                }
                else
                {
                    Globals.cl.frame.valid = true;
                }
            }

            if (Globals.cl.time > Globals.cl.frame.servertime)
            {
                Globals.cl.time = Globals.cl.frame.servertime;
            }
            else if (Globals.cl.time < Globals.cl.frame.servertime - 100)
            {
                Globals.cl.time = Globals.cl.frame.servertime - 100;
            }
            len = MSG.ReadByte(Globals.net_message);
            MSG.ReadData(Globals.net_message, Globals.cl.frame.areabits, len);
            cmd = MSG.ReadByte(Globals.net_message);
            CL_parse.SHOWNET(CL_parse.svc_strings[cmd]);
            if (cmd != Defines.svc_playerinfo)
            {
                Com.Error(Defines.ERR_DROP, "CL_ParseFrame: not playerinfo");
            }
            ParsePlayerstate(old, Globals.cl.frame);
            cmd = MSG.ReadByte(Globals.net_message);
            CL_parse.SHOWNET(CL_parse.svc_strings[cmd]);
            if (cmd != Defines.svc_packetentities)
            {
                Com.Error(Defines.ERR_DROP, "CL_ParseFrame: not packetentities");
            }
            ParsePacketEntities(old, Globals.cl.frame);
            Globals.cl.frames[Globals.cl.frame.serverframe & Defines.UPDATE_MASK].Set(Globals.cl.frame);
            if (Globals.cl.frame.valid)
            {
                if (Globals.cls.state != Defines.ca_active)
                {
                    Globals.cls.state              = Defines.ca_active;
                    Globals.cl.force_refdef        = true;
                    Globals.cl.predicted_origin[0] = Globals.cl.frame.playerstate.pmove.origin[0] * 0.125F;
                    Globals.cl.predicted_origin[1] = Globals.cl.frame.playerstate.pmove.origin[1] * 0.125F;
                    Globals.cl.predicted_origin[2] = Globals.cl.frame.playerstate.pmove.origin[2] * 0.125F;
                    Math3D.VectorCopy(Globals.cl.frame.playerstate.viewangles, Globals.cl.predicted_angles);
                    if (Globals.cls.disable_servercount != Globals.cl.servercount && Globals.cl.refresh_prepped)
                    {
                        SCR.EndLoadingPlaque();
                    }
                }

                Globals.cl.sound_prepped = true;
                FireEntityEvents(Globals.cl.frame);
                CL_pred.CheckPredictionError();
            }
        }