Exemplo n.º 1
0
 /// <summary>
 /// Updates resource and content versions using the specified version information
 /// </summary>
 /// <param name="info">Version information obtained via the Riot API</param>
 public static void UpdateVersions(RealmInfo info)
 {
     Resource.ContentURL     = info.BaseURL;
     Resource.ContentVersion = info.ContentVersion;
     Resource.Validate();
     return;
 }
Exemplo n.º 2
0
        public void AddRealm(int id, string connString)
        {
            using (MySqlConnection conn = GetConnection())
            {
                MySqlCommand cmd = conn.CreateCommand();
                cmd.CommandText = "SELECT id, name, icon, flag, gamebuild FROM realmlist WHERE id = @id";
                cmd.Parameters.AddWithValue("@id", id);
                conn.Open();

                using (MySqlDataReader reader = cmd.ExecuteReader())
                {
                    if (reader.Read())
                    {
                        RealmInfo realm = new RealmInfo(connString)
                        {
                            Id        = id,
                            Name      = reader.GetString("name"),
                            Type      = RealmInfo.GetRealmType(reader.GetInt16("icon")),
                            Flags     = reader.GetInt16("flag"),
                            GameBuild = reader.GetInt32("gamebuild")
                        };

                        realms.Add(realm);
                    }
                    else
                    {
                        throw new ArgumentException($"Invalid Id {id}. That realm doesn't exists.");
                    }
                }
            }
        }
Exemplo n.º 3
0
        public override void Write(BinaryWriter writer)
        {
            writer.Write(Sequence);
            writer.Write(Final);
            writer.Write(Offset);
            writer.Write(Realms.Count);
            writer.Pad(8);

            for (int i = 0; i < MaxRealmsPerPacket; i++)
            {
                if (i < Realms.Count)
                {
                    RealmInfo realm = Realms[i];
                    writer.Write(realm.Id);
                    writer.Write(realm.Position);
                    writer.Write(realm.Flags);
                    writer.Pad(4);
                    writer.Write(realm.Icon);
                    writer.Pad(4);
                    writer.WriteStringLength(realm.Name, 0x40);
                }
                else
                {
                    writer.Pad(0x54);
                }
            }
        }
Exemplo n.º 4
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            System.Windows.Forms.RichTextBox r = new System.Windows.Forms.RichTextBox();
            string contents = e.Argument as string;

            r.Rtf = contents;
            string        text     = r.Text;
            List <byte[]> rooms    = new List <byte[]>();
            List <Room>   Rooms    = new List <Room>();
            string        needle   = "Packet ID: 33";
            int           count    = 0;
            int           total    = Regex.Matches(text, needle).Count;
            int           position = -2;
            string        work     = text;

            while ((position = work.IndexOf(needle)) != -1)
            {
                work = work.Substring(position + (needle.Length)).Trim();
                int end = 0;
                end = work.IndexOf('}');
                string pak = work.Substring(0, end + 1);
                work = work.Substring(pak.Length);
                Room a = new Room();
                try
                {
                    Room b = a.FromBytes(RealmInfo.GetByteArrayFromString(pak));
                    Rooms.Add(b);
                }
                catch { }
                count++;
                backgroundWorker1.ReportProgress(count * 100 / total);
            }
            Parser_RoomsCompleted(Rooms);
        }
Exemplo n.º 5
0
        private static void SendCharacterList(LobbySession session)
        {
            session.NewEvent(new DatabaseGenericEvent <List <CharacterInfo> >(DatabaseManager.DataCentre.GetCharacters(session.ServiceAccount.Id), characters =>
            {
                session.Characters = characters;

                ServerCharacterList characterList = new ServerCharacterList
                {
                    VeteranRank               = 0,
                    DaysTillNextVeteranRank   = 0u,
                    DaysSubscribed            = 0u,
                    SubscriptionDaysRemaining = 0u,
                    RealmCharacterLimit       = session.ServiceAccount.RealmCharacterLimit,
                    AccountCharacterLimit     = session.ServiceAccount.AccountCharacterLimit,
                    Expansion = session.ServiceAccount.Expansion,
                    Offset    = 1
                };

                if (session.Characters.Count == 0)
                {
                    session.Send(characterList);
                    return;
                }

                for (int i = 0; i < session.Characters.Count; i++)
                {
                    // client expects no more than 2 characters per chunk
                    if (i % ServerCharacterList.MaxCharactersPerPacket == 0)
                    {
                        // flush previous chunk
                        if (i != 0)
                        {
                            session.Send(characterList);
                            session.FlushPacketQueue();
                            characterList.Characters.Clear();
                        }

                        // weird...
                        characterList.Offset = (byte)(session.Characters.Count - i <= ServerCharacterList.MaxCharactersPerPacket ? i * 2 + 1 : i * 2);
                    }

                    RealmInfo realmInfo = AssetManager.GetRealmInfo(session.Characters[i].RealmId);
                    if (realmInfo == null)
                    {
                        continue;
                    }

                    characterList.Characters.Add(((byte)i, realmInfo.Name, session.Characters[i]));

                    // flush final chunk
                    if (i == session.Characters.Count - 1)
                    {
                        session.Send(characterList);
                        session.FlushPacketQueue();
                    }
                }
Exemplo n.º 6
0
        public ActionResult Realm(int id)
        {
            AuthService context       = HttpContext.RequestServices.GetService(typeof(AuthService)) as AuthService;
            RealmInfo   realm         = context.GetRealm(id);
            long        allianceCount = realm.GetFactionOnlinePlayersCount(Faction.ALLIANCE);
            long        hordeCount    = realm.GetFactionOnlinePlayersCount(Faction.HORDE);
            long        totalCount    = realm.GetOnlinePlayersCount();

            return(new OkObjectResult(new { allianceCount = allianceCount, hordeCount = hordeCount, totalCount = totalCount }));
        }
        private void UpdateList()
        {
            LastRealmListUpdate = DateTime.Now;
            if (realms.Count > 0)
            {
                ArrayList list = new ArrayList(realms.Values);
                DateTime  now  = DateTime.Now;
                TimeSpan  span;
                foreach (RealmInfo info in list)
                {
                    span = now.Subtract(info.LastUpdate);
                    if (span.TotalSeconds > 30)
                    {
                        realms.Remove(info.IP);
                        realmListDirty = true;
                    }
                }
            }

            if (realmListDirty)
            {
                realmListDirty = false;
                BinWriter w = new BinWriter();
                w.Write((byte)0x10);
                w.Write((short)0);
                w.Write(0);
                w.Write((byte)realms.Count);
                if (realms.Count > 0)
                {
                    IEnumerator e = realms.Values.GetEnumerator();
                    while (e.MoveNext())
                    {
                        //						Console.WriteLine("Realm: ");
                        RealmInfo info = (RealmInfo)e.Current;
                        w.Write(0);
                        w.Write((byte)0);
                        w.Write(info.Description);
                        w.Write(info.IP);
                        w.Write(info.Users);
                        w.Write(0);
                        w.Write((byte)0);
                    }
                    w.Set(1, (short)(w.BaseStream.Length - 3));
                    byte[] newList = new byte[w.BaseStream.Length];
                    Array.Copy(w.GetBuffer(), 0, newList, 0, newList.Length);
                    realmList = newList;
                }
            }
        }
Exemplo n.º 8
0
        private static void SendRealmList(LobbySession session)
        {
            ReadOnlyCollection <RealmInfo> realmInfo = AssetManager.RealmInfoStore;

            ServerRealmList realmList = new ServerRealmList {
                Sequence = session.Sequence
            };

            for (ushort i = 0; i < realmInfo.Count; i++)
            {
                // client expects no more than 6 realms per chunk
                if (i % ServerRealmList.MaxRealmsPerPacket == 0)
                {
                    // flush previous chunk
                    if (i != 0)
                    {
                        session.Send(realmList);
                        realmList.Realms.Clear();
                    }

                    realmList.Offset = i;
                    realmList.Final  = (ushort)(realmInfo.Count - i < ServerRealmList.MaxRealmsPerPacket ? 1 : 0);
                }

                RealmInfo realm = realmInfo[i];
                realmList.Realms.Add(new ServerRealmList.RealmInfo
                {
                    Id       = realm.Id,
                    Position = i,
                    Name     = realm.Name,
                    Flags    = realm.Flags
                });

                // flush final chunk
                if (i == realmInfo.Count - 1)
                {
                    session.Send(realmList);
                }
            }
        }
 internal void UpdateRealm(string UpdaterIP, string Description, string IP, int Users)
 {
     realms[UpdaterIP] = new RealmInfo(Description, IP, Users);
     realmListDirty    = true;
     UpdateList();
 }