diff --git a/Source/Framework/Database/Databases/WorldDatabase.cs b/Source/Framework/Database/Databases/WorldDatabase.cs index 6a75fbbf7..e73f83b4f 100644 --- a/Source/Framework/Database/Databases/WorldDatabase.cs +++ b/Source/Framework/Database/Databases/WorldDatabase.cs @@ -24,7 +24,7 @@ namespace Framework.Database PrepareStatement(WorldStatements.SEL_QUEST_POOLS, "SELECT entry, pool_entry FROM pool_quest"); PrepareStatement(WorldStatements.DEL_CRELINKED_RESPAWN, "DELETE FROM linked_respawn WHERE guid = ?"); PrepareStatement(WorldStatements.REP_CREATURE_LINKED_RESPAWN, "REPLACE INTO linked_respawn (guid, linkedGuid) VALUES (?, ?)"); - PrepareStatement(WorldStatements.SEL_CREATURE_TEXT, "SELECT entry, groupid, id, text, type, language, probability, emote, duration, sound, BroadcastTextID, TextRange FROM creature_text"); + PrepareStatement(WorldStatements.SEL_CREATURE_TEXT, "SELECT CreatureID, GroupID, ID, Text, Type, Language, Probability, Emote, Duration, Sound, BroadcastTextId, TextRange FROM creature_text"); PrepareStatement(WorldStatements.SEL_SMART_SCRIPTS, "SELECT entryorguid, source_type, id, link, event_type, event_phase_mask, event_chance, event_flags, event_param1, event_param2, event_param3, event_param4, event_param_string, action_type, action_param1, action_param2, action_param3, action_param4, action_param5, action_param6, target_type, target_param1, target_param2, target_param3, target_x, target_y, target_z, target_o FROM smart_scripts ORDER BY entryorguid, source_type, id, link"); PrepareStatement(WorldStatements.SEL_SMARTAI_WP, "SELECT entry, pointid, position_x, position_y, position_z FROM waypoints ORDER BY entry, pointid"); PrepareStatement(WorldStatements.DEL_GAMEOBJECT, "DELETE FROM gameobject WHERE guid = ?"); diff --git a/Source/Game/Text/CreatureTextManager.cs b/Source/Game/Text/CreatureTextManager.cs index dde9cfa7c..5577d3a15 100644 --- a/Source/Game/Text/CreatureTextManager.cs +++ b/Source/Game/Text/CreatureTextManager.cs @@ -25,6 +25,7 @@ using Game.Groups; using Game.Maps; using Game.Network; using Game.Network.Packets; +using System; using System.Collections.Generic; namespace Game @@ -56,8 +57,8 @@ namespace Game { CreatureTextEntry temp = new CreatureTextEntry(); - temp.entry = result.Read(0); - temp.group = result.Read(1); + temp.creatureId = result.Read(0); + temp.groupId = result.Read(1); temp.id = result.Read(2); temp.text = result.Read(3); temp.type = (ChatMsg)result.Read(4); @@ -73,25 +74,25 @@ namespace Game { if (!CliDB.SoundKitStorage.ContainsKey(temp.sound)) { - Log.outError(LogFilter.Sql, "GossipManager: Entry {0}, Group {1} in table `creature_texts` has Sound {2} but sound does not exist.", temp.entry, temp.group, temp.sound); + Log.outError(LogFilter.Sql, "GossipManager: Entry {0}, Group {1} in table `creature_texts` has Sound {2} but sound does not exist.", temp.creatureId, temp.groupId, temp.sound); temp.sound = 0; } } if (ObjectManager.GetLanguageDescByID(temp.lang) == null) { - Log.outError(LogFilter.Sql, "GossipManager: Entry {0}, Group {1} in table `creature_texts` using Language {2} but Language does not exist.", temp.entry, temp.group, temp.lang); + Log.outError(LogFilter.Sql, "GossipManager: Entry {0}, Group {1} in table `creature_texts` using Language {2} but Language does not exist.", temp.creatureId, temp.groupId, temp.lang); temp.lang = Language.Universal; } if (temp.type >= ChatMsg.Max) { - Log.outError(LogFilter.Sql, "GossipManager: Entry {0}, Group {1} in table `creature_texts` has Type {2} but this Chat Type does not exist.", temp.entry, temp.group, temp.type); + Log.outError(LogFilter.Sql, "GossipManager: Entry {0}, Group {1} in table `creature_texts` has Type {2} but this Chat Type does not exist.", temp.creatureId, temp.groupId, temp.type); temp.type = ChatMsg.Say; } if (temp.emote != 0) { if (!CliDB.EmotesStorage.ContainsKey((uint)temp.emote)) { - Log.outError(LogFilter.Sql, "GossipManager: Entry {0}, Group {1} in table `creature_texts` has Emote {2} but emote does not exist.", temp.entry, temp.group, temp.emote); + Log.outError(LogFilter.Sql, "GossipManager: Entry {0}, Group {1} in table `creature_texts` has Emote {2} but emote does not exist.", temp.creatureId, temp.groupId, temp.emote); temp.emote = Emote.OneshotNone; } } @@ -100,24 +101,24 @@ namespace Game { if (!CliDB.BroadcastTextStorage.ContainsKey(temp.BroadcastTextId)) { - Log.outError(LogFilter.Sql, "CreatureTextMgr: Entry {0}, Group {1}, Id {2} in table `creature_texts` has non-existing or incompatible BroadcastTextId {3}.", temp.entry, temp.group, temp.id, temp.BroadcastTextId); + Log.outError(LogFilter.Sql, "CreatureTextMgr: Entry {0}, Group {1}, Id {2} in table `creature_texts` has non-existing or incompatible BroadcastTextId {3}.", temp.creatureId, temp.groupId, temp.id, temp.BroadcastTextId); temp.BroadcastTextId = 0; } } if (temp.TextRange > CreatureTextRange.World) { - Log.outError(LogFilter.Sql, "CreatureTextMgr: Entry {0}, Group {1}, Id {2} in table `creature_text` has incorrect TextRange {3}.", temp.entry, temp.group, temp.id, temp.TextRange); + Log.outError(LogFilter.Sql, "CreatureTextMgr: Entry {0}, Group {1}, Id {2} in table `creature_text` has incorrect TextRange {3}.", temp.creatureId, temp.groupId, temp.id, temp.TextRange); temp.TextRange = CreatureTextRange.Normal; } - if (!mTextMap.ContainsKey(temp.entry)) + if (!mTextMap.ContainsKey(temp.creatureId)) { - mTextMap[temp.entry] = new MultiMap(); + mTextMap[temp.creatureId] = new MultiMap(); ++creatureCount; } - mTextMap[temp.entry].Add(temp.group, temp); + mTextMap[temp.creatureId].Add(temp.groupId, temp); ++textCount; } while (result.NextRow()); @@ -130,26 +131,33 @@ namespace Game 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"); + SQLResult result = DB.World.Query("SELECT CreatureId, GroupId, ID, Locale, Text FROM creature_text_locale"); 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(3 + locale - 1), (LocaleConstant)locale, loc.Text); - } + uint creatureId = result.Read(0); + uint groupId = result.Read(1); + uint id = result.Read(2); + string localeName = result.Read(3); + string text = result.Read(4); + + var key = new CreatureTextId(creatureId, groupId, id); + if (!mLocaleTextMap.ContainsKey(key)) + mLocaleTextMap[key] = new CreatureTextLocale(); + + LocaleConstant locale = localeName.ToEnum(); + if (locale == LocaleConstant.enUS) + continue; + + CreatureTextLocale data = mLocaleTextMap[key]; + ObjectManager.AddLocaleString(text, locale, data.Text); - mLocaleTextMap[new CreatureTextId(result.Read(0), result.Read(1), result.Read(2))] = loc; - ++textCount; } while (result.NextRow()); - Log.outInfo(LogFilter.ServerLoading, "Loaded {0} creature localized texts in {1} ms", textCount, Time.GetMSTimeDiffToNow(oldMSTime)); + Log.outInfo(LogFilter.ServerLoading, "Loaded {0} creature localized texts in {1} ms", mLocaleTextMap.Count, Time.GetMSTimeDiffToNow(oldMSTime)); } public uint SendChat(Creature source, byte textGroup, WorldObject whisperTarget = null, ChatMsg msgType = ChatMsg.Addon, Language language = Language.Addon, @@ -218,12 +226,12 @@ namespace Game if (srcPlr) { - PlayerTextBuilder builder = new PlayerTextBuilder(source, finalSource, finalSource.GetGender(), finalType, textEntry.group, textEntry.id, finalLang, whisperTarget); + PlayerTextBuilder builder = new PlayerTextBuilder(source, finalSource, finalSource.GetGender(), finalType, textEntry.groupId, textEntry.id, finalLang, whisperTarget); SendChatPacket(finalSource, builder, finalType, whisperTarget, range, team, gmOnly); } else { - CreatureTextBuilder builder = new CreatureTextBuilder(finalSource, finalSource.GetGender(), finalType, textEntry.group, textEntry.id, finalLang, whisperTarget); + CreatureTextBuilder builder = new CreatureTextBuilder(finalSource, finalSource.GetGender(), finalType, textEntry.groupId, textEntry.id, finalLang, whisperTarget); SendChatPacket(finalSource, builder, finalType, whisperTarget, range, team, gmOnly); } @@ -539,8 +547,8 @@ namespace Game public class CreatureTextEntry { - public uint entry; - public byte group; + public uint creatureId; + public byte groupId; public byte id; public string text; public ChatMsg type;