public void ReadPacket(PacketReader reader)
        {
            //TODO: Make
            var offset = 0x2A;
            File.WriteAllBytes("AvatarProfileResponsePacket dump", ((MemoryStream)reader.BaseStream).ToArray());
            Unknown1 = reader.ReadInt32();
            UserID1 = reader.ReadInt64();
            UserID2 = reader.ReadInt64();
            if (reader.ReadBoolean())
            {
                Clan = new Clan();
                Clan.ID = reader.ReadInt64();
                Clan.Name = reader.ReadString();
                Clan.Badge = reader.ReadInt32();
                reader.ReadInt32();
                Clan.Level = reader.ReadInt32();
                offset += 1;
            }
            if (Unknown2 = reader.ReadBoolean())
            {
                Unknown3 = reader.ReadInt64();
                offset += 1;
            }

            reader.Seek(offset, SeekOrigin.Current);
            Unknown4 = reader.ReadInt32();
            AllianceCastleLevel = reader.ReadInt32(); // -1 if not constructed
            AllianceCastleUnitCapacity = reader.ReadInt32();
            AllianceCastleUnitCount = reader.ReadInt32();
            TownHallLevel = reader.ReadInt32();
            Username = reader.ReadString();
            FacebookID = reader.ReadString();
            Level = reader.ReadInt32();
            Experience = reader.ReadInt32();
            Gems = reader.ReadInt32(); // they seemed randomized or scrambled for non local player
            Gems1 = reader.ReadInt32();
            Unknown5 = reader.ReadInt32();
            Unknown6 = reader.ReadInt32();
            Trophies = reader.ReadInt32();
            AttackWon = reader.ReadInt32();
            AttackLost = reader.ReadInt32(); // randomized
            DefenseWon = reader.ReadInt32();
            DefenseLost = reader.ReadInt32(); // randomized
        }
Exemplo n.º 2
0
 public void ReadPacket(PacketReader reader)
 {
     FailureReason = (LoginFailureReason)reader.ReadInt32();
     var fingerprintJson = reader.ReadString();
     if (fingerprintJson != null)
         Fingerprint = new Fingerprint(fingerprintJson);
     HostName = reader.ReadString();
     AssetsRootUrl = reader.ReadString();
     iTunesUrl = reader.ReadString();
     Unknown1 = reader.ReadString();
     RemainingTime = reader.ReadInt32();
     Unknown2 = reader.ReadByte();
     CompressedFingerprintJson = reader.ReadByteArray();
     Unknown3 = reader.ReadString();
     Unknown4 = reader.ReadString();
 }
        /// <summary>
        /// The read.
        /// </summary>
        /// <param name="client">
        /// </param>
        /// <param name="packet">
        /// </param>
        public static void Read(Client client, byte[] packet)
        {
            // TODO: Fix this mess.
            ushort data_length = BitConverter.ToUInt16(new[] { packet[3], packet[2] }, 0);
            byte[] sender_ID = BitConverter.GetBytes(client.Character.characterId);
            Array.Reverse(sender_ID);
            MemoryStream m_stream = new MemoryStream();
            m_stream.Write(packet, 0, 9);
            m_stream.Write(sender_ID, 0, 4);
            m_stream.Write(packet, 9, packet.Length - 9);
            m_stream.Capacity = (int)m_stream.Length;
            byte[] message = m_stream.GetBuffer();
            byte[] new_length = BitConverter.GetBytes(message.Length - 4);
            message[2] = new_length[1];
            message[3] = new_length[0];
            m_stream.Close();
            m_stream.Dispose();

            foreach (Client m_client in client.Server.Clients)
            {
                if (!m_client.KnownClients.Contains(client.Character.characterId))
                {
                    byte[] pname = PlayerName.New(client, client.Character.characterId);
                    m_client.Send(pname);
                    m_client.KnownClients.Add(client.Character.characterId);
                }

                m_client.Send(message);
            }

            PacketReader reader = new PacketReader(ref packet);
            reader.ReadUInt16();
            reader.ReadUInt16();
            reader.ReadUInt16();
            reader.ReadUInt16();
            reader.ReadByte();
            string text = reader.ReadString();
            string channelName = ChatChannels.GetChannel(packet).Name;
            ChatLogger.WriteString(channelName, text, client.Character.characterName);
        }
Exemplo n.º 4
0
        bool ReceivePacket()
        {
            byte[] packet = ReadPacket ();

                if (packet.Length == 0) {
                    return false;
                }

                if (IsReplyPacket (packet)) {
                    int id = GetPacketId (packet);
                    ReplyCallback cb = null;
                    lock (reply_packets_monitor) {
                        reply_cbs.TryGetValue (id, out cb);
                        if (cb == null) {
                            reply_packets [id] = packet;
                            Monitor.PulseAll (reply_packets_monitor);
                        } else {
                            int c = reply_cb_counts [id];
                            c --;
                            if (c == 0) {
                                reply_cbs.Remove (id);
                                reply_cb_counts.Remove (id);
                            }
                        }
                    }

                    if (cb != null)
                        cb.Invoke (id, packet);
                } else {
                    PacketReader r = new PacketReader (packet);

                    if (r.CommandSet == CommandSet.EVENT && r.Command == (int)CmdEvent.COMPOSITE) {
                        int spolicy = r.ReadByte ();
                        int nevents = r.ReadInt ();

                        SuspendPolicy suspend_policy = decode_suspend_policy (spolicy);

                        EventInfo[] events = new EventInfo [nevents];

                        for (int i = 0; i < nevents; ++i) {
                            EventKind kind = (EventKind)r.ReadByte ();
                            int req_id = r.ReadInt ();

                            EventType etype = (EventType)kind;

                            long thread_id = r.ReadId ();
                            if (kind == EventKind.VM_START) {
                                events [i] = new EventInfo (etype, req_id) { ThreadId = thread_id };
                                //EventHandler.VMStart (req_id, thread_id, null);
                            } else if (kind == EventKind.VM_DEATH) {
                                int exit_code = 0;
                                if (Version.AtLeast (2, 27))
                                    exit_code = r.ReadInt ();
                                //EventHandler.VMDeath (req_id, 0, null);
                                events [i] = new EventInfo (etype, req_id) { ExitCode = exit_code };
                            } else if (kind == EventKind.THREAD_START) {
                                events [i] = new EventInfo (etype, req_id) { ThreadId = thread_id, Id = thread_id };
                                //EventHandler.ThreadStart (req_id, thread_id, thread_id);
                            } else if (kind == EventKind.THREAD_DEATH) {
                                events [i] = new EventInfo (etype, req_id) { ThreadId = thread_id, Id = thread_id };
                                //EventHandler.ThreadDeath (req_id, thread_id, thread_id);
                            } else if (kind == EventKind.ASSEMBLY_LOAD) {
                                long id = r.ReadId ();
                                events [i] = new EventInfo (etype, req_id) { ThreadId = thread_id, Id = id };
                                //EventHandler.AssemblyLoad (req_id, thread_id, id);
                            } else if (kind == EventKind.ASSEMBLY_UNLOAD) {
                                long id = r.ReadId ();
                                events [i] = new EventInfo (etype, req_id) { ThreadId = thread_id, Id = id };
                                //EventHandler.AssemblyUnload (req_id, thread_id, id);
                            } else if (kind == EventKind.TYPE_LOAD) {
                                long id = r.ReadId ();
                                events [i] = new EventInfo (etype, req_id) { ThreadId = thread_id, Id = id };
                                //EventHandler.TypeLoad (req_id, thread_id, id);
                            } else if (kind == EventKind.METHOD_ENTRY) {
                                long id = r.ReadId ();
                                events [i] = new EventInfo (etype, req_id) { ThreadId = thread_id, Id = id };
                                //EventHandler.MethodEntry (req_id, thread_id, id);
                            } else if (kind == EventKind.METHOD_EXIT) {
                                long id = r.ReadId ();
                                events [i] = new EventInfo (etype, req_id) { ThreadId = thread_id, Id = id };
                                //EventHandler.MethodExit (req_id, thread_id, id);
                            } else if (kind == EventKind.BREAKPOINT) {
                                long id = r.ReadId ();
                                long loc = r.ReadLong ();
                                events [i] = new EventInfo (etype, req_id) { ThreadId = thread_id, Id = id, Location = loc };
                                //EventHandler.Breakpoint (req_id, thread_id, id, loc);
                            } else if (kind == EventKind.STEP) {
                                long id = r.ReadId ();
                                long loc = r.ReadLong ();
                                events [i] = new EventInfo (etype, req_id) { ThreadId = thread_id, Id = id, Location = loc };
                                //EventHandler.Step (req_id, thread_id, id, loc);
                            } else if (kind == EventKind.EXCEPTION) {
                                long id = r.ReadId ();
                                long loc = 0; // FIXME
                                events [i] = new EventInfo (etype, req_id) { ThreadId = thread_id, Id = id, Location = loc };
                                //EventHandler.Exception (req_id, thread_id, id, loc);
                            } else if (kind == EventKind.APPDOMAIN_CREATE) {
                                long id = r.ReadId ();
                                events [i] = new EventInfo (etype, req_id) { ThreadId = thread_id, Id = id };
                                //EventHandler.AppDomainCreate (req_id, thread_id, id);
                            } else if (kind == EventKind.APPDOMAIN_UNLOAD) {
                                long id = r.ReadId ();
                                events [i] = new EventInfo (etype, req_id) { ThreadId = thread_id, Id = id };
                                //EventHandler.AppDomainUnload (req_id, thread_id, id);
                            } else if (kind == EventKind.USER_BREAK) {
                                long id = 0;
                                long loc = 0;
                                events [i] = new EventInfo (etype, req_id) { ThreadId = thread_id, Id = id, Location = loc };
                                //EventHandler.Exception (req_id, thread_id, id, loc);
                            } else if (kind == EventKind.USER_LOG) {
                                int level = r.ReadInt ();
                                string category = r.ReadString ();
                                string message = r.ReadString ();
                                events [i] = new EventInfo (etype, req_id) { ThreadId = thread_id, Level = level, Category = category, Message = message };
                                //EventHandler.Exception (req_id, thread_id, id, loc);
                            } else if (kind == EventKind.KEEPALIVE) {
                                events [i] = new EventInfo (etype, req_id) { };
                            } else {
                                throw new NotImplementedException ("Unknown event kind: " + kind);
                            }
                        }

                        EventHandler.Events (suspend_policy, events);
                    }
                }

                return true;
        }
Exemplo n.º 5
0
        private static void ClientTextCommand( PacketReader p, PacketHandlerEventArgs args )
        {
            int type = p.ReadByte();
            string command = p.ReadString();

            switch ( type )
            {
                case 0x24: // Use skill
                {
                    int skillIndex;

                    try{ skillIndex = Convert.ToInt32( command.Split( ' ' )[0] ); }
                    catch{ break; }

                    if ( World.Player != null )
                        World.Player.LastSkill = skillIndex;

                    if ( Macros.MacroManager.AcceptActions )
                        MacroManager.Action( new UseSkillAction( skillIndex ) );

                    if ( skillIndex == (int)SkillName.Stealth && !World.Player.Visible )
                        StealthSteps.Hide();
                    break;
                }
                case 0x27: // Cast spell from book
                {
                    try
                    {
                        string[] split = command.Split( ' ' );

                        if ( split.Length > 0 )
                        {
                            ushort spellID = Convert.ToUInt16( split[0] );
                            Serial serial = Convert.ToUInt32( split.Length > 1 ? Utility.ToInt32( split[1], -1 ) : -1 );
                            Spell s = Spell.Get( spellID );
                            if ( s != null )
                            {
                                s.OnCast( p );
                                args.Block = true;
                                if ( Macros.MacroManager.AcceptActions )
                                    MacroManager.Action( new BookCastSpellAction( s, serial ) );
                            }
                        }
                    }
                    catch
                    {
                    }
                    break;
                }
                case 0x56: // Cast spell from macro
                {
                    try
                    {
                        ushort spellID = Convert.ToUInt16( command );
                        Spell s = Spell.Get( spellID );
                        if ( s != null )
                        {
                            s.OnCast( p );
                            args.Block = true;
                            if ( Macros.MacroManager.AcceptActions )
                                MacroManager.Action( new MacroCastSpellAction( s ) );
                        }
                    }
                    catch
                    {
                    }
                    break;
                }
            }
        }
Exemplo n.º 6
0
        private static void ServerList( PacketReader p, PacketHandlerEventArgs args )
        {
            p.ReadByte(); //unknown
            ushort numServers = p.ReadUInt16();

            for ( int i = 0; i < numServers; ++i )
            {
                ushort num = p.ReadUInt16();
                World.Servers[num] = p.ReadString( 32 );
                p.ReadByte(); // full %
                p.ReadSByte(); // time zone
                p.ReadUInt32(); // ip
            }
        }
Exemplo n.º 7
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
            }
        }
Exemplo n.º 8
0
        public void ReadPacket(PacketReader reader)
        {
            LastVisit = TimeSpan.FromSeconds(reader.ReadInt32());

            //Unknown1 = reader.ReadInt();
            reader.Seek(4, SeekOrigin.Current);

            TimeStamp = reader.ReadInt64();
            UserID = reader.ReadInt64();
            ShieldDuration = TimeSpan.FromSeconds(reader.ReadInt32());

            //Unknown2 = reader.ReadLong();
            reader.Seek(8, SeekOrigin.Current);
            Compressed = reader.ReadBoolean();
            Home = new Village();
            Home.ReadFromPacketReader(reader);

            //Unknown4 = reader.ReadInt();
            reader.Seek(4, SeekOrigin.Current);

            //UserID2 = reader.ReadLong();
            //UserID3 = reader.ReadLong();
            reader.Seek(16, SeekOrigin.Current);

            if ((HasClan = reader.ReadBoolean()))
            {
                Clan = new Clan()
                {
                    ID = reader.ReadInt64(),
                    Name = reader.ReadString(),
                    Badge = reader.ReadInt32(),
                };
                Level = reader.ReadInt32(); // member status?
                Level = reader.ReadInt32();
            }

            if (reader.ReadBoolean())
                reader.Seek(8, SeekOrigin.Current);
            if (reader.ReadBoolean())
                reader.Seek(8, SeekOrigin.Current);

            //Unknown5 = (byte)reader.ReadByte();
            //Unknown6 = reader.ReadInt();
            //Unknown7 = reader.ReadLong();
            //Unknown8 = reader.ReadLong();
            reader.Seek(4, SeekOrigin.Current);

            AllianceCastleLevel = reader.ReadInt32();
            AllianceCastleCapacity = reader.ReadInt32();
            AllianceCastleUsed = reader.ReadInt32();
            TownHallLevel = reader.ReadInt32();
            Username = reader.ReadString();
            FacebookID = reader.ReadInt32();
            Level = reader.ReadInt32();
            Experience = reader.ReadInt32();
            Gems = reader.ReadInt32();
            //Gems1 = reader.ReadInt();

            //Unknown9 = reader.ReadLong();
            reader.Seek(12, SeekOrigin.Current);

            TrophiesCount = reader.ReadInt32();
            AttackWon = reader.ReadInt32();
            AttackLost = reader.ReadInt32();
            DefenceWon = reader.ReadInt32();
            DefenceLost = reader.ReadInt32();

            reader.Seek(21, SeekOrigin.Current);

            HasName = reader.ReadBoolean();

            reader.Seek(16, SeekOrigin.Current);
        }
        public void ReadPacket(PacketReader reader)
        {
            var offset = 0x2A;
            LastVisit = TimeSpan.FromSeconds(reader.ReadInt32());
            Unknown1 = reader.ReadInt32();
            Timestamp = DateTimeConverter.FromUnixTimestamp(reader.ReadInt32());
            Unknown2 = reader.ReadInt32();
            UserID = reader.ReadInt64();
            ShieldDuration = TimeSpan.FromSeconds(reader.ReadInt32());
            Unknown3 = reader.ReadInt32();
            Unknown4 = reader.ReadInt32();
            Compressed = reader.ReadBoolean();
            Home = new Village();
            Home.Read(reader);

            Avatar = new Avatar();
            // Seems like a whole object
            Unknown6 = reader.ReadInt32();
            UserID1 = reader.ReadInt64();
            UserID2 = reader.ReadInt64();
            Avatar.ID = UserID1;

            switch (reader.ReadByte())
            {
                case 0:
                    break;

                case 1:
                    Avatar.Clan = new Clan();
                    Avatar.Clan.ID = reader.ReadInt64();
                    Avatar.Clan.Name = reader.ReadString();
                    Avatar.Clan.Badge = reader.ReadInt32();
                    reader.ReadInt32();
                    Avatar.Clan.Level = reader.ReadInt32();
                    offset += 1;
                    break;

                case 2: // clanless but clan castle built?
                    var lel = reader.ReadInt64();
                    break;
            }

            if (Unknown7 = reader.ReadBoolean())
                Unknown8 = reader.ReadInt64();

            if (Unknown9 = reader.ReadBoolean())
                Unknown10 = reader.ReadInt64();

            reader.Seek(offset, SeekOrigin.Current);
            Unknown11 = reader.ReadInt32();
            AllianceCastleLevel = reader.ReadInt32(); // -1 if not constructed
            AllianceCastleUnitCapacity = reader.ReadInt32();
            AllianceCastleUnitCount = reader.ReadInt32();
            Avatar.TownHallLevel = reader.ReadInt32();
            Avatar.Username = reader.ReadString();
            FacebookID = reader.ReadString();
            Avatar.Level = reader.ReadInt32();
            Avatar.Experience = reader.ReadInt32();
            Avatar.Gems = reader.ReadInt32();
            Gems1 = reader.ReadInt32();
            Unknown14 = reader.ReadInt32();
            Unknown15 = reader.ReadInt32();
            Avatar.Trophies = reader.ReadInt32();
            Avatar.AttacksWon = reader.ReadInt32();
            Avatar.AttacksLost = reader.ReadInt32();
            Avatar.DefencesWon = reader.ReadInt32();
            Avatar.DefencesLost = reader.ReadInt32();
            Unknown16 = reader.ReadInt32();
            Unknown17 = reader.ReadInt32();
            Unknown18 = reader.ReadInt32();
            if (Unknown19 = reader.ReadBoolean())
                Unknown20 = reader.ReadInt64();
            Unknown21 = reader.ReadByte();
            Unknown22 = reader.ReadInt32();
            Unknown23 = reader.ReadInt32();
            Unknown24 = reader.ReadInt32();
            Unknown25 = reader.ReadInt32();

            var count1 = reader.ReadInt32();
            for (int i = 0; i < count1; i++)
            {
                var id = reader.ReadInt32(); // resource id from resources.csv
                var capacity = reader.ReadInt32();
            }

            var count2 = reader.ReadInt32();
            for (int i = 0; i < count2; i++)
            {
                var id = reader.ReadInt32(); // resource id from resources.csv
                var amount = reader.ReadInt32();
            }

            var count3 = reader.ReadInt32();
            for (int i = 0; i < count3; i++)
            {
                var id = reader.ReadInt32(); // unit id from characters.csv
                var amount = reader.ReadInt32();
            }

            var count4 = reader.ReadInt32();
            for (int i = 0; i < count4; i++)
            {
                var id = reader.ReadInt32(); // spell id from spells.csv
                var amount = reader.ReadInt32();
            }

            var count5 = reader.ReadInt32();
            for (int i = 0; i < count5; i++)
            {
                var id = reader.ReadInt32(); // unit id from characters.csv
                var level = reader.ReadInt32();
            }

            var count6 = reader.ReadInt32();
            for (int i = 0; i < count6; i++)
            {
                var id = reader.ReadInt32(); // spell id from spells.csv
                var level = reader.ReadInt32();
            }

            var count7 = reader.ReadInt32();
            for (int i = 0; i < count7; i++)
            {
                var id = reader.ReadInt32(); // hero id from heros.csv
                var level = reader.ReadInt32();
            }

            var count8 = reader.ReadInt32();
            for (int i = 0; i < count8; i++)
            {
                var id = reader.ReadInt32(); // hero id from heros.csv
                var health = reader.ReadInt32();
            }

            var count9 = reader.ReadInt32();
            for (int i = 0; i < count9; i++)
            {
                var id = reader.ReadInt32(); // hero id from heros.csv
                var state = reader.ReadInt32();
            }

            var count10 = reader.ReadInt32();
            for (int i = 0; i < count10; i++)
            {
                var id = reader.ReadInt32(); // unit id from characters.csv
                var amount = reader.ReadInt32();
                var level = reader.ReadInt32();
            }

            var count11 = reader.ReadInt32();
            for (int i = 0; i < count11; i++)
            {
                var id = reader.ReadInt32(); // mission id from missions.csv
            }

            var count12 = reader.ReadInt32();
            for (int i = 0; i < count12; i++)
            {
                var id = reader.ReadInt32(); // achievement id from achievements.csv
            }

            var count13 = reader.ReadInt32();
            for (int i = 0; i < count13; i++)
            {
                var id = reader.ReadInt32(); // achievement id from achievements.csv
                var progress = reader.ReadInt32();
            }

            var count14 = reader.ReadInt32();
            for (int i = 0; i < count14; i++)
            {
                var id = reader.ReadInt32(); // npc id from npcs.csv
                var stars = reader.ReadInt32();
            }

            var count15 = reader.ReadInt32();
            for (int i = 0; i < count15; i++)
            {
                var id = reader.ReadInt32(); // npc id from npcs.csv
                var gold = reader.ReadInt32();
            }

            var count16 = reader.ReadInt32();
            for (int i = 0; i < count16; i++)
            {
                var id = reader.ReadInt32(); // npc id from npcs.csv
                var elixir = reader.ReadInt32();
            }

            Unknown26 = reader.ReadInt32();
            Unknown27 = reader.ReadInt32();
            Unknown28 = reader.ReadInt32();
        }
Exemplo n.º 10
0
        private static void MobileStatus( PacketReader p )
        {
            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();

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

                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 || type == 0x04 )
                {
                    player.StatCap = p.ReadUInt16();
                    player.Followers = p.ReadByte();
                    player.FollowersMax = p.ReadByte();

                    if ( type == 0x04 )
                    {
                        /*m_Stream.Write( (short) beheld.FireResistance ); // Fire
                        m_Stream.Write( (short) beheld.ColdResistance ); // Cold
                        m_Stream.Write( (short) beheld.PoisonResistance ); // Poison
                        m_Stream.Write( (short) beheld.EnergyResistance ); // Energy
                        m_Stream.Write( (short) 0 ); // Luck
                        m_Stream.Write( (short) 0 ); // Damage min
                        m_Stream.Write( (short) 0 ); // Damage max*/
                        p.Seek( 14, SeekOrigin.Current );
                        player.Tithe = p.ReadInt32();
                    }
                }
            }
        }
Exemplo n.º 11
0
        public void ReadPacket(PacketReader reader)
        {
            Unknown1 = reader.ReadInt32();
            Unknown2 = reader.ReadInt32();
            UserID = reader.ReadInt64();
            Shield = TimeSpan.FromSeconds(reader.ReadInt32());
            Unknown3 = reader.ReadInt32();
            Unknown4 = reader.ReadInt32();
            Compressed = reader.ReadBoolean();
            Home = new Village();
            Home.Read(reader);
            Unknown5 = reader.ReadInt32();

            UserID1 = reader.ReadInt64();
            UserID2 = reader.ReadInt64();

            var offset = 0x2A;
            bool isClan = reader.ReadBoolean();
            if (isClan)
            {
                Clan = new Clan();
                Clan.ID = reader.ReadInt64();
                Clan.Name = reader.ReadString();
                Clan.Badge = reader.ReadInt32();
                Unknown6 = reader.ReadInt32();
                Clan.Level = reader.ReadInt32();
                offset += 1;
            }

            bool Unknown7 = reader.ReadBoolean();
            if (Unknown7)
                Unknown8 = reader.ReadInt64();

            bool Unknown9 = reader.ReadBoolean();
            if (Unknown9)
                Unknown10 = reader.ReadInt64();

            reader.Seek(offset, SeekOrigin.Current);
            Unknown11 = reader.ReadInt32();
            Unknown12 = reader.ReadInt32();
            Unknown13 = reader.ReadInt32();

            ClanUnits = reader.ReadInt32();
            TownHall = reader.ReadInt32();
            Username = reader.ReadString();
            FacebookID = reader.ReadString();
            Stars = reader.ReadInt32();
            Points = reader.ReadInt32();

            Unknown14 = reader.ReadInt32();
            Unknown15 = reader.ReadInt32();
            Unknown16 = reader.ReadInt32();
            Unknown17 = reader.ReadInt32();

            Trophies = reader.ReadInt32();
            AttacksWon = reader.ReadInt32();
            Unknown18 = reader.ReadInt32();
            DefenseWon = reader.ReadInt32();
            Unknown19 = reader.ReadInt32();

            Unknown20 = reader.ReadInt32();
            Unknown21 = reader.ReadInt32();
            Unknown22 = reader.ReadInt32();

            bool Unknown23 = reader.ReadBoolean();
            if (Unknown23)
                Unknown24 = reader.ReadInt64();

            Unknown25 = reader.ReadByte();
            Unknown26 = reader.ReadInt32();
            Unknown27 = reader.ReadInt32();
            Unknown28 = reader.ReadInt32();
            Unknown29 = reader.ReadInt32();

            var count = reader.ReadInt32(); //storage
            for (int i = 0; i < count; i++)
            {
                var id = reader.ReadInt32();
                var capacity = reader.ReadInt32();
            }

            count = reader.ReadInt32(); //resources
            for (int i = 0; i < count; i++)
            {
                var id = reader.ReadInt32();
                var capacity = reader.ReadInt32();
            }

            count = reader.ReadInt32(); //units
            for (int i = 0; i < count; i++)
            {
                var id = reader.ReadInt32();
                var capacity = reader.ReadInt32();
            }

            count = reader.ReadInt32(); //spells
            for (int i = 0; i < count; i++)
            {
                var id = reader.ReadInt32();
                var capacity = reader.ReadInt32();
            }

            count = reader.ReadInt32(); //unit_upgrades
            for (int i = 0; i < count; i++)
            {
                var id = reader.ReadInt32();
                var capacity = reader.ReadInt32();
            }

            count = reader.ReadInt32(); //spell_upgrades
            for (int i = 0; i < count; i++)
            {
                var id = reader.ReadInt32();
                var capacity = reader.ReadInt32();
            }

            count = reader.ReadInt32(); //hero_upgrades
            for (int i = 0; i < count; i++)
            {
                var id = reader.ReadInt32();
                var capacity = reader.ReadInt32();
            }

            count = reader.ReadInt32(); //hero_health
            for (int i = 0; i < count; i++)
            {
                var id = reader.ReadInt32();
                var capacity = reader.ReadInt32();
            }

            count = reader.ReadInt32(); //hero_state
            for (int i = 0; i < count; i++)
            {
                var id = reader.ReadInt32();
                var capacity = reader.ReadInt32();
            }

            count = reader.ReadInt32(); //alliance_units
            for (int i = 0; i < count; i++)
            {
                var id = reader.ReadInt32();
                var capacity = reader.ReadInt32();
                var level = reader.ReadInt32();
            }

            // more (needed?) values...
        }