mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Misc: Update locales_creature_text to simple system
This commit is contained in:
56
sql/updates/world/master/2017_11_04_00_world.sql
Normal file
56
sql/updates/world/master/2017_11_04_00_world.sql
Normal file
@@ -0,0 +1,56 @@
|
||||
-- creature_text
|
||||
ALTER TABLE `creature_text` CHANGE `entry` `CreatureID` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0';
|
||||
ALTER TABLE `creature_text` CHANGE `groupid` `GroupID` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0';
|
||||
ALTER TABLE `creature_text` CHANGE `id` `ID` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0';
|
||||
ALTER TABLE `creature_text` CHANGE `text` `Text` LONGTEXT;
|
||||
ALTER TABLE `creature_text` CHANGE `type` `Type` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0';
|
||||
ALTER TABLE `creature_text` CHANGE `language` `Language` TINYINT(3) NOT NULL DEFAULT '0';
|
||||
ALTER TABLE `creature_text` CHANGE `probability` `Probability` FLOAT UNSIGNED NOT NULL DEFAULT '0';
|
||||
ALTER TABLE `creature_text` CHANGE `emote` `Emote` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0';
|
||||
ALTER TABLE `creature_text` CHANGE `duration` `Duration` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0';
|
||||
ALTER TABLE `creature_text` CHANGE `sound` `Sound` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0';
|
||||
|
||||
-- creature_text_locale
|
||||
DROP TABLE IF EXISTS `creature_text_locale`;
|
||||
CREATE TABLE IF NOT EXISTS `creature_text_locale` (
|
||||
`CreatureID` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`GroupID` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`ID` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`Locale` VARCHAR(4) NOT NULL,
|
||||
`Text` TEXT,
|
||||
PRIMARY KEY (`CreatureID`, `GroupID`, `ID`)
|
||||
) ENGINE=MYISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
-- koKR
|
||||
INSERT INTO `creature_text_locale` (`CreatureID`, `GroupID`, `ID`, `Locale`, `Text`)
|
||||
(SELECT `entry`, `groupid`, `id`, "koKR", `text_loc1` FROM `locales_creature_text` WHERE LENGTH(text_loc1) > 0);
|
||||
|
||||
-- frFR
|
||||
INSERT INTO `creature_text_locale` (`CreatureID`, `GroupID`, `ID`, `Locale`, `Text`)
|
||||
(SELECT `entry`, `groupid`, `id`, "frFR", `text_loc2` FROM `locales_creature_text` WHERE LENGTH(text_loc2) > 0);
|
||||
|
||||
-- deDE
|
||||
INSERT INTO `creature_text_locale` (`CreatureID`, `GroupID`, `ID`, `Locale`, `Text`)
|
||||
(SELECT `entry`, `groupid`, `id`, "deDE", `text_loc3` FROM `locales_creature_text` WHERE LENGTH(text_loc3) > 0);
|
||||
|
||||
-- zhCN
|
||||
INSERT INTO `creature_text_locale` (`CreatureID`, `GroupID`, `ID`, `Locale`, `Text`)
|
||||
(SELECT `entry`, `groupid`, `id`, "zhCN", `text_loc4` FROM `locales_creature_text` WHERE LENGTH(text_loc4) > 0);
|
||||
|
||||
-- zhTW
|
||||
INSERT INTO `creature_text_locale` (`CreatureID`, `GroupID`, `ID`, `Locale`, `Text`)
|
||||
(SELECT `entry`, `groupid`, `id`, "zhTW", `text_loc5` FROM `locales_creature_text` WHERE LENGTH(text_loc5) > 0);
|
||||
|
||||
-- esES
|
||||
INSERT INTO `creature_text_locale` (`CreatureID`, `GroupID`, `ID`, `Locale`, `Text`)
|
||||
(SELECT `entry`, `groupid`, `id`, "esES", `text_loc6` FROM `locales_creature_text` WHERE LENGTH(text_loc6) > 0);
|
||||
|
||||
-- esMX
|
||||
INSERT INTO `creature_text_locale` (`CreatureID`, `GroupID`, `ID`, `Locale`, `Text`)
|
||||
(SELECT `entry`, `groupid`, `id`, "esMX", `text_loc7` FROM `locales_creature_text` WHERE LENGTH(text_loc7) > 0);
|
||||
|
||||
-- ruRU
|
||||
INSERT INTO `creature_text_locale` (`CreatureID`, `GroupID`, `ID`, `Locale`, `Text`)
|
||||
(SELECT `entry`, `groupid`, `id`, "ruRU", `text_loc8` FROM `locales_creature_text` WHERE LENGTH(text_loc8) > 0);
|
||||
|
||||
DROP TABLE IF EXISTS `locales_creature_text`;
|
||||
@@ -26,7 +26,7 @@ void WorldDatabaseConnection::DoPrepareStatements()
|
||||
PrepareStatement(WORLD_SEL_QUEST_POOLS, "SELECT entry, pool_entry FROM pool_quest", CONNECTION_SYNCH);
|
||||
PrepareStatement(WORLD_DEL_CRELINKED_RESPAWN, "DELETE FROM linked_respawn WHERE guid = ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(WORLD_REP_CREATURE_LINKED_RESPAWN, "REPLACE INTO linked_respawn (guid, linkedGuid) VALUES (?, ?)", CONNECTION_ASYNC);
|
||||
PrepareStatement(WORLD_SEL_CREATURE_TEXT, "SELECT entry, groupid, id, text, type, language, probability, emote, duration, sound, BroadcastTextId, TextRange FROM creature_text", CONNECTION_SYNCH);
|
||||
PrepareStatement(WORLD_SEL_CREATURE_TEXT, "SELECT CreatureID, GroupID, ID, Text, Type, Language, Probability, Emote, Duration, Sound, BroadcastTextId, TextRange FROM creature_text", CONNECTION_SYNCH);
|
||||
PrepareStatement(WORLD_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", CONNECTION_SYNCH);
|
||||
PrepareStatement(WORLD_SEL_SMARTAI_WP, "SELECT entry, pointid, position_x, position_y, position_z FROM waypoints ORDER BY entry, pointid", CONNECTION_SYNCH);
|
||||
PrepareStatement(WORLD_DEL_GAMEOBJECT, "DELETE FROM gameobject WHERE guid = ?", CONNECTION_ASYNC);
|
||||
|
||||
@@ -108,8 +108,8 @@ void CreatureTextMgr::LoadCreatureTexts()
|
||||
Field* fields = result->Fetch();
|
||||
CreatureTextEntry temp;
|
||||
|
||||
temp.entry = fields[0].GetUInt32();
|
||||
temp.group = fields[1].GetUInt8();
|
||||
temp.creatureId = fields[0].GetUInt32();
|
||||
temp.groupId = fields[1].GetUInt8();
|
||||
temp.id = fields[2].GetUInt8();
|
||||
temp.text = fields[3].GetString();
|
||||
temp.type = ChatMsg(fields[4].GetUInt8());
|
||||
@@ -125,20 +125,20 @@ void CreatureTextMgr::LoadCreatureTexts()
|
||||
{
|
||||
if (!sSoundKitStore.LookupEntry(temp.sound))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "CreatureTextMgr: Entry %u, Group %u in table `creature_text` has Sound %u but sound does not exist.", temp.entry, temp.group, temp.sound);
|
||||
TC_LOG_ERROR("sql.sql", "CreatureTextMgr: Entry %u, Group %u in table `creature_text` has Sound %u but sound does not exist.", temp.creatureId, temp.groupId, temp.sound);
|
||||
temp.sound = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!GetLanguageDescByID(temp.lang))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "CreatureTextMgr: Entry %u, Group %u in table `creature_text` using Language %u but Language does not exist.", temp.entry, temp.group, uint32(temp.lang));
|
||||
TC_LOG_ERROR("sql.sql", "CreatureTextMgr: Entry %u, Group %u in table `creature_text` using Language %u but Language does not exist.", temp.creatureId, temp.groupId, uint32(temp.lang));
|
||||
temp.lang = LANG_UNIVERSAL;
|
||||
}
|
||||
|
||||
if (temp.type >= MAX_CHAT_MSG_TYPE)
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "CreatureTextMgr: Entry %u, Group %u in table `creature_text` has Type %u but this Chat Type does not exist.", temp.entry, temp.group, uint32(temp.type));
|
||||
TC_LOG_ERROR("sql.sql", "CreatureTextMgr: Entry %u, Group %u in table `creature_text` has Type %u but this Chat Type does not exist.", temp.creatureId, temp.groupId, uint32(temp.type));
|
||||
temp.type = CHAT_MSG_SAY;
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ void CreatureTextMgr::LoadCreatureTexts()
|
||||
{
|
||||
if (!sEmotesStore.LookupEntry(temp.emote))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "CreatureTextMgr: Entry %u, Group %u in table `creature_text` has Emote %u but emote does not exist.", temp.entry, temp.group, uint32(temp.emote));
|
||||
TC_LOG_ERROR("sql.sql", "CreatureTextMgr: Entry %u, Group %u in table `creature_text` has Emote %u but emote does not exist.", temp.creatureId, temp.groupId, uint32(temp.emote));
|
||||
temp.emote = EMOTE_ONESHOT_NONE;
|
||||
}
|
||||
}
|
||||
@@ -155,19 +155,19 @@ void CreatureTextMgr::LoadCreatureTexts()
|
||||
{
|
||||
if (!sBroadcastTextStore.LookupEntry(temp.BroadcastTextId))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "CreatureTextMgr: Entry %u, Group %u, Id %u in table `creature_text` has non-existing or incompatible BroadcastTextId %u.", temp.entry, temp.group, temp.id, temp.BroadcastTextId);
|
||||
TC_LOG_ERROR("sql.sql", "CreatureTextMgr: Entry %u, Group %u, Id %u in table `creature_text` has non-existing or incompatible BroadcastTextId %u.", temp.creatureId, temp.groupId, temp.id, temp.BroadcastTextId);
|
||||
temp.BroadcastTextId = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (temp.TextRange > TEXT_RANGE_WORLD)
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "CreatureTextMgr: Entry %u, Group %u, Id %u in table `creature_text` has incorrect TextRange %u.", temp.entry, temp.group, temp.id, temp.TextRange);
|
||||
TC_LOG_ERROR("sql.sql", "CreatureTextMgr: Entry %u, Group %u, Id %u in table `creature_text` has incorrect TextRange %u.", temp.creatureId, temp.groupId, temp.id, temp.TextRange);
|
||||
temp.TextRange = TEXT_RANGE_NORMAL;
|
||||
}
|
||||
|
||||
// add the text into our entry's group
|
||||
mTextMap[temp.entry][temp.group].push_back(temp);
|
||||
mTextMap[temp.creatureId][temp.groupId].push_back(temp);
|
||||
|
||||
++textCount;
|
||||
}
|
||||
@@ -182,27 +182,30 @@ void CreatureTextMgr::LoadCreatureTextLocales()
|
||||
|
||||
mLocaleTextMap.clear(); // for reload case
|
||||
|
||||
QueryResult result = WorldDatabase.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");
|
||||
QueryResult result = WorldDatabase.Query("SELECT CreatureId, GroupId, ID, Locale, Text FROM creature_text_locale");
|
||||
|
||||
if (!result)
|
||||
return;
|
||||
|
||||
uint32 textCount = 0;
|
||||
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
CreatureTextLocale& loc = mLocaleTextMap[CreatureTextId(fields[0].GetUInt32(), uint32(fields[1].GetUInt8()), uint32(fields[2].GetUInt8()))];
|
||||
for (uint8 i = OLD_TOTAL_LOCALES - 1; i > 0; --i)
|
||||
{
|
||||
LocaleConstant locale = LocaleConstant(i);
|
||||
ObjectMgr::AddLocaleString(fields[3 + i - 1].GetString(), locale, loc.Text);
|
||||
}
|
||||
|
||||
++textCount;
|
||||
uint32 creatureId = fields[0].GetUInt32();
|
||||
uint32 groupId = fields[1].GetUInt8();
|
||||
uint32 id = fields[2].GetUInt8();
|
||||
std::string localeName = fields[3].GetString();
|
||||
std::string text = fields[4].GetString();
|
||||
|
||||
CreatureTextLocale& data = mLocaleTextMap[CreatureTextId(creatureId, groupId, id)];
|
||||
LocaleConstant locale = GetLocaleByName(localeName);
|
||||
if (locale == LOCALE_enUS)
|
||||
continue;
|
||||
|
||||
ObjectMgr::AddLocaleString(text, locale, data.Text);
|
||||
} while (result->NextRow());
|
||||
|
||||
TC_LOG_INFO("server.loading", ">> Loaded %u creature localized texts in %u ms", textCount, GetMSTimeDiffToNow(oldMSTime));
|
||||
TC_LOG_INFO("server.loading", ">> Loaded %u creature localized texts in %u ms", uint32(mLocaleTextMap.size()), GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
|
||||
uint32 CreatureTextMgr::SendChat(Creature* source, uint8 textGroup, WorldObject const* whisperTarget /*= nullptr*/, ChatMsg msgType /*= CHAT_MSG_ADDON*/, Language language /*= LANG_ADDON*/, CreatureTextRange range /*= TEXT_RANGE_NORMAL*/, uint32 sound /*= 0*/, Team team /*= TEAM_OTHER*/, bool gmOnly /*= false*/, Player* srcPlr /*= nullptr*/)
|
||||
@@ -268,12 +271,12 @@ uint32 CreatureTextMgr::SendChat(Creature* source, uint8 textGroup, WorldObject
|
||||
|
||||
if (srcPlr)
|
||||
{
|
||||
PlayerTextBuilder builder(source, finalSource, finalSource->getGender(), finalType, iter->group, iter->id, finalLang, whisperTarget);
|
||||
PlayerTextBuilder builder(source, finalSource, finalSource->getGender(), finalType, iter->groupId, iter->id, finalLang, whisperTarget);
|
||||
SendChatPacket(finalSource, builder, finalType, whisperTarget, range, team, gmOnly);
|
||||
}
|
||||
else
|
||||
{
|
||||
CreatureTextBuilder builder(finalSource, finalSource->getGender(), finalType, iter->group, iter->id, finalLang, whisperTarget);
|
||||
CreatureTextBuilder builder(finalSource, finalSource->getGender(), finalType, iter->groupId, iter->id, finalLang, whisperTarget);
|
||||
SendChatPacket(finalSource, builder, finalType, whisperTarget, range, team, gmOnly);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,8 +41,8 @@ enum CreatureTextRange
|
||||
|
||||
struct CreatureTextEntry
|
||||
{
|
||||
uint32 entry;
|
||||
uint8 group;
|
||||
uint32 creatureId;
|
||||
uint8 groupId;
|
||||
uint8 id;
|
||||
std::string text;
|
||||
ChatMsg type;
|
||||
|
||||
Reference in New Issue
Block a user