本文整理汇总了C++中worldpackets::chat::Chat类的典型用法代码示例。如果您正苦于以下问题:C++ Chat类的具体用法?C++ Chat怎么用?C++ Chat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Chat类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: operator
WorldPackets::Chat::Chat* operator()(LocaleConstant locale) const
{
std::string const& text = sCreatureTextMgr->GetLocalizedChatString(_source->GetEntry(), _gender, _textGroup, _textId, locale);
WorldPackets::Chat::Chat* chat = new WorldPackets::Chat::Chat();
chat->Initialize(_msgType, Language(_language), _talker, _target, text, 0, "", locale);
return chat;
}
示例2: HandleChatIgnoredOpcode
void WorldSession::HandleChatIgnoredOpcode(WorldPackets::Chat::ChatReportIgnored& chatReportIgnored)
{
Player* player = ObjectAccessor::FindConnectedPlayer(chatReportIgnored.IgnoredGUID);
if (!player || !player->GetSession())
return;
WorldPackets::Chat::Chat packet;
packet.Initialize(CHAT_MSG_IGNORED, LANG_UNIVERSAL, _player, _player, GetPlayer()->GetName());
player->SendDirectMessage(packet.Write());
}
示例3: SendSysMessage
void ChatHandler::SendSysMessage(const char *str)
{
WorldPackets::Chat::Chat packet;
// need copy to prevent corruption by strtok call in LineFromMessage original string
char* buf = strdup(str);
char* pos = buf;
while (char* line = LineFromMessage(pos))
{
packet.Initalize(CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line);
m_session->SendPacket(packet.Write());
}
free(buf);
}
示例4: Say
void Channel::Say(ObjectGuid const& guid, std::string const& what, uint32 lang) const
{
if (what.empty())
return;
// TODO: Add proper RBAC check
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
lang = LANG_UNIVERSAL;
if (!IsOn(guid))
{
NotMemberAppend appender;
ChannelNameBuilder<NotMemberAppend> builder(this, appender);
SendToOne(builder, guid);
return;
}
PlayerInfo const& playerInfo = _playersStore.at(guid);
if (playerInfo.IsMuted())
{
MutedAppend appender;
ChannelNameBuilder<MutedAppend> builder(this, appender);
SendToOne(builder, guid);
return;
}
auto builder = [&](LocaleConstant locale)
{
LocaleConstant localeIdx = sWorld->GetAvailableDbcLocale(locale);
WorldPackets::Chat::Chat* packet = new WorldPackets::Chat::Chat();
if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
packet->Initialize(CHAT_MSG_CHANNEL, Language(lang), player, player, what, 0, GetName(localeIdx));
else
{
packet->Initialize(CHAT_MSG_CHANNEL, Language(lang), nullptr, nullptr, what, 0, GetName(localeIdx));
packet->SenderGUID = guid;
packet->TargetGUID = guid;
}
return packet;
};
SendToAll(builder, !playerInfo.IsModerator() ? guid : ObjectGuid::Empty);
}
示例5: AddonSay
void Channel::AddonSay(ObjectGuid const& guid, std::string const& prefix, std::string const& what) const
{
if (what.empty())
return;
if (!IsOn(guid))
{
NotMemberAppend appender;
ChannelNameBuilder<NotMemberAppend> builder(this, appender);
SendToOne(builder, guid);
return;
}
PlayerInfo const& playerInfo = _playersStore.at(guid);
if (playerInfo.IsMuted())
{
MutedAppend appender;
ChannelNameBuilder<MutedAppend> builder(this, appender);
SendToOne(builder, guid);
return;
}
auto builder = [&](LocaleConstant locale)
{
LocaleConstant localeIdx = sWorld->GetAvailableDbcLocale(locale);
WorldPackets::Chat::Chat* packet = new WorldPackets::Chat::Chat();
if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
packet->Initialize(CHAT_MSG_CHANNEL, LANG_ADDON, player, player, what, 0, GetName(localeIdx), DEFAULT_LOCALE, prefix);
else
{
packet->Initialize(CHAT_MSG_CHANNEL, LANG_ADDON, nullptr, nullptr, what, 0, GetName(localeIdx), DEFAULT_LOCALE, prefix);
packet->SenderGUID = guid;
packet->TargetGUID = guid;
}
return packet;
};
SendToAllWithAddon(builder, prefix, !playerInfo.IsModerator() ? guid : ObjectGuid::Empty);
}
示例6: Say
void Channel::Say(ObjectGuid const& guid, std::string const& what, uint32 lang)
{
if (what.empty())
return;
// TODO: Add proper RBAC check
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
lang = LANG_UNIVERSAL;
if (!IsOn(guid))
{
WorldPackets::Channel::ChannelNotify notify;
MakeNotMember(notify);
SendToOne(notify.Write(), guid);
return;
}
if (_playersStore[guid].IsMuted())
{
WorldPackets::Channel::ChannelNotify notify;
MakeMuted(notify);
SendToOne(notify.Write(), guid);
return;
}
WorldPackets::Chat::Chat packet;
if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
packet.Initialize(CHAT_MSG_CHANNEL, Language(lang), player, player, what, 0, _name);
else
{
packet.Initialize(CHAT_MSG_CHANNEL, Language(lang), nullptr, nullptr, what, 0, _name);
packet.SenderGUID = guid;
packet.TargetGUID = guid;
}
SendToAll(packet.Write(), !_playersStore[guid].IsModerator() ? guid : ObjectGuid::Empty);
}
示例7: SendSysMessage
void ChatHandler::SendSysMessage(const char *str, bool escapeCharacters)
{
WorldPackets::Chat::Chat packet;
// need copy to prevent corruption by strtok call in LineFromMessage original string
char* buf;
char* pos;
if (escapeCharacters && strchr(str, '|'))
{
size_t startPos = 0;
std::ostringstream o;
while (const char* charPos = strchr(str + startPos, '|'))
{
o.write(str + startPos, charPos - str - startPos);
o << "||";
startPos = charPos - str + 1;
}
o.write(str + startPos, strlen(str) - startPos);
buf = strdup(o.str().c_str());
}
else
{
buf = strdup(str);
}
pos = buf;
while (char* line = LineFromMessage(pos))
{
packet.Initialize(CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line);
m_session->SendPacket(packet.Write());
}
free(buf);
}
示例8: HandleChatMessage
void WorldSession::HandleChatMessage(ChatMsg type, uint32 lang, std::string msg, std::string target /*= ""*/)
{
Player* sender = GetPlayer();
if (lang == LANG_UNIVERSAL && type != CHAT_MSG_EMOTE)
{
TC_LOG_ERROR("network", "CMSG_MESSAGECHAT: Possible hacking-attempt: %s tried to send a message in universal language", GetPlayerInfo().c_str());
SendNotification(LANG_UNKNOWN_LANGUAGE);
return;
}
// prevent talking at unknown language (cheating)
LanguageDesc const* langDesc = GetLanguageDescByID(lang);
if (!langDesc)
{
SendNotification(LANG_UNKNOWN_LANGUAGE);
return;
}
if (langDesc->skill_id != 0 && !sender->HasSkill(langDesc->skill_id))
{
// also check SPELL_AURA_COMPREHEND_LANGUAGE (client offers option to speak in that language)
Unit::AuraEffectList const& langAuras = sender->GetAuraEffectsByType(SPELL_AURA_COMPREHEND_LANGUAGE);
bool foundAura = false;
for (Unit::AuraEffectList::const_iterator i = langAuras.begin(); i != langAuras.end(); ++i)
{
if ((*i)->GetMiscValue() == int32(lang))
{
foundAura = true;
break;
}
}
if (!foundAura)
{
SendNotification(LANG_NOT_LEARNED_LANGUAGE);
return;
}
}
// send in universal language if player in .gm on mode (ignore spell effects)
if (sender->IsGameMaster())
lang = LANG_UNIVERSAL;
else
{
// send in universal language in two side iteration allowed mode
if (HasPermission(rbac::RBAC_PERM_TWO_SIDE_INTERACTION_CHAT))
lang = LANG_UNIVERSAL;
else
{
switch (type)
{
case CHAT_MSG_PARTY:
case CHAT_MSG_RAID:
case CHAT_MSG_RAID_WARNING:
// allow two side chat at group channel if two side group allowed
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP))
lang = LANG_UNIVERSAL;
break;
case CHAT_MSG_GUILD:
case CHAT_MSG_OFFICER:
// allow two side chat at guild channel if two side guild allowed
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD))
lang = LANG_UNIVERSAL;
break;
default:
break;
}
}
// but overwrite it by SPELL_AURA_MOD_LANGUAGE auras (only single case used)
Unit::AuraEffectList const& ModLangAuras = sender->GetAuraEffectsByType(SPELL_AURA_MOD_LANGUAGE);
if (!ModLangAuras.empty())
lang = ModLangAuras.front()->GetMiscValue();
}
if (!sender->CanSpeak())
{
std::string timeStr = secsToTimeString(m_muteTime - time(NULL));
SendNotification(GetTrinityString(LANG_WAIT_BEFORE_SPEAKING), timeStr.c_str());
return;
}
if (sender->HasAura(GM_SILENCE_AURA) && type != CHAT_MSG_WHISPER)
{
SendNotification(GetTrinityString(LANG_GM_SILENCE), sender->GetName().c_str());
return;
}
if (msg.empty())
return;
if (ChatHandler(this).ParseCommands(msg.c_str()))
return;
// Strip invisible characters for non-addon messages
if (sWorld->getBoolConfig(CONFIG_CHAT_FAKE_MESSAGE_PREVENTING))
stripLineInvisibleChars(msg);
if (sWorld->getIntConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_SEVERITY) && !ChatHandler(this).isValidChatMessage(msg.c_str()))
{
//.........这里部分代码省略.........
示例9: HandleChatAddonMessage
void WorldSession::HandleChatAddonMessage(ChatMsg type, std::string prefix, std::string text, std::string target /*= ""*/)
{
Player* sender = GetPlayer();
if (prefix.empty() || prefix.length() > 16)
return;
// Disabled addon channel?
if (!sWorld->getBoolConfig(CONFIG_ADDON_CHANNEL))
return;
switch (type)
{
case CHAT_MSG_GUILD:
case CHAT_MSG_OFFICER:
{
if (sender->GetGuildId())
if (Guild* guild = sGuildMgr->GetGuildById(sender->GetGuildId()))
guild->BroadcastAddonToGuild(this, type == CHAT_MSG_OFFICER, text, prefix);
break;
}
case CHAT_MSG_WHISPER:
{
if (!normalizePlayerName(target))
break;
Player* receiver = ObjectAccessor::FindPlayerByName(target);
if (!receiver)
break;
sender->WhisperAddon(text, prefix, receiver);
break;
}
// Messages sent to "RAID" while in a party will get delivered to "PARTY"
case CHAT_MSG_PARTY:
case CHAT_MSG_RAID:
case CHAT_MSG_INSTANCE_CHAT:
{
Group* group = nullptr;
int32 subGroup = -1;
if (type != CHAT_MSG_INSTANCE_CHAT)
group = sender->GetOriginalGroup();
if (!group)
{
group = sender->GetGroup();
if (!group)
break;
if (type == CHAT_MSG_PARTY)
subGroup = sender->GetSubGroup();
}
WorldPackets::Chat::Chat packet;
packet.Initialize(type, LANG_ADDON, sender, nullptr, text, 0, "", DEFAULT_LOCALE, prefix);
group->BroadcastAddonMessagePacket(packet.Write(), prefix, true, subGroup, sender->GetGUID());
break;
}
case CHAT_MSG_CHANNEL:
{
if (Channel* chn = ChannelMgr::GetChannelForPlayerByNamePart(target, sender))
chn->Say(sender->GetGUID(), text.c_str(), uint32(LANG_ADDON));
break;
}
default:
{
TC_LOG_ERROR("misc", "HandleAddonMessagechatOpcode: unknown addon message type %u", type);
break;
}
}
}