Update locales_creature_text to simple system

This commit is contained in:
hondacrx
2017-11-04 19:01:39 -04:00
parent 420d11b847
commit 8c863de8a6
2 changed files with 35 additions and 27 deletions
@@ -24,7 +24,7 @@ namespace Framework.Database
PrepareStatement(WorldStatements.SEL_QUEST_POOLS, "SELECT entry, pool_entry FROM pool_quest"); 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.DEL_CRELINKED_RESPAWN, "DELETE FROM linked_respawn WHERE guid = ?");
PrepareStatement(WorldStatements.REP_CREATURE_LINKED_RESPAWN, "REPLACE INTO linked_respawn (guid, linkedGuid) VALUES (?, ?)"); 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_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.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 = ?"); PrepareStatement(WorldStatements.DEL_GAMEOBJECT, "DELETE FROM gameobject WHERE guid = ?");
+34 -26
View File
@@ -25,6 +25,7 @@ using Game.Groups;
using Game.Maps; using Game.Maps;
using Game.Network; using Game.Network;
using Game.Network.Packets; using Game.Network.Packets;
using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace Game namespace Game
@@ -56,8 +57,8 @@ namespace Game
{ {
CreatureTextEntry temp = new CreatureTextEntry(); CreatureTextEntry temp = new CreatureTextEntry();
temp.entry = result.Read<uint>(0); temp.creatureId = result.Read<uint>(0);
temp.group = result.Read<byte>(1); temp.groupId = result.Read<byte>(1);
temp.id = result.Read<byte>(2); temp.id = result.Read<byte>(2);
temp.text = result.Read<string>(3); temp.text = result.Read<string>(3);
temp.type = (ChatMsg)result.Read<byte>(4); temp.type = (ChatMsg)result.Read<byte>(4);
@@ -73,25 +74,25 @@ namespace Game
{ {
if (!CliDB.SoundKitStorage.ContainsKey(temp.sound)) 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; temp.sound = 0;
} }
} }
if (ObjectManager.GetLanguageDescByID(temp.lang) == null) 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; temp.lang = Language.Universal;
} }
if (temp.type >= ChatMsg.Max) 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; temp.type = ChatMsg.Say;
} }
if (temp.emote != 0) if (temp.emote != 0)
{ {
if (!CliDB.EmotesStorage.ContainsKey((uint)temp.emote)) 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; temp.emote = Emote.OneshotNone;
} }
} }
@@ -100,24 +101,24 @@ namespace Game
{ {
if (!CliDB.BroadcastTextStorage.ContainsKey(temp.BroadcastTextId)) 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; temp.BroadcastTextId = 0;
} }
} }
if (temp.TextRange > CreatureTextRange.World) 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; temp.TextRange = CreatureTextRange.Normal;
} }
if (!mTextMap.ContainsKey(temp.entry)) if (!mTextMap.ContainsKey(temp.creatureId))
{ {
mTextMap[temp.entry] = new MultiMap<byte,CreatureTextEntry>(); mTextMap[temp.creatureId] = new MultiMap<byte,CreatureTextEntry>();
++creatureCount; ++creatureCount;
} }
mTextMap[temp.entry].Add(temp.group, temp); mTextMap[temp.creatureId].Add(temp.groupId, temp);
++textCount; ++textCount;
} while (result.NextRow()); } while (result.NextRow());
@@ -130,26 +131,33 @@ namespace Game
mLocaleTextMap.Clear(); // for reload case 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()) if (result.IsEmpty())
return; return;
uint textCount = 0;
do do
{ {
CreatureTextLocale loc = new CreatureTextLocale(); uint creatureId = result.Read<uint>(0);
for (byte locale = 1; locale < (int)LocaleConstant.OldTotal; ++locale) uint groupId = result.Read<byte>(1);
{ uint id = result.Read<byte>(2);
ObjectManager.AddLocaleString(result.Read<string>(3 + locale - 1), (LocaleConstant)locale, loc.Text); string localeName = result.Read<string>(3);
} string text = result.Read<string>(4);
var key = new CreatureTextId(creatureId, groupId, id);
if (!mLocaleTextMap.ContainsKey(key))
mLocaleTextMap[key] = new CreatureTextLocale();
LocaleConstant locale = localeName.ToEnum<LocaleConstant>();
if (locale == LocaleConstant.enUS)
continue;
CreatureTextLocale data = mLocaleTextMap[key];
ObjectManager.AddLocaleString(text, locale, data.Text);
mLocaleTextMap[new CreatureTextId(result.Read<uint>(0), result.Read<byte>(1), result.Read<byte>(2))] = loc;
++textCount;
} while (result.NextRow()); } 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, 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) 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); SendChatPacket(finalSource, builder, finalType, whisperTarget, range, team, gmOnly);
} }
else 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); SendChatPacket(finalSource, builder, finalType, whisperTarget, range, team, gmOnly);
} }
@@ -539,8 +547,8 @@ namespace Game
public class CreatureTextEntry public class CreatureTextEntry
{ {
public uint entry; public uint creatureId;
public byte group; public byte groupId;
public byte id; public byte id;
public string text; public string text;
public ChatMsg type; public ChatMsg type;