Example #1
0
        public void LoadCreatureTextLocales()
        {
            uint oldMSTime = Time.GetMSTime();

            mLocaleTextMap.Clear(); // for reload case

            SQLResult result = DB.World.Query("SELECT entry, groupid, id, text_loc1, text_loc2, text_loc3, text_loc4, text_loc5, text_loc6, text_loc7, text_loc8 FROM locales_creature_text");

            if (result.IsEmpty())
            {
                return;
            }

            uint textCount = 0;

            do
            {
                CreatureTextLocale loc = new CreatureTextLocale();
                for (byte locale = 1; locale < (int)LocaleConstant.OldTotal; ++locale)
                {
                    ObjectManager.AddLocaleString(result.Read <string>(3 + locale - 1), (LocaleConstant)locale, loc.Text);
                }

                mLocaleTextMap[new CreatureTextId(result.Read <uint>(0), result.Read <byte>(1), result.Read <byte>(2))] = loc;
                ++textCount;
            } while (result.NextRow());

            Log.outInfo(LogFilter.ServerLoading, "Loaded {0} creature localized texts in {1} ms", textCount, Time.GetMSTimeDiffToNow(oldMSTime));
        }
        public void LoadCreatureTextLocales()
        {
            uint oldMSTime = Time.GetMSTime();

            mLocaleTextMap.Clear(); // for reload case

            SQLResult result = DB.World.Query("SELECT CreatureId, GroupId, ID, Locale, Text FROM creature_text_locale");

            if (result.IsEmpty())
                return;

            do
            {
                uint creatureId = result.Read<uint>(0);
                uint groupId = result.Read<byte>(1);
                uint id = result.Read<byte>(2);
                string localeName = result.Read<string>(3);
                Locale locale = localeName.ToEnum<Locale>();
                if (!SharedConst.IsValidLocale(locale) || locale == Locale.enUS)
                    continue;

                var key = new CreatureTextId(creatureId, groupId, id);
                if (!mLocaleTextMap.ContainsKey(key))
                    mLocaleTextMap[key] = new CreatureTextLocale();

                CreatureTextLocale data = mLocaleTextMap[key];
                ObjectManager.AddLocaleString(result.Read<string>(4), locale, data.Text);

            } while (result.NextRow());

            Log.outInfo(LogFilter.ServerLoading, "Loaded {0} creature localized texts in {1} ms", mLocaleTextMap.Count, Time.GetMSTimeDiffToNow(oldMSTime));
        }