Beispiel #1
0
        void UpdatePosition()
        {
            if (movement)
            {
                double scale = Math.Ceiling(Server.updateTimer.Interval / 25.0);
                int    steps = movementSpeed * (int)scale;
                for (int i = 0; i < steps; i++)
                {
                    DoMove();
                }
            }

            byte[] packet = Entities.GetPositionPacket(this);
            oldpos = pos; oldrot = rot;
            if (packet == null)
            {
                return;
            }

            Player[] players = PlayerInfo.Online.Items;
            foreach (Player p in players)
            {
                if (p.level == level)
                {
                    p.Send(packet);
                }
            }
        }
Beispiel #2
0
        unsafe static void UpdatePosition(Player p)
        {
            Player[] players = PlayerInfo.Online.Items;
            byte *   src     = stackalloc byte[10 * 256]; // 10 = size of absolute update
            byte *   ptr     = src;

            foreach (Player pl in players)
            {
                if (p == pl || p.level != pl.level || !CanSeeEntity(p, pl))
                {
                    continue;
                }
                byte pitch = p.hasChangeModel ? MakePitch(pl) : MakeClassicPitch(pl);
                Entities.GetPositionPacket(ref ptr, pl.id, pl.tempPos, pl.oldpos, pl.rot, pl.oldrot, pitch);
            }

            int count = (int)(ptr - src);

            if (count == 0)
            {
                return;
            }
            byte[] packet = new byte[count];
            for (int i = 0; i < packet.Length; i++)
            {
                packet[i] = src[i];
            }
            p.Send(packet);
        }
Beispiel #3
0
        void UpdatePosition()
        {
            //pingDelayTimer.Stop();
            byte[] packet = Entities.GetPositionPacket(id, pos, oldpos, rot,
                                                       oldrot, MakePitch(), false);
            if (packet == null)
            {
                return;
            }
            byte[] oldPacket = null;

            Player[] players = PlayerInfo.Online.Items;
            foreach (Player p in players)
            {
                if (p == this || p.level != level)
                {
                    continue;
                }

                // For clients that don't support ChangeModel, we still need to provide
                // some visual indication that they are infected.
                if (!p.hasChangeModel && oldPacket == null)
                {
                    oldPacket = Entities.GetPositionPacket(id, pos, oldpos, rot,
                                                           oldrot, MakeClassicPitch(), false);
                }
                p.SendRaw(p.hasChangeModel ? packet : oldPacket);
            }
            oldpos = pos; oldrot = rot;
        }
Beispiel #4
0
        static void UpdatePosition(Player p)
        {
            //pingDelayTimer.Stop();
            byte[] packet = Entities.GetPositionPacket(p.id, p.pos, p.oldpos, p.rot,
                                                       p.oldrot, MakePitch(p), false);
            if (packet == null)
            {
                return;
            }
            byte[] oldPacket = null;

            Player[] players = PlayerInfo.Online.Items;
            foreach (Player pl in players)
            {
                if (pl == p || pl.level != p.level || !CanSeeEntity(pl, p))
                {
                    continue;
                }

                // For clients that don't support ChangeModel, we still need to provide
                // some visual indication that they are infected.
                if (!pl.hasChangeModel && oldPacket == null)
                {
                    oldPacket = Entities.GetPositionPacket(p.id, p.pos, p.oldpos, p.rot,
                                                           p.oldrot, MakeClassicPitch(p), false);
                }
                pl.SendRaw(pl.hasChangeModel ? packet : oldPacket);
            }
            p.oldpos = p.pos; p.oldrot = p.rot;
        }
Beispiel #5
0
        unsafe static void UpdatePosition(Player p)
        {
            Player[] players = PlayerInfo.Online.Items;
            byte *   src     = stackalloc byte[16 * 256]; // 16 = size of absolute update, with extended positions
            byte *   ptr     = src;

            foreach (Player pl in players)
            {
                if (p == pl || p.level != pl.level || !p.CanSeeEntity(pl))
                {
                    continue;
                }

                Orientation rot = pl.Rot;
                rot.HeadX = p.hasChangeModel ? MakePitch(pl, rot.HeadX) : MakeClassicPitch(pl, rot.HeadX);
                Entities.GetPositionPacket(ref ptr, pl.id, pl.hasExtPositions, p.hasExtPositions,
                                           pl.tempPos, pl.lastPos, rot, pl.lastRot);
            }

            int count = (int)(ptr - src);

            if (count == 0)
            {
                return;
            }

            byte[] packet = new byte[count];
            for (int i = 0; i < packet.Length; i++)
            {
                packet[i] = src[i];
            }
            p.Send(packet);
        }
Beispiel #6
0
        unsafe static void UpdatePositions(Level lvl)
        {
            byte *src = stackalloc byte[16 * 256]; // 16 = size of absolute update, with extended positions
            byte *ext = stackalloc byte[16 * 256];
            byte *ptrSrc = src, ptrExt = ext;

            PlayerBot[] bots = lvl.Bots.Items;
            for (int i = 0; i < bots.Length; i++)
            {
                PlayerBot bot = bots[i];
                if (bot.movement)
                {
                    bot.PerformMovement();
                }
                Position pos = bot.Pos; Orientation rot = bot.Rot;

                Entities.GetPositionPacket(ref ptrSrc, bot.id, true, false,
                                           pos, bot.lastPos, rot, bot.lastRot);
                Entities.GetPositionPacket(ref ptrExt, bot.id, true, true,
                                           pos, bot.lastPos, rot, bot.lastRot);
                bot.lastPos = pos; bot.lastRot = rot;
            }

            int countSrc = (int)(ptrSrc - src);

            if (countSrc == 0)
            {
                return;
            }
            int countExt = (int)(ptrExt - ext);

            byte[] srcPacket = new byte[countSrc];
            byte[] extPacket = new byte[countExt];
            for (int i = 0; i < srcPacket.Length; i++)
            {
                srcPacket[i] = src[i];
            }
            for (int i = 0; i < extPacket.Length; i++)
            {
                extPacket[i] = ext[i];
            }

            Player[] players = PlayerInfo.Online.Items;
            foreach (Player p in players)
            {
                if (p.level != lvl)
                {
                    continue;
                }
                byte[] packet = p.hasExtPositions ? extPacket : srcPacket;
                p.Send(packet);
            }
        }
Beispiel #7
0
        unsafe static void UpdatePosition(Player p)
        {
            Player[] players = PlayerInfo.Online.Items;
            byte *   src     = stackalloc byte[16 * 256]; // 16 = size of absolute update, with extended positions
            byte *   ptr     = src;

            foreach (Player pl in players)
            {
                if (p == pl || p.level != pl.level || !p.CanSeeEntity(pl))
                {
                    continue;
                }

                Orientation rot = pl.Rot; byte pitch = rot.HeadX;
                if (Server.flipHead || p.flipHead)
                {
                    pitch = FlippedPitch(pitch);
                }

                // flip head when infected, but doesn't support model
                if (!p.hasChangeModel)
                {
                    ZSData data = ZSGame.TryGet(p);
                    if (data != null && data.Infected)
                    {
                        pitch = FlippedPitch(pitch);
                    }
                }

                rot.HeadX = pitch;
                Entities.GetPositionPacket(ref ptr, pl.id, pl.hasExtPositions, p.hasExtPositions,
                                           pl.tempPos, pl.lastPos, rot, pl.lastRot);
            }

            int count = (int)(ptr - src);

            if (count == 0)
            {
                return;
            }

            byte[] packet = new byte[count];
            for (int i = 0; i < packet.Length; i++)
            {
                packet[i] = src[i];
            }
            p.Send(packet);
        }
Beispiel #8
0
        void UpdatePosition()
        {
            byte[] packet = Entities.GetPositionPacket(id, pos, oldpos, rot, oldrot, rot[1], true);
            oldpos = pos; oldrot = rot;
            if (packet == null)
            {
                return;
            }

            Player[] players = PlayerInfo.Online.Items;
            foreach (Player p in players)
            {
                if (p.level == level)
                {
                    p.SendRaw(packet);
                }
            }
        }