46 *data = packet.
Move();
75 *data = packet.
Move();
109 TC_LOG_INFO(
"server.loading",
">> Loaded 0 ceature texts. DB table `creature_text` is empty.");
118 Field* fields = result->Fetch();
138 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);
184 while (result->NextRow());
203 Field* fields = result->Fetch();
208 std::string localeName = fields[3].
GetString();
216 }
while (result->NextRow());
229 TC_LOG_ERROR(
"sql.sql.creaturetextmgr",
"CreatureTextMgr: Could not find Text for Creature {} ({}) in 'creature_text' table. Ignoring.", source->
GetName(), source->
GetGUID().
ToString());
234 CreatureTextHolder::const_iterator itr = textHolder.find(textGroup);
235 if (itr == textHolder.end())
237 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());
245 for (CreatureTextGroup::const_iterator giter = textGroupContainer.begin(); giter != textGroupContainer.end(); ++giter)
246 if (std::find(repeatGroup.begin(), repeatGroup.end(), giter->id) == repeatGroup.end())
247 tempGroup.push_back(*giter);
249 if (tempGroup.empty())
252 tempGroup = textGroupContainer;
262 uint32 finalSound = sound ? sound : iter->sound;
265 range = iter->TextRange;
268 SendSound(source, finalSound, finalType, whisperTarget, range, team, gmOnly);
270 Unit* finalSource = source;
272 finalSource = srcPlr;
279 PlayerTextBuilder builder(source, finalSource, finalSource->
GetGender(), finalType, iter->groupId, iter->id, finalLang, whisperTarget);
280 SendChatPacket(finalSource, builder, finalType, whisperTarget, range, team, gmOnly);
285 SendChatPacket(finalSource, builder, finalType, whisperTarget, range, team, gmOnly);
289 return iter->duration;
313 if (!sound || !source)
330 if (
Group const* group = whisperPlayer->GetGroup())
359 if (itr->GetSource()->GetAreaId() == areaId && (!team ||
Team(itr->GetSource()->GetTeam()) == team) && (!gmOnly || itr->GetSource()->IsGameMaster()))
360 itr->GetSource()->SendDirectMessage(data);
368 if (itr->GetSource()->GetZoneId() == zoneId && (!team ||
Team(itr->GetSource()->GetTeam()) == team) && (!gmOnly || itr->GetSource()->IsGameMaster()))
369 itr->GetSource()->SendDirectMessage(data);
376 if ((!team ||
Team(itr->GetSource()->GetTeam()) == team) && (!gmOnly || itr->GetSource()->IsGameMaster()))
377 itr->GetSource()->SendDirectMessage(data);
383 for (SessionMap::const_iterator iter = smap.begin(); iter != smap.end(); ++iter)
384 if (
Player* player = iter->second->GetPlayer())
385 if ((!team ||
Team(player->GetTeam()) == team) && (!gmOnly || player->IsGameMaster()))
386 player->SendDirectMessage(data);
411 CreatureTextMap::const_iterator sList =
mTextMap.find(sourceEntry);
414 TC_LOG_DEBUG(
"entities.unit",
"CreatureTextMgr::TextExist: Could not find Text for Creature (entry {}) in 'creature_text' table.", sourceEntry);
419 CreatureTextHolder::const_iterator itr = textHolder.find(textGroup);
420 if (itr == textHolder.end())
422 TC_LOG_DEBUG(
"entities.unit",
"CreatureTextMgr::TextExist: Could not find TextGroup {} for Creature (entry {}).",
uint32(textGroup), sourceEntry);
431 CreatureTextMap::const_iterator mapitr =
mTextMap.find(entry);
435 CreatureTextHolder::const_iterator holderItr = mapitr->second.find(textGroup);
436 if (holderItr == mapitr->second.end())
439 CreatureTextGroup::const_iterator groupItr = holderItr->second.begin();
440 for (; groupItr != holderItr->second.end(); ++groupItr)
441 if (groupItr->id ==
id)
444 if (groupItr == holderItr->second.end())
450 std::string baseText =
"";
454 baseText = bct->
GetText(locale, gender);
456 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)
@ CHAT_MSG_MONSTER_WHISPER
@ CHAT_MSG_RAID_BOSS_WHISPER
@ CHAT_MSG_RAID_BOSS_EMOTE
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
@ WORLD_SEL_CREATURE_TEXT
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
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 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)
static void SendNonChatPacket(WorldObject *source, WorldPacket const *data, ChatMsg msgType, WorldObject const *whisperTarget, CreatureTextRange range, Team team, bool gmOnly)
static void SendSound(Creature *source, uint32 sound, ChatMsg msgType, WorldObject const *whisperTarget=nullptr, CreatureTextRange range=TEXT_RANGE_NORMAL, Team team=TEAM_OTHER, bool gmOnly=false)
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, LocaleConstant 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
void Initialize(ChatMsg chatType, Language language, WorldObject const *sender, WorldObject const *receiver, std::string_view message, uint32 achievementId=0, std::string_view channelName="", LocaleConstant locale=DEFAULT_LOCALE, std::string_view addonPrefix="")
WorldPacket const * Write() override
std::size_t TargetGUIDPos
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