void Channel::JoinChannel(Player* player, std::string const& pass) { ObjectGuid 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::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::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::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; 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::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()) && player->GetGroup()) { WorldPacket data; MakeNotInLfg(&data); SendToOne(&data, guid); return; } player->JoinedChannel(this); if (_announce && (!AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()) || !sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL))) { WorldPacket data; MakeJoined(&data, guid); SendToAll(&data); } PlayerInfo pinfo; pinfo.player = guid; pinfo.flags = MEMBER_FLAG_NONE; pinfo.lastSpeakTime = 0; pinfo.plrPtr = player; playersStore[guid] = pinfo; if (_channelRights.joinMessage.length()) ChatHandler(player->GetSession()).PSendSysMessage("%s", _channelRights.joinMessage.c_str()); WorldPacket data; MakeYouJoined(&data); SendToOne(&data, guid); JoinNotify(player); // Custom channel handling if (!IsConstant()) { // Update last_used timestamp in db if (!playersStore.empty()) UpdateChannelUseageInDB(); if (_channelRights.moderators.find(player->GetSession()->GetAccountId()) != _channelRights.moderators.end()) { playersStore[guid].SetModerator(true); FlagsNotify(player); } // If the channel has no owner yet and ownership is allowed, set the new owner. if (!_ownerGUID && _ownership) SetOwner(guid, false); if (_channelRights.flags & CHANNEL_RIGHT_CANT_SPEAK) playersStore[guid].SetMuted(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; } bool banOffline = false; // pussywizard bool isGoodConstantModerator = _channelRights.moderators.find(player->GetSession()->GetAccountId()) != _channelRights.moderators.end(); uint64 victim = 0; uint32 badAccId = 0; uint32 badSecurity = 0; Player* bad = ObjectAccessor::FindPlayerByName(badname, false); if (bad) { victim = bad->GetGUID(); badAccId = bad->GetSession()->GetAccountId(); badSecurity = bad->GetSession()->GetSecurity(); } bool isOnChannel = victim && IsOn(victim); if (!isOnChannel) { if (ban && (AccountMgr::IsGMAccount(sec) || isGoodConstantModerator)) { if (uint32 lowGuid = sWorld->GetGlobalPlayerGUID(badname)) if (const GlobalPlayerData* gpd = sWorld->GetGlobalPlayerData(lowGuid)) { if (Player::TeamIdForRace(gpd->race) == Player::TeamIdForRace(player->getRace())) { banOffline = true; victim = MAKE_NEW_GUID(lowGuid, 0, HIGHGUID_PLAYER); badAccId = gpd->accountId; } else { ChatHandler(player->GetSession()).PSendSysMessage("Character %s has other faction!", badname.c_str()); return; } } if (!banOffline) { WorldPacket data; MakePlayerNotFound(&data, badname); SendToOne(&data, good); return; } } else { WorldPacket data; MakePlayerNotFound(&data, badname); SendToOne(&data, good); return; } } bool changeowner = _ownerGUID == victim; bool isBadConstantModerator = _channelRights.moderators.find(badAccId) != _channelRights.moderators.end(); if (!AccountMgr::IsGMAccount(sec) && !isGoodConstantModerator) { if (changeowner && good != _ownerGUID) { WorldPacket data; MakeNotOwner(&data); SendToOne(&data, good); return; } if (ban && (_channelRights.flags & CHANNEL_RIGHT_CANT_BAN) || !ban && (_channelRights.flags & CHANNEL_RIGHT_CANT_KICK)) { WorldPacket data; MakeNotModerator(&data); SendToOne(&data, good); return; } if (isBadConstantModerator || AccountMgr::IsGMAccount(badSecurity)) { WorldPacket data; MakeNotModerator(&data); SendToOne(&data, good); return; } } bool notify = !(AccountMgr::IsGMAccount(sec) && sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL)); if (ban) { if (!IsBanned(victim)) { bannedStore[GUID_LOPART(victim)] = time(NULL) + CHANNEL_BAN_DURATION; AddChannelBanToDB(GUID_LOPART(victim), time(NULL) + CHANNEL_BAN_DURATION); if (notify) { WorldPacket data; MakePlayerBanned(&data, victim, good); SendToAll(&data); } } } else if (notify) { WorldPacket data; MakePlayerKicked(&data, victim, good); SendToAll(&data); } if (isOnChannel) { playersStore.erase(victim); bad->LeftChannel(this); RemoveWatching(bad); LeaveNotify(bad); } if (changeowner && _ownership) { if (good != victim) SetOwner(good); else if (!playersStore.empty()) { uint64 newowner = 0; for (Channel::PlayerContainer::const_iterator itr = playersStore.begin(); itr != playersStore.end(); ++itr) { newowner = itr->second.player; if (!itr->second.plrPtr->GetSession()->GetSecurity()) break; } SetOwner(newowner); } else SetOwner(0); } }
bool Channel::ExecuteSayCommand( const std::string& in ) { if ( in.length() == 0 ) return true; if ( in[0] != '/' ) return false; wxString subcmd = TowxString(in).BeforeFirst(' ').Lower(); wxString params = TowxString(in).AfterFirst( ' ' ); wxString cmdline = TowxString(in); wxString param = GetWordParam( cmdline ); if ( param == _T("/me") ) { DoAction(STD_STRING(cmdline)); return true; } else if (( in == "/part") || (in == "/p") ) { Leave(); uidata.panel = 0; return true; } else if ( param == _T("/sayver") ) { //!this instance is not replaced with GetAppname for sake of help/debug online DoAction( "is using SpringLobby v" + getSpringlobbyVersion() ); return true; } else if(subcmd==_T("/userban")){ m_banned_users.insert(STD_STRING(params)); m_serv.SayPrivate(_T("ChanServ"),_T("!kick #")+TowxString(GetName())+_T(" ")+params); return true; } else if(subcmd==_T("/userunban")){ m_banned_users.erase(STD_STRING(params)); return true; } else if(subcmd==_T("/banregex")){ ui().OnChannelMessage(*this,_T("/banregex ")+params); m_do_ban_regex=!params.empty(); if(m_do_ban_regex){ #ifdef wxHAS_REGEX_ADVANCED m_ban_regex.Compile(params, wxRE_ADVANCED); #else m_ban_regex.Compile(params, wxRE_EXTENDED); #endif if(!m_ban_regex.IsValid())ui().OnChannelMessage(*this,_T("Invalid regular expression")); } return true; } else if(subcmd==_T("/unbanregex")){ ui().OnChannelMessage(*this,_T("/unbanregex ")+params); m_do_unban_regex=!params.empty(); if(m_do_unban_regex){ #ifdef wxHAS_REGEX_ADVANCED m_unban_regex.Compile(params, wxRE_ADVANCED); #else m_unban_regex.Compile(params, wxRE_EXTENDED); #endif if(!m_unban_regex.IsValid())ui().OnChannelMessage(*this,_T("Invalid regular expression")); } return true; } else if (subcmd==_T("/checkban")) { if(IsBanned(STD_STRING(params))){ ui().OnChannelMessage(*this,params+_T(" is banned")); }else{ ui().OnChannelMessage(*this,params+_T(" is not banned")); } return true; } else if(subcmd==_T("/banregexmsg")){ ui().OnChannelMessage(*this,_T("/banregexmsg ")+params); m_ban_regex_msg=STD_STRING(params); return true; } return false; }
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()) { WorldPackets::Channel::ChannelNotify notify; MakePlayerAlreadyMember(notify, guid); player->SendDirectMessage(notify.Write()); } return; } if (IsBanned(guid)) { WorldPackets::Channel::ChannelNotify notify; MakeBanned(notify); player->SendDirectMessage(notify.Write()); return; } if (!_password.empty() && pass != _password) { WorldPackets::Channel::ChannelNotify notify; MakeWrongPassword(notify); player->SendDirectMessage(notify.Write()); return; } if (HasFlag(CHANNEL_FLAG_LFG) && sWorld->getBoolConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) && //FIXME: Move to RBAC player->GetGroup()) { WorldPackets::Channel::ChannelNotify notify; MakeNotInLfg(notify); player->SendDirectMessage(notify.Write()); return; } player->JoinedChannel(this); if (_announce && !player->GetSession()->HasPermission(rbac::RBAC_PERM_SILENTLY_JOIN_CHANNEL)) { WorldPackets::Channel::ChannelNotify notify; MakeJoined(notify, guid); SendToAll(notify.Write()); } PlayerInfo playerInfo; playerInfo.PlayerGuid = guid; _playersStore[guid] = playerInfo; /* WorldPackets::Channel::ChannelNotify notify; MakeYouJoined(notify); player->SendDirectMessage(notify.Write()); */ WorldPackets::Channel::ChannelNotifyJoined notify; //notify.ChannelWelcomeMsg = ""; notify.ChatChannelID = _channelId; //notify.InstanceID = 0; notify._ChannelFlags = _flags; notify._Channel = _name; player->SendDirectMessage(notify.Write()); 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. if (_ownerGUID.IsEmpty() && _ownership) { SetOwner(guid, _playersStore.size() > 1); _playersStore[guid].SetModerator(true); } } }
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::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); } }
/** Move a character from a remote account into this one. */ bool Rename::UserCmd_MoveChar(uint iClientID, const wstring &wscCmd, const wstring &wscParam, const wchar_t *usage) { HK_ERROR err; // Don't indicate an error if moving is disabled. if (!set_bEnableMoveChar) return false; // Indicate an error if the command does not appear to be formatted correctly // and stop processing but tell FLHook that we processed the command. if (wscParam.size()==0) { PrintUserCmdText(iClientID, L"ERR Invalid parameters"); PrintUserCmdText(iClientID, usage); return true; } uint iBaseID; pub::Player::GetBase(iClientID, iBaseID); if (!iBaseID) { PrintUserCmdText(iClientID, L"ERR Not in base"); return true; } // Get the target account directory. string scFile; wstring wscMovingCharname = Trim(GetParam(wscParam, L' ', 0)); if (!GetUserFilePath(scFile, wscMovingCharname, "-movechar.ini")) { PrintUserCmdText(iClientID, L"ERR Character does not exist"); return true; } // Check the move char code. wstring wscCode = Trim(GetParam(wscParam, L' ', 1)); wstring wscTargetCode = IniGetWS(scFile, "Settings", "Code", L""); if (!wscTargetCode.length() || wscTargetCode!=wscCode) { PrintUserCmdText(iClientID, L"ERR Move character access denied"); return true; } // Get the character name for this connection. wstring wscCharname = (const wchar_t*)Players.GetActiveCharacterName(iClientID); for (map<wstring, LockedShipsStruct>::iterator i = MapLockedShips.begin(); i != MapLockedShips.end(); ++i) { if ((i->first == wscMovingCharname) && (i->second.LockLevel > 0)) { PrintUserCmdText(iClientID, L"ERR This ship is locked. The FBI has been notified."); wstring spurdoip; HkGetPlayerIP(iClientID, spurdoip); AddLog("SHIPLOCK: Attempt to movechar locked ship %s from IP %s", wstos(wscMovingCharname).c_str(), wstos(spurdoip).c_str()); ConPrint(L"SHIPLOCK: Attempt to movechar locked ship %s from IP %s\n", wscMovingCharname.c_str(), spurdoip.c_str()); return true; } } // Prevent ships from banned accounts from being moved. if (IsBanned(wscMovingCharname)) { PrintUserCmdText(iClientID, L"ERR not permitted"); return true; } // Saving the characters forces an anti-cheat checks and fixes // up a multitude of other problems. HkSaveChar(wscCharname); HkSaveChar(wscMovingCharname); // Read the current number of credits for the player // and check that the character has enough cash. int iCash = 0; if ((err = HkGetCash(wscCharname, iCash)) != HKE_OK) { PrintUserCmdText(iClientID, L"ERR "+HkErrGetText(err)); return true; } if (set_iMoveCost>0 && iCash<set_iMoveCost) { PrintUserCmdText(iClientID, L"ERR Insufficient credits"); return true; } // Check there is room in this account. CAccount *acc=Players.FindAccountFromClientID(iClientID); if (acc->iNumberOfCharacters >= 7) { PrintUserCmdText(iClientID, L"ERR Too many characters in account"); return true; } // Copy character file into this account with a temp name. char szDataPath[MAX_PATH]; GetUserDataPath(szDataPath); string scAcctPath = string(szDataPath) + "\\Accts\\MultiPlayer\\"; wstring wscDir; wstring wscSourceDir; wstring wscSourceFile; if ((err = HkGetAccountDirName(wscCharname, wscDir))!=HKE_OK) { PrintUserCmdText(iClientID, L"ERR "+HkErrGetText(err)); return true; } if ((err = HkGetAccountDirName(wscMovingCharname, wscSourceDir))!=HKE_OK) { PrintUserCmdText(iClientID, L"ERR "+HkErrGetText(err)); return true; } if ((err = HkGetCharFileName(wscMovingCharname, wscSourceFile))!=HKE_OK) { PrintUserCmdText(iClientID, L"ERR "+HkErrGetText(err)); return true; } // Remove cash if we're charging for it. if (set_iMoveCost>0) HkAddCash(wscCharname, 0-set_iMoveCost); HkSaveChar(wscCharname); // Schedule the move MOVE o; o.wscDestinationCharname = wscCharname; o.wscMovingCharname = wscMovingCharname; o.scSourceFile = scAcctPath + wstos(wscSourceDir) + "\\" + wstos(wscSourceFile) + ".fl"; o.scDestFile = scAcctPath + wstos(wscDir) + "\\" + wstos(wscSourceFile) + ".fl"; o.scDestFileTemp = scAcctPath + wstos(wscDir) + "\\" + wstos(wscSourceFile) + ".fl.moving"; pendingMoves.push_back(o); // Delete the move code ::DeleteFileA(scFile.c_str()); // Kick HkKickReason(o.wscDestinationCharname, L"Moving character, please wait 10 seconds before reconnecting"); HkKickReason(o.wscMovingCharname, L"Moving character, please wait 10 seconds before reconnecting"); return 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; } if (ban && !IsBanned(victim)) { bannedStore.insert(victim); UpdateChannelInDB(); if (!AccountMgr::IsGMAccount(sec)) { WorldPacket data; MakePlayerBanned(&data, victim, good); SendToAll(&data); } } else if (!AccountMgr::IsGMAccount(sec)) { 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(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::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::KickOrBan(Player const* player, std::string const& badname, bool ban) { ObjectGuid const& good = player->GetGUID(); if (!IsOn(good)) { WorldPackets::Channel::ChannelNotify notify; MakeNotMember(notify); player->SendDirectMessage(notify.Write()); return; } if (!_playersStore[good].IsModerator() && !player->GetSession()->HasPermission(rbac::RBAC_PERM_CHANGE_CHANNEL_NOT_MODERATOR)) { WorldPackets::Channel::ChannelNotify notify; MakeNotModerator(notify); player->SendDirectMessage(notify.Write()); return; } Player* bad = ObjectAccessor::FindConnectedPlayerByName(badname); ObjectGuid victim = bad ? bad->GetGUID() : ObjectGuid::Empty; if (!victim || !IsOn(victim)) { WorldPackets::Channel::ChannelNotify notify; MakePlayerNotFound(notify, badname); player->SendDirectMessage(notify.Write()); return; } bool changeowner = _ownerGUID == victim; if (!player->GetSession()->HasPermission(rbac::RBAC_PERM_CHANGE_CHANNEL_NOT_MODERATOR) && changeowner && good != _ownerGUID) { WorldPackets::Channel::ChannelNotify notify; MakeNotOwner(notify); player->SendDirectMessage(notify.Write()); return; } if (ban && !IsBanned(victim)) { _bannedStore.insert(victim); UpdateChannelInDB(); if (!player->GetSession()->HasPermission(rbac::RBAC_PERM_SILENTLY_JOIN_CHANNEL)) { WorldPackets::Channel::ChannelNotify notify; MakePlayerBanned(notify, victim, good); SendToAll(notify.Write()); } } else if (!player->GetSession()->HasPermission(rbac::RBAC_PERM_SILENTLY_JOIN_CHANNEL)) { WorldPackets::Channel::ChannelNotify notify; MakePlayerKicked(notify, victim, good); SendToAll(notify.Write()); } _playersStore.erase(victim); bad->LeftChannel(this); if (changeowner && _ownership && !_playersStore.empty()) { _playersStore[good].SetModerator(true); SetOwner(good); } }
void Channel::KickOrBan(Player const* player, std::string const& badname, bool ban) { ObjectGuid good = player->GetGUID(); if (!IsOn(good)) { WorldPacket data; MakeNotMember(&data); SendToOne(&data, good); return; } if (!playersStore[good].IsModerator() && !player->GetSession()->HasPermission(rbac::RBAC_PERM_CHANGE_CHANNEL_NOT_MODERATOR)) { WorldPacket data; MakeNotModerator(&data); SendToOne(&data, good); return; } Player* bad = sObjectAccessor->FindPlayerByName(badname); ObjectGuid victim = bad ? bad->GetGUID() : ObjectGuid::Empty; if (!victim || !IsOn(victim)) { WorldPacket data; MakePlayerNotFound(&data, badname); SendToOne(&data, good); return; } bool changeowner = _ownerGUID == victim; if (!player->GetSession()->HasPermission(rbac::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::RBAC_PERM_SILENTLY_JOIN_CHANNEL)) { WorldPacket data; MakePlayerBanned(&data, victim, good); SendToAll(&data); } } else if (!player->GetSession()->HasPermission(rbac::RBAC_PERM_SILENTLY_JOIN_CHANNEL)) { WorldPacket data; MakePlayerKicked(&data, victim, good); SendToAll(&data); } playersStore.erase(victim); bad->LeftChannel(this); if (changeowner && _ownership && !playersStore.empty()) { ObjectGuid 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; } Player *plr = sObjectMgr.GetPlayer(p); if ((!plr || !plr->isGameMaster()) && !IsConstant() && m_name != "world" && m_name != "engworld" && m_name != "handel") { uint32 limitCount = sWorld.getConfig(CONFIG_PRIVATE_CHANNEL_LIMIT); if (limitCount && players.size() > limitCount) { MakeInvalidName(&data); SendToOne(&data, p); return; } } if (!m_ownerGUID && (!plr || !plr->CanSpeak())) // muted players can't create new channels { MakeBanned(&data);//no idea what to send SendToOne(&data, p); return; } if (IsBanned(p) && (!plr || !plr->isGameMaster())) { MakeBanned(&data); SendToOne(&data, p); return; } if (m_password.length() > 0 && strcmp(pass, m_password.c_str()) && (!plr || !plr->isGameMaster())) { MakeWrongPassword(&data); SendToOne(&data, p); return; } if (plr) { if (IsLFG() && sWorld.getConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && !plr->GetSession()->HasPermissions(PERM_GMT) && 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()->HasPermissions(PERM_GMT) || !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); JoinNotify(p); // if no owner first logged will become if (!IsConstant() && !m_ownerGUID) { 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 = sObjectMgr.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); JoinNotify(p); // if no owner first logged will become if(!IsConstant() && !m_ownerGUID) { SetOwner(p, (players.size() > 1 ? true : false)); 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); _UpdateBanListInDB(); } else MakePlayerKicked(&data, bad->GetGUID(), good); SendToAll(&data); players.erase(bad->GetGUID()); bad->LeftChannel(this); if (changeowner) { uint64 newowner = !players.empty() ? good : false; players[newowner].SetModerator(true); SetOwner(newowner); } } } }
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::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); }