55 TC_LOG_INFO(
"server.loading",
">> Loaded 0 ceature texts. DB table `creature_text` is empty.");
64 Field* fields = result->Fetch();
85 TC_LOG_ERROR(
"sql.sql",
"CreatureTextMgr: Entry {}, Group {} in table `creature_text` has Sound {} but sound does not exist.", temp.
creatureId, temp.
groupId, temp.
sound);
137 while (result->NextRow());
155 Field* fields = result->Fetch();
168 }
while (result->NextRow());
173uint32 CreatureTextMgr::SendChat(
Creature* source,
uint8 textGroup,
WorldObject const* whisperTarget ,
ChatMsg msgType ,
Language language ,
CreatureTextRange range ,
uint32 sound ,
SoundKitPlayType playType ,
Team team ,
bool gmOnly ,
Player* srcPlr )
181 TC_LOG_ERROR(
"sql.sql.creaturetextmgr",
"CreatureTextMgr: Could not find Text for Creature {} ({}) in 'creature_text' table. Ignoring.", source->
GetName(), source->
GetGUID().
ToString());
186 CreatureTextHolder::const_iterator itr = textHolder.find(textGroup);
187 if (itr == textHolder.end())
189 TC_LOG_ERROR(
"sql.sql.creaturetextmgr",
"CreatureTextMgr: Could not find TextGroup {} for Creature {} ({}) in 'creature_text' table. Ignoring.",
uint32(textGroup), source->
GetName(), source->
GetGUID().
ToString());
197 for (CreatureTextGroup::const_iterator giter = textGroupContainer.begin(); giter != textGroupContainer.end(); ++giter)
198 if (std::find(repeatGroup.begin(), repeatGroup.end(), giter->id) == repeatGroup.end())
199 tempGroup.push_back(*giter);
201 if (tempGroup.empty())
204 tempGroup = textGroupContainer;
214 uint32 finalSound = iter->sound;
220 finalPlayType = playType;
224 finalSound = broadcastTextSoundId;
227 range = iter->TextRange;
229 Unit* finalSource = source;
231 finalSource = srcPlr;
235 Trinity::CreatureTextTextBuilder builder(source, finalSource, finalSource->
GetGender(), finalType, iter->groupId, iter->id, finalLang, whisperTarget, iter->BroadcastTextId, iter->emote, finalSound, finalPlayType, bct ? bct->
ConditionID : 0);
236 SendChatPacket(finalSource, builder, finalType, whisperTarget, range, team, gmOnly);
240 Trinity::CreatureTextTextBuilder builder(finalSource, finalSource, finalSource->
GetGender(), finalType, iter->groupId, iter->id, finalLang, whisperTarget, iter->BroadcastTextId, iter->emote, finalSound, finalPlayType, bct ? bct->
ConditionID : 0);
241 SendChatPacket(finalSource, builder, finalType, whisperTarget, range, team, gmOnly);
245 return iter->duration;
272 CreatureTextMap::const_iterator sList =
mTextMap.find(sourceEntry);
275 TC_LOG_DEBUG(
"entities.unit",
"CreatureTextMgr::TextExist: Could not find Text for Creature (entry {}) in 'creature_text' table.", sourceEntry);
280 CreatureTextHolder::const_iterator itr = textHolder.find(textGroup);
281 if (itr == textHolder.end())
283 TC_LOG_DEBUG(
"entities.unit",
"CreatureTextMgr::TextExist: Could not find TextGroup {} for Creature (entry {}).",
uint32(textGroup), sourceEntry);
292 CreatureTextMap::const_iterator mapitr =
mTextMap.find(entry);
296 CreatureTextHolder::const_iterator holderItr = mapitr->second.find(textGroup);
297 if (holderItr == mapitr->second.end())
300 CreatureTextGroup::const_iterator groupItr = holderItr->second.begin();
301 for (; groupItr != holderItr->second.end(); ++groupItr)
302 if (groupItr->id ==
id)
305 if (groupItr == holderItr->second.end())
311 std::string baseText =
"";
317 baseText = groupItr->text;
LocaleConstant GetLocaleByName(std::string_view name)
constexpr bool IsValidLocale(LocaleConstant locale)
std::vector< CreatureTextEntry > CreatureTextGroup
std::unordered_map< uint8, CreatureTextGroup > CreatureTextHolder
std::vector< uint8 > CreatureTextRepeatIds
DB2Storage< EmotesEntry > sEmotesStore("Emotes.db2", &EmotesLoadInfo::Instance)
DB2Storage< BroadcastTextEntry > sBroadcastTextStore("BroadcastText.db2", &BroadcastTextLoadInfo::Instance)
DB2Storage< SoundKitEntry > sSoundKitStore("SoundKit.db2", &SoundKitLoadInfo::Instance)
std::shared_ptr< ResultSet > QueryResult
std::shared_ptr< PreparedResultSet > PreparedQueryResult
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
#define TC_LOG_DEBUG(filterType__, message__,...)
#define TC_LOG_ERROR(filterType__, message__,...)
#define TC_LOG_INFO(filterType__, message__,...)
@ CHAT_MSG_RAID_BOSS_EMOTE
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
@ WORLD_SEL_CREATURE_TEXT
ObjectGuid const & GetGUID() const
LocaleCreatureTextMap mLocaleTextMap
std::string GetLocalizedChatString(uint32 entry, uint8 gender, uint8 textGroup, uint32 id, LocaleConstant locale) const
static void SendChatPacket(WorldObject *source, Builder const &builder, ChatMsg msgType, WorldObject const *whisperTarget=nullptr, CreatureTextRange range=TEXT_RANGE_NORMAL, Team team=TEAM_OTHER, bool gmOnly=false)
bool TextExist(uint32 sourceEntry, uint8 textGroup) const
static float GetRangeForChatType(ChatMsg msgType)
void LoadCreatureTextLocales()
static CreatureTextMgr * instance()
uint32 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, SoundKitPlayType playType=SoundKitPlayType::Normal, Team team=TEAM_OTHER, bool gmOnly=false, Player *srcPlr=nullptr)
CreatureTextRepeatIds GetTextRepeatGroup(uint8 textGroup)
void SetTextRepeatId(uint8 textGroup, uint8 id)
void ClearTextRepeatGroup(uint8 textGroup)
static char const * GetBroadcastTextValue(BroadcastTextEntry const *broadcastText, LocaleConstant locale=DEFAULT_LOCALE, uint8 gender=GENDER_MALE, bool forceGender=false)
Class used to access individual fields of database query result.
float GetFloat() const noexcept
uint32 GetUInt32() const noexcept
std::string_view GetStringView() const noexcept
uint8 GetUInt8() const noexcept
std::string GetString() const noexcept
std::string ToString() const
static void AddLocaleString(std::string_view value, LocaleConstant localeConstant, std::vector< std::string > &data)
static std::string_view GetLocaleString(std::vector< std::string > const &data, LocaleConstant locale)
std::string const & GetName() const
@ CONFIG_LISTEN_RANGE_YELL
@ CONFIG_LISTEN_RANGE_SAY
@ CONFIG_LISTEN_RANGE_TEXTEMOTE
auto SelectRandomWeightedContainerElement(C const &container, std::span< double > const &weights) -> decltype(std::ranges::begin(container))
std::array< uint32, 2 > SoundKitID
SoundKitPlayType SoundPlayType
CreatureTextRange TextRange
std::vector< std::string > Text