71 SF_LOG_INFO(
"server.loading",
">> Loaded 0 ceature texts. DB table `creature_texts` is empty.");
81 Field* fields = result->Fetch();
98 SF_LOG_ERROR(
"sql.sql",
"CreatureTextMgr: Entry %u, Group %u in table `creature_texts` has Sound %u but sound does not exist.", temp.
entry, temp.
group, temp.
sound);
104 SF_LOG_ERROR(
"sql.sql",
"CreatureTextMgr: Entry %u, Group %u in table `creature_texts` using Language %u but Language does not exist.", temp.
entry, temp.
group,
uint32(temp.
lang));
109 SF_LOG_ERROR(
"sql.sql",
"CreatureTextMgr: Entry %u, Group %u in table `creature_texts` has Type %u but this Chat Type does not exist.", temp.
entry, temp.
group,
uint32(temp.
type));
116 SF_LOG_ERROR(
"sql.sql",
"CreatureTextMgr: Entry %u, Group %u in table `creature_texts` has Emote %u but emote does not exist.", temp.
entry, temp.
group,
uint32(temp.
emote));
128 }
while (result->NextRow());
130 SF_LOG_INFO(
"server.loading",
">> Loaded %u creature texts for %u creatures in %u ms", textCount, creatureCount,
GetMSTimeDiffToNow(oldMSTime));
139 QueryResult result =
WorldDatabase.Query(
"SELECT entry, groupid, id, text_loc1, text_loc2, text_loc3, text_loc4, text_loc5, text_loc6, text_loc7, text_loc8, text_loc9, text_loc10, text_loc11 FROM locales_creature_text");
148 Field* fields = result->Fetch();
157 }
while (result->NextRow());
170 SF_LOG_ERROR(
"sql.sql",
"CreatureTextMgr: Could not find Text for Creature(%s) Entry %u in 'creature_text' table. Ignoring.", source->
GetName().c_str(), source->
GetEntry());
175 CreatureTextHolder::const_iterator itr = textHolder.find(textGroup);
176 if (itr == textHolder.end())
186 for (CreatureTextGroup::const_iterator giter = textGroupContainer.begin(); giter != textGroupContainer.end(); ++giter)
187 if (std::find(repeatGroup.begin(), repeatGroup.end(), giter->id) == repeatGroup.end())
188 tempGroup.push_back(*giter);
190 if (tempGroup.empty())
195 CreatureTextRepeatGroup::iterator groupItr = mapItr->second.find(textGroup);
196 groupItr->second.clear();
199 tempGroup = textGroupContainer;
203 float lastChance = -1;
204 bool isEqualChanced =
true;
206 float totalChance = 0;
208 for (CreatureTextGroup::const_iterator iter = tempGroup.begin(); iter != tempGroup.end(); ++iter)
210 if (lastChance >= 0 && lastChance != iter->probability)
211 isEqualChanced =
false;
213 lastChance = iter->probability;
214 totalChance += iter->probability;
221 for (CreatureTextGroup::const_iterator iter = tempGroup.begin(); iter != tempGroup.end(); ++iter)
224 uint32 r = std::rand() % 100;
232 if (isEqualChanced || offset < 0)
233 pos = std::rand() % count;
234 else if (offset >= 0)
237 CreatureTextGroup::const_iterator iter = tempGroup.begin() + pos;
241 uint32 finalSound = sound ? sound : iter->sound;
244 SendSound(source, finalSound, finalType, whisperTarget, range, team, gmOnly);
246 Unit* finalSource = source;
248 finalSource = srcPlr;
255 PlayerTextBuilder builder(source, finalSource, finalType, iter->group, iter->id, finalLang, whisperTarget);
256 SendChatPacket(finalSource, builder, finalType, whisperTarget, range, team, gmOnly);
260 CreatureTextBuilder builder(finalSource, finalType, iter->group, iter->id, finalLang, whisperTarget);
261 SendChatPacket(finalSource, builder, finalType, whisperTarget, range, team, gmOnly);
263 if (isEqualChanced || (!isEqualChanced && totalChance == 100.0f))
266 return iter->duration;
290 if (!sound || !source)
347 if (itr->GetSource()->GetAreaId() == areaId && (!team ||
Team(itr->GetSource()->GetTeam()) == team) && (!gmOnly || itr->GetSource()->IsGameMaster()))
348 itr->GetSource()->GetSession()->SendPacket(data);
356 if (itr->GetSource()->GetZoneId() == zoneId && (!team ||
Team(itr->GetSource()->GetTeam()) == team) && (!gmOnly || itr->GetSource()->IsGameMaster()))
357 itr->GetSource()->GetSession()->SendPacket(data);
364 if ((!team ||
Team(itr->GetSource()->GetTeam()) == team) && (!gmOnly || itr->GetSource()->IsGameMaster()))
365 itr->GetSource()->GetSession()->SendPacket(data);
371 for (SessionMap::const_iterator iter = smap.begin(); iter != smap.end(); ++iter)
373 if (player->GetSession() && (!team ||
Team(player->GetTeam()) == team) && (!gmOnly || player->IsGameMaster()))
374 player->GetSession()->SendPacket(data);
399 if (std::find(repeats.begin(), repeats.end(),
id) == repeats.end())
400 repeats.push_back(
id);
413 CreatureTextRepeatGroup::const_iterator groupItr = (*mapItr).second.find(textGroup);
414 if (groupItr != mapItr->second.end())
415 ids = groupItr->second;
425 CreatureTextMap::const_iterator sList =
mTextMap.find(sourceEntry);
428 SF_LOG_DEBUG(
"entities.unit",
"CreatureTextMgr::TextExist: Could not find Text for Creature (entry %u) in 'creature_text' table.", sourceEntry);
433 CreatureTextHolder::const_iterator itr = textHolder.find(textGroup);
434 if (itr == textHolder.end())
436 SF_LOG_DEBUG(
"entities.unit",
"CreatureTextMgr::TextExist: Could not find TextGroup %u for Creature (entry %u).",
uint32(textGroup), sourceEntry);
445 CreatureTextMap::const_iterator mapitr =
mTextMap.find(entry);
449 CreatureTextHolder::const_iterator holderItr = mapitr->second.find(textGroup);
450 if (holderItr == mapitr->second.end())
453 CreatureTextGroup::const_iterator groupItr = holderItr->second.begin();
454 for (; groupItr != holderItr->second.end(); ++groupItr)
455 if (groupItr->id ==
id)
458 if (groupItr == holderItr->second.end())
461 std::string baseText = groupItr->text;
const uint8 TOTAL_LOCALES
std::vector< uint8 > CreatureTextRepeatIds
UNORDERED_MAP< uint8, CreatureTextGroup > CreatureTextHolder
std::vector< CreatureTextEntry > CreatureTextGroup
DBCStorage< SoundEntriesEntry > sSoundEntriesStore(SoundEntriesfmt)
DBCStorage< EmotesEntry > sEmotesStore(EmotesEntryfmt)
#define SF_LOG_DEBUG(filterType__,...)
#define SF_LOG_ERROR(filterType__,...)
#define SF_LOG_INFO(filterType__,...)
LanguageDesc const * GetLanguageDescByID(Language lang)
Skyfire::AutoPtr< PreparedResultSet, Skyfire::Mutex > PreparedQueryResult
Skyfire::AutoPtr< ResultSet, Skyfire::Mutex > QueryResult
@ CHAT_MSG_RAID_BOSS_WHISPER
@ CHAT_MSG_RAID_BOSS_EMOTE
@ CHAT_MSG_MONSTER_WHISPER
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
@ WORLD_SEL_CREATURE_TEXT
bool WriteBit(uint32 bit)
void WriteByteSeq(uint8 b)
static size_t BuildChatPacket(WorldPacket &data, ChatMsg chatType, Language language, ObjectGuid senderGUID, ObjectGuid receiverGUID, std::string const &message, uint8 chatTag, std::string const &senderName="", std::string const &receiverName="", uint32 achievementId=0, bool gmMessage=false, std::string const &channelName="", std::string const &addonPrefix="")
WorldObject const * _target
CreatureTextBuilder(WorldObject *obj, ChatMsg msgtype, uint8 textGroup, uint32 id, Language language, WorldObject const *target)
size_t operator()(WorldPacket *data, LocaleConstant locale) const
LocaleCreatureTextMap mLocaleTextMap
std::string GetLocalizedChatString(uint32 entry, uint8 textGroup, uint32 id, LocaleConstant locale) const
uint32 SendChat(Creature *source, uint8 textGroup, WorldObject const *whisperTarget=NULL, ChatMsg msgType=ChatMsg::CHAT_MSG_ADDON, Language language=Language::LANG_ADDON, CreatureTextRange range=TEXT_RANGE_NORMAL, uint32 sound=0, Team team=TEAM_OTHER, bool gmOnly=false, Player *srcPlr=NULL)
void SetRepeatId(Creature *source, uint8 textGroup, uint8 id)
void LoadCreatureTextLocales()
CreatureTextRepeatMap mTextRepeatMap
void SendEmote(Unit *source, uint32 emote)
bool TextExist(uint32 sourceEntry, uint8 textGroup)
CreatureTextRepeatIds GetRepeatGroup(Creature *source, uint8 textGroup)
void SendNonChatPacket(WorldObject *source, WorldPacket *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
void SendChatPacket(WorldObject *source, Builder const &builder, ChatMsg msgType, WorldObject const *whisperTarget=NULL, CreatureTextRange range=TEXT_RANGE_NORMAL, Team team=TEAM_OTHER, bool gmOnly=false) const
std::string GetString() const
PlayerList const & GetPlayers() const
LinkedListHead::Iterator< MapReference const > const_iterator
uint32 GetGUIDLow() const
static void AddLocaleString(std::string const &s, LocaleConstant locale, StringVector &data)
static void GetLocaleString(const StringVector &data, int loc_idx, std::string &value)
WorldSession * GetSession() const
PlayerTextBuilder(WorldObject *obj, WorldObject *speaker, ChatMsg msgtype, uint8 textGroup, uint32 id, Language language, WorldObject const *target)
size_t operator()(WorldPacket *data, LocaleConstant locale) const
WorldObject const * _target
void HandleEmoteCommand(uint32 anim_id)
static Player * GetPlayer(WorldObject &object, uint64 guid)
virtual void SendMessageToSetInRange(WorldPacket *data, float dist, bool self)
std::string const & GetName() const
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
WorldDatabaseWorkerPool WorldDatabase
Accessor to the world database.
UNORDERED_MAP< uint32, WorldSession * > SessionMap
@ CONFIG_LISTEN_RANGE_YELL
@ CONFIG_LISTEN_RANGE_TEXTEMOTE
@ CONFIG_LISTEN_RANGE_SAY