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; } PlayerPointer plr = GetPlayer(p); if (m_securityLevel && (!plr.get() || plr->GetSession()->GetSecurity() < m_securityLevel)) { MakeWrongPassword(&data); SendToOne(&data, p); return; } if (plr && plr->ToPlayer()) { if (plr->GetGuildId() && (GetFlags() == 0x38)) return; plr->ToPlayer()->JoinedChannel(this); } if (m_announce && (!plr.get() || 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 (HasFlag(CHANNEL_FLAG_CUSTOM) && !IsConstant() && !m_ownerGuid) { SetOwner(p, (m_players.size() > 1 ? true : false)); m_players[p].SetModerator(true); } }
void Channel::List(PlayerPointer player) { ObjectGuid p = player->GetObjectGuid(); MasterPlayer* masterPlayer = player->ToMasterPlayer(); Player* asPlayer = player->ToPlayer(); if (!IsOn(p)) { WorldPacket data; MakeNotMember(&data); SendToOne(&data, p); } else { WorldPacket data(SMSG_CHANNEL_LIST, 1 + (GetName().size() + 1) + 1 + 4 + m_players.size() * (8 + 1)); data << uint8(1); // channel type? data << GetName(); // channel name data << uint8(GetFlags()); // channel flags? size_t pos = data.wpos(); data << uint32(0); // size of list, placeholder AccountTypes gmLevelInWhoList = (AccountTypes)sWorld.getConfig(CONFIG_UINT32_GM_LEVEL_IN_WHO_LIST); uint32 count = 0; for (PlayerList::const_iterator i = m_players.begin(); i != m_players.end(); ++i) { if (masterPlayer) { MasterPlayer* plr = sObjectAccessor.FindMasterPlayer(i->first); // PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters // MODERATOR, GAME MASTER, ADMINISTRATOR can see all if (plr && (masterPlayer->GetSession()->GetSecurity() > SEC_PLAYER || plr->GetSession()->GetSecurity() <= gmLevelInWhoList) && plr->IsVisibleGloballyFor(masterPlayer)) { data << ObjectGuid(i->first); data << uint8(i->second.flags); // flags seems to be changed... ++count; } } else { Player *plr = sObjectMgr.GetPlayer(i->first); // PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters // MODERATOR, GAME MASTER, ADMINISTRATOR can see all if (plr && (asPlayer->GetSession()->GetSecurity() > SEC_PLAYER || plr->GetSession()->GetSecurity() <= gmLevelInWhoList) && plr->IsVisibleGloballyFor(asPlayer)) { data << ObjectGuid(i->first); data << uint8(i->second.flags); // flags seems to be changed... ++count; } } } data.put<uint32>(pos, count); SendToOne(&data, p); } }