Пример #1
0
        public static void UpdateViewAngles(ref Common.PlayerState ps, Input.UserCommand cmd)
        {
            if (ps.pm_type == Common.PMType.INTERMISSION || ps.pm_type == Common.PMType.SPINTERMISSION)
            {
                return;
            }

            //if (ps.pm_type != Common.PMType.SPECTATOR )//&& ps.stats[0] <= 0)
            //{
            //    return;
            //}

            // circularly clamp the angles with deltas
            short temp = (short)(cmd.anglex + ps.delta_angles[0]);
            // don't let the player look up or down more than 90 degrees
            if (temp > 16000)
            {
                ps.delta_angles[0] = 16000 - cmd.anglex;
                temp = 16000;
            }
            else if (temp < -16000)
            {
                ps.delta_angles[0] = -16000 - cmd.anglex;
                temp = -16000;
            }

            ps.viewangles[0] = temp * (360.0f / 65536);
            temp = (short)(cmd.angley + ps.delta_angles[1]);
            ps.viewangles[1] = temp * (360.0f / 65536);
            temp = (short)(cmd.anglez + ps.delta_angles[2]);
            ps.viewangles[2] = temp * (360.0f / 65536);
            //Common.Instance.WriteLine(ps.viewangles[0] + "\t:\t" + ps.viewangles[1]);
        }
Пример #2
0
        void ClientThink(client_t cl, Input.UserCommand cmd)
        {
            cl.lastUsercmd = cmd;

            if (cl.state != clientState_t.CS_ACTIVE)
                return; // may have been kicked during the last usercmd

            Game.Instance.Client_Think(cl.id);
        }
Пример #3
0
        void ClientEnterWorld(client_t cl, Input.UserCommand cmd)
        {
            Common.Instance.WriteLine("Going from PRIMED to ACTIVE for {0}", cl.name);
            cl.state = clientState_t.CS_ACTIVE;

            // resend all configstrings using the cs commands since these are
            // no longer sent when the client is CS_PRIMED
            UpdateConfigStrings(cl);

            // set up the entity for the client
            int clientNum = cl.id;
            sharedEntity ent = sv.gentities[clientNum];
            ent.s.number = clientNum;
            cl.gentity = ent;

            cl.deltaMessage = -1;
            cl.nextSnapshotTime = (int)time; // generate a snapshot immediately
            cl.lastUsercmd = cmd;

            Game.Instance.Client_Begin(clientNum);
        }
Пример #4
0
        void SpectatorThink(gentity_t ent, Input.UserCommand ucmd)
        {
            gclient_t client = ent.client;
            if (client.sess.spectatorState != spectatorState_t.SPECTATOR_FOLLOW)
            {
                client.ps.pm_type = Common.PMType.SPECTATOR;
                client.ps.speed = sv_speed.Integer;  // faster than normal

                // set up for pmove
                pmove_t pm = new pmove_t();
                pm.Trace = new TraceDelegate(Server.Instance.SV_Trace);
                pm.ps = client.ps;
                pm.cmd = ucmd;
                pm.tracemask = (int)(brushflags.CONTENTS_SOLID | brushflags.CONTENTS_MOVEABLE | brushflags.CONTENTS_SLIME | brushflags.CONTENTS_OPAQUE);
                pm.pmove_fixed = CVars.Instance.VariableIntegerValue("pmove_fixed");
                pm.pmove_msec = CVars.Instance.VariableIntegerValue("pmove_msec");
                //pm.Trace += new TraceDelegate(Server.Instance.Trace);
                //pm.PointContents += new TraceContentsDelegate(Server.Instance.PointContents);
                pm.mins = Common.playerMins;
                pm.maxs = Common.playerMaxs;
                // perform a pmove
                Common.Instance.Pmove(pm);
                //if(!pm.ps.velocity.Equals(Vector3.Zero))
                //Common.Instance.WriteLine("vel: {0}", pm.ps.velocity);
                // save results of pmove
                ent.s.origin = client.ps.origin;

                Server.Instance.UnlinkEntity(GEntityToSharedEntity(ent));
            }
            client.oldbuttons = client.buttons;
            client.buttons = ucmd.buttons;
        }