Exemplo n.º 1
0
        private Packet?FilterServerPacket(Packet rawPacket)
        {
            if (rawPacket.Id == PacketDefinitions.GeneralInformationPacket.Id && rawPacket.Payload[4] == 8)
            {
                var packet = new SetMapPacket();
                packet.Deserialize(rawPacket);
                reloginInfo.MapId = packet.MapId;
            }

            return(rawPacket);
        }
Exemplo n.º 2
0
        private Packet?FilterServerPackets(Packet rawPacket)
        {
            var discardCurrentPacket = false;

            if (rawPacket.Id == PacketDefinitions.GeneralInformationPacket.Id && rawPacket.Payload[4] == 8)
            {
                var packet = new SetMapPacket();
                packet.Deserialize(rawPacket);
                player.MapId = packet.MapId;
            }

            if (rawPacket.Id != PacketDefinitions.CharacterMoveAck.Id)
            {
                return(rawPacket);
            }

            if (player.WalkRequestQueue.TryDequeue(out var walkRequest))
            {
                try
                {
                    if (walkRequest.IssuedByProxy)
                    {
                        client.PauseClient(PauseClientChoice.Pause);
                        client.DrawGamePlayer(player.PlayerId, player.BodyType,
                                              player.Location, player.Direction, player.MovementType, player.Color);
                        foreach (var mobile in UO.Mobiles)
                        {
                            if (mobile.Id != player.PlayerId)
                            {
                                UO.Client.ObjectInfo(mobile.Id, mobile.Type, mobile.Location, mobile.Color);
                            }
                        }
                        client.PauseClient(PauseClientChoice.Resume);

                        discardCurrentPacket = true;
                    }

                    if (player.Direction != walkRequest.Direction)
                    {
                        player.Direction = walkRequest.Direction;
                    }
                    else
                    {
                        player.Location = player.Location.LocationInDirection(walkRequest.Direction);
                    }

                    if (gameObjects[player.PlayerId] is Mobile updatedMobile)
                    {
                        gameObjects.UpdateObject(updatedMobile.UpdateLocation(player.Location, player.Direction, player.MovementType));
                    }
                }
                finally
                {
                    OnWalkRequestDequeued();
                }
            }

            eventJournalSource.Publish(new PlayerMoveAcceptedEvent());

            return(discardCurrentPacket ? (Packet?)null : rawPacket);
        }