chore(Core/Texts): Rename parameter for creature texts (#10317)

This commit is contained in:
Nefertumm
2022-01-31 06:48:55 -03:00
committed by GitHub
parent 4df8b23c5f
commit ede60e2bc0
3 changed files with 20 additions and 20 deletions
+2 -2
View File
@@ -51,9 +51,9 @@ void CreatureAI::OnCharmed(bool /*apply*/)
AISpellInfoType* UnitAI::AISpellInfo; AISpellInfoType* UnitAI::AISpellInfo;
AISpellInfoType* GetAISpellInfo(uint32 i) { return &CreatureAI::AISpellInfo[i]; } AISpellInfoType* GetAISpellInfo(uint32 i) { return &CreatureAI::AISpellInfo[i]; }
void CreatureAI::Talk(uint8 id, WorldObject const* whisperTarget /*= nullptr*/) void CreatureAI::Talk(uint8 id, WorldObject const* target /*= nullptr*/)
{ {
sCreatureTextMgr->SendChat(me, id, whisperTarget); sCreatureTextMgr->SendChat(me, id, target);
} }
inline bool IsValidCombatTarget(Creature* source, Player* target) inline bool IsValidCombatTarget(Creature* source, Player* target)
+11 -11
View File
@@ -196,7 +196,7 @@ void CreatureTextMgr::LoadCreatureTextLocales()
LOG_INFO("server.loading", " "); LOG_INFO("server.loading", " ");
} }
uint32 CreatureTextMgr::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*/, TeamId teamId /*= TEAM_NEUTRAL*/, bool gmOnly /*= false*/, Player* srcPlr /*= nullptr*/) uint32 CreatureTextMgr::SendChat(Creature* source, uint8 textGroup, WorldObject const* target /*= nullptr*/, ChatMsg msgType /*= CHAT_MSG_ADDON*/, Language language /*= LANG_ADDON*/, CreatureTextRange range /*= TEXT_RANGE_NORMAL*/, uint32 sound /*= 0*/, TeamId teamId /*= TEAM_NEUTRAL*/, bool gmOnly /*= false*/, Player* srcPlr /*= nullptr*/)
{ {
if (!source) if (!source)
return 0; return 0;
@@ -282,7 +282,7 @@ uint32 CreatureTextMgr::SendChat(Creature* source, uint8 textGroup, WorldObject
range = iter->TextRange; range = iter->TextRange;
if (finalSound) if (finalSound)
SendSound(source, finalSound, finalType, whisperTarget, range, teamId, gmOnly); SendSound(source, finalSound, finalType, target, range, teamId, gmOnly);
Unit* finalSource = source; Unit* finalSource = source;
if (srcPlr) if (srcPlr)
@@ -293,13 +293,13 @@ uint32 CreatureTextMgr::SendChat(Creature* source, uint8 textGroup, WorldObject
if (srcPlr) if (srcPlr)
{ {
PlayerTextBuilder builder(source, finalSource, finalSource->getGender(), finalType, iter->group, iter->id, finalLang, whisperTarget); PlayerTextBuilder builder(source, finalSource, finalSource->getGender(), finalType, iter->group, iter->id, finalLang, target);
SendChatPacket(finalSource, builder, finalType, whisperTarget, range, teamId, gmOnly); SendChatPacket(finalSource, builder, finalType, target, range, teamId, gmOnly);
} }
else else
{ {
CreatureTextBuilder builder(finalSource, finalSource->getGender(), finalType, iter->group, iter->id, finalLang, whisperTarget); CreatureTextBuilder builder(finalSource, finalSource->getGender(), finalType, iter->group, iter->id, finalLang, target);
SendChatPacket(finalSource, builder, finalType, whisperTarget, range, teamId, gmOnly); SendChatPacket(finalSource, builder, finalType, target, range, teamId, gmOnly);
} }
if (isEqualChanced || (!isEqualChanced && totalChance == 100.0f)) if (isEqualChanced || (!isEqualChanced && totalChance == 100.0f))
SetRepeatId(source, textGroup, iter->id); SetRepeatId(source, textGroup, iter->id);
@@ -326,17 +326,17 @@ float CreatureTextMgr::GetRangeForChatType(ChatMsg msgType) const
return dist; return dist;
} }
void CreatureTextMgr::SendSound(Creature* source, uint32 sound, ChatMsg msgType, WorldObject const* whisperTarget, CreatureTextRange range, TeamId teamId, bool gmOnly) void CreatureTextMgr::SendSound(Creature* source, uint32 sound, ChatMsg msgType, WorldObject const* target, CreatureTextRange range, TeamId teamId, bool gmOnly)
{ {
if (!sound || !source) if (!sound || !source)
return; return;
WorldPacket data(SMSG_PLAY_SOUND, 4); WorldPacket data(SMSG_PLAY_SOUND, 4);
data << uint32(sound); data << uint32(sound);
SendNonChatPacket(source, &data, msgType, whisperTarget, range, teamId, gmOnly); SendNonChatPacket(source, &data, msgType, target, range, teamId, gmOnly);
} }
void CreatureTextMgr::SendNonChatPacket(WorldObject* source, WorldPacket* data, ChatMsg msgType, WorldObject const* whisperTarget, CreatureTextRange range, TeamId teamId, bool gmOnly) const void CreatureTextMgr::SendNonChatPacket(WorldObject* source, WorldPacket* data, ChatMsg msgType, WorldObject const* target, CreatureTextRange range, TeamId teamId, bool gmOnly) const
{ {
float dist = GetRangeForChatType(msgType); float dist = GetRangeForChatType(msgType);
@@ -347,10 +347,10 @@ void CreatureTextMgr::SendNonChatPacket(WorldObject* source, WorldPacket* data,
{ {
if (range == TEXT_RANGE_NORMAL)//ignores team and gmOnly if (range == TEXT_RANGE_NORMAL)//ignores team and gmOnly
{ {
if (!whisperTarget || whisperTarget->GetTypeId() != TYPEID_PLAYER) if (!target || target->GetTypeId() != TYPEID_PLAYER)
return; return;
whisperTarget->ToPlayer()->GetSession()->SendPacket(data); target->ToPlayer()->GetSession()->SendPacket(data);
return; return;
} }
break; break;
+7 -7
View File
@@ -94,21 +94,21 @@ public:
void LoadCreatureTextLocales(); void LoadCreatureTextLocales();
CreatureTextMap const& GetTextMap() const { return mTextMap; } CreatureTextMap const& GetTextMap() const { return mTextMap; }
void SendSound(Creature* source, uint32 sound, ChatMsg msgType, WorldObject const* whisperTarget, CreatureTextRange range, TeamId teamId, bool gmOnly); void SendSound(Creature* source, uint32 sound, ChatMsg msgType, WorldObject const* target, CreatureTextRange range, TeamId teamId, bool gmOnly);
void SendEmote(Unit* source, uint32 emote); void SendEmote(Unit* source, uint32 emote);
//if sent, returns the 'duration' of the text else 0 if error //if sent, returns the 'duration' of the text else 0 if error
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, TeamId teamId = TEAM_NEUTRAL, bool gmOnly = false, Player* srcPlr = nullptr); uint32 SendChat(Creature* source, uint8 textGroup, WorldObject const* target = nullptr, ChatMsg msgType = CHAT_MSG_ADDON, Language language = LANG_ADDON, CreatureTextRange range = TEXT_RANGE_NORMAL, uint32 sound = 0, TeamId teamId = TEAM_NEUTRAL, bool gmOnly = false, Player* srcPlr = nullptr);
bool TextExist(uint32 sourceEntry, uint8 textGroup); bool TextExist(uint32 sourceEntry, uint8 textGroup);
std::string GetLocalizedChatString(uint32 entry, uint8 gender, uint8 textGroup, uint32 id, LocaleConstant locale) const; std::string GetLocalizedChatString(uint32 entry, uint8 gender, uint8 textGroup, uint32 id, LocaleConstant locale) const;
template<class Builder> void SendChatPacket(WorldObject* source, Builder const& builder, ChatMsg msgType, WorldObject const* whisperTarget = nullptr, CreatureTextRange range = TEXT_RANGE_NORMAL, TeamId teamId = TEAM_NEUTRAL, bool gmOnly = false) const; template<class Builder> void SendChatPacket(WorldObject* source, Builder const& builder, ChatMsg msgType, WorldObject const* target = nullptr, CreatureTextRange range = TEXT_RANGE_NORMAL, TeamId teamId = TEAM_NEUTRAL, bool gmOnly = false) const;
private: private:
CreatureTextRepeatIds GetRepeatGroup(Creature* source, uint8 textGroup); CreatureTextRepeatIds GetRepeatGroup(Creature* source, uint8 textGroup);
void SetRepeatId(Creature* source, uint8 textGroup, uint8 id); void SetRepeatId(Creature* source, uint8 textGroup, uint8 id);
void SendNonChatPacket(WorldObject* source, WorldPacket* data, ChatMsg msgType, WorldObject const* whisperTarget, CreatureTextRange range, TeamId teamId, bool gmOnly) const; void SendNonChatPacket(WorldObject* source, WorldPacket* data, ChatMsg msgType, WorldObject const* target, CreatureTextRange range, TeamId teamId, bool gmOnly) const;
float GetRangeForChatType(ChatMsg msgType) const; float GetRangeForChatType(ChatMsg msgType) const;
CreatureTextMap mTextMap; CreatureTextMap mTextMap;
@@ -177,7 +177,7 @@ private:
}; };
template<class Builder> template<class Builder>
void CreatureTextMgr::SendChatPacket(WorldObject* source, Builder const& builder, ChatMsg msgType, WorldObject const* whisperTarget /*= nullptr*/, CreatureTextRange range /*= TEXT_RANGE_NORMAL*/, TeamId teamId /*= TEAM_NEUTRAL*/, bool gmOnly /*= false*/) const void CreatureTextMgr::SendChatPacket(WorldObject* source, Builder const& builder, ChatMsg msgType, WorldObject const* target /*= nullptr*/, CreatureTextRange range /*= TEXT_RANGE_NORMAL*/, TeamId teamId /*= TEAM_NEUTRAL*/, bool gmOnly /*= false*/) const
{ {
if (!source) if (!source)
return; return;
@@ -191,10 +191,10 @@ void CreatureTextMgr::SendChatPacket(WorldObject* source, Builder const& builder
{ {
if (range == TEXT_RANGE_NORMAL) //ignores team and gmOnly if (range == TEXT_RANGE_NORMAL) //ignores team and gmOnly
{ {
if (!whisperTarget || whisperTarget->GetTypeId() != TYPEID_PLAYER) if (!target || target->GetTypeId() != TYPEID_PLAYER)
return; return;
localizer(const_cast<Player*>(whisperTarget->ToPlayer())); localizer(const_cast<Player*>(target->ToPlayer()));
return; return;
} }
break; break;