Beispiel #1
0
        public void OnReceive(IAsyncResult result)
        {
            int num = this.m_Socket.EndReceive(result);
            switch (num)
            {
                case 0:
                case -1:
                    this.m_Socket.Close();
                    return;

                default:
                    this.m_Length += num;
                    for (int i = 0; this.m_Length > 0; i = 0)
                    {
                        if (this.m_Buffer[0] == 0xa8)
                        {
                            if (this.m_Length >= 3)
                            {
                                i = (this.m_Buffer[1] << 8) | this.m_Buffer[2];
                                if (this.m_Length < i)
                                {
                                    i = 0;
                                }
                                else
                                {
                                    PacketReader pvSrc = new PacketReader(this.m_Buffer, 0, i, false, 0xa8, "Shard List");
                                    this.ShardList(pvSrc);
                                }
                            }
                        }
                        else if (this.m_Buffer[0] == 140)
                        {
                            i = 11;
                            if (this.m_Length < i)
                            {
                                i = 0;
                            }
                            else
                            {
                                PacketReader reader2 = new PacketReader(this.m_Buffer, 0, i, true, 140, "Shard Relay");
                                this.ShardRelay(reader2);
                                this.m_Socket.Close();
                                return;
                            }
                        }
                        if (i == 0)
                        {
                            break;
                        }
                        this.m_Length -= i;
                        for (int j = 0; j < this.m_Length; j++)
                        {
                            this.m_Buffer[j] = this.m_Buffer[j + i];
                        }
                    }
                    break;
            }
            this.m_Socket.BeginReceive(this.m_Buffer, this.m_Length, this.m_Buffer.Length - this.m_Length, SocketFlags.None, new AsyncCallback(this.OnReceive), null);
        }
Beispiel #2
0
 public void CharacterList(PacketReader pvSrc)
 {
     int num = pvSrc.ReadByte();
     for (int i = 0; i < 5; i++)
     {
         string name = pvSrc.ReadString(60);
         if (name.Length > 0)
         {
             CharacterProfile profile = null;
             for (int j = 0; (profile == null) && (j < this.m_Shard.Characters.Length); j++)
             {
                 if (this.m_Shard.Characters[j].Index == i)
                 {
                     profile = this.m_Shard.Characters[j];
                 }
             }
             if (profile != null)
             {
                 profile.Name = name;
             }
             else
             {
                 this.m_Shard.AddCharacter(new CharacterProfile(this.m_Shard, name, i));
             }
         }
         else
         {
             CharacterProfile character = null;
             for (int k = 0; (character == null) && (k < this.m_Shard.Characters.Length); k++)
             {
                 if (this.m_Shard.Characters[k].Index == i)
                 {
                     character = this.m_Shard.Characters[k];
                 }
             }
             if (character != null)
             {
                 this.m_Shard.RemoveCharacter(character);
             }
         }
     }
     Array.Sort(this.m_Shard.Characters, new CharacterComparer());
     new Timer(new OnTick(this.Update_OnTick), 0, 1).Start(false);
 }
Beispiel #3
0
        public void OnReceive(IAsyncResult result)
        {
            int count = this.m_Socket.EndReceive(result);
            switch (count)
            {
                case 0:
                case -1:
                    this.m_Socket.Close();
                    return;

                default:
                    count = this.m_CryptoProvider.Decrypt(this.m_Compressed, 0, count, this.m_Buffer, this.m_Length);
                    this.m_Length += count;
                    for (int i = 0; this.m_Length > 0; i = 0)
                    {
                        if (this.m_Buffer[0] == 0xa9)
                        {
                            if (this.m_Length >= 3)
                            {
                                i = (this.m_Buffer[1] << 8) | this.m_Buffer[2];
                                if (this.m_Length >= i)
                                {
                                    PacketReader pvSrc = new PacketReader(this.m_Buffer, 0, i, false, 0xa8, "Character List");
                                    this.CharacterList(pvSrc);
                                    this.m_Socket.Close();
                                    ShardProfile[] shards = this.m_Account.Shards;
                                    int index = Array.IndexOf(shards, this.m_Shard) + 1;
                                    if ((index >= 0) && (index < shards.Length))
                                    {
                                        new ServerSync(this.m_Server, this.m_Account, shards[index]);
                                    }
                                    return;
                                }
                                i = 0;
                            }
                        }
                        else if (this.m_Buffer[0] == 0xb9)
                        {
                            i = 3;
                            if (this.m_Length < i)
                            {
                                i = 0;
                            }
                        }
                        if (i == 0)
                        {
                            break;
                        }
                        this.m_Length -= i;
                        for (int j = 0; j < this.m_Length; j++)
                        {
                            this.m_Buffer[j] = this.m_Buffer[j + i];
                        }
                    }
                    break;
            }
            this.m_Socket.BeginReceive(this.m_Compressed, 0, this.m_Compressed.Length, SocketFlags.None, new AsyncCallback(this.OnReceive), null);
        }
Beispiel #4
0
 public void Handle(PacketReader pvSrc)
 {
     this.m_Callback(pvSrc);
     this.m_Count++;
 }
Beispiel #5
0
 public void ShardRelay(PacketReader pvSrc)
 {
     int num = ((pvSrc.ReadByte() | (pvSrc.ReadByte() << 8)) | (pvSrc.ReadByte() << 0x10)) | (pvSrc.ReadByte() << 0x18);
     int num2 = pvSrc.ReadInt16();
     int num3 = pvSrc.ReadInt32();
     if (this.m_Shard != null)
     {
         this.m_Shard.Auth = num3;
         this.m_Shard.Address = new IPAddress((long) ((ulong) num));
         this.m_Shard.Port = num2;
         new ShardSync(this.m_Server, this.m_Account, this.m_Shard);
     }
 }
Beispiel #6
0
 public void ShardList(PacketReader pvSrc)
 {
     pvSrc.ReadByte();
     int num = pvSrc.ReadInt16();
     if (num > 0)
     {
         int port = this.m_Server.Port;
         switch (port)
         {
             case 0x1e5f:
             case 0x1e60:
                 port = 0x1389;
                 break;
         }
         for (int i = 0; i < num; i++)
         {
             int index = pvSrc.ReadInt16();
             string name = pvSrc.ReadString(0x20);
             int percentFull = pvSrc.ReadByte();
             int timeZone = pvSrc.ReadSByte();
             IPAddress address = new IPAddress((long) pvSrc.ReadUInt32());
             if (this.m_Shard == null)
             {
                 ShardProfile profile = null;
                 for (int j = 0; (profile == null) && (j < this.m_Account.Shards.Length); j++)
                 {
                     if (this.m_Account.Shards[j].Name == name)
                     {
                         profile = this.m_Account.Shards[j];
                     }
                 }
                 if (profile == null)
                 {
                     this.m_Account.AddShard(profile = new ShardProfile(this.m_Account, address, port, index, timeZone, percentFull, 0xbadf00d, name));
                 }
                 else
                 {
                     profile.Index = index;
                     profile.Address = address;
                     profile.Port = port;
                     profile.TimeZone = timeZone;
                     profile.PercentFull = percentFull;
                 }
                 if (i == 0)
                 {
                     new Timer(new OnTick(this.Update_OnTick), 0, 1).Start(false);
                 }
             }
         }
         ShardProfile[] shards = this.m_Account.Shards;
         if (shards.Length > 0)
         {
             if (this.m_Shard == null)
             {
                 Array.Sort(shards, new ShardComparer());
                 this.m_Shard = shards[0];
             }
             this.Send(new PServerSelection(this.m_Shard.Index));
         }
     }
 }