コード例 #1
0
        public static void Pmove(pmove_t pmove)
        {
            pm          = pmove;
            pm.numtouch = 0;
            Math3D.VectorClear(pm.viewangles);
            pm.viewheight      = 0;
            pm.groundentity    = null;
            pm.watertype       = 0;
            pm.waterlevel      = 0;
            pml.groundsurface  = null;
            pml.groundcontents = 0;
            pml.origin[0]      = pm.s.origin[0] * 0.125F;
            pml.origin[1]      = pm.s.origin[1] * 0.125F;
            pml.origin[2]      = pm.s.origin[2] * 0.125F;
            pml.velocity[0]    = pm.s.velocity[0] * 0.125F;
            pml.velocity[1]    = pm.s.velocity[1] * 0.125F;
            pml.velocity[2]    = pm.s.velocity[2] * 0.125F;
            Math3D.VectorCopy(pm.s.origin, pml.previous_origin);
            pml.frametime = (pm.cmd.msec & 0xFF) * 0.001F;
            PM_ClampAngles();
            if (pm.s.pm_type == Defines.PM_SPECTATOR)
            {
                PM_FlyMove(false);
                PM_SnapPosition();
                return;
            }

            if (pm.s.pm_type >= Defines.PM_DEAD)
            {
                pm.cmd.forwardmove = 0;
                pm.cmd.sidemove    = 0;
                pm.cmd.upmove      = 0;
            }

            if (pm.s.pm_type == Defines.PM_FREEZE)
            {
                return;
            }
            PM_CheckDuck();
            if (pm.snapinitial)
            {
                PM_InitialSnapPosition();
            }
            PM_CatagorizePosition();
            if (pm.s.pm_type == Defines.PM_DEAD)
            {
                PM_DeadMove();
            }
            PM_CheckSpecialMovement();
            if (pm.s.pm_time != 0)
            {
                Int32 msec;
                msec = pm.cmd.msec >> 3;
                if (msec == 0)
                {
                    msec = 1;
                }
                if (msec >= (pm.s.pm_time & 0xFF))
                {
                    pm.s.pm_flags &= (Byte) ~(pmove_t.PMF_TIME_WATERJUMP | pmove_t.PMF_TIME_LAND | pmove_t.PMF_TIME_TELEPORT);
                    pm.s.pm_time   = 0;
                }
                else
                {
                    pm.s.pm_time = ( Byte )((pm.s.pm_time & 0xFF) - msec);
                }
            }

            if ((pm.s.pm_flags & pmove_t.PMF_TIME_TELEPORT) != 0)
            {
            }
            else if ((pm.s.pm_flags & pmove_t.PMF_TIME_WATERJUMP) != 0)
            {
                pml.velocity[2] -= pm.s.gravity * pml.frametime;
                if (pml.velocity[2] < 0)
                {
                    pm.s.pm_flags &= (Byte) ~(pmove_t.PMF_TIME_WATERJUMP | pmove_t.PMF_TIME_LAND | pmove_t.PMF_TIME_TELEPORT);
                    pm.s.pm_time   = 0;
                }

                PM_StepSlideMove();
            }
            else
            {
                PM_CheckJump();
                PM_Friction();
                if (pm.waterlevel >= 2)
                {
                    PM_WaterMove();
                }
                else
                {
                    Single[] angles = new Single[] { 0, 0, 0 };
                    Math3D.VectorCopy(pm.viewangles, angles);
                    if (angles[Defines.PITCH] > 180)
                    {
                        angles[Defines.PITCH] = angles[Defines.PITCH] - 360;
                    }
                    angles[Defines.PITCH] /= 3;
                    Math3D.AngleVectors(angles, pml.forward, pml.right, pml.up);
                    PM_AirMove();
                }
            }

            PM_CatagorizePosition();
            PM_SnapPosition();
        }
コード例 #2
0
ファイル: CL_pred.cs プロジェクト: optimus-code/Q2Sharp
        public static void PredictMovement()
        {
            if (Globals.cls.state != Defines.ca_active)
            {
                return;
            }
            if (Globals.cl_paused.value != 0F)
            {
                return;
            }
            if (Globals.cl_predict.value == 0F || (Globals.cl.frame.playerstate.pmove.pm_flags & pmove_t.PMF_NO_PREDICTION) != 0)
            {
                for (int i = 0; i < 3; i++)
                {
                    Globals.cl.predicted_angles[i] = Globals.cl.viewangles[i] + Math3D.SHORT2ANGLE(Globals.cl.frame.playerstate.pmove.delta_angles[i]);
                }

                return;
            }

            int ack     = Globals.cls.netchan.incoming_acknowledged;
            int current = Globals.cls.netchan.outgoing_sequence;

            if (current - ack >= Defines.CMD_BACKUP)
            {
                if (Globals.cl_showmiss.value != 0F)
                {
                    Com.Printf("exceeded CMD_BACKUP\\n");
                }
                return;
            }

            pmove_t pm = new pmove_t();

            pm.trace               = new AnonymousTraceAdapter();
            pm.pointcontents       = new AnonymousPointContentsAdapter();
            PMove.pm_airaccelerate = Lib.Atof(Globals.cl.configstrings[Defines.CS_AIRACCEL]);
            pm.s.Set(Globals.cl.frame.playerstate.pmove);
            int       frame = 0;
            usercmd_t cmd;

            while (++ack < current)
            {
                frame = ack & (Defines.CMD_BACKUP - 1);
                cmd   = Globals.cl.cmds[frame];
                pm.cmd.Set(cmd);
                PMove.Pmove(pm);
                Math3D.VectorCopy(pm.s.origin, Globals.cl.predicted_origins[frame]);
            }

            int oldframe = (ack - 2) & (Defines.CMD_BACKUP - 1);
            int oldz     = Globals.cl.predicted_origins[oldframe][2];
            int step     = pm.s.origin[2] - oldz;

            if (step > 63 && step < 160 && (pm.s.pm_flags & pmove_t.PMF_ON_GROUND) != 0)
            {
                Globals.cl.predicted_step      = step * 0.125F;
                Globals.cl.predicted_step_time = (int)(Globals.cls.realtime - Globals.cls.frametime * 500);
            }

            Globals.cl.predicted_origin[0] = pm.s.origin[0] * 0.125F;
            Globals.cl.predicted_origin[1] = pm.s.origin[1] * 0.125F;
            Globals.cl.predicted_origin[2] = pm.s.origin[2] * 0.125F;
            Math3D.VectorCopy(pm.viewangles, Globals.cl.predicted_angles);
        }