Example #1
0
        /// <summary>
        /// Loads the broadcast texts form the database.
        /// </summary>
        private static void LoadBroadcastText()
        {
            string query =
                "SELECT ID, Text, Text1, EmoteID1, EmoteID2, EmoteID3, EmoteDelay1, EmoteDelay2, EmoteDelay3, EmotesID, LanguageID, Flags, SoundEntriesID1, SoundEntriesID2, ConditionID " +
                $"FROM {Settings.HotfixesDatabase}.broadcast_text " +
                $"UNION ALL " +
                $"SELECT a.ID, a.Text_lang, a.Text1_lang, b.EmoteID1, b.EmoteID2, b.EmoteID3, b.EmoteDelay1, b.EmoteDelay2, b.EmoteDelay3, b.EmotesID, b.LanguageID, b.Flags, b.SoundEntriesID1, b.SoundEntriesID2, b.ConditionID " +
                $"FROM {Settings.HotfixesDatabase}.broadcast_text_locale a LEFT JOIN {Settings.HotfixesDatabase}.broadcast_text b ON ( (a.ID= b.ID) AND ((a.locale='ruRU') OR (a.locale='zhCN') ) ); ";

            using (var reader = SQLConnector.ExecuteQuery(query))
            {
                if (reader == null)
                {
                    return;
                }

                while (reader.Read())
                {
                    var id    = Convert.ToInt32(reader["Id"]);
                    var text  = Convert.ToString(reader["Text"]);
                    var text1 = Convert.ToString(reader["Text1"]);

                    if (!BroadcastTexts.ContainsKey(text))
                    {
                        BroadcastTexts[text] = new List <int>();
                    }
                    BroadcastTexts[text].Add(id);

                    if (!BroadcastText1s.ContainsKey(text1))
                    {
                        BroadcastText1s[text1] = new List <int>();
                    }
                    BroadcastText1s[text1].Add(id);

                    if (!Settings.UseDBC)
                    {
                        continue;
                    }

                    var broadcastText = new BroadcastTextEntry()
                    {
                        Text  = text,
                        Text1 = text1,
                    };
                    broadcastText.EmoteID           = new ushort[3];
                    broadcastText.EmoteID[0]        = Convert.ToUInt16(reader["EmoteID1"]);
                    broadcastText.EmoteID[1]        = Convert.ToUInt16(reader["EmoteID2"]);
                    broadcastText.EmoteID[2]        = Convert.ToUInt16(reader["EmoteID3"]);
                    broadcastText.EmoteDelay        = new ushort[3];
                    broadcastText.EmoteDelay[0]     = Convert.ToUInt16(reader["EmoteDelay1"]);
                    broadcastText.EmoteDelay[1]     = Convert.ToUInt16(reader["EmoteDelay2"]);
                    broadcastText.EmoteDelay[2]     = Convert.ToUInt16(reader["EmoteDelay3"]);
                    broadcastText.EmotesID          = Convert.ToUInt16(reader["EmotesID"]);
                    broadcastText.LanguageID        = Convert.ToByte(reader["LanguageID"]);
                    broadcastText.Flags             = Convert.ToByte(reader["Flags"]);
                    broadcastText.ConditionID       = Convert.ToUInt32(reader["ConditionID"]);
                    broadcastText.SoundEntriesID    = new uint[2];
                    broadcastText.SoundEntriesID[0] = Convert.ToUInt32(reader["SoundEntriesID1"]);
                    broadcastText.SoundEntriesID[1] = Convert.ToUInt32(reader["SoundEntriesID2"]);

                    if (!DBC.DBC.BroadcastText.ContainsKey(id))
                    {
                        DBC.DBC.BroadcastText.TryAdd(id, broadcastText);
                    }
                    else
                    {
                        DBC.DBC.BroadcastText[id] = broadcastText;
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Loads the broadcast texts form the database.
        /// </summary>
        private static void LoadBroadcastText()
        {
            var    soundFieldName = Settings.TargetedDatabase >= TargetedDatabase.Shadowlands ? "Kit" : "Entries";
            string query          =
                $"SELECT ID, Text, Text1, EmoteID1, EmoteID2, EmoteID3, EmoteDelay1, EmoteDelay2, EmoteDelay3, EmotesID, LanguageID, Flags, ConditionID, Sound{soundFieldName}ID1, Sound{soundFieldName}ID2 " +
                $"FROM {Settings.HotfixesDatabase}.broadcast_text;";

            if (Settings.TargetedDatabase == TargetedDatabase.WrathOfTheLichKing || Settings.TargetedDatabase == TargetedDatabase.Cataclysm)
            {
                query = "SELECT ID, LanguageID, Text, Text1, EmoteID1, EmoteID2, EmoteID3, EmoteDelay1, EmoteDelay2, EmoteDelay3, SoundEntriesID, EmotesID, Flags " +
                        $"FROM {Settings.TDBDatabase}.broadcast_text;";
            }

            using (var command = SQLConnector.CreateCommand(query))
            {
                if (command == null)
                {
                    return;
                }

                using (MySqlDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        var id    = Convert.ToInt32(reader["Id"]);
                        var text  = Convert.ToString(reader["Text"]);
                        var text1 = Convert.ToString(reader["Text1"]);

                        if (!BroadcastTexts.ContainsKey(text))
                        {
                            BroadcastTexts[text] = new List <int>();
                        }
                        BroadcastTexts[text].Add(id);

                        if (!BroadcastText1s.ContainsKey(text1))
                        {
                            BroadcastText1s[text1] = new List <int>();
                        }
                        BroadcastText1s[text1].Add(id);

                        if (!Settings.UseDBC)
                        {
                            continue;
                        }

                        var broadcastText = new BroadcastTextEntry()
                        {
                            Text  = text,
                            Text1 = text1,
                        };
                        broadcastText.EmoteID       = new ushort[3];
                        broadcastText.EmoteID[0]    = Convert.ToUInt16(reader["EmoteID1"]);
                        broadcastText.EmoteID[1]    = Convert.ToUInt16(reader["EmoteID2"]);
                        broadcastText.EmoteID[2]    = Convert.ToUInt16(reader["EmoteID3"]);
                        broadcastText.EmoteDelay    = new ushort[3];
                        broadcastText.EmoteDelay[0] = Convert.ToUInt16(reader["EmoteDelay1"]);
                        broadcastText.EmoteDelay[1] = Convert.ToUInt16(reader["EmoteDelay2"]);
                        broadcastText.EmoteDelay[2] = Convert.ToUInt16(reader["EmoteDelay3"]);
                        broadcastText.EmotesID      = Convert.ToUInt16(reader["EmotesID"]);
                        broadcastText.LanguageID    = Convert.ToInt32(reader["LanguageID"]);
                        broadcastText.Flags         = Convert.ToByte(reader["Flags"]);
                        if (Settings.TargetedDatabase == TargetedDatabase.WrathOfTheLichKing || Settings.TargetedDatabase == TargetedDatabase.Cataclysm)
                        {
                            broadcastText.ConditionID       = 0;
                            broadcastText.SoundEntriesID    = new uint[2];
                            broadcastText.SoundEntriesID[0] = Convert.ToUInt32(reader["SoundEntriesID"]);
                            broadcastText.SoundEntriesID[1] = 0;
                        }
                        else
                        {
                            broadcastText.ConditionID       = Convert.ToUInt32(reader["ConditionID"]);
                            broadcastText.SoundEntriesID    = new uint[2];
                            broadcastText.SoundEntriesID[0] = Convert.ToUInt32(reader[$"Sound{soundFieldName}ID1"]);
                            broadcastText.SoundEntriesID[1] = Convert.ToUInt32(reader[$"Sound{soundFieldName}ID2"]);
                        }

                        if (!DBC.DBC.BroadcastText.ContainsKey(id))
                        {
                            DBC.DBC.BroadcastText.Add(id, broadcastText);
                        }
                        else
                        {
                            DBC.DBC.BroadcastText[id] = broadcastText;
                        }
                    }
                }
            }
        }