Esempio n. 1
0
        /// <summary>Processes each client update packet sent from the client, updating internal state.</summary>
        internal void ProcessClientUpdate(PlayerPositionUpdateClient ppuc, out SpawnAppearance sa, out PlayerPositionUpdateServer ppus)
        {
            float dist = 0, tmp;
            tmp = this.X - ppuc.XPos;
            dist += tmp * tmp;
            tmp = this.Y - ppuc.YPos;
            dist += tmp * tmp;
            dist = (float)Math.Sqrt(dist);

            // TODO: Perhaps a warp check in the future, for now just log stuff
            if (dist > 50.0f * 50.0f)
            {
                _log.WarnFormat("{0}: Large position change: {1} units", this.Name, Math.Sqrt(dist));
                _log.WarnFormat("Coords: ({0:F4}, {1:F4}, {2:F4}) -> ({3:F4}, {4:F4}, {5:F4})", this.X, this.Y, this.Z, ppuc.XPos, ppuc.YPos, ppuc.ZPos);
                _log.WarnFormat("Deltas: ({0:F2}, {1:F2}, {2:F2}) -> ({3:F2}, {4:F2}, {5:F2})", _deltaX, _deltaY, _deltaZ, ppuc.DeltaX, ppuc.DeltaY, ppuc.DeltaZ);
            }

            // TODO: proximity timer?

            _deltaX = ppuc.DeltaX;
            _deltaY = ppuc.DeltaY;
            _deltaZ = ppuc.DeltaZ;
            _deltaHeading = ppuc.DeltaHeading;
            this.Heading = ppuc.Heading;

            // TODO: tracking skill increase check

            sa = new SpawnAppearance();
            if (ppuc.YPos != this.Y || ppuc.XPos != this.X)
            {
                if (!_sneaking && !_invis)
                {
                    _hidden = false;
                    _improvedHidden = false;
                    sa = new SpawnAppearance((ushort)this.ID, 0x03, 0);
                }
            }

            ppus = new PlayerPositionUpdateServer();
            if (ppuc.YPos != this.Y || ppuc.XPos != this.X || ppuc.Heading != this.Heading || ppuc.Animation != this.Animation)
                ppus = GetSpawnUpdate();

            this.X = ppuc.XPos;
            this.Y = ppuc.YPos;
            this.Z = ppuc.ZPos;
            this.Animation = ppuc.Animation;
        }
        internal void SendStancePacket(SpawnAppearanceType appearType, Mob mob, short stanceValue, bool wholeZone, bool ignoreSelf, Client target)
        {
            SpawnAppearance sa = new SpawnAppearance((ushort)mob.ID, (ushort)appearType, (uint)stanceValue);
            EQApplicationPacket<SpawnAppearance> saPack = new EQApplicationPacket<SpawnAppearance>(AppOpCode.SpawnAppearance, sa);

            if (wholeZone)
                this.QueuePacketToClients(mob, saPack, ignoreSelf);
            else if (target != null)
                QueuePacketToClient(target, saPack, false, ZoneConnectionState.Connected);
            else if (mob is ZonePlayer)
                QueuePacketToClient(((ZonePlayer)mob).Client, saPack, false, ZoneConnectionState.Connected);
        }