Ejemplo n.º 1
0
        private static void ExtendedPacket( PacketReader p, PacketHandlerEventArgs args )
        {
            ushort type = p.ReadUInt16();

            switch ( type )
            {
                case 0x04: // close gump
                {
                    // int serial, int tid
                    if ( World.Player != null )
                        World.Player.HasGump = false;
                    break;
                }
                case 0x06: // party messages
                {
                    OnPartyMessage( p, args );
                    break;
                }
                case 0x08: // map change
                {
                    if ( World.Player != null )
                        World.Player.Map = p.ReadByte();
                    break;
                }
                case 0x14: // context menu
                {
                    p.ReadInt16(); // 0x01
                    UOEntity ent = null;
                    Serial ser = p.ReadUInt32();
                    if ( ser.IsMobile )
                        ent = World.FindMobile( ser );
                    else if ( ser.IsItem )
                        ent = World.FindItem( ser );

                    if ( ent != null )
                    {
                        byte count = p.ReadByte();

                        try
                        {
                            ent.ContextMenu.Clear();

                            for(int i=0;i<count;i++)
                            {
                                ushort idx = p.ReadUInt16();
                                ushort num = p.ReadUInt16();
                                ushort flags = p.ReadUInt16();
                                ushort color = 0;

                                if ( (flags&0x02) != 0 )
                                    color = p.ReadUInt16();

                                ent.ContextMenu.Add( idx, num );
                            }
                        }
                        catch
                        {
                        }
                    }
                    break;
                }
                case 0x18: // map patches
                {
                    if ( World.Player != null )
                    {
                        int count = p.ReadInt32() * 2;
                        try
                        {
                            World.Player.MapPatches = new int[count];
                            for(int i=0;i<count;i++)
                                World.Player.MapPatches[i] = p.ReadInt32();
                        }
                        catch
                        {
                        }
                    }
                    break;
                }
                case 0x19: //  stat locks
                {
                    if ( p.ReadByte() == 0x02 )
                    {
                        Mobile m = World.FindMobile( p.ReadUInt32() );
                        if ( World.Player == m && m != null )
                        {
                            p.ReadByte();// 0?

                            byte locks = p.ReadByte();

                            World.Player.StrLock = (LockType)((locks>>4) & 3);
                            World.Player.DexLock = (LockType)((locks>>2) & 3);
                            World.Player.IntLock = (LockType)(locks & 3);
                        }
                    }
                    break;
                }
                case 0x1D: // Custom House "General Info"
                {
                    Item i = World.FindItem( p.ReadUInt32() );
                    if ( i != null )
                        i.HouseRevision = p.ReadInt32();
                    break;
                }
            }
        }
Ejemplo n.º 2
0
 private static void ServerChange( PacketReader p, PacketHandlerEventArgs args )
 {
     if ( World.Player != null )
         World.Player.Position = new Point3D( p.ReadUInt16(), p.ReadUInt16(), p.ReadInt16() );
 }
Ejemplo n.º 3
0
        private static void DropRequest( PacketReader p, PacketHandlerEventArgs args )
        {
            Serial iser = p.ReadUInt32();
            int x = p.ReadInt16();
            int y = p.ReadInt16();
            int z = p.ReadSByte();
            if ( Engine.UsePostKRPackets )
                /* grid num */p.ReadByte();
            Point3D newPos = new Point3D( x, y, z );
            Serial dser = p.ReadUInt32();

            if ( Macros.MacroManager.AcceptActions )
                MacroManager.Action( new DropAction( dser, newPos ) );

            Item i = World.FindItem( iser );
            if ( i == null )
                return;

            Item dest = World.FindItem( dser );
            if ( dest != null && dest.IsContainer && World.Player != null && ( dest.IsChildOf( World.Player.Backpack ) || dest.IsChildOf( World.Player.Quiver ) ) )
                i.IsNew = true;

            if ( Config.GetBool( "QueueActions" ) )
                args.Block = DragDropManager.Drop( i, dser, newPos );
        }
Ejemplo n.º 4
0
        private static void MobileStatus( PacketReader p, PacketHandlerEventArgs args )
        {
            Serial serial = p.ReadUInt32();
            Mobile m = World.FindMobile( serial );
            if ( m == null )
                World.AddMobile( m = new Mobile( serial ) );

            m.Name = p.ReadString( 30 );

            m.Hits = p.ReadUInt16();
            m.HitsMax = p.ReadUInt16();

            p.ReadBoolean();//CanBeRenamed

            byte type = p.ReadByte();

            if ( m == World.Player && type != 0x00 )
            {
                PlayerData player = (PlayerData)m;

                player.Female = p.ReadBoolean();

                int oStr = player.Str, oDex = player.Dex, oInt = player.Int;

                player.Str = p.ReadUInt16();
                player.Dex = p.ReadUInt16();
                player.Int = p.ReadUInt16();

                if ( player.Str != oStr && oStr != 0 && Config.GetBool( "DisplaySkillChanges" ) )
                    World.Player.SendMessage( MsgLevel.Force, LocString.StrChanged, player.Str - oStr > 0 ? "+" : "", player.Str - oStr, player.Str );

                if ( player.Dex != oDex && oDex != 0 && Config.GetBool( "DisplaySkillChanges" ) )
                    World.Player.SendMessage( MsgLevel.Force, LocString.DexChanged, player.Dex - oDex > 0 ? "+" : "", player.Dex - oDex, player.Dex );

                if ( player.Int != oInt && oInt != 0 && Config.GetBool( "DisplaySkillChanges" ) )
                    World.Player.SendMessage( MsgLevel.Force, LocString.IntChanged, player.Int - oInt > 0 ? "+" : "", player.Int - oInt, player.Int );

                player.Stam = p.ReadUInt16();
                player.StamMax = p.ReadUInt16();
                player.Mana = p.ReadUInt16();
                player.ManaMax = p.ReadUInt16();

                player.Gold = p.ReadUInt32();
                player.AR = p.ReadUInt16(); // ar / physical resist
                player.Weight = p.ReadUInt16();

                if ( type >= 0x03 )
                {
                    if ( type > 0x04 )
                    {
                        player.MaxWeight = p.ReadUInt16();

                        p.ReadByte(); // race?
                    }

                    player.StatCap = p.ReadUInt16();

                    if ( type > 0x03 )
                    {
                        player.Followers = p.ReadByte();
                        player.FollowersMax = p.ReadByte();

                        player.FireResistance = p.ReadInt16();
                        player.ColdResistance = p.ReadInt16();
                        player.PoisonResistance = p.ReadInt16();
                        player.EnergyResistance = p.ReadInt16();

                        player.Luck = p.ReadInt16();

                        player.DamageMin = p.ReadUInt16();
                        player.DamageMax = p.ReadUInt16();

                        player.Tithe = p.ReadInt32();
                    }
                }

                ClientCommunication.RequestTitlebarUpdate();

                ClientCommunication.PostHitsUpdate();
                ClientCommunication.PostStamUpdate();
                ClientCommunication.PostManaUpdate();

                Engine.MainWindow.UpdateTitle(); // update player name
            }
        }
Ejemplo n.º 5
0
        private static void RunUOProtocolExtention(PacketReader p, PacketHandlerEventArgs args)
        {
            args.Block = true;

            switch (p.ReadByte())
            {
                case 1: // Custom Party information
                {
                    Serial serial;

                    PacketHandlers.SpecialPartyReceived++;

                    while ((serial = p.ReadUInt32()) > 0)
                    {
                        Mobile mobile = World.FindMobile(serial);

                        short x = p.ReadInt16();
                        short y = p.ReadInt16();
                        byte map = p.ReadByte();

                        if (mobile == null)
                        {
                            World.AddMobile( mobile = new Mobile(serial) );
                            mobile.Visible = false;
                        }

                        if ( mobile.Name == null || mobile.Name.Length <= 0 )
                            mobile.Name = "(Not Seen)";

                        if ( !m_Party.Contains( serial ) )
                            m_Party.Add( serial );

                        if ( map == World.Player.Map )
                            mobile.Position = new Point3D(x, y, mobile.Position.Z);
                        else
                            mobile.Position = Point3D.Zero;
                    }

                    if (Engine.MainWindow.MapWindow != null)
                        Engine.MainWindow.MapWindow.UpdateMap();

                    break;
                }
                case 0xFE: // Begin Handshake/Features Negotiation
                {
                    ulong features = p.ReadRawUInt64();

                    if ( ClientCommunication.HandleNegotiate( features ) != 0 )
                    {
                        ClientCommunication.SendToServer( new RazorNegotiateResponse() );
                        Engine.MainWindow.UpdateControlLocks();
                    }
                    break;
                }
            }
        }
Ejemplo n.º 6
0
        private static void LoginConfirm( PacketReader p, PacketHandlerEventArgs args )
        {
            World.Items.Clear();
            World.Mobiles.Clear();

            UseNewStatus = false;

            Serial serial = p.ReadUInt32();

            PlayerData m = new PlayerData( serial );
            m.Name = World.OrigPlayerName;

            Mobile test = World.FindMobile( serial );
            if ( test != null )
                test.Remove();

            World.AddMobile( World.Player = m );
            Config.LoadProfileFor( World.Player );

            PlayerData.ExternalZ = false;

            p.ReadUInt32(); // always 0?
            m.Body = p.ReadUInt16();
            m.Position = new Point3D( p.ReadUInt16(), p.ReadUInt16(), p.ReadInt16() );
            m.Direction = (Direction)p.ReadByte();
            m.Resync();

            //ClientCommunication.SendToServer( new SkillsQuery( m ) );
            //ClientCommunication.SendToServer( new StatusQuery( m ) );

            ClientCommunication.RequestTitlebarUpdate();
            ClientCommunication.PostLogin( (int)serial.Value );
            Engine.MainWindow.UpdateTitle(); // update player name & shard name
            /*
            //the rest of the packet: (total length: 37)
            m_Stream.Write( (byte) 0 );
            m_Stream.Write( (int) -1 );

            m_Stream.Write( (short) 0 );
            m_Stream.Write( (short) 0 );
            m_Stream.Write( (short) (map==null?6144:map.Width) );
            m_Stream.Write( (short) (map==null?4096:map.Height) );

            Stream.Fill();
            */

            ClientCommunication.BeginCalibratePosition();
        }
Ejemplo n.º 7
0
        private static void DropRequest(PacketReader p, PacketHandlerEventArgs args)
        {
            Serial serial = p.ReadUInt32();
            int x = p.ReadInt16();
            int y = p.ReadInt16();
            int z = p.ReadSByte();
            Item container = World.FindItem(p.ReadUInt32());

            if (items.ContainsKey(serial))
            {
                args.Block = true;
                FakeItem fake = items[serial];
                if (container == World.Player.Backpack)
                    fake.Position = new Point3D(x, y, z);
                else
                    foreach (Serial s in fake.List.Take(lifting))
                        DragDrop.Move(World.FindItem(s), container);
                lifting = 0;
                Resend();
            }
            else
                args.Block = PacketHandler.ProcessViewers(dropRequest, p);
        }
Ejemplo n.º 8
0
        private void ImportObjects(string[] args, int length, string full, Client client)
        {
            string zone = args[1];
            string folder = args[2];

            var packetList = Directory.GetFiles(folder);
            Array.Sort(packetList);

            List<GameObject> newObjects = new List<GameObject>();
            foreach (var path in packetList)
            {
                var data = File.ReadAllBytes(path);
                PacketReader reader = new PacketReader(data);
                PacketHeader header = reader.ReadStruct<PacketHeader>();
                if (header.Type != 0x8 || header.Subtype != 0xB)
                {
                    Logger.WriteWarning("[WRN] File {0} not an Object spawn packet, skipping.", path);
                    continue;
                }

                GameObject newObj = new GameObject();
                newObj.ObjectID = (int)reader.ReadStruct<ObjectHeader>().ID;
                var pos = reader.ReadEntityPosition();
                newObj.RotX = pos.RotX;
                newObj.RotY = pos.RotY;
                newObj.RotZ = pos.RotZ;
                newObj.RotW = pos.RotW;

                newObj.PosX = pos.PosX;
                newObj.PosY = pos.PosY;
                newObj.PosZ = pos.PosZ;
                reader.ReadInt16();
                newObj.ObjectName = reader.ReadFixedLengthAscii(0x2C);
                var objHeader = reader.ReadStruct<ObjectHeader>(); // Seems to always be blank...
                if (objHeader.ID != 0)
                    Logger.WriteWarning("[OBJ] It seems object {0} has a nonzero objHeader! ({1}) Investigate.", newObj.ObjectName, objHeader.ID);
                newObj.ZoneName = zone;
                var thingCount = reader.ReadUInt32();
                newObj.ObjectFlags = new byte[thingCount * 4];
                for (int i = 0; i < thingCount; i++)
                {
                    Buffer.BlockCopy(BitConverter.GetBytes(reader.ReadUInt32()), 0, newObj.ObjectFlags, i * 4, 4); // This should work
                }
                newObjects.Add(newObj);
                Logger.WriteInternal("[OBJ] Adding new Object {0} to the database for zone {1}", newObj.ObjectName, zone);
            }

            using (var db = new PolarisEf())
            {
                db.GameObjects.AddRange(newObjects);
                db.SaveChanges();
            }
        }
Ejemplo n.º 9
0
        private void ImportNPCs(string[] args, int length, string full, Client client)
        {
            string zone = args[1];
            string folder = args[2];

            var packetList = Directory.GetFiles(folder);
            Array.Sort(packetList);

            List<NPC> newNPCs = new List<NPC>();
            foreach (var path in packetList)
            {
                var data = File.ReadAllBytes(path);
                PacketReader reader = new PacketReader(data);
                PacketHeader header = reader.ReadStruct<PacketHeader>();
                if (header.Type != 0x8 || header.Subtype != 0xC)
                {
                    Logger.WriteWarning("[WRN] File {0} not an NPC spawn packet, skipping.", path);
                    continue;
                }

                NPC newNPC = new NPC();
                newNPC.EntityID = (int)reader.ReadStruct<ObjectHeader>().ID;
                var pos = reader.ReadEntityPosition();
                newNPC.RotX = pos.RotX;
                newNPC.RotY = pos.RotY;
                newNPC.RotZ = pos.RotZ;
                newNPC.RotW = pos.RotW;

                newNPC.PosX = pos.PosX;
                newNPC.PosY = pos.PosY;
                newNPC.PosZ = pos.PosZ;
                reader.ReadInt16();
                newNPC.NPCName = reader.ReadFixedLengthAscii(0x20);
                newNPC.ZoneName = zone;
                newNPCs.Add(newNPC);
                Logger.WriteInternal("[NPC] Adding new NPC {0} to the database for zone {1}", newNPC.NPCName, zone);
            }

            using (var db = new PolarisEf())
            {
                db.NPCs.AddRange(newNPCs);
                db.SaveChanges();
            }
        }
Ejemplo n.º 10
0
 private static void ServerChange( PacketReader p )
 {
     World.Player.Position = new Point3D( p.ReadUInt16(), p.ReadUInt16(), p.ReadInt16() );
 }