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;
219 finalPlayType = playType;
223 finalSound = broadcastTextSoundId;
226 range = iter->TextRange;
229 SendSound(source, finalSound, finalType, whisperTarget, range, team, gmOnly, iter->BroadcastTextId, finalPlayType);
231 Unit* finalSource = source;
233 finalSource = srcPlr;
241 SendChatPacket(finalSource, builder, finalType, whisperTarget, range, team, gmOnly);
246 SendChatPacket(finalSource, builder, finalType, whisperTarget, range, team, gmOnly);
250 return iter->duration;
275 if (!sound || !source)
303 if (
Group const* group = whisperPlayer->GetGroup())
332 if (itr->GetSource()->GetAreaId() == areaId && (!team ||
Team(itr->GetSource()->GetEffectiveTeam()) == team) && (!gmOnly || itr->GetSource()->IsGameMaster()))
333 itr->GetSource()->SendDirectMessage(data);
341 if (itr->GetSource()->GetZoneId() == zoneId && (!team ||
Team(itr->GetSource()->GetEffectiveTeam()) == team) && (!gmOnly || itr->GetSource()->IsGameMaster()))
342 itr->GetSource()->SendDirectMessage(data);
349 if ((!team ||
Team(itr->GetSource()->GetEffectiveTeam()) == team) && (!gmOnly || itr->GetSource()->IsGameMaster()))
350 itr->GetSource()->SendDirectMessage(data);
356 for (SessionMap::const_iterator iter = smap.begin(); iter != smap.end(); ++iter)
357 if (
Player* player = iter->second->GetPlayer())
358 if ((!team ||
Team(player->GetTeam()) == team) && (!gmOnly || player->IsGameMaster()))
359 player->SendDirectMessage(data);
363 if (!whisperTarget || !whisperTarget->
IsPlayer())
390 CreatureTextMap::const_iterator sList =
mTextMap.find(sourceEntry);
393 TC_LOG_DEBUG(
"entities.unit",
"CreatureTextMgr::TextExist: Could not find Text for Creature (entry {}) in 'creature_text' table.", sourceEntry);
398 CreatureTextHolder::const_iterator itr = textHolder.find(textGroup);
399 if (itr == textHolder.end())
401 TC_LOG_DEBUG(
"entities.unit",
"CreatureTextMgr::TextExist: Could not find TextGroup {} for Creature (entry {}).",
uint32(textGroup), sourceEntry);
410 CreatureTextMap::const_iterator mapitr =
mTextMap.find(entry);
414 CreatureTextHolder::const_iterator holderItr = mapitr->second.find(textGroup);
415 if (holderItr == mapitr->second.end())
418 CreatureTextGroup::const_iterator groupItr = holderItr->second.begin();
419 for (; groupItr != holderItr->second.end(); ++groupItr)
420 if (groupItr->id ==
id)
423 if (groupItr == holderItr->second.end())
429 std::string baseText =
"";
435 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__,...)
#define TC_LOG_ERROR(filterType__,...)
#define TC_LOG_INFO(filterType__,...)
@ CHAT_MSG_MONSTER_WHISPER
@ CHAT_MSG_RAID_BOSS_WHISPER
@ CHAT_MSG_RAID_BOSS_EMOTE
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
@ WORLD_SEL_CREATURE_TEXT
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)
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, uint32 keyBroadcastTextId=0, SoundKitPlayType playType=SoundKitPlayType::Normal)
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, SoundKitPlayType playType=SoundKitPlayType::Normal, 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)
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.
std::string GetString() const
std::string_view GetStringView() const
PlayerList const & GetPlayers() const
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)
static ObjectGuid GetGUID(Object const *o)
static Player * ToPlayer(Object *o)
void SendDirectMessage(WorldPacket const *data) const
void HandleEmoteCommand(Emote emoteId, Player *target=nullptr, Trinity::IteratorPair< int32 const * > spellVisualKitIds={}, int32 sequenceVariation=0)
constexpr WorldLocation GetWorldLocation() const
std::string const & GetName() const
virtual void SendMessageToSetInRange(WorldPacket const *data, float dist, bool self) const
WorldPacket const * Write() override
TaggedPosition<::Position::XYZ > Position
ObjectGuid TargetObjectGUID
ObjectGuid SourceObjectGUID
WorldPacket const * Write() override
std::unordered_map< uint32, WorldSession * > SessionMap
@ CONFIG_LISTEN_RANGE_YELL
@ CONFIG_LISTEN_RANGE_SAY
@ CONFIG_LISTEN_RANGE_TEXTEMOTE
auto SelectRandomWeightedContainerElement(C const &container, std::span< double > const &weights) -> decltype(std::begin(container))
SoundKitPlayType SoundPlayType
CreatureTextRange TextRange
std::vector< std::string > Text