本文整理汇总了C++中PrivateChatChannel类的典型用法代码示例。如果您正苦于以下问题:C++ PrivateChatChannel类的具体用法?C++ PrivateChatChannel怎么用?C++ PrivateChatChannel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PrivateChatChannel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
void Chat::removeUserFromAllChannels(const Player& player)
{
for (auto& it : normalChannels) {
it.second.removeUser(player);
}
for (auto& it : partyChannels) {
it.second.removeUser(player);
}
for (auto& it : guildChannels) {
it.second.removeUser(player);
}
auto it = privateChannels.begin();
while (it != privateChannels.end()) {
PrivateChatChannel* channel = &it->second;
channel->removeInvite(player.getGUID());
channel->removeUser(player);
if (channel->getOwner() == player.getGUID()) {
channel->closeChannel();
it = privateChannels.erase(it);
} else {
++it;
}
}
}
示例2: switch
ChatChannel* Chat::createChannel(Player* player, uint16_t channelId)
{
if(!player || player->isRemoved() || getChannel(player, channelId))
return NULL;
switch(channelId)
{
case CHANNEL_GUILD:
{
ChatChannel* newChannel = NULL;
if((newChannel = new ChatChannel(channelId, player->getGuildName(), ChatChannel::staticFlags)))
m_guildChannels[player->getGuildId()] = newChannel;
return newChannel;
}
case CHANNEL_PARTY:
{
ChatChannel* newChannel = NULL;
if(player->getParty() && (newChannel = new ChatChannel(channelId, partyName, ChatChannel::staticFlags)))
m_partyChannels[player->getParty()] = newChannel;
return newChannel;
}
case CHANNEL_PRIVATE:
{
//only 1 private channel for each premium player
if(!player->isPremium() || getPrivateChannel(player))
return NULL;
//find a free private channel slot
for(uint16_t i = 100; i < 10000; ++i)
{
if(m_privateChannels.find(i) != m_privateChannels.end())
continue;
uint16_t flags = 0;
if(dummyPrivate)
flags = dummyPrivate->getFlags();
PrivateChatChannel* newChannel = NULL;
if((newChannel = new PrivateChatChannel(i, player->getName() + "'s Channel", flags)))
{
newChannel->setOwner(player->getGUID());
m_privateChannels[i] = newChannel;
}
return newChannel;
}
}
default:
break;
}
return NULL;
}
示例3: getPrivateChannel
PrivateChatChannel* Chat::getPrivateChannel(const Player& player)
{
for (PrivateChannelMap::iterator it = privateChannels.begin(); it != privateChannels.end(); ++it) {
PrivateChatChannel* channel = it->second;
if (channel->getOwner() == player.getGUID()) {
return channel;
}
}
return NULL;
}
示例4: getChannel
ChannelList Chat::getChannelList(Player* player)
{
ChannelList list;
NormalChannelMap::iterator itn;
PrivateChannelMap::iterator it;
bool gotPrivate = false;
// If has guild
if(player->getGuildId() && player->getGuildName().length()){
ChatChannel *channel = getChannel(player, CHANNEL_GUILD);
if(channel)
list.push_back(channel);
else if((channel = createChannel(player, CHANNEL_GUILD)))
list.push_back(channel);
}
if(player->getParty()){
ChatChannel *channel = getChannel(player, CHANNEL_PARTY);
if(channel)
list.push_back(channel);
else if((channel = createChannel(player, CHANNEL_PARTY)))
list.push_back(channel);
}
for(itn = m_normalChannels.begin(); itn != m_normalChannels.end(); ++itn){
if(!player->hasFlag(PlayerFlag_CannotBeMuted)){
if(itn->first == CHANNEL_TRADE && player->getVocationId() == 0)
continue;
if(itn->first == CHANNEL_TRADE_ROOK && player->getVocationId() != 0)
continue;
}
ChatChannel *channel = itn->second;
list.push_back(channel);
}
for(it = m_privateChannels.begin(); it != m_privateChannels.end(); ++it){
PrivateChatChannel* channel = it->second;
if(channel){
if(channel->isInvited(player))
list.push_back(channel);
if(channel->getOwner() == player->getGUID())
gotPrivate = true;
}
}
if(!gotPrivate)
list.push_front(dummyPrivate);
return list;
}
示例5: ChatChannel
ChatChannel* Chat::createChannel(Player* player, const uint16_t& channelId)
{
if (getChannel(player, channelId))
{
return NULL;
}
if (channelId == CHANNEL_GUILD)
{
ChatChannel* newChannel = new ChatChannel(channelId, player->getGuild()->getName());
m_guildChannels[player->getGuildId()] = newChannel;
return newChannel;
}
else if (channelId == CHANNEL_PARTY)
{
if (!player->getParty())
{
return NULL;
}
PrivateChatChannel* newChannel = new PrivateChatChannel(channelId, "Party");
m_partyChannels[player->getParty()] = newChannel;
return newChannel;
}
else if (channelId == CHANNEL_PRIVATE)
{
// Private chat channel
//only 1 private channel for each player
if (getPrivateChannel(player))
{
return NULL;
}
//find a free private channel slot
uint16_t i = getFreePrivateChannelId();
if (i != 0)
{
PrivateChatChannel* newChannel = new PrivateChatChannel(i, player->getName() + "'s Channel");
if (!newChannel)
{
return NULL;
}
newChannel->setOwner(player->getGUID());
m_privateChannels[i] = newChannel;
return newChannel;
}
}
return NULL;
}
示例6: deleteChannel
bool Chat::deleteChannel(Party* party)
{
PartyChannelMap::iterator it = m_partyChannels.find(party);
if(it == m_partyChannels.end())
return false;
PrivateChatChannel* cc = it->second;
cc->closeChannel();
m_partyChannels.erase(it);
delete cc;
return true;
}
示例7: sendCreatureChannelSay
void Spectators::sendCreatureChannelSay(const Creature* creature, MessageClasses type, const std::string& text, uint16_t channelId, uint32_t statementId)
{
if(!owner)
return;
owner->sendCreatureChannelSay(creature, type, text, channelId, statementId);
PrivateChatChannel* tmp = g_chat.getPrivateChannel(owner->getPlayer());
if(!tmp || tmp->getId() != channelId)
return;
for(SpectatorList::iterator it = spectators.begin(); it != spectators.end(); ++it)
it->first->sendCreatureChannelSay(creature, type, text, channelId, statementId);
}
示例8: sendChannelMessage
void Spectators::sendChannelMessage(std::string author, std::string text, MessageClasses type, uint16_t channel)
{
if(!owner)
return;
owner->sendChannelMessage(author, text, type, channel);
PrivateChatChannel* tmp = g_chat.getPrivateChannel(owner->getPlayer());
if(!tmp || tmp->getId() != channel)
return;
for(SpectatorList::iterator it = spectators.begin(); it != spectators.end(); ++it)
it->first->sendChannelMessage(author, text, type, channel);
}
示例9: switch
ChatChannel* Chat::createChannel(const Player& player, uint16_t channelId)
{
if (getChannel(player, channelId)) {
return NULL;
}
switch (channelId) {
case CHANNEL_GUILD: {
Guild* guild = player.getGuild();
if (guild) {
ChatChannel* newChannel = new ChatChannel(channelId, guild->getName());
guildChannels[guild->getId()] = newChannel;
return newChannel;
}
break;
}
case CHANNEL_PARTY: {
Party* party = player.getParty();
if (party) {
ChatChannel* newChannel = new ChatChannel(channelId, "Party");
partyChannels[party] = newChannel;
return newChannel;
}
break;
}
case CHANNEL_PRIVATE: {
//only 1 private channel for each premium player
if (!player.isPremium() || getPrivateChannel(player)) {
return NULL;
}
//find a free private channel slot
for (uint16_t i = 100; i < 10000; ++i) {
if (privateChannels.find(i) == privateChannels.end()) {
PrivateChatChannel* newChannel = new PrivateChatChannel(i, player.getName() + "'s Channel");
newChannel->setOwner(player.getGUID());
privateChannels[i] = newChannel;
return newChannel;
}
}
break;
}
default:
break;
}
return NULL;
}
示例10: getPrivateChannel
PrivateChatChannel* Chat::getPrivateChannel(Player* player)
{
if(!player || player->isRemoved())
return NULL;
PrivateChatChannel* channel = NULL;
for(PrivateChannelMap::iterator it = m_privateChannels.begin(); it != m_privateChannels.end(); ++it)
{
if((channel = it->second) && channel->getOwner() == player->getGUID())
return channel;
}
return NULL;
}
示例11: chat
void Spectators::chat(uint16_t channelId)
{
if(!owner)
return;
PrivateChatChannel* tmp = g_chat.getPrivateChannel(owner->getPlayer());
if(!tmp || tmp->getId() != channelId)
return;
for(SpectatorList::iterator it = spectators.begin(); it != spectators.end(); ++it)
{
it->first->sendClosePrivate(channelId);
it->first->sendCreatureSay(owner->getPlayer(), MSG_PRIVATE, "Chat has been disabled.", NULL, 0);
}
}
示例12: sendCreatePrivateChannel
void Spectators::sendCreatePrivateChannel(uint16_t channelId, const std::string& channelName)
{
if(!owner)
return;
owner->sendCreatePrivateChannel(channelId, channelName);
PrivateChatChannel* tmp = g_chat.getPrivateChannel(owner->getPlayer());
if(!tmp || tmp->getId() != channelId)
return;
for(SpectatorList::iterator it = spectators.begin(); it != spectators.end(); ++it)
{
it->first->sendCreatePrivateChannel(channelId, channelName);
it->first->sendCreatureSay(owner->getPlayer(), MSG_PRIVATE, "Chat has been enabled.", NULL, 0);
}
}
示例13: getChannel
ChannelList Chat::getChannelList(Player* player)
{
ChannelList list;
NormalChannelMap::iterator itn;
PrivateChannelMap::iterator it;
bool gotPrivate = false;
// If has guild
if(player->getGuildId() && player->getGuildName().length()){
ChatChannel *channel = getChannel(player, 0x00);
if(channel)
list.push_back(channel);
else if((channel = createChannel(player, 0x00)))
list.push_back(channel);
}
for(itn = m_normalChannels.begin(); itn != m_normalChannels.end(); ++itn){
if(itn->first == 0x03 && !player->hasFlag(PlayerFlag_CanAnswerRuleViolations)){ //Rule violations channel
continue;
}
ChatChannel *channel = itn->second;
list.push_back(channel);
}
for(it = m_privateChannels.begin(); it != m_privateChannels.end(); ++it){
PrivateChatChannel* channel = it->second;
if(channel){
if(channel->isInvited(player))
list.push_back(channel);
if(channel->getOwner() == player->getGUID())
gotPrivate = true;
}
}
if(!gotPrivate)
list.push_front(dummyPrivate);
return list;
}
示例14: removeUserFromAllChannels
void Chat::removeUserFromAllChannels(const Player& player)
{
for (auto& it : normalChannels) {
it.second.removeUser(player);
}
for (const auto& it : partyChannels) {
it.second->removeUser(player);
}
for (const auto& it : guildChannels) {
it.second->removeUser(player);
}
for (const auto& it : privateChannels) {
PrivateChatChannel* channel = it.second;
channel->removeUser(player);
if (channel->getOwner() == player.getGUID()) {
deleteChannel(player, channel->getId());
}
}
}
示例15: createChannel
ChannelList Chat::getChannelList(Player* player)
{
ChannelList list;
if(!player || player->isRemoved())
return list;
ChatChannel* channel = NULL;
if(player->getParty() && ((channel = getChannel(player, CHANNEL_PARTY)) || (channel = createChannel(player, CHANNEL_PARTY))))
list.push_back(channel);
if(player->getGuildId() && player->getGuildName().length() && ((channel = getChannel(
player, CHANNEL_GUILD)) || (channel = createChannel(player, CHANNEL_GUILD))))
list.push_back(channel);
for(NormalChannelMap::iterator it = m_normalChannels.begin(); it != m_normalChannels.end(); ++it)
{
if((channel = getChannel(player, it->first)))
list.push_back(it->second);
}
bool hasPrivate = false;
PrivateChatChannel* privChannel = NULL;
for(PrivateChannelMap::iterator pit = m_privateChannels.begin(); pit != m_privateChannels.end(); ++pit)
{
if(!(privChannel = pit->second))
continue;
if(privChannel->isInvited(player))
list.push_back(privChannel);
if(privChannel->getOwner() == player->getGUID())
hasPrivate = true;
}
if(!hasPrivate && player->isPremium())
list.push_front(dummyPrivate);
return list;
}