void Channel::Join(ObjectGuid p, const char* pass) { WorldPacket data; if (IsOn(p)) { if (!IsConstant()) // non send error message for built-in channels { MakePlayerAlreadyMember(&data, p); SendToOne(&data, p); } return; } if (IsBanned(p)) { MakeBanned(&data); SendToOne(&data, p); return; } if (m_password.length() > 0 && strcmp(pass, m_password.c_str())) { MakeWrongPassword(&data); SendToOne(&data, p); return; } Player* plr = sObjectMgr.GetPlayer(p); if (plr) { if (HasFlag(CHANNEL_FLAG_LFG) && sWorld.getConfig(CONFIG_BOOL_RESTRICTED_LFG_CHANNEL) && plr->GetSession()->GetSecurity() == SEC_PLAYER) { MakeNotInLfg(&data); SendToOne(&data, p); return; } if (plr->GetGuildId() && (GetFlags() == 0x38)) return; plr->JoinedChannel(this); } if (m_announce && (!plr || plr->GetSession()->GetSecurity() < SEC_GAMEMASTER || !sWorld.getConfig(CONFIG_BOOL_SILENTLY_GM_JOIN_TO_CHANNEL))) { MakeJoined(&data, p); SendToAll(&data); } data.clear(); PlayerInfo& pinfo = m_players[p]; pinfo.player = p; pinfo.flags = 0; MakeYouJoined(&data); SendToOne(&data, p); JoinNotify(p); // if no owner first logged will become if (!IsConstant() && !m_ownerGuid) { SetOwner(p, (m_players.size() > 1 ? true : false)); m_players[p].SetModerator(true); } }
void Channel::KickOrBan(uint64 good, const char *badname, bool ban) { AccountTypes sec = SEC_PLAYER; Player *gplr = sObjectMgr->GetPlayer(good); if (gplr) sec = gplr->GetSession()->GetSecurity(); if (!IsOn(good)) { WorldPacket data; MakeNotMember(&data); SendToOne(&data, good); } else if (!players[good].IsModerator() && sec < SEC_GAMEMASTER) { WorldPacket data; MakeNotModerator(&data); SendToOne(&data, good); } else { Player *bad = sObjectMgr->GetPlayer(badname); if (bad == NULL || !IsOn(bad->GetGUID())) { WorldPacket data; MakePlayerNotFound(&data, badname); SendToOne(&data, good); } else if (sec < SEC_GAMEMASTER && bad->GetGUID() == m_ownerGUID && good != m_ownerGUID) { WorldPacket data; MakeNotOwner(&data); SendToOne(&data, good); } else { bool changeowner = (m_ownerGUID == bad->GetGUID()); WorldPacket data; if (ban && !IsBanned(bad->GetGUID())) { banned.insert(bad->GetGUID()); MakePlayerBanned(&data, bad->GetGUID(), good); UpdateChannelInDB(); } else MakePlayerKicked(&data, bad->GetGUID(), good); SendToAll(&data); players.erase(bad->GetGUID()); bad->LeftChannel(this); if (changeowner && m_ownership && !players.empty()) { uint64 newowner = good; players[newowner].SetModerator(true); SetOwner(newowner); } } } }
void Channel::SetMode(Player* player, const char* targetName, bool moderator, bool set) { ObjectGuid guid = player->GetObjectGuid(); if (!IsOn(guid)) { WorldPacket data; MakeNotMember(&data); SendToOne(&data, guid); return; } if (!m_players[guid].IsModerator() && player->GetSession()->GetSecurity() < SEC_GAMEMASTER) { WorldPacket data; MakeNotModerator(&data); SendToOne(&data, guid); return; } Player* target = sObjectMgr.GetPlayer(targetName); if (!target) { WorldPacket data; MakePlayerNotFound(&data, targetName); SendToOne(&data, guid); return; } ObjectGuid targetGuid = target->GetObjectGuid(); if (moderator && guid == m_ownerGuid && targetGuid == m_ownerGuid) return; if (!IsOn(targetGuid)) { WorldPacket data; MakePlayerNotFound(&data, targetName); SendToOne(&data, guid); return; } // allow make moderator from another team only if both is GMs // at this moment this only way to show channel post for GM from another team if ((player->GetSession()->GetSecurity() < SEC_GAMEMASTER || target->GetSession()->GetSecurity() < SEC_GAMEMASTER) && player->GetTeam() != target->GetTeam() && !sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)) { WorldPacket data; MakePlayerNotFound(&data, targetName); SendToOne(&data, guid); return; } if (m_ownerGuid == targetGuid && m_ownerGuid != guid) { WorldPacket data; MakeNotOwner(&data); SendToOne(&data, guid); return; } // set channel moderator if (moderator) SetModerator(targetGuid, set); else SetMute(targetGuid, set); }
void Channel::Join(Player* player, const char* password) { ObjectGuid guid = player->GetObjectGuid(); WorldPacket data; if (IsOn(guid)) { if (!IsConstant()) // non send error message for built-in channels { MakePlayerAlreadyMember(&data, guid); SendToOne(&data, guid); } return; } if (IsBanned(guid)) { MakeBanned(&data); SendToOne(&data, guid); return; } if (m_password.length() > 0 && strcmp(password, m_password.c_str())) { MakeWrongPassword(&data); SendToOne(&data, guid); return; } if (HasFlag(CHANNEL_FLAG_LFG) && sWorld.getConfig(CONFIG_BOOL_RESTRICTED_LFG_CHANNEL) && player->GetSession()->GetSecurity() == SEC_PLAYER && (player->GetGroup() || player->m_lookingForGroup.Empty())) { MakeNotInLfg(&data); SendToOne(&data, guid); return; } if (player->GetGuildId() && (GetFlags() == 0x38)) return; // join channel player->JoinedChannel(this); if (m_announce && (player->GetSession()->GetSecurity() < SEC_GAMEMASTER || !sWorld.getConfig(CONFIG_BOOL_SILENTLY_GM_JOIN_TO_CHANNEL))) { MakeJoined(&data, guid); SendToAll(&data); } data.clear(); PlayerInfo& pinfo = m_players[guid]; pinfo.player = guid; pinfo.flags = MEMBER_FLAG_NONE; MakeYouJoined(&data); SendToOne(&data, guid); JoinNotify(guid); // if no owner first logged will become if (!IsConstant() && !m_ownerGuid) { SetOwner(guid, (m_players.size() > 1 ? true : false)); m_players[guid].SetModerator(true); } }
void Channel::Say(Player* player, const char* text, uint32 lang) { if (!text) return; uint32 sec = 0; ObjectGuid guid = player->GetObjectGuid(); Player* plr = sObjectMgr.GetPlayer(guid); bool speakInLocalDef = false; bool speakInWorldDef = false; if (plr) { sec = plr->GetSession()->GetSecurity(); if (plr->isGameMaster()) { speakInLocalDef = true; speakInWorldDef = true; } HonorRankInfo honorInfo = plr->GetHonorRankInfo(); //We can speak in local defense if we're above this rank (see .h file) if (honorInfo.rank >= SPEAK_IN_LOCALDEFENSE_RANK) speakInLocalDef = true; // Are we not allowed to speak in WorldDefense at all? // if (honorInfo.rank >= SPEAK_IN_WORLDDEFENSE_RANK) // speakInWorldDef = true; } if (!IsOn(guid)) { WorldPacket data; MakeNotMember(&data); SendToOne(&data, guid); return; } else if (m_players[guid].IsMuted() || (GetChannelId() == CHANNEL_ID_LOCAL_DEFENSE && !speakInLocalDef) || (GetChannelId() == CHANNEL_ID_WORLD_DEFENSE && !speakInWorldDef)) { WorldPacket data; MakeMuted(&data); SendToOne(&data, guid); return; } if (m_moderate && !m_players[guid].IsModerator() && player->GetSession()->GetSecurity() < SEC_GAMEMASTER) { WorldPacket data; MakeNotModerator(&data); SendToOne(&data, guid); return; } // send channel message if (sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)) lang = LANG_UNIVERSAL; WorldPacket data; ChatHandler::BuildChatPacket(data, CHAT_MSG_CHANNEL, text, Language(lang), player->GetChatTag(), guid, player->GetName(), ObjectGuid(), "", m_name.c_str(), player->GetHonorRankInfo().rank); SendToAll(&data, !m_players[guid].IsModerator() ? guid : ObjectGuid()); }
void Channel::KickOrBan(Player* player, const char* targetName, bool ban) { ObjectGuid guid = player->GetObjectGuid(); if (!IsOn(guid)) { WorldPacket data; MakeNotMember(&data); SendToOne(&data, guid); return; } if (!m_players[guid].IsModerator() && player->GetSession()->GetSecurity() < SEC_GAMEMASTER) { WorldPacket data; MakeNotModerator(&data); SendToOne(&data, guid); return; } Player* target = sObjectMgr.GetPlayer(targetName); if (!target) { WorldPacket data; MakePlayerNotFound(&data, targetName); SendToOne(&data, guid); return; } ObjectGuid targetGuid = target->GetObjectGuid(); if (!IsOn(targetGuid)) { WorldPacket data; MakePlayerNotFound(&data, targetName); SendToOne(&data, guid); return; } bool changeowner = m_ownerGuid == targetGuid; if (player->GetSession()->GetSecurity() < SEC_GAMEMASTER && changeowner && guid != m_ownerGuid) { WorldPacket data; MakeNotOwner(&data); SendToOne(&data, guid); return; } // kick or ban player WorldPacket data; if (ban && !IsBanned(targetGuid)) { m_banned.insert(targetGuid); MakePlayerBanned(&data, targetGuid, guid); } else MakePlayerKicked(&data, targetGuid, guid); SendToAll(&data); m_players.erase(targetGuid); target->LeftChannel(this); if (changeowner) { ObjectGuid newowner = !m_players.empty() ? guid : ObjectGuid(); SetOwner(newowner); } }
void Channel::JoinChannel(Player* player, std::string const& pass) { uint64 guid = player->GetGUID(); if (IsOn(guid)) { // Do not send error message for built-in channels if (!IsConstant()) { WorldPacket data; MakePlayerAlreadyMember(&data, guid); SendToOne(&data, guid); } return; } if (IsBanned(guid)) { WorldPacket data; MakeBanned(&data); SendToOne(&data, guid); return; } if (!_password.empty() && pass != _password) { WorldPacket data; MakeWrongPassword(&data); SendToOne(&data, guid); return; } if (HasFlag(CHANNEL_FLAG_LFG) && sWorld->getBoolConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) && //FIXME: Move to RBAC player->GetGroup()) { WorldPacket data; MakeNotInLfg(&data); SendToOne(&data, guid); return; } player->JoinedChannel(this); if (_announce && !player->GetSession()->HasPermission(RBAC_PERM_SILENTLY_JOIN_CHANNEL)) { WorldPacket data; MakeJoined(&data, guid); SendToAll(&data); } PlayerInfo pinfo; pinfo.player = guid; pinfo.flags = MEMBER_FLAG_NONE; playersStore[guid] = pinfo; WorldPacket data; MakeYouJoined(&data); SendToOne(&data, guid); JoinNotify(guid); // Custom channel handling if (!IsConstant()) { // Update last_used timestamp in db if (!playersStore.empty()) UpdateChannelUseageInDB(); // If the channel has no owner yet and ownership is allowed, set the new owner. if (!_ownerGUID && _ownership) { SetOwner(guid, playersStore.size() > 1); playersStore[guid].SetModerator(true); } } }
void Channel::KickOrBan(Player const* player, std::string const& badname, bool ban) { AccountTypes sec = player->GetSession()->GetSecurity(); uint64 good = player->GetGUID(); if (!IsOn(good)) { WorldPacket data; MakeNotMember(&data); SendToOne(&data, good); return; } if (!playersStore[good].IsModerator() && !AccountMgr::IsGMAccount(sec)) { WorldPacket data; MakeNotModerator(&data); SendToOne(&data, good); return; } Player* bad = sObjectAccessor->FindPlayerByName(badname); uint64 victim = bad ? bad->GetGUID() : 0; if (!victim || !IsOn(victim)) { WorldPacket data; MakePlayerNotFound(&data, badname); SendToOne(&data, good); return; } bool changeowner = _ownerGUID == victim; if (!AccountMgr::IsGMAccount(sec) && changeowner && good != _ownerGUID) { WorldPacket data; MakeNotOwner(&data); SendToOne(&data, good); return; } bool notify = !(AccountMgr::IsGMAccount(sec) && sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL)); if (ban && !IsBanned(victim)) { bannedStore.insert(victim); UpdateChannelInDB(); if (notify) { WorldPacket data; MakePlayerBanned(&data, victim, good); SendToAll(&data); } } else if (notify) { WorldPacket data; MakePlayerKicked(&data, victim, good); SendToAll(&data); } playersStore.erase(victim); bad->LeftChannel(this); if (changeowner && _ownership && !playersStore.empty()) { uint64 newowner = good; playersStore[newowner].SetModerator(true); SetOwner(newowner); } }
void Channel::KickOrBan(uint64 good, const char *badname, bool ban) { AccountTypes sec = SEC_PLAYER; Player* gplr = ObjectAccessor::FindPlayer(good); if (gplr) sec = gplr->GetSession()->GetSecurity(); if (!IsOn(good)) { WorldPacket data; MakeNotMember(&data); SendToOne(&data, good); } else if (!players[good].IsModerator() && !AccountMgr::IsGMAccount(sec)) { WorldPacket data; MakeNotModerator(&data); SendToOne(&data, good); } else { Player* bad = sObjectAccessor->FindPlayerByName(badname); if (bad == NULL || !IsOn(bad->GetGUID())) { WorldPacket data; MakePlayerNotFound(&data, badname); SendToOne(&data, good); } else if (!AccountMgr::IsGMAccount(sec) && bad->GetGUID() == m_ownerGUID && good != m_ownerGUID) { WorldPacket data; MakeNotOwner(&data); SendToOne(&data, good); } else { bool changeowner = (m_ownerGUID == bad->GetGUID()); WorldPacket data; bool notify = !(AccountMgr::IsGMAccount(sec) && sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL)); if (ban && !IsBanned(bad->GetGUID())) { banned.insert(bad->GetGUID()); UpdateChannelInDB(); if (notify) MakePlayerBanned(&data, bad->GetGUID(), good); } else if (notify) MakePlayerKicked(&data, bad->GetGUID(), good); if (notify) SendToAll(&data); players.erase(bad->GetGUID()); bad->LeftChannel(this); if (changeowner && m_ownership && !players.empty()) { uint64 newowner = good; players[newowner].SetModerator(true); SetOwner(newowner); } } } }
void Channel::Join(uint64 p, const char *pass) { WorldPacket data; if (IsOn(p)) { if (!IsConstant()) // non send error message for built-in channels { MakePlayerAlreadyMember(&data, p); SendToOne(&data, p); } return; } if (IsBanned(p)) { MakeBanned(&data); SendToOne(&data, p); return; } if (m_password.length() > 0 && strcmp(pass, m_password.c_str())) { MakeWrongPassword(&data); SendToOne(&data, p); return; } Player *plr = ObjectAccessor::FindPlayer(p); if (plr) { if (HasFlag(CHANNEL_FLAG_LFG) && sWorld->getConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && plr->GetSession()->GetSecurity() == SEC_PLAYER && plr->GetGroup()) { MakeNotInLfg(&data); SendToOne(&data, p); return; } plr->JoinedChannel(this); } if (m_announce && (!plr || plr->GetSession()->GetSecurity() < SEC_GAMEMASTER || !sWorld->getConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL))) { MakeJoined(&data, p); SendToAll(&data); } data.clear(); PlayerInfo pinfo; pinfo.player = p; pinfo.flags = MEMBER_FLAG_NONE; players[p] = pinfo; MakeYouJoined(&data); SendToOne(&data, p); JoinNotify(p); // if no owner first logged will become if (!IsConstant() && !m_ownerGUID) { SetOwner(p, (players.size() > 1 ? true : false)); players[p].SetModerator(true); } /* else if (!IsConstant() && m_ownerGUID && plr && m_ownerGUID == plr->GetGUID())) { SetOwner(p, (players.size() > 1 ? true : false)); players[p].SetModerator(true); }*/ }
void Channel::KickOrBan(Player const* player, std::string const& badname, bool ban) { ObjectGuid const& good = player->GetGUID(); if (!IsOn(good)) { NotMemberAppend appender; ChannelNameBuilder<NotMemberAppend> builder(this, appender); SendToOne(builder, good); return; } PlayerInfo& info = _playersStore.at(good); if (!info.IsModerator() && !player->GetSession()->HasPermission(rbac::RBAC_PERM_CHANGE_CHANNEL_NOT_MODERATOR)) { NotModeratorAppend appender; ChannelNameBuilder<NotModeratorAppend> builder(this, appender); SendToOne(builder, good); return; } Player* bad = ObjectAccessor::FindConnectedPlayerByName(badname); ObjectGuid const& victim = bad ? bad->GetGUID() : ObjectGuid::Empty; if (!victim || !IsOn(victim)) { PlayerNotFoundAppend appender(badname); ChannelNameBuilder<PlayerNotFoundAppend> builder(this, appender); SendToOne(builder, good); return; } bool changeowner = _ownerGuid == victim; if (!player->GetSession()->HasPermission(rbac::RBAC_PERM_CHANGE_CHANNEL_NOT_MODERATOR) && changeowner && good != _ownerGuid) { NotOwnerAppend appender; ChannelNameBuilder<NotOwnerAppend> builder(this, appender); SendToOne(builder, good); return; } if (ban && !IsBanned(victim)) { _bannedStore.insert(victim); UpdateChannelInDB(); if (!player->GetSession()->HasPermission(rbac::RBAC_PERM_SILENTLY_JOIN_CHANNEL)) { PlayerBannedAppend appender(good, victim); ChannelNameBuilder<PlayerBannedAppend> builder(this, appender); SendToAll(builder); } } else if (!player->GetSession()->HasPermission(rbac::RBAC_PERM_SILENTLY_JOIN_CHANNEL)) { PlayerKickedAppend appender(good, victim); ChannelNameBuilder<PlayerKickedAppend> builder(this, appender); SendToAll(builder); } _playersStore.erase(victim); bad->LeftChannel(this); if (changeowner && _ownershipEnabled && !_playersStore.empty()) { info.SetModerator(true); SetOwner(good); } }
void Channel::LeaveChannel(Player* player, bool send) { ObjectGuid const& guid = player->GetGUID(); if (!IsOn(guid)) { if (send) { NotMemberAppend appender; ChannelNameBuilder<NotMemberAppend> builder(this, appender); SendToOne(builder, guid); } return; } player->LeftChannel(this); if (send) { /* YouLeftAppend appender; ChannelNameBuilder<YouLeftAppend> builder(this, appender); SendToOne(builder, guid); */ auto builder = [&](LocaleConstant locale) { LocaleConstant localeIdx = sWorld->GetAvailableDbcLocale(locale); WorldPackets::Channel::ChannelNotifyLeft* notify = new WorldPackets::Channel::ChannelNotifyLeft(); notify->Channel = GetName(localeIdx); notify->ChatChannelID = 0; //notify->Suspended = false; return notify; }; SendToOne(builder, guid); } PlayerInfo& info = _playersStore.at(guid); bool changeowner = info.IsOwner(); _playersStore.erase(guid); if (_announceEnabled && !player->GetSession()->HasPermission(rbac::RBAC_PERM_SILENTLY_JOIN_CHANNEL)) { LeftAppend appender(guid); ChannelNameBuilder<LeftAppend> builder(this, appender); SendToAll(builder); } LeaveNotify(player); if (!IsConstant()) { // Update last_used timestamp in db UpdateChannelUseageInDB(); // If the channel owner left and there are still playersStore inside, pick a new owner // do not pick invisible gm owner unless there are only invisible gms in that channel (rare) if (changeowner && _ownershipEnabled && !_playersStore.empty()) { PlayerContainer::iterator itr; for (itr = _playersStore.begin(); itr != _playersStore.end(); ++itr) { if (!itr->second.IsInvisible()) break; } if (itr == _playersStore.end()) itr = _playersStore.begin(); ObjectGuid const& newowner = itr->first; itr->second.SetModerator(true); SetOwner(newowner); // if the new owner is invisible gm, set flag to automatically choose a new owner if (itr->second.IsInvisible()) _isOwnerInvisible = true; } } }
void Channel::JoinChannel(Player* player, std::string const& pass) { ObjectGuid const& guid = player->GetGUID(); if (IsOn(guid)) { // Do not send error message for built-in channels if (!IsConstant()) { PlayerAlreadyMemberAppend appender(guid); ChannelNameBuilder<PlayerAlreadyMemberAppend> builder(this, appender); SendToOne(builder, guid); } return; } if (IsBanned(guid)) { BannedAppend appender; ChannelNameBuilder<BannedAppend> builder(this, appender); SendToOne(builder, guid); return; } if (!_channelPassword.empty() && pass != _channelPassword) { WrongPasswordAppend appender; ChannelNameBuilder<WrongPasswordAppend> builder(this, appender); SendToOne(builder, guid); return; } if (HasFlag(CHANNEL_FLAG_LFG) && sWorld->getBoolConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) && //FIXME: Move to RBAC player->GetGroup()) { NotInLFGAppend appender; ChannelNameBuilder<NotInLFGAppend> builder(this, appender); SendToOne(builder, guid); return; } player->JoinedChannel(this); if (_announceEnabled && !player->GetSession()->HasPermission(rbac::RBAC_PERM_SILENTLY_JOIN_CHANNEL)) { JoinedAppend appender(guid); ChannelNameBuilder<JoinedAppend> builder(this, appender); SendToAll(builder); } bool newChannel = _playersStore.empty(); PlayerInfo& playerInfo = _playersStore[guid]; playerInfo.SetInvisible(!player->isGMVisible()); /* YouJoinedAppend appender; ChannelNameBuilder<YouJoinedAppend> builder(this, appender); SendToOne(builder, guid); */ auto builder = [&](LocaleConstant /*locale*/) { WorldPackets::Channel::ChannelNotifyJoined* notify = new WorldPackets::Channel::ChannelNotifyJoined(); //notify->ChannelWelcomeMsg = ""; notify->ChatChannelID = _channelId; //notify->InstanceID = 0; notify->_ChannelFlags = _channelFlags; notify->_Channel = _channelName; return notify; }; SendToOne(builder, guid); JoinNotify(player); // Custom channel handling if (!IsConstant()) { // Update last_used timestamp in db if (!_playersStore.empty()) UpdateChannelUseageInDB(); // If the channel has no owner yet and ownership is allowed, set the new owner. // or if the owner was a GM with .gm visible off // don't do this if the new player is, too, an invis GM, unless the channel was empty if (_ownershipEnabled && (newChannel || !playerInfo.IsInvisible()) && (_ownerGuid.IsEmpty() || _isOwnerInvisible)) { _isOwnerInvisible = playerInfo.IsInvisible(); SetOwner(guid, !newChannel && !_isOwnerInvisible); playerInfo.SetModerator(true); } } }
void Channel::SetMode(uint64 p, const char *p2n, bool mod, bool set) { Player *plr = sObjectMgr->GetPlayer(p); if (!plr) return; uint32 sec = plr->GetSession()->GetSecurity(); if (!IsOn(p)) { WorldPacket data; MakeNotMember(&data); SendToOne(&data, p); } else if (!players[p].IsModerator() && sec < SEC_GAMEMASTER) { WorldPacket data; MakeNotModerator(&data); SendToOne(&data, p); } else { Player *newp = sObjectMgr->GetPlayer(p2n); if (!newp) { WorldPacket data; MakePlayerNotFound(&data, p2n); SendToOne(&data, p); return; } if (p == m_ownerGUID && newp->GetGUID() == m_ownerGUID && mod) return; if (!IsOn(newp->GetGUID())) { WorldPacket data; MakePlayerNotFound(&data, p2n); SendToOne(&data, p); return; } // allow make moderator from another team only if both is GMs // at this moment this only way to show channel post for GM from another team if ((plr->GetSession()->GetSecurity() < SEC_GAMEMASTER || newp->GetSession()->GetSecurity() < SEC_GAMEMASTER) && plr->GetTeam() != newp->GetTeam() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)) { WorldPacket data; MakePlayerNotFound(&data, p2n); SendToOne(&data, p); return; } if (m_ownerGUID == newp->GetGUID() && m_ownerGUID != p) { WorldPacket data; MakeNotOwner(&data); SendToOne(&data, p); return; } if (mod) SetModerator(newp->GetGUID(), set); else SetMute(newp->GetGUID(), set); } }
void Channel::KickOrBan(Player const* player, std::string const& badname, bool ban) { uint64 good = player->GetGUID(); if (!IsOn(good)) { WorldPacket data; MakeNotMember(&data); SendToOne(&data, good); return; } if (!playersStore[good].IsModerator() && !player->GetSession()->HasPermission(RBAC_PERM_CHANGE_CHANNEL_NOT_MODERATOR)) { WorldPacket data; MakeNotModerator(&data); SendToOne(&data, good); return; } Player* bad = sObjectAccessor->FindPlayerByName(badname); uint64 victim = bad ? bad->GetGUID() : 0; if (!victim || !IsOn(victim)) { WorldPacket data; MakePlayerNotFound(&data, badname); SendToOne(&data, good); return; } bool changeowner = _ownerGUID == victim; if (!player->GetSession()->HasPermission(RBAC_PERM_CHANGE_CHANNEL_NOT_MODERATOR) && changeowner && good != _ownerGUID) { WorldPacket data; MakeNotOwner(&data); SendToOne(&data, good); return; } if (ban && !IsBanned(victim)) { bannedStore.insert(victim); UpdateChannelInDB(); if (!player->GetSession()->HasPermission(RBAC_PERM_SILENTLY_JOIN_CHANNEL)) { WorldPacket data; MakePlayerBanned(&data, victim, good); SendToAll(&data); } } else if (!player->GetSession()->HasPermission(RBAC_PERM_SILENTLY_JOIN_CHANNEL)) { WorldPacket data; MakePlayerKicked(&data, victim, good); SendToAll(&data); } playersStore.erase(victim); bad->LeftChannel(this); if (changeowner && _ownership && !playersStore.empty()) { uint64 newowner = good; playersStore[newowner].SetModerator(true); SetOwner(newowner); } }
void Channel::Join(uint64 p, const char *pass) { WorldPacket data; if (IsOn(p)) { if (!IsConstant()) // non send error message for built-in channels { MakePlayerAlreadyMember(&data, p); SendToOne(&data, p); } return; } if (IsBanned(p)) { MakeBanned(&data); SendToOne(&data, p); return; } if (m_password.length() > 0 && strcmp(pass, m_password.c_str())) { MakeWrongPassword(&data); SendToOne(&data, p); return; } Player *player = ObjectAccessor::FindPlayer(p); if (player) { if (HasFlag(CHANNEL_FLAG_LFG) && sWorld->getBoolConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) && player->GetGroup()) { MakeNotInLfg(&data); SendToOne(&data, p); return; } player->JoinedChannel(this); } if (m_announce && (!player || !AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()) || !sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL))) { MakeJoined(&data, p); SendToAll(&data); } data.clear(); PlayerInfo pinfo; pinfo.player = p; pinfo.flags = MEMBER_FLAG_NONE; players[p] = pinfo; MakeYouJoined(&data); SendToOne(&data, p); JoinNotify(p); // Custom channel handling if (!IsConstant()) { // Update last_used timestamp in db if (!players.empty()) UpdateChannelUseageInDB(); // If the channel has no owner yet and ownership is allowed, set the new owner. if (!m_ownerGUID && m_ownership) { SetOwner(p, (players.size() > 1 ? true : false)); players[p].SetModerator(true); } } }
void Channel::Join(uint64 p, const char *pass) { WorldPacket data; if(IsOn(p)) { if(!IsConstant()) // non send error message for built-in channels { MakePlayerAlreadyMember(&data, p); SendToOne(&data, p); } return; } if(IsBanned(p)) { MakeBanned(&data); SendToOne(&data, p); return; } if(m_password.length() > 0 && strcmp(pass, m_password.c_str())) { MakeWrongPassword(&data); SendToOne(&data, p); return; } Player *plr = objmgr.GetPlayer(p); if(plr) { if(HasFlag(CHANNEL_FLAG_LFG) && sWorld.getConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && plr->GetSession()->GetSecurity() == SEC_PLAYER && (plr->GetGroup() || plr->m_lookingForGroup.Empty()) ) { MakeNotInLfg(&data); SendToOne(&data, p); return; } if(plr->GetGuildId() && (GetFlags() == 0x38)) return; plr->JoinedChannel(this); } if(m_announce && (!plr || plr->GetSession()->GetSecurity() < SEC_GAMEMASTER || !sWorld.getConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL) )) { MakeJoined(&data, p); SendToAll(&data); } data.clear(); PlayerInfo pinfo; pinfo.player = p; pinfo.flags = 0; players[p] = pinfo; MakeYouJoined(&data); SendToOne(&data, p); sIRC.Handle_WoW_Channel(m_name, objmgr.GetPlayer(p), CHANNEL_JOIN); JoinNotify(p); }