97 TC_LOG_INFO(
"server.loading",
">> Loaded 0 ceature texts. DB table `creature_text` is empty.");
106 Field* fields = result->Fetch();
126 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);
172 while (result->NextRow());
191 Field* fields = result->Fetch();
196 std::string localeName = fields[3].
GetString();
204 }
while (result->NextRow());
217 TC_LOG_ERROR(
"sql.sql.creaturetextmgr",
"CreatureTextMgr: Could not find Text for Creature {} ({}) in 'creature_text' table. Ignoring.", source->
GetName(), source->
GetGUID().
ToString());
222 CreatureTextHolder::const_iterator itr = textHolder.find(textGroup);
223 if (itr == textHolder.end())
225 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());
233 for (CreatureTextGroup::const_iterator giter = textGroupContainer.begin(); giter != textGroupContainer.end(); ++giter)
234 if (std::find(repeatGroup.begin(), repeatGroup.end(), giter->id) == repeatGroup.end())
235 tempGroup.push_back(*giter);
237 if (tempGroup.empty())
240 tempGroup = textGroupContainer;
250 uint32 finalSound = sound ? sound : iter->sound;
253 range = iter->TextRange;
256 SendSound(source, finalSound, finalType, whisperTarget, range, team, gmOnly);
258 Unit* finalSource = source;
260 finalSource = srcPlr;
267 PlayerTextBuilder builder(source, finalSource, finalSource->
GetGender(), finalType, iter->groupId, iter->id, finalLang, whisperTarget);
268 SendChatPacket(finalSource, builder, finalType, whisperTarget, range, team, gmOnly);
273 SendChatPacket(finalSource, builder, finalType, whisperTarget, range, team, gmOnly);
277 return iter->duration;
301 if (!sound || !source)
318 if (
Group const* group = whisperPlayer->GetGroup())
347 if (itr->GetSource()->GetAreaId() == areaId && (!team ||
Team(itr->GetSource()->GetTeam()) == team) && (!gmOnly || itr->GetSource()->IsGameMaster()))
348 itr->GetSource()->SendDirectMessage(data);
356 if (itr->GetSource()->GetZoneId() == zoneId && (!team ||
Team(itr->GetSource()->GetTeam()) == team) && (!gmOnly || itr->GetSource()->IsGameMaster()))
357 itr->GetSource()->SendDirectMessage(data);
364 if ((!team ||
Team(itr->GetSource()->GetTeam()) == team) && (!gmOnly || itr->GetSource()->IsGameMaster()))
365 itr->GetSource()->SendDirectMessage(data);
371 for (SessionMap::const_iterator iter = smap.begin(); iter != smap.end(); ++iter)
372 if (
Player* player = iter->second->GetPlayer())
373 if ((!team ||
Team(player->GetTeam()) == team) && (!gmOnly || player->IsGameMaster()))
374 player->SendDirectMessage(data);
399 CreatureTextMap::const_iterator sList =
mTextMap.find(sourceEntry);
402 TC_LOG_DEBUG(
"entities.unit",
"CreatureTextMgr::TextExist: Could not find Text for Creature (entry {}) in 'creature_text' table.", sourceEntry);
407 CreatureTextHolder::const_iterator itr = textHolder.find(textGroup);
408 if (itr == textHolder.end())
410 TC_LOG_DEBUG(
"entities.unit",
"CreatureTextMgr::TextExist: Could not find TextGroup {} for Creature (entry {}).",
uint32(textGroup), sourceEntry);
419 CreatureTextMap::const_iterator mapitr =
mTextMap.find(entry);
423 CreatureTextHolder::const_iterator holderItr = mapitr->second.find(textGroup);
424 if (holderItr == mapitr->second.end())
427 CreatureTextGroup::const_iterator groupItr = holderItr->second.begin();
428 for (; groupItr != holderItr->second.end(); ++groupItr)
429 if (groupItr->id ==
id)
432 if (groupItr == holderItr->second.end())
438 std::string baseText =
"";
442 baseText = bct->
GetText(locale, gender);
444 baseText = groupItr->text;
LocaleConstant GetLocaleByName(const std::string &name)
std::vector< CreatureTextEntry > CreatureTextGroup
std::unordered_map< uint8, CreatureTextGroup > CreatureTextHolder
std::vector< uint8 > CreatureTextRepeatIds
DBCStorage< SoundEntriesEntry > sSoundEntriesStore(SoundEntriesfmt)
DBCStorage< EmotesEntry > sEmotesStore(EmotesEntryfmt)
std::shared_ptr< ResultSet > QueryResult
std::shared_ptr< PreparedResultSet > PreparedQueryResult
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
#define TC_LOG_DEBUG(filterType__,...)
#define TC_LOG_ERROR(filterType__,...)
#define TC_LOG_INFO(filterType__,...)
LanguageDesc const * GetLanguageDescByID(uint32 lang)
#define MAX_CHAT_MSG_TYPE
@ CHAT_MSG_MONSTER_WHISPER
@ CHAT_MSG_RAID_BOSS_WHISPER
@ CHAT_MSG_RAID_BOSS_EMOTE
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
@ WORLD_SEL_CREATURE_TEXT
static size_t BuildChatPacket(WorldPacket &data, ChatMsg chatType, Language language, ObjectGuid senderGUID, ObjectGuid receiverGUID, std::string_view message, uint8 chatTag, std::string const &senderName="", std::string const &receiverName="", uint32 achievementId=0, bool gmMessage=false, std::string const &channelName="")
WorldObject const * _target
CreatureTextBuilder(WorldObject const *obj, uint8 gender, ChatMsg msgtype, uint8 textGroup, uint32 id, uint32 language, WorldObject const *target)
WorldObject const * _source
size_t operator()(WorldPacket *data, LocaleConstant locale) const
LocaleCreatureTextMap mLocaleTextMap
std::string GetLocalizedChatString(uint32 entry, uint8 gender, uint8 textGroup, uint32 id, LocaleConstant locale) const
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) const
void LoadCreatureTextLocales()
void SendEmote(Unit *source, Emote emote)
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, Team team=TEAM_OTHER, bool gmOnly=false, Player *srcPlr=nullptr)
bool TextExist(uint32 sourceEntry, uint8 textGroup)
void SendNonChatPacket(WorldObject *source, WorldPacket const *data, ChatMsg msgType, WorldObject const *whisperTarget, CreatureTextRange range, Team team, bool gmOnly) const
void SendSound(Creature *source, uint32 sound, ChatMsg msgType, WorldObject const *whisperTarget, CreatureTextRange range, Team team, bool gmOnly)
float GetRangeForChatType(ChatMsg msgType) const
CreatureTextRepeatIds GetTextRepeatGroup(uint8 textGroup)
void SetTextRepeatId(uint8 textGroup, uint8 id)
void ClearTextRepeatGroup(uint8 textGroup)
Class used to access individual fields of database query result.
std::string GetString() const
PlayerList const & GetPlayers() const
std::string ToString() const
static std::string_view GetLocaleString(std::vector< std::string > const &data, size_t locale)
static void AddLocaleString(std::string &&value, LocaleConstant localeConstant, std::vector< std::string > &data)
static ObjectGuid GetGUID(Object const *o)
static Player * ToPlayer(Object *o)
PlayerTextBuilder(WorldObject const *obj, WorldObject const *speaker, uint8 gender, ChatMsg msgtype, uint8 textGroup, uint32 id, uint32 language, WorldObject const *target)
WorldObject const * _talker
size_t operator()(WorldPacket *data, LocaleConstant locale) const
WorldObject const * _source
WorldObject const * _target
void SendDirectMessage(WorldPacket const *data) const
void HandleEmoteCommand(Emote emoteId)
std::string const & GetName() const
virtual void SendMessageToSetInRange(WorldPacket const *data, float dist, bool self) const
std::unordered_map< uint32, WorldSession * > SessionMap
@ CONFIG_LISTEN_RANGE_YELL
@ CONFIG_LISTEN_RANGE_SAY
@ CONFIG_LISTEN_RANGE_TEXTEMOTE
auto SelectRandomWeightedContainerElement(C const &container, std::vector< double > weights) -> decltype(std::begin(container))
std::string const & GetText(LocaleConstant locale=DEFAULT_LOCALE, uint8 gender=GENDER_MALE, bool forceGender=false) const
CreatureTextRange TextRange
std::vector< std::string > Text