mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 01:08:35 +00:00
Core/Text: Add support for BroadcastTextID in creature_text table. (#265)
This commit is contained in:
1
data/sql/updates/db_world/2016_12_02_00.sql
Normal file
1
data/sql/updates/db_world/2016_12_02_00.sql
Normal file
File diff suppressed because one or more lines are too long
@@ -15,7 +15,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, TextRange FROM creature_text", CONNECTION_SYNCH);
|
||||
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_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, 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);
|
||||
|
||||
@@ -17,19 +17,20 @@
|
||||
class CreatureTextBuilder
|
||||
{
|
||||
public:
|
||||
CreatureTextBuilder(WorldObject* obj, ChatMsg msgtype, uint8 textGroup, uint32 id, uint32 language, WorldObject const* target)
|
||||
: _source(obj), _msgType(msgtype), _textGroup(textGroup), _textId(id), _language(language), _target(target)
|
||||
CreatureTextBuilder(WorldObject* obj, uint8 gender, ChatMsg msgtype, uint8 textGroup, uint32 id, uint32 language, WorldObject const* target)
|
||||
: _source(obj), _gender(gender), _msgType(msgtype), _textGroup(textGroup), _textId(id), _language(language), _target(target)
|
||||
{
|
||||
}
|
||||
|
||||
size_t operator()(WorldPacket* data, LocaleConstant locale) const
|
||||
{
|
||||
std::string const& text = sCreatureTextMgr->GetLocalizedChatString(_source->GetEntry(), _textGroup, _textId, locale);
|
||||
std::string const& text = sCreatureTextMgr->GetLocalizedChatString(_source->GetEntry(), _gender, _textGroup, _textId, locale);
|
||||
|
||||
return ChatHandler::BuildChatPacket(*data, _msgType, Language(_language), _source, _target, text, 0, "", locale);
|
||||
}
|
||||
|
||||
WorldObject* _source;
|
||||
uint8 _gender;
|
||||
ChatMsg _msgType;
|
||||
uint8 _textGroup;
|
||||
uint32 _textId;
|
||||
@@ -40,20 +41,21 @@ class CreatureTextBuilder
|
||||
class PlayerTextBuilder
|
||||
{
|
||||
public:
|
||||
PlayerTextBuilder(WorldObject* obj, WorldObject* speaker, ChatMsg msgtype, uint8 textGroup, uint32 id, uint32 language, WorldObject const* target)
|
||||
: _source(obj), _talker(speaker), _msgType(msgtype), _textGroup(textGroup), _textId(id), _language(language), _target(target)
|
||||
PlayerTextBuilder(WorldObject* obj, WorldObject* speaker, uint8 gender, ChatMsg msgtype, uint8 textGroup, uint32 id, uint32 language, WorldObject const* target)
|
||||
: _source(obj), _talker(speaker), _gender(gender), _msgType(msgtype), _textGroup(textGroup), _textId(id), _language(language), _target(target)
|
||||
{
|
||||
}
|
||||
|
||||
size_t operator()(WorldPacket* data, LocaleConstant locale) const
|
||||
{
|
||||
std::string const& text = sCreatureTextMgr->GetLocalizedChatString(_source->GetEntry(), _textGroup, _textId, locale);
|
||||
std::string const& text = sCreatureTextMgr->GetLocalizedChatString(_source->GetEntry(), _gender, _textGroup, _textId, locale);
|
||||
|
||||
return ChatHandler::BuildChatPacket(*data, _msgType, Language(_language), _talker, _target, text, 0, "", locale);
|
||||
}
|
||||
|
||||
WorldObject* _source;
|
||||
WorldObject* _talker;
|
||||
uint8 _gender;
|
||||
ChatMsg _msgType;
|
||||
uint8 _textGroup;
|
||||
uint32 _textId;
|
||||
@@ -85,17 +87,18 @@ void CreatureTextMgr::LoadCreatureTexts()
|
||||
Field* fields = result->Fetch();
|
||||
CreatureTextEntry temp;
|
||||
|
||||
temp.entry = fields[0].GetUInt32();
|
||||
temp.group = fields[1].GetUInt8();
|
||||
temp.id = fields[2].GetUInt8();
|
||||
temp.text = fields[3].GetString();
|
||||
temp.type = ChatMsg(fields[4].GetUInt8());
|
||||
temp.lang = Language(fields[5].GetUInt8());
|
||||
temp.probability = fields[6].GetFloat();
|
||||
temp.emote = Emote(fields[7].GetUInt32());
|
||||
temp.duration = fields[8].GetUInt32();
|
||||
temp.sound = fields[9].GetUInt32();
|
||||
temp.TextRange = CreatureTextRange(fields[10].GetUInt8());
|
||||
temp.entry = fields[0].GetUInt32();
|
||||
temp.group = fields[1].GetUInt8();
|
||||
temp.id = fields[2].GetUInt8();
|
||||
temp.text = fields[3].GetString();
|
||||
temp.type = ChatMsg(fields[4].GetUInt8());
|
||||
temp.lang = Language(fields[5].GetUInt8());
|
||||
temp.probability = fields[6].GetFloat();
|
||||
temp.emote = Emote(fields[7].GetUInt32());
|
||||
temp.duration = fields[8].GetUInt32();
|
||||
temp.sound = fields[9].GetUInt32();
|
||||
temp.BroadcastTextId = fields[10].GetUInt32();
|
||||
temp.TextRange = CreatureTextRange(fields[11].GetUInt8());
|
||||
|
||||
if (temp.sound)
|
||||
{
|
||||
@@ -122,7 +125,14 @@ void CreatureTextMgr::LoadCreatureTexts()
|
||||
temp.emote = EMOTE_ONESHOT_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
if (temp.BroadcastTextId)
|
||||
{
|
||||
if (!sObjectMgr->GetBroadcastText(temp.BroadcastTextId))
|
||||
{
|
||||
sLog->outErrorDb("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);
|
||||
temp.BroadcastTextId = 0;
|
||||
}
|
||||
}
|
||||
if (temp.TextRange > TEXT_RANGE_WORLD)
|
||||
{
|
||||
sLog->outErrorDb("CreatureTextMgr: Entry %u, Group %u, Id %u in table `creature_text` has incorrect TextRange %u.", temp.entry, temp.group, temp.id, temp.TextRange);
|
||||
@@ -265,12 +275,12 @@ uint32 CreatureTextMgr::SendChat(Creature* source, uint8 textGroup, WorldObject
|
||||
|
||||
if (srcPlr)
|
||||
{
|
||||
PlayerTextBuilder builder(source, finalSource, finalType, iter->group, iter->id, finalLang, whisperTarget);
|
||||
PlayerTextBuilder builder(source, finalSource, finalSource->getGender(), finalType, iter->group, iter->id, finalLang, whisperTarget);
|
||||
SendChatPacket(finalSource, builder, finalType, whisperTarget, range, teamId, gmOnly);
|
||||
}
|
||||
else
|
||||
{
|
||||
CreatureTextBuilder builder(finalSource, finalType, iter->group, iter->id, finalLang, whisperTarget);
|
||||
CreatureTextBuilder builder(finalSource, finalSource->getGender(), finalType, iter->group, iter->id, finalLang, whisperTarget);
|
||||
SendChatPacket(finalSource, builder, finalType, whisperTarget, range, teamId, gmOnly);
|
||||
}
|
||||
if (isEqualChanced || (!isEqualChanced && totalChance == 100.0f))
|
||||
@@ -434,7 +444,7 @@ bool CreatureTextMgr::TextExist(uint32 sourceEntry, uint8 textGroup)
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string CreatureTextMgr::GetLocalizedChatString(uint32 entry, uint8 textGroup, uint32 id, LocaleConstant locale) const
|
||||
std::string CreatureTextMgr::GetLocalizedChatString(uint32 entry, uint8 gender, uint8 textGroup, uint32 id, LocaleConstant locale) const
|
||||
{
|
||||
CreatureTextMap::const_iterator mapitr = mTextMap.find(entry);
|
||||
if (mapitr == mTextMap.end())
|
||||
@@ -452,5 +462,19 @@ std::string CreatureTextMgr::GetLocalizedChatString(uint32 entry, uint8 textGrou
|
||||
if (groupItr == holderItr->second.end())
|
||||
return "";
|
||||
|
||||
return groupItr->text;
|
||||
if (locale > MAX_LOCALES)
|
||||
locale = DEFAULT_LOCALE;
|
||||
std::string baseText = "";
|
||||
BroadcastText const* bct = sObjectMgr->GetBroadcastText(groupItr->BroadcastTextId);
|
||||
if (bct)
|
||||
baseText = bct->GetText(locale, gender);
|
||||
else
|
||||
baseText = groupItr->text;
|
||||
if (locale != DEFAULT_LOCALE && !bct)
|
||||
{
|
||||
LocaleCreatureTextMap::const_iterator locItr = mLocaleTextMap.find(CreatureTextId(entry, uint32(textGroup), id));
|
||||
if (locItr != mLocaleTextMap.end())
|
||||
ObjectMgr::GetLocaleString(locItr->second.Text, locale, baseText);
|
||||
}
|
||||
return baseText;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ struct CreatureTextEntry
|
||||
uint32 duration;
|
||||
uint32 sound;
|
||||
CreatureTextRange TextRange;
|
||||
uint32 BroadcastTextId;
|
||||
};
|
||||
|
||||
struct CreatureTextLocale
|
||||
@@ -86,7 +87,7 @@ class CreatureTextMgr
|
||||
//if sent, returns the 'duration' of the text else 0 if error
|
||||
uint32 SendChat(Creature* source, uint8 textGroup, WorldObject const* whisperTarget = NULL, ChatMsg msgType = CHAT_MSG_ADDON, Language language = LANG_ADDON, CreatureTextRange range = TEXT_RANGE_NORMAL, uint32 sound = 0, TeamId teamId = TEAM_NEUTRAL, bool gmOnly = false, Player* srcPlr = NULL);
|
||||
bool TextExist(uint32 sourceEntry, uint8 textGroup);
|
||||
std::string GetLocalizedChatString(uint32 entry, uint8 textGroup, uint32 id, LocaleConstant locale) const;
|
||||
std::string GetLocalizedChatString(uint32 entry, uint8 gender, uint8 textGroup, uint32 id, LocaleConstant locale) const;
|
||||
|
||||
template<class Builder> void SendChatPacket(WorldObject* source, Builder const& builder, ChatMsg msgType, WorldObject const* whisperTarget = NULL, CreatureTextRange range = TEXT_RANGE_NORMAL, TeamId teamId = TEAM_NEUTRAL, bool gmOnly = false) const;
|
||||
|
||||
|
||||
@@ -1619,7 +1619,7 @@ class instance_icecrown_citadel : public InstanceMapScript
|
||||
if (player->GetQuestStatus(QUEST_A_FEAST_OF_SOULS) == QUEST_STATUS_INCOMPLETE)
|
||||
{
|
||||
uint8 id = urand(0, 15);
|
||||
std::string const& text = sCreatureTextMgr->GetLocalizedChatString(NPC_THE_LICH_KING_LH, 20+id, 0, LOCALE_enUS);
|
||||
std::string const& text = sCreatureTextMgr->GetLocalizedChatString(NPC_THE_LICH_KING_LH, 0, 20 + id, 0, LOCALE_enUS);
|
||||
WorldPacket data;
|
||||
ChatHandler::BuildChatPacket(data, CHAT_MSG_MONSTER_WHISPER, LANG_UNIVERSAL, 0, player->GetGUID(), text, CHAT_TAG_NONE, "The Lich King");
|
||||
player->SendPlaySound(17235 + id, true);
|
||||
|
||||
@@ -1360,7 +1360,7 @@ public:
|
||||
return;
|
||||
|
||||
uint8 id = GetSpeachId();
|
||||
std::string const& text = sCreatureTextMgr->GetLocalizedChatString(me->GetEntry(), id, 0, LOCALE_enUS);
|
||||
std::string const& text = sCreatureTextMgr->GetLocalizedChatString(me->GetEntry(), 0, id, 0, LOCALE_enUS);
|
||||
WorldPacket data;
|
||||
ChatHandler::BuildChatPacket(data, CHAT_MSG_MONSTER_WHISPER, LANG_UNIVERSAL, me->GetGUID(), summoner->GetGUID(), text, CHAT_TAG_NONE, "Toalu'u the Mystic");
|
||||
summoner->ToPlayer()->SendDirectMessage(&data);
|
||||
|
||||
@@ -648,7 +648,7 @@ public:
|
||||
if (owner->ToPlayer()->GetGroup())
|
||||
{
|
||||
_hasParty = true;
|
||||
std::string const& text = sCreatureTextMgr->GetLocalizedChatString(me->GetEntry(), 0 /*text group*/, urand(0, 60) /*text id*/, LOCALE_enUS);
|
||||
std::string const& text = sCreatureTextMgr->GetLocalizedChatString(me->GetEntry(), 0, 0 /*text group*/, urand(0, 60) /*text id*/, LOCALE_enUS);
|
||||
|
||||
_data.Initialize(SMSG_MESSAGECHAT, 200); // guess size
|
||||
_data << uint8(CHAT_MSG_MONSTER_PARTY);
|
||||
|
||||
Reference in New Issue
Block a user