void WorldSession::HandleGroupAcceptOpcode( WorldPacket & /*recv_data*/ ) { Group *group = GetPlayer()->GetGroupInvite(); if (!group) return; // remove in from ivites in any case group->RemoveInvite(GetPlayer()); /** error handling **/ /********************/ // not have place if(group->IsFull()) { SendPartyResult(PARTY_OP_INVITE, "", PARTY_RESULT_PARTY_FULL); return; } // everything's fine, do it if(!group->AddMember(GetPlayer()->GetGUID(), GetPlayer()->GetName())) return; uint8 subgroup = group->GetMemberGroup(GetPlayer()->GetGUID()); GetPlayer()->SetGroup(group, subgroup); }
void WorldSession::HandleGroupAcceptOpcode(WorldPacket& recvData) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GROUP_ACCEPT"); #endif recvData.read_skip<uint32>(); Group* group = GetPlayer()->GetGroupInvite(); if (!group) return; // Remove player from invitees in any case group->RemoveInvite(GetPlayer()); if (GetPlayer()->IsSpectator()) { SendPartyResult(PARTY_OP_INVITE, "", ERR_INVITE_RESTRICTED); return; } if (group->GetLeaderGUID() == GetPlayer()->GetGUID()) { sLog->outError("HandleGroupAcceptOpcode: player %s(%d) tried to accept an invite to his own group", GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow()); return; } // Group is full if (group->IsFull()) { SendPartyResult(PARTY_OP_INVITE, "", ERR_GROUP_FULL); return; } Player* leader = ObjectAccessor::FindPlayerInOrOutOfWorld(group->GetLeaderGUID()); // Forming a new group, create it if (!group->IsCreated()) { // This can happen if the leader is zoning. To be removed once delayed actions for zoning are implemented if (!leader || leader->IsSpectator()) { group->RemoveAllInvites(); return; } // If we're about to create a group there really should be a leader present ASSERT(leader); group->RemoveInvite(leader); group->Create(leader); sGroupMgr->AddGroup(group); } // Everything is fine, do it, PLAYER'S GROUP IS SET IN ADDMEMBER!!! if (!group->AddMember(GetPlayer())) return; group->BroadcastGroupUpdate(); }
void WorldSession::HandleGroupAcceptOpcode(WorldPacket& recvData) { TC_LOG_DEBUG("network", "WORLD: Received CMSG_GROUP_ACCEPT"); recvData.read_skip<uint32>(); Group* group = GetPlayer()->GetGroupInvite(); if (!group) return; // Remove player from invitees in any case group->RemoveInvite(GetPlayer()); if (group->GetLeaderGUID() == GetPlayer()->GetGUID()) { TC_LOG_ERROR("network", "HandleGroupAcceptOpcode: player %s(%d) tried to accept an invite to his own group", GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().GetCounter()); return; } // Group is full if (group->IsFull()) { SendPartyResult(PARTY_OP_INVITE, "", ERR_GROUP_FULL); return; } Player* leader = ObjectAccessor::FindPlayer(group->GetLeaderGUID()); // Forming a new group, create it if (!group->IsCreated()) { // This can happen if the leader is zoning. To be removed once delayed actions for zoning are implemented if (!leader) { group->RemoveAllInvites(); return; } // If we're about to create a group there really should be a leader present ASSERT(leader); group->RemoveInvite(leader); group->Create(leader); sGroupMgr->AddGroup(group); } // Everything is fine, do it, PLAYER'S GROUP IS SET IN ADDMEMBER!!! if (!group->AddMember(GetPlayer())) return; group->BroadcastGroupUpdate(); }
void WorldSession::HandleGroupAcceptOpcode( WorldPacket & recv_data ) { if (!GetPlayer()->GetPlayerbotAI()) recv_data.read_skip<uint32>(); // roles mask? Group *group = GetPlayer()->GetGroupInvite(); if (!group) return; if (group->GetLeaderGuid() == GetPlayer()->GetObjectGuid()) { sLog.outError("HandleGroupAcceptOpcode: %s tried to accept an invite to his own group", GetPlayer()->GetGuidStr().c_str()); return; } // remove in from invites in any case group->RemoveInvite(GetPlayer()); /** error handling **/ /********************/ // not have place if(group->IsFull()) { SendPartyResult(PARTY_OP_INVITE, "", ERR_GROUP_FULL); return; } Player* leader = sObjectMgr.GetPlayer(group->GetLeaderGuid()); // forming a new group, create it if (!group->IsCreated()) { if (leader) group->RemoveInvite(leader); if (group->Create(group->GetLeaderGuid(), group->GetLeaderName())) sObjectMgr.AddGroup(group); else return; } // everything is fine, do it, PLAYER'S GROUP IS SET IN ADDMEMBER!!! if(!group->AddMember(GetPlayer()->GetObjectGuid(), GetPlayer()->GetName())) return; // Frozen Mod group->BroadcastGroupUpdate(); // Frozen Mod }
void WorldSession::HandleGroupAcceptOpcode(WorldPacket & /*recv_data*/) { Group *group = GetPlayer()->GetGroupInvite(); if (!group) return; if (group->GetLeaderGUID() == GetPlayer()->GetGUID()) { sLog.outError("HandleGroupAcceptOpcode: player %s(%d) tried to accept an invite to his own group", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow()); return; } // remove in from ivites in any case group->RemoveInvite(GetPlayer()); /** error handling **/ /********************/ // not have place if (group->IsFull()) { SendPartyResult(PARTY_OP_INVITE, "", ERR_GROUP_FULL); return; } Player* leader = objmgr.GetPlayer(group->GetLeaderGUID()); // forming a new group, create it if (!group->IsCreated()) { if (leader) group->RemoveInvite(leader); group->Create(group->GetLeaderGUID(), group->GetLeaderName()); objmgr.AddGroup(group); } // everything's fine, do it, PLAYER'S GROUP IS SET IN ADDMEMBER!!! if (!group->AddMember(GetPlayer()->GetGUID(), GetPlayer()->GetName())) return; SendLfgUpdatePlayer(LFG_UPDATETYPE_REMOVED_FROM_QUEUE); for (GroupReference *itr = group->GetFirstMember(); itr != NULL; itr = itr->next()) if (Player *plrg = itr->getSource()) { plrg->GetSession()->SendLfgUpdatePlayer(LFG_UPDATETYPE_CLEAR_LOCK_LIST); plrg->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_CLEAR_LOCK_LIST); } group->BroadcastGroupUpdate(); }
void WorldSession::HandleGroupAcceptOpcode( WorldPacket & /*recv_data*/ ) { Group *group = GetPlayer()->GetGroupInvite(); if (!group) return; if(group->GetLeaderGUID() == GetPlayer()->GetGUID()) { sLog.outError("HandleGroupAcceptOpcode: player %s(%d) tried to accept an invite to his own group", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow()); return; } // remove in from invites in any case group->RemoveInvite(GetPlayer()); /** error handling **/ /********************/ // not have place if(group->IsFull()) { SendPartyResult(PARTY_OP_INVITE, "", ERR_GROUP_FULL); return; } Player* leader = sObjectMgr.GetPlayer(group->GetLeaderGUID()); if(leader && leader->InBattleGround()) { SendPartyResult(PARTY_OP_INVITE, "", ERR_INVITE_RESTRICTED); return; } // forming a new group, create it if(!group->IsCreated()) { if (leader) group->RemoveInvite(leader); if (group->Create(group->GetLeaderGUID(), group->GetLeaderName())) sObjectMgr.AddGroup(group); else return; } // everything is fine, do it, PLAYER'S GROUP IS SET IN ADDMEMBER!!! if(!group->AddMember(GetPlayer()->GetGUID(), GetPlayer()->GetName())) return; }
void WorldSession::HandleGroupAcceptOpcode( WorldPacket & /*recv_data*/ ) { Group *group = GetPlayer()->GetGroupInvite(); if (!group) return; if(group->GetLeaderGUID() == GetPlayer()->GetGUID()) { sLog.outError("HandleGroupAcceptOpcode: player %s(%d) tried to accept an invite to his own group", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow()); return; } // remove in from ivites in any case group->RemoveInvite(GetPlayer()); /** error handling **/ /********************/ // not have place if(group->IsFull()) { SendPartyResult(PARTY_OP_INVITE, "", PARTY_RESULT_PARTY_FULL); return; } Player* leader = objmgr.GetPlayer(group->GetLeaderGUID()); if(leader && leader->InBattleGround()) { SendPartyResult(PARTY_OP_INVITE, "", PARTY_RESULT_INVITE_RESTRICTED); return; } // forming a new group, create it if(!group->IsCreated()) { if(leader) group->RemoveInvite(leader); group->Create(group->GetLeaderGUID(), group->GetLeaderName()); objmgr.AddGroup(group); } // everything's fine, do it if(!group->AddMember(GetPlayer()->GetGUID(), GetPlayer()->GetName())) return; uint8 subgroup = group->GetMemberGroup(GetPlayer()->GetGUID()); GetPlayer()->SetGroup(group, subgroup); }
static bool HandleGroupJoinCommand(ChatHandler* handler, char const* args) { if (!*args) return false; Player* playerSource = NULL; Player* playerTarget = NULL; Group* groupSource = NULL; Group* groupTarget = NULL; uint64 guidSource = 0; uint64 guidTarget = 0; char* nameplgrStr = strtok((char*)args, " "); char* nameplStr = strtok(NULL, " "); if (!handler->GetPlayerGroupAndGUIDByName(nameplgrStr, playerSource, groupSource, guidSource, true)) return false; if (!groupSource) { handler->PSendSysMessage(LANG_GROUP_NOT_IN_GROUP, playerSource->GetName().c_str()); handler->SetSentErrorMessage(true); return false; } if (!handler->GetPlayerGroupAndGUIDByName(nameplStr, playerTarget, groupTarget, guidTarget, true)) return false; if (groupTarget || playerTarget->GetGroup() == groupSource) { handler->PSendSysMessage(LANG_GROUP_ALREADY_IN_GROUP, playerTarget->GetName().c_str()); handler->SetSentErrorMessage(true); return false; } if (!groupSource->IsFull()) { handler->PSendSysMessage(LANG_GROUP_FULL); handler->SetSentErrorMessage(true); return false; } groupSource->AddMember(playerTarget); groupSource->BroadcastGroupUpdate(); handler->PSendSysMessage(LANG_GROUP_PLAYER_JOINED, playerTarget->GetName().c_str(), playerSource->GetName().c_str()); return true; }
void WorldSession::HandleGroupAcceptOpcode( WorldPacket & recv_data ) { recv_data.read_skip<uint32>(); // value received in WorldSession::HandleGroupInviteOpcode and also skipeed currently? Group *group = GetPlayer()->GetGroupInvite(); if (!group) return; if(group->GetLeaderGUID() == GetPlayer()->GetGUID()) { sLog.outError("HandleGroupAcceptOpcode: player %s(%d) tried to accept an invite to his own group", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow()); return; } // remove in from ivites in any case group->RemoveInvite(GetPlayer()); /** error handling **/ /********************/ // not have place if(group->IsFull()) { SendPartyResult(PARTY_OP_INVITE, "", PARTY_RESULT_PARTY_FULL); return; } Player* leader = sObjectMgr.GetPlayer(group->GetLeaderGUID()); // forming a new group, create it if(!group->IsCreated()) { if( leader ) group->RemoveInvite(leader); group->Create(group->GetLeaderGUID(), group->GetLeaderName()); sObjectMgr.AddGroup(group); } // everything's fine, do it, PLAYER'S GROUP IS SET IN ADDMEMBER!!! if(!group->AddMember(GetPlayer()->GetGUID(), GetPlayer()->GetName())) return; }
bool Battlefield::AddPlayerToGroup(Player * player) { Group* grp; if(player->GetTeam() == ALLIANCE) grp = m_raidGroup[TEAM_ALLIANCE]; else grp = m_raidGroup[TEAM_HORDE]; if(!grp->IsCreated()) { grp->Create(player->GetObjectGuid(),player->GetName()); grp->ConvertToRaid(); grp->AddMember(player->GetObjectGuid(),player->GetName()); } else if(!grp->IsFull()) { grp->AddMember(player->GetObjectGuid(),player->GetName()); } else return false; return true; }
void WorldSession::HandleGroupInviteOpcode(WorldPacket& recv_data) { std::string membername; recv_data >> membername; // attempt add selected player // cheating if (!normalizePlayerName(membername)) { SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_CANT_FIND_TARGET); return; } Player* player = ObjectAccessor::Instance().FindPlayerByName(membername.c_str()); // no player if (!player) { SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_CANT_FIND_TARGET); return; } // restrict invite to GMs if (!sWorld.getConfig(CONFIG_ALLOW_GM_GROUP) && !GetPlayer()->isGameMaster() && player->isGameMaster()) { SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_CANT_FIND_TARGET); return; } // can't group with if (!sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP) && GetPlayer()->GetTeam() != player->GetTeam()) { SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_TARGET_UNFRIENDLY); return; } if (GetPlayer()->GetInstanceId() != 0 && player->GetInstanceId() != 0 && GetPlayer()->GetInstanceId() != player->GetInstanceId() && GetPlayer()->GetMapId() == player->GetMapId()) { SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_NOT_IN_YOUR_INSTANCE); return; } // just ignore us if (player->GetInstanceId() != 0 && player->GetDifficulty() != GetPlayer()->GetDifficulty()) { SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_TARGET_IGNORE_YOU); return; } if (player->GetSocial()->HasIgnore(GetPlayer()->GetGUIDLow())) { SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_TARGET_IGNORE_YOU); return; } Group* group = GetPlayer()->GetGroup(); if (group && group->isBGGroup()) group = GetPlayer()->GetOriginalGroup(); Group* group2 = player->GetGroup(); if (group2 && group2->isBGGroup()) group2 = player->GetOriginalGroup(); // player already in another group or invited if (group2 || player->GetGroupInvite()) { SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_ALREADY_IN_GROUP); return; } if (group) { // not have permissions for invite if (!group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID())) { SendPartyResult(PARTY_OP_INVITE, "", PARTY_RESULT_YOU_NOT_LEADER); return; } // not have place if (group->IsFull()) { SendPartyResult(PARTY_OP_INVITE, "", PARTY_RESULT_PARTY_FULL); return; } } // ok, but group not exist, start a new group // but don't create and save the group to the DB until // at least one person joins if (!group) { group = new Group; // new group: if can't add then delete if (!group->AddLeaderInvite(GetPlayer())) { delete group; return; } if (!group->AddInvite(player)) { delete group; return; } } else { // already existed group: if can't add then just leave if (!group->AddInvite(player)) { return; } } // ok, we do it WorldPacket data(SMSG_GROUP_INVITE, 10); // guess size data << GetPlayer()->GetName(); player->GetSession()->SendPacket(&data); SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_OK); }
void WorldSession::HandleGroupInviteOpcode(WorldPacket& recv_data) { ObjectGuid guid; recv_data.read_skip<uint32>(); // cross-realm party related recv_data.read_skip<uint32>(); // roles mask? recv_data.ReadGuidMask<2, 7>(guid); uint32 realmLength = recv_data.ReadBits(9); recv_data.ReadGuidMask<3>(guid); uint32 nameLength = recv_data.ReadBits(10); recv_data.ReadGuidMask<5, 4, 6, 0, 1>(guid); recv_data.ReadGuidBytes<4, 7, 6>(guid); std::string membername = recv_data.ReadString(nameLength); std::string realmname = recv_data.ReadString(realmLength); // attempt add selected player // cheating if (!normalizePlayerName(membername)) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_BAD_PLAYER_NAME_S); return; } Player* player = sObjectMgr.GetPlayer(membername.c_str()); // no player if (!player) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_BAD_PLAYER_NAME_S); return; } // can't group with if (!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_GROUP) && GetPlayer()->GetTeam() != player->GetTeam()) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_PLAYER_WRONG_FACTION); return; } if (GetPlayer()->GetInstanceId() != 0 && player->GetInstanceId() != 0 && GetPlayer()->GetInstanceId() != player->GetInstanceId() && GetPlayer()->GetMapId() == player->GetMapId()) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_TARGET_NOT_IN_INSTANCE_S); return; } // just ignore us if (player->GetSocial()->HasIgnore(GetPlayer()->GetObjectGuid())) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_IGNORING_YOU_S); return; } Group* group = GetPlayer()->GetGroup(); if (group && group->isBGGroup()) group = GetPlayer()->GetOriginalGroup(); if (group && group->isRaidGroup() && !player->GetAllowLowLevelRaid() && (player->getLevel() < sWorld.getConfig(CONFIG_UINT32_MIN_LEVEL_FOR_RAID))) { SendPartyResult(PARTY_OP_INVITE, "", ERR_RAID_DISALLOWED_BY_LEVEL); return; } // player already invited if (player->GetGroupInvite()) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_ALREADY_IN_GROUP_S); return; } Group* group2 = player->GetGroup(); if (group2 && group2->isBGGroup()) group2 = player->GetOriginalGroup(); // player already in another group if (group2) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_ALREADY_IN_GROUP_S); // tell the player that they were invited but it failed as they were already in a group player->GetSession()->SendGroupInvite(player, true); return; } if (group) { // not have permissions for invite if (!group->IsLeader(GetPlayer()->GetObjectGuid()) && !group->IsAssistant(GetPlayer()->GetObjectGuid())) { SendPartyResult(PARTY_OP_INVITE, "", ERR_NOT_LEADER); return; } // not have place if (group->IsFull()) { SendPartyResult(PARTY_OP_INVITE, "", ERR_GROUP_FULL); return; } } // ok, but group not exist, start a new group // but don't create and save the group to the DB until // at least one person joins if (!group) { group = new Group; // new group: if can't add then delete if (!group->AddLeaderInvite(GetPlayer())) { delete group; return; } if (!group->AddInvite(player)) { delete group; return; } } else { // already existing group: if can't add then just leave if (!group->AddInvite(player)) { return; } } player->GetSession()->SendGroupInvite(_player); SendPartyResult(PARTY_OP_INVITE, membername, ERR_PARTY_RESULT_OK); }
void WorldSession::HandleGroupInviteResponseOpcode(WorldPacket& recv_data) { bool unk = recv_data.ReadBit(); bool accepted = recv_data.ReadBit(); if (unk) recv_data.read_skip<uint32>(); Group* group = GetPlayer()->GetGroupInvite(); if (!group) return; if (accepted) { // remove in from invites in any case group->RemoveInvite(GetPlayer()); if (group->GetLeaderGuid() == GetPlayer()->GetObjectGuid()) { sLog.outError("HandleGroupInviteResponseOpcode: %s tried to accept an invite to his own group", GetPlayer()->GetGuidStr().c_str()); return; } /** error handling **/ /********************/ // not have place if (group->IsFull()) { SendPartyResult(PARTY_OP_INVITE, "", ERR_GROUP_FULL); return; } Player* leader = sObjectMgr.GetPlayer(group->GetLeaderGuid()); // forming a new group, create it if (!group->IsCreated()) { if (leader) group->RemoveInvite(leader); if (group->Create(group->GetLeaderGuid(), group->GetLeaderName())) sObjectMgr.AddGroup(group); else return; } // everything is fine, do it, PLAYER'S GROUP IS SET IN ADDMEMBER!!! if (!group->AddMember(GetPlayer()->GetObjectGuid(), GetPlayer()->GetName())) return; } else { // uninvite, group can be deleted GetPlayer()->UninviteFromGroup(); // remember leader if online Player* leader = sObjectMgr.GetPlayer(group->GetLeaderGuid()); if (!leader || !leader->GetSession()) return; // report WorldPacket data(SMSG_GROUP_DECLINE, 10); // guess size data << GetPlayer()->GetName(); leader->GetSession()->SendPacket(&data); } }
void LFGQueue::Update(uint32 diff) { if(m_QueuedGroups.empty() && m_QueuedPlayers.empty()) return; // Iterate over QueuedPlayersMap to update players timers and remove offline/disconnected players. for(QueuedPlayersMap::iterator qPlayer = m_QueuedPlayers.begin(); qPlayer != m_QueuedPlayers.end(); ++qPlayer) { Player* plr = sObjectMgr.GetPlayer(qPlayer->first); // Player could have been disconnected if(!plr ||!plr->IsInWorld()) { m_OfflinePlayers[qPlayer->first] = qPlayer->second; m_QueuedPlayers.erase(qPlayer); break; } qPlayer->second.timeInLFG += diff; // Update player timer and give him queue priority. if(qPlayer->second.timeInLFG >= (30 * MINUTE * IN_MILLISECONDS)) { qPlayer->second.hasQueuePriority = true; } } if(!m_QueuedGroups.empty()) { // Iterate over QueuedGroupsMap to fill groups with roles they're missing. for(QueuedGroupsMap::iterator qGroup = m_QueuedGroups.begin(); qGroup != m_QueuedGroups.end(); ++qGroup) { Group* grp = sObjectMgr.GetGroupById(qGroup->first); // Safe check if(!grp) return; // Remove group from Queue if it's full if(grp->IsFull()) { RemoveGroupFromQueue(qGroup->first, GROUP_SYSTEM_LEAVE); break; } // Iterate over QueuedPlayersMap to find suitable player to join group for(QueuedPlayersMap::iterator qPlayer = m_QueuedPlayers.begin(); qPlayer != m_QueuedPlayers.end(); ++qPlayer) { Player* plr = sObjectMgr.GetPlayer(qPlayer->first); // Check here that players team and areaId they're in queue are same if(qPlayer->second.team == qGroup->second.team && qPlayer->second.areaId == qGroup->second.areaId) { // Check if player can perform tank role if((canPerformRole(qPlayer->second.roleMask, LFG_ROLE_TANK) & qGroup->second.availableRoles) == LFG_ROLE_TANK) { if(FindRoleToGroup(plr, grp, LFG_ROLE_TANK)) { break; } else { continue; } } // Check if player can perform healer role if((canPerformRole(qPlayer->second.roleMask, LFG_ROLE_HEALER) & qGroup->second.availableRoles) == LFG_ROLE_HEALER) { if(FindRoleToGroup(plr, grp, LFG_ROLE_HEALER)) { break; } else { continue; } } // Check if player can perform dps role if((canPerformRole(qPlayer->second.roleMask, LFG_ROLE_DPS) & qGroup->second.availableRoles) == LFG_ROLE_DPS) { if(FindRoleToGroup(plr, grp, LFG_ROLE_DPS)) { break; } else { continue; } } // Check if group is full, no need to try to iterate same group if it's already full. if(grp->IsFull()) { RemoveGroupFromQueue(qGroup->first, GROUP_SYSTEM_LEAVE); break; } } } // Update group timer. After each 5 minutes group will be broadcasted they're still waiting more members. if (qGroup->second.groupTimer <= diff) { WorldPacket data; BuildInProgressPacket(data); grp->BroadcastPacket(&data, true); qGroup->second.groupTimer = 5 * MINUTE * IN_MILLISECONDS; } else { qGroup->second.groupTimer -= diff; } } } // Pick first 2 players and form group out of them also inserting them into queue as group. if(m_QueuedPlayers.size() > 5) { // Pick Leader as first target. QueuedPlayersMap::iterator nPlayer1 = m_QueuedPlayers.begin(); if(findInArea(nPlayer1->second.areaId) > 5) { Group* newQueueGroup = new Group; // Iterate of QueuedPlayersMap and pick first member to accompany leader. for(QueuedPlayersMap::iterator nPlayer2 = m_QueuedPlayers.begin(); nPlayer2 != m_QueuedPlayers.end(); ++nPlayer2) { if(nPlayer1->first == nPlayer2->first) continue; if(nPlayer1->second.team == nPlayer2->second.team && nPlayer1->second.areaId == nPlayer2->second.areaId) { Player* leader = sObjectMgr.GetPlayer(nPlayer1->first); Player* member = sObjectMgr.GetPlayer(nPlayer2->first); uint32 areaId = nPlayer1->second.areaId; if(!newQueueGroup->IsCreated()) { if(newQueueGroup->Create(leader->GetObjectGuid(), leader->GetName())) sObjectMgr.AddGroup(newQueueGroup); else return; } WorldPacket data; BuildMemberAddedPacket(data, member->GetGUID()); leader->GetSession()->SendPacket(&data); // Add member to the group. Leader is already added upon creation of group. newQueueGroup->AddMember(member->GetObjectGuid(), member->GetName(), GROUP_LFG); // Add this new group to GroupQueue now and remove players from PlayerQueue RemovePlayerFromQueue(nPlayer1->first, PLAYER_SYSTEM_LEAVE); RemovePlayerFromQueue(nPlayer2->first, PLAYER_SYSTEM_LEAVE); AddToQueue(leader, areaId); break; } } } } }
////////////////////////////////////////////////////////////// /// This function handles CMSG_GROUP_INVITE ////////////////////////////////////////////////////////////// void WorldSession::HandleGroupInviteOpcode( WorldPacket & recv_data ) { if(!_player->IsInWorld()) return; CHECK_PACKET_SIZE(recv_data, 1); WorldPacket data(100); std::string membername; Player * player = NULL; Group *group = NULL; recv_data >> membername; if(_player->HasBeenInvited())return; player = objmgr.GetPlayer(membername.c_str(), false); if ( player == NULL) { SendPartyCommandResult(_player, 0, membername, ERR_PARTY_CANNOT_FIND); return; } if (player == _player) { return; } if ( _player->InGroup() && !_player->IsGroupLeader() ) { SendPartyCommandResult(_player, 0, "", ERR_PARTY_YOU_ARE_NOT_LEADER); return; } group = _player->GetGroup(); if ( group != NULL ) { if (group->IsFull()) { SendPartyCommandResult(_player, 0, "", ERR_PARTY_IS_FULL); return; } } if ( player->InGroup() ) { SendPartyCommandResult(_player, player->GetGroup()->GetGroupType(), membername, ERR_PARTY_ALREADY_IN_GROUP); return; } if(player->GetTeam()!=_player->GetTeam() && _player->GetSession()->GetPermissionCount() == 0) { SendPartyCommandResult(_player, 0, membername, ERR_PARTY_WRONG_FACTION); return; } if ( player->HasBeenInvited() ) { SendPartyCommandResult(_player, 0, membername, ERR_PARTY_ALREADY_IN_GROUP); return; } if( player->Social_IsIgnoring( _player->GetLowGUID() ) ) { SendPartyCommandResult(_player, 0, membername, ERR_PARTY_IS_IGNORING_YOU); return; } // 16/08/06 - change to guid to prevent very unlikely event of a crash in deny, etc _player->SetInviter(_player->GetLowGUID());//bugfix if player invtied 2 people-> he can be in 2 parties data.SetOpcode(SMSG_GROUP_INVITE); data << GetPlayer()->GetName(); player->GetSession()->SendPacket(&data); uint32 gtype = 0; if(group) gtype = group->GetGroupType(); SendPartyCommandResult(_player, gtype, membername, ERR_PARTY_NO_ERROR); // 16/08/06 - change to guid to prevent very unlikely event of a crash in deny, etc player->SetInviter(_player->GetLowGUID()); }
void WorldSession::HandlePartyInviteResponseOpcode(WorldPackets::Party::PartyInviteResponse& packet) { Group* group = GetPlayer()->GetGroupInvite(); if (!group) return; if (packet.Accept) { // Remove player from invitees in any case group->RemoveInvite(GetPlayer()); if (group->GetLeaderGUID() == GetPlayer()->GetGUID()) { TC_LOG_ERROR("network", "HandleGroupAcceptOpcode: player %s (%s) tried to accept an invite to his own group", GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().ToString().c_str()); return; } // Group is full if (group->IsFull()) { SendPartyResult(PARTY_OP_INVITE, "", ERR_GROUP_FULL); return; } Player* leader = ObjectAccessor::FindPlayer(group->GetLeaderGUID()); // Forming a new group, create it if (!group->IsCreated()) { // This can happen if the leader is zoning. To be removed once delayed actions for zoning are implemented if (!leader) { group->RemoveAllInvites(); return; } // If we're about to create a group there really should be a leader present ASSERT(leader); group->RemoveInvite(leader); group->Create(leader); sGroupMgr->AddGroup(group); } // Everything is fine, do it, PLAYER'S GROUP IS SET IN ADDMEMBER!!! if (!group->AddMember(GetPlayer())) return; group->BroadcastGroupUpdate(); } else { // Remember leader if online (group pointer will be invalid if group gets disbanded) Player* leader = ObjectAccessor::FindConnectedPlayer(group->GetLeaderGUID()); // uninvite, group can be deleted GetPlayer()->UninviteFromGroup(); if (!leader || !leader->GetSession()) return; // report WorldPackets::Party::GroupDecline decline(GetPlayer()->GetName()); leader->GetSession()->SendPacket(decline.Write()); } }
////////////////////////////////////////////////////////////// /// This function handles CMSG_GROUP_INVITE ////////////////////////////////////////////////////////////// void WorldSession::HandleGroupInviteOpcode( WorldPacket & recv_data ) { if(!_player->IsInWorld()) { return; } CHECK_PACKET_SIZE(recv_data, 1); std::string membername; Player * player = NULL; Group *group = NULL; recv_data.read_skip( 10 ); //no idea, they were all 0 recv_data >> membername; //tried to make sure the other guy can't accept the invited /* if( _player->HasBeenInvited() ) { return; } */ player = objmgr.GetPlayer(membername.c_str(), false); if ( player == NULL) { SendPartyCommandResult(_player, 0, membername, ERR_PARTY_CANNOT_FIND); return; } if (player == _player) { return; } if ( _player->InGroup() && !_player->IsGroupLeader() ) { SendPartyCommandResult(_player, 0, "", ERR_PARTY_YOU_ARE_NOT_LEADER); return; } group = _player->GetGroup(); if( group != NULL ) { if(group->IsFull()) { SendPartyCommandResult(_player, 0, "", ERR_PARTY_IS_FULL); return; } } if ( player->InGroup() ) { SendPartyCommandResult(_player, player->GetGroup()->GetGroupType(), membername, ERR_PARTY_ALREADY_IN_GROUP); return; } if(player->GetTeam()!=_player->GetTeam() && _player->GetSession()->GetPermissionCount() == 0 && !sWorld.interfaction_group) { SendPartyCommandResult(_player, 0, membername, ERR_PARTY_WRONG_FACTION); return; } //tried to make sure the other guy can't accept the invited /* if ( player->HasBeenInvited() ) { SendPartyCommandResult(_player, 0, membername, ERR_PARTY_ALREADY_IN_GROUP); return; }*/ if( player->Social_IsIgnoring( _player->GetLowGUID() ) ) { SendPartyCommandResult(_player, 0, membername, ERR_PARTY_IS_IGNORING_YOU); return; } /* {SERVER} Packet: (0x1F7F) SMSG_GROUP_INVITE PacketSize = 16 TimeStamp = 30686468 01 55 64 72 65 61 00 AA 2A 00 00 00 00 00 00 00 14333 {SERVER} Packet: (0x4723) UNKNOWN PacketSize = 44 TimeStamp = 17757047 4E E0 1001110 11100000 6F 00 00 00 03 go3 00 00 00 00 00 00 00 00 4C go2 44 75 6E 65 6D 61 75 6C 00 Dunemaul 00 00 00 00 41 6E 61 72 6B 65 00 Anarke 00 1F 59 15 00 go7 AF go1 81 go6 EB go0 {SERVER} Packet: (0xFA67) SMSG_NAME_QUERY_RESPONSE PacketSize = 20 TimeStamp = 17676894 CF EA AE 4D 02 80 01 00 41 6E 61 72 6B 65 00 00 02 00 06 00 {SERVER} Packet: (0x4723) UNKNOWN PacketSize = 46 TimeStamp = 18686064 4E E0 6F 00 00 00 00 00 00 00 00 42 00 00 00 81 44 75 6E 65 6D 61 75 6C 00 00 00 00 00 44 72 61 69 73 69 75 73 00 00 69 E3 1F 00 B0 81 F7 11001111 {SERVER} Packet: (0xFA67) SMSG_NAME_QUERY_RESPONSE PacketSize = 22 TimeStamp = 18570343 CF F6 B1 80 01 80 01 00 44 72 61 69 73 69 75 73 00 00 0A 00 03 00 */ uint64 inviter_guid = _player->GetGUID(); uint8 *guid_bytes = (uint8*)&inviter_guid; uint16 guid_mask = 0; //!!not confirmed, but seems to work ! /* if( guid_bytes[0] ) guid_mask |= BIT_0; if( guid_bytes[1] ) guid_mask |= BIT_1; if( guid_bytes[2] ) guid_mask |= BIT_2; if( guid_bytes[3] ) guid_mask |= BIT_3;*/ guid_mask = 0xE04E; sStackWorldPacket( data,SMSG_GROUP_INVITE, 100); data << uint16(guid_mask);//guid mask data << uint32( 0 ); //? // if( guid_bytes[3] ) data << ObfuscateByte( guid_bytes[3] ); data << uint32( 0x00000000 ); data << uint32( 0x00000000 ); // if( guid_bytes[2] ) data << ObfuscateByte( guid_bytes[2] ); data << ""; //realm name data << uint32( 0x00000000 ); data << GetPlayer()->GetName(); data << uint32( 0 ); // if( guid_bytes[7] ) data << ObfuscateByte( guid_bytes[7] ); // if( guid_bytes[1] ) data << ObfuscateByte( guid_bytes[1] ); // if( guid_bytes[6] ) data << ObfuscateByte( guid_bytes[6] ); // if( guid_bytes[0] ) data << ObfuscateByte( guid_bytes[0] ); player->GetSession()->SendPacket(&data); uint32 gtype = 0; if(group) gtype = group->GetGroupType(); SendPartyCommandResult(_player, gtype, membername, ERR_PARTY_NO_ERROR); // 16/08/06 - change to guid to prevent very unlikely event of a crash in deny, etc player->SetInviter( _player->GetLowGUID() ); // 16/08/06 - change to guid to prevent very unlikely event of a crash in deny, etc _player->SetInviter( player->GetLowGUID() );//bugfix if player invtied 2 people-> he can be in 2 parties }
void WorldSession::HandleGroupInviteOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GROUP_INVITE"); std::string memberName; uint32 unk; // GroupType? recvData >> memberName; recvData >> unk; // in CMSG_GROUP_ACCEPT as well. // attempt add selected player // cheating if (!normalizePlayerName(memberName)) { SendPartyResult(PARTY_OP_INVITE, memberName, ERR_BAD_PLAYER_NAME_S); return; } Player* player = sObjectAccessor->FindPlayerByName(memberName.c_str()); // no player if (!player) { SendPartyResult(PARTY_OP_INVITE, memberName, ERR_BAD_PLAYER_NAME_S); return; } // restrict invite to GMs if (!sWorld->getBoolConfig(CONFIG_ALLOW_GM_GROUP) && !GetPlayer()->isGameMaster() && player->isGameMaster()) { SendPartyResult(PARTY_OP_INVITE, memberName, ERR_BAD_PLAYER_NAME_S); return; } // can't group with if (!GetPlayer()->isGameMaster() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP) && GetPlayer()->GetTeam() != player->GetTeam()) { SendPartyResult(PARTY_OP_INVITE, memberName, ERR_PLAYER_WRONG_FACTION); return; } if (GetPlayer()->GetInstanceId() != 0 && player->GetInstanceId() != 0 && GetPlayer()->GetInstanceId() != player->GetInstanceId() && GetPlayer()->GetMapId() == player->GetMapId()) { SendPartyResult(PARTY_OP_INVITE, memberName, ERR_TARGET_NOT_IN_INSTANCE_S); return; } // just ignore us if (player->GetInstanceId() != 0 && player->GetDungeonDifficulty() != GetPlayer()->GetDungeonDifficulty()) { SendPartyResult(PARTY_OP_INVITE, memberName, ERR_IGNORING_YOU_S); return; } if (player->GetSocial()->HasIgnore(GetPlayer()->GetGUIDLow())) { SendPartyResult(PARTY_OP_INVITE, memberName, ERR_IGNORING_YOU_S); return; } //uint64 invitedGuid = player->GetGUID(); Group* group = GetPlayer()->GetGroup(); if (group && group->isBGGroup()) group = GetPlayer()->GetOriginalGroup(); Group* group2 = player->GetGroup(); if (group2 && group2->isBGGroup()) group2 = player->GetOriginalGroup(); // player already in another group or invited if (group2 || player->GetGroupInvite()) { SendPartyResult(PARTY_OP_INVITE, memberName, ERR_ALREADY_IN_GROUP_S); if (group2) { // tell the player that they were invited but it failed as they were already in a group WorldPacket data(SMSG_GROUP_INVITE, 10); // guess size data << uint8(0); // invited/already in group flag data << GetPlayer()->GetName(); // max len 48 (Inviter name length) data << uint32(0); // Realm name? data << uint8(0); // count data << uint32(0); // unk player->GetSession()->SendPacket(&data); } return; } if (group) { // not have permissions for invite if (!group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID())) { SendPartyResult(PARTY_OP_INVITE, "", ERR_NOT_LEADER); return; } // not have place if (group->IsFull()) { SendPartyResult(PARTY_OP_INVITE, "", ERR_GROUP_FULL); return; } } // ok, but group not exist, start a new group // but don't create and save the group to the DB until // at least one person joins if (!group) { group = new Group; // new group: if can't add then delete if (!group->AddLeaderInvite(GetPlayer())) { delete group; return; } if (!group->AddInvite(player)) { delete group; return; } } else { // already existed group: if can't add then just leave if (!group->AddInvite(player)) { return; } } // ok, we do it WorldPacket data(SMSG_GROUP_INVITE, 10); // guess size data << uint8(1); // invited/already in group flag data << GetPlayer()->GetName(); // max len 48 (Inviter name length) data << uint32(0); // realmName? data << uint8(0); // count data << uint32(0); // unk player->GetSession()->SendPacket(&data); SendPartyResult(PARTY_OP_INVITE, memberName, ERR_PARTY_RESULT_OK); }
void WorldSession::LFGLoop() { QueryResult *result = WorldDatabase.Query("SELECT guid,zoneid,is_group FROM lfg_queue"); if (result) { do { Field* fields = result->Fetch(); //is this entry a group? if(fields[2].GetUInt32() == 1) { //is there anyone in the queue looking for a group for this groups instance? QueryResult *resultLFG = WorldDatabase.PQuery("SELECT guid,zoneid,is_group,player_name FROM lfg_queue WHERE zoneid = '%u' AND is_group = 0", fields[1].GetUInt32()); if (resultLFG) { do { Field* fieldsLFG = resultLFG->Fetch(); Player *plr = sObjectAccessor.FindPlayerByName(fieldsLFG[3].GetString()); Group *grp = sObjectMgr.GetGroupById(fields[0].GetUInt32()); if(!grp->IsFull()) { //check for roles if(GroupHasRole(ROLE_TANK, grp) && GroupHasRole(ROLE_HEALER, grp)) { //group has both dps & tank, add anyone. grp->AddMember(plr->GetGUID(), plr->GetName()); RemovePlayerFromQueue(plr->GetGUIDLow()); if(grp->IsFull()) { SendMeetingStoneCompleteToParty(grp); } } else if(GroupHasRole(ROLE_TANK, grp) && !GroupHasRole(ROLE_HEALER, grp)) { //tank but healers missing //is player healer? if(isPlayerHealer(plr)) { grp->AddMember(plr->GetGUID(), plr->GetName()); RemovePlayerFromQueue(plr->GetGUIDLow()); if(grp->IsFull()) { SendMeetingStoneCompleteToParty(grp); } } //player is not healer but group can take one more random.. else if(!isPlayerHealer(plr) && grp->GetMembersCount() < 4) { grp->AddMember(plr->GetGUID(), plr->GetName()); RemovePlayerFromQueue(plr->GetGUIDLow()); if(grp->IsFull()) { SendMeetingStoneCompleteToParty(grp); } } } else if(!GroupHasRole(ROLE_TANK, grp) && !GroupHasRole(ROLE_HEALER, grp)) { //group has neither tank or healer if(isPlayerHealer(plr) || isPlayerTank(plr)) { grp->AddMember(plr->GetGUID(), plr->GetName()); RemovePlayerFromQueue(plr->GetGUIDLow()); if(grp->IsFull()) { SendMeetingStoneCompleteToParty(grp); } } else { if(grp->GetMembersCount() < 3) { //theres room for 1 more random, let the player join. grp->AddMember(plr->GetGUID(), plr->GetName()); RemovePlayerFromQueue(plr->GetGUIDLow()); if(grp->IsFull()) { SendMeetingStoneCompleteToParty(grp); } } } } } } while (resultLFG->NextRow()); } } else { //its a player, is there any other non-grouped players thats looking for the same instance? QueryResult *result_mp = WorldDatabase.PQuery("SELECT guid,zoneid,is_group,player_name FROM lfg_queue WHERE zoneid = '%u' AND is_group = 0", fields[1].GetUInt32()); if(result_mp->GetRowCount() > 1) { int i = 1; Group* grp; grp = new Group; do { Field* fields_mp = result_mp->Fetch(); Player *plr = sObjectAccessor.FindPlayerByName(fields_mp[3].GetString()); if(!grp->IsCreated()) { if (grp->Create(plr->GetGUID(), plr->GetName())) { sObjectMgr.AddGroup(grp); RemovePlayerFromQueue(plr->GetGUIDLow()); } } else { grp->AddMember(plr->GetGUID(), plr->GetName()); RemovePlayerFromQueue(plr->GetGUIDLow()); } plr = NULL; } while (result_mp->NextRow()); //if this group did not fill up, add it into LFM queue if(!grp->IsFull()) { AddGroupToQueue(grp->GetId(), fields[1].GetUInt32()); } } } } while (result->NextRow()); } }
void WorldSession::HandleGroupInviteOpcode(WorldPacket& recvData) { TC_LOG_DEBUG("network", "WORLD: Received CMSG_GROUP_INVITE"); std::string membername; recvData >> membername; recvData.read_skip<uint32>(); // attempt add selected player // cheating if (!normalizePlayerName(membername)) { // If Fake WHO List system is on and the invited is fake, we return that he's already in a group if (sWorld->getBoolConfig(CONFIG_FAKE_WHO_LIST)) { QueryResult result = CharacterDatabase.PQuery("SELECT guid FROM characters WHERE name = '%s' AND online > 1", membername.c_str()); if (result) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_ALREADY_IN_GROUP_S); return; } } SendPartyResult(PARTY_OP_INVITE, membername, ERR_BAD_PLAYER_NAME_S); return; } Player* player = ObjectAccessor::FindPlayerByName(membername); // no player if (!player) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_BAD_PLAYER_NAME_S); return; } // restrict invite to GMs if (!sWorld->getBoolConfig(CONFIG_ALLOW_GM_GROUP) && !GetPlayer()->IsGameMaster() && player->IsGameMaster()) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_BAD_PLAYER_NAME_S); return; } // can't group with if (!GetPlayer()->IsGameMaster() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP) && GetPlayer()->GetTeam() != player->GetTeam()) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_PLAYER_WRONG_FACTION); return; } if (GetPlayer()->GetInstanceId() != 0 && player->GetInstanceId() != 0 && GetPlayer()->GetInstanceId() != player->GetInstanceId() && GetPlayer()->GetMapId() == player->GetMapId()) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_TARGET_NOT_IN_INSTANCE_S); return; } // just ignore us if (player->GetInstanceId() != 0 && player->GetDungeonDifficulty() != GetPlayer()->GetDungeonDifficulty()) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_IGNORING_YOU_S); return; } if (player->GetSocial()->HasIgnore(GetPlayer()->GetGUIDLow())) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_IGNORING_YOU_S); return; } Group* group = GetPlayer()->GetGroup(); if (group && group->isBGGroup()) group = GetPlayer()->GetOriginalGroup(); Group* group2 = player->GetGroup(); if (group2 && group2->isBGGroup()) group2 = player->GetOriginalGroup(); // player already in another group or invited if (group2 || player->GetGroupInvite()) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_ALREADY_IN_GROUP_S); if (group2) { // tell the player that they were invited but it failed as they were already in a group WorldPacket data(SMSG_GROUP_INVITE, 10); // guess size data << uint8(0); // invited/already in group flag data << GetPlayer()->GetName(); // max len 48 data << uint32(0); // unk data << uint8(0); // count data << uint32(0); // unk player->GetSession()->SendPacket(&data); } return; } if (group) { // not have permissions for invite if (!group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID())) { SendPartyResult(PARTY_OP_INVITE, "", ERR_NOT_LEADER); return; } // not have place if (group->IsFull()) { SendPartyResult(PARTY_OP_INVITE, "", ERR_GROUP_FULL); return; } } // ok, but group not exist, start a new group // but don't create and save the group to the DB until // at least one person joins if (!group) { group = new Group; // new group: if can't add then delete if (!group->AddLeaderInvite(GetPlayer())) { delete group; return; } if (!group->AddInvite(player)) { delete group; return; } } else { // already existed group: if can't add then just leave if (!group->AddInvite(player)) { return; } } // ok, we do it WorldPacket data(SMSG_GROUP_INVITE, 10); // guess size data << uint8(1); // invited/already in group flag data << GetPlayer()->GetName(); // max len 48 data << uint32(0); // unk data << uint8(0); // count data << uint32(0); // unk player->GetSession()->SendPacket(&data); SendPartyResult(PARTY_OP_INVITE, membername, ERR_PARTY_RESULT_OK); }
////////////////////////////////////////////////////////////// /// This function handles CMSG_GROUP_INVITE ////////////////////////////////////////////////////////////// void WorldSession::HandleGroupInviteOpcode( WorldPacket & recv_data ) { WorldPacket data; std::string membername; Group *group; Player * player; recv_data >> membername; player = objmgr.GetPlayer(membername.c_str()); if ( player == NULL ) { data.Initialize(SMSG_PARTY_COMMAND_RESULT); data << uint32( 0 ); data << membername; data << uint32( 0x00000001 ); SendPacket( &data ); return; } if ( GetPlayer()->IsInGroup() && (GetPlayer()->GetGroupLeader() != GetPlayer()->GetGUID() )) { data.Initialize(SMSG_PARTY_COMMAND_RESULT); data << uint32( 0 ); data << uint8( 0 ); data << uint32( 0x00000006 ); SendPacket( &data ); return; } group = objmgr.GetGroupByLeader( GetPlayer()->GetGroupLeader() ); if ( group != NULL ) { if (group->IsFull()) { data.Initialize(SMSG_PARTY_COMMAND_RESULT); data << uint32( 0 ); data << uint8( 0 ); data << uint32( 0x00000003 ); SendPacket( &data ); return; } } if ( player->IsInGroup() ) { data.Initialize(SMSG_PARTY_COMMAND_RESULT); data << uint32( 0x0 ); data << membername; data << uint32( 0x00000004 ); SendPacket( &data ); return; } if ( player->IsInvited() ) return; data.Initialize(SMSG_GROUP_INVITE); data << GetPlayer()->GetName(); player->GetSession()->SendPacket(&data); data.Initialize(SMSG_PARTY_COMMAND_RESULT); data << uint32( 0x0 ); data << membername; data << uint32( 0x00000000 ); SendPacket( &data ); player->SetLeader(GetPlayer()->GetGUID()); player->SetInvited(); }
void WorldSession::HandleGroupInviteOpcode(WorldPacket& recvData) { time_t now = time(NULL); if (now - timeLastGroupInviteCommand < 5) return; else timeLastGroupInviteCommand = now; ObjectGuid crossRealmGuid; // unused recvData.read_skip<uint32>(); // Non-zero in cross realm invites recvData.read_skip<uint32>(); // Always 0 recvData.read_skip<uint8>(); // Unknown std::string realmName, memberName; realmName = ""; memberName = ""; crossRealmGuid[5] = recvData.ReadBit(); uint8 nameLen = recvData.ReadBits(9); crossRealmGuid[2] = recvData.ReadBit(); crossRealmGuid[1] = recvData.ReadBit(); crossRealmGuid[7] = recvData.ReadBit(); crossRealmGuid[4] = recvData.ReadBit(); crossRealmGuid[3] = recvData.ReadBit(); uint8 realmLen = recvData.ReadBits(9); crossRealmGuid[0] = recvData.ReadBit(); crossRealmGuid[6] = recvData.ReadBit(); recvData.FlushBits(); recvData.ReadByteSeq(crossRealmGuid[0]); recvData.ReadByteSeq(crossRealmGuid[4]); realmName = recvData.ReadString(realmLen); recvData.ReadByteSeq(crossRealmGuid[5]); recvData.ReadByteSeq(crossRealmGuid[6]); memberName = recvData.ReadString(nameLen); recvData.ReadByteSeq(crossRealmGuid[1]); recvData.ReadByteSeq(crossRealmGuid[7]); recvData.ReadByteSeq(crossRealmGuid[3]); recvData.ReadByteSeq(crossRealmGuid[2]); // Attempt to add selected player. auto delimeter_pos = memberName.find("-"); if (delimeter_pos > 0) memberName = memberName.substr(0, delimeter_pos); // cheating if (!normalizePlayerName(memberName)) { SendPartyResult(PARTY_OP_INVITE, memberName, ERR_BAD_PLAYER_NAME_S); return; } Player* player = sObjectAccessor->FindPlayerByName(memberName.c_str()); // no player if (!player) { SendPartyResult(PARTY_OP_INVITE, memberName, ERR_BAD_PLAYER_NAME_S); return; } // restrict invite to GMs if (!sWorld->getBoolConfig(CONFIG_ALLOW_GM_GROUP) && !GetPlayer()->isGameMaster() && player->isGameMaster()) { SendPartyResult(PARTY_OP_INVITE, memberName, ERR_BAD_PLAYER_NAME_S); return; } // can't group with if (!GetPlayer()->isGameMaster() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP) && GetPlayer()->GetTeam() != player->GetTeam()) { SendPartyResult(PARTY_OP_INVITE, memberName, ERR_PLAYER_WRONG_FACTION); return; } if (GetPlayer()->GetInstanceId() != 0 && player->GetInstanceId() != 0 && GetPlayer()->GetInstanceId() != player->GetInstanceId() && GetPlayer()->GetMapId() == player->GetMapId()) { SendPartyResult(PARTY_OP_INVITE, memberName, ERR_TARGET_NOT_IN_INSTANCE_S); return; } // just ignore us if (player->GetInstanceId() != 0 && player->GetDungeonDifficulty() != GetPlayer()->GetDungeonDifficulty()) { SendPartyResult(PARTY_OP_INVITE, memberName, ERR_IGNORING_YOU_S); return; } if (player->GetSocial()->HasIgnore(GetPlayer()->GetGUIDLow())) { SendPartyResult(PARTY_OP_INVITE, memberName, ERR_IGNORING_YOU_S); return; } Group* group = GetPlayer()->GetGroup(); if (group && group->isBGGroup()) group = GetPlayer()->GetOriginalGroup(); Group* group2 = player->GetGroup(); if (group2 && group2->isBGGroup()) group2 = player->GetOriginalGroup(); // player already in another group or invited if (group2 || player->GetGroupInvite()) { SendPartyResult(PARTY_OP_INVITE, memberName, ERR_ALREADY_IN_GROUP_S); if (group2) player->GetSession()->SendGroupInviteNotification(GetPlayer()->GetName(), true); return; } if (group) { // not have permissions for invite if (!group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID()) && !(group->GetGroupType() & GROUPTYPE_EVERYONE_IS_ASSISTANT)) { SendPartyResult(PARTY_OP_INVITE, "", ERR_NOT_LEADER); return; } // not have place if (group->IsFull()) { SendPartyResult(PARTY_OP_INVITE, "", ERR_GROUP_FULL); return; } } // ok, but group not exist, start a new group // but don't create and save the group to the DB until // at least one person joins if (!group) { group = new Group; // new group: if can't add then delete if (!group->AddLeaderInvite(GetPlayer())) { delete group; return; } if (!group->AddInvite(player)) { delete group; return; } } else { // already existed group: if can't add then just leave if (!group->AddInvite(player)) { return; } } // ok, we do it player->GetSession()->SendGroupInviteNotification(GetPlayer()->GetName(), false); SendPartyResult(PARTY_OP_INVITE, memberName, ERR_PARTY_RESULT_OK); }
void WorldSession::HandleGroupInviteOpcode(WorldPacket& recv_data) { std::string membername; recv_data >> membername; // attempt add selected player // cheating if (!normalizePlayerName(membername)) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_BAD_PLAYER_NAME_S); return; } Player* player = sObjectMgr.GetPlayer(membername.c_str()); // no player if (!player) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_BAD_PLAYER_NAME_S); return; } // can't group with if (!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_GROUP) && GetPlayer()->GetTeam() != player->GetTeam()) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_PLAYER_WRONG_FACTION); return; } if (GetPlayer()->GetInstanceId() != 0 && player->GetInstanceId() != 0 && GetPlayer()->GetInstanceId() != player->GetInstanceId() && GetPlayer()->GetMapId() == player->GetMapId()) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_TARGET_NOT_IN_INSTANCE_S); return; } // just ignore us if (player->GetSocial()->HasIgnore(GetPlayer()->GetObjectGuid())) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_IGNORING_YOU_S); return; } Group* group = GetPlayer()->GetGroup(); if (group && group->isBGGroup()) group = GetPlayer()->GetOriginalGroup(); Group* group2 = player->GetGroup(); if (group2 && group2->isBGGroup()) group2 = player->GetOriginalGroup(); // player already in another group or invited if (group2 || player->GetGroupInvite()) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_ALREADY_IN_GROUP_S); return; } if (group) { // not have permissions for invite if (!group->IsLeader(GetPlayer()->GetObjectGuid()) && !group->IsAssistant(GetPlayer()->GetObjectGuid())) { SendPartyResult(PARTY_OP_INVITE, "", ERR_NOT_LEADER); return; } // not have place if (group->IsFull()) { SendPartyResult(PARTY_OP_INVITE, "", ERR_GROUP_FULL); return; } } // ok, but group not exist, start a new group // but don't create and save the group to the DB until // at least one person joins if (!group) { group = new Group; // new group: if can't add then delete if (!group->AddLeaderInvite(GetPlayer())) { delete group; return; } if (!group->AddInvite(player)) { delete group; return; } } else { // already existing group: if can't add then just leave if (!group->AddInvite(player)) { return; } } // ok, we do it WorldPacket data(SMSG_GROUP_INVITE, 10); // guess size data << GetPlayer()->GetName(); player->GetSession()->SendPacket(&data); SendPartyResult(PARTY_OP_INVITE, membername, ERR_PARTY_RESULT_OK); }
void WorldSession::HandleGroupInviteResponseOpcode(WorldPacket& recvData) { TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GROUP_INVITE_RESPONSE"); recvData.ReadBit(); // unk always 0 bool accept = recvData.ReadBit(); // Never actually received? /*if (accept) recvData.read_skip<uint32>(); // unk*/ Group* group = GetPlayer()->GetGroupInvite(); if (!group) return; if (accept) { // Remove player from invitees in any case group->RemoveInvite(GetPlayer()); if (group->GetLeaderGUID() == GetPlayer()->GetGUID()) { TC_LOG_ERROR(LOG_FILTER_NETWORKIO, "HandleGroupAcceptOpcode: player %s(%d) tried to accept an invite to his own group", GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow()); return; } // Group is full if (group->IsFull()) { SendPartyResult(PARTY_OP_INVITE, "", ERR_GROUP_FULL); return; } Player* leader = ObjectAccessor::FindPlayer(group->GetLeaderGUID()); // Forming a new group, create it if (!group->IsCreated()) { // This can happen if the leader is zoning. To be removed once delayed actions for zoning are implemented if (!leader) { group->RemoveAllInvites(); return; } // If we're about to create a group there really should be a leader present ASSERT(leader); group->RemoveInvite(leader); group->Create(leader); sGroupMgr->AddGroup(group); } // Everything is fine, do it, PLAYER'S GROUP IS SET IN ADDMEMBER!!! if (!group->AddMember(GetPlayer())) return; group->BroadcastGroupUpdate(); } else { // Remember leader if online (group pointer will be invalid if group gets disbanded) Player* leader = ObjectAccessor::FindPlayer(group->GetLeaderGUID()); // uninvite, group can be deleted GetPlayer()->UninviteFromGroup(); if (!leader || !leader->GetSession()) return; // report WorldPacket data(SMSG_GROUP_DECLINE, GetPlayer()->GetName().size()); data << GetPlayer()->GetName(); leader->GetSession()->SendPacket(&data); } }
void WorldSession::HandleGroupInviteOpcode( WorldPacket & recv_data ) { std::string membername; recv_data >> membername; // attempt add selected player // cheating if(membername.empty()) { SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_CANT_FIND_TARGET); return; } normalizePlayerName(membername); Player *player = objmgr.GetPlayer(membername.c_str()); // no player if(!player) { SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_CANT_FIND_TARGET); return; } // can't group with if(!sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP) && GetPlayer()->GetTeam() != player->GetTeam()) { SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_TARGET_UNFRIENDLY); return; } // just ignore us if(player->HasInIgnoreList(GetPlayer()->GetGUID())) { SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_TARGET_IGNORE_YOU); return; } // player already in another group or invited if(player->GetGroup() || player->GetGroupInvite() ) { SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_ALREADY_IN_GROUP); return; } Group *group = GetPlayer()->GetGroup(); if(group) { // not have permissions for invite if(!group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID())) { SendPartyResult(PARTY_OP_INVITE, "", PARTY_RESULT_YOU_NOT_LEADER); return; } // not have place if(group->IsFull()) { SendPartyResult(PARTY_OP_INVITE, "", PARTY_RESULT_PARTY_FULL); return; } } // ok, but group not exist, creating new if(!group) { group = new Group; if(!group->Create(GetPlayer()->GetGUID(), GetPlayer()->GetName())) { delete group; return; } objmgr.AddGroup(group); // new group: if can't add then delete if(!group->AddInvite(player)) { group->Disband(true); objmgr.RemoveGroup(group); delete group; return; } } else { // already existed group: if can't add then just leave if(!group->AddInvite(player)) { return; } } // ok, we do it WorldPacket data(SMSG_GROUP_INVITE, 10); // guess size data << GetPlayer()->GetName(); player->GetSession()->SendPacket(&data); SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_OK); }
void WorldSession::HandlePartyInviteOpcode(WorldPackets::Party::PartyInviteClient& packet) { Player* player = ObjectAccessor::FindPlayerByName(packet.TargetName); // no player if (!player) { SendPartyResult(PARTY_OP_INVITE, packet.TargetName, ERR_BAD_PLAYER_NAME_S); return; } // restrict invite to GMs if (!sWorld->getBoolConfig(CONFIG_ALLOW_GM_GROUP) && !GetPlayer()->IsGameMaster() && player->IsGameMaster()) { SendPartyResult(PARTY_OP_INVITE, player->GetName(), ERR_BAD_PLAYER_NAME_S); return; } // can't group with if (!GetPlayer()->IsGameMaster() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP) && GetPlayer()->GetTeam() != player->GetTeam()) { SendPartyResult(PARTY_OP_INVITE, player->GetName(), ERR_PLAYER_WRONG_FACTION); return; } if (GetPlayer()->GetInstanceId() != 0 && player->GetInstanceId() != 0 && GetPlayer()->GetInstanceId() != player->GetInstanceId() && GetPlayer()->GetMapId() == player->GetMapId()) { SendPartyResult(PARTY_OP_INVITE, player->GetName(), ERR_TARGET_NOT_IN_INSTANCE_S); return; } // just ignore us if (player->GetInstanceId() != 0 && player->GetDungeonDifficultyID() != GetPlayer()->GetDungeonDifficultyID()) { SendPartyResult(PARTY_OP_INVITE, player->GetName(), ERR_IGNORING_YOU_S); return; } if (player->GetSocial()->HasIgnore(GetPlayer()->GetGUID())) { SendPartyResult(PARTY_OP_INVITE, player->GetName(), ERR_IGNORING_YOU_S); return; } Group* group = GetPlayer()->GetGroup(); if (group && group->isBGGroup()) group = GetPlayer()->GetOriginalGroup(); Group* group2 = player->GetGroup(); if (group2 && group2->isBGGroup()) group2 = player->GetOriginalGroup(); // player already in another group or invited if (group2 || player->GetGroupInvite()) { SendPartyResult(PARTY_OP_INVITE, player->GetName(), ERR_ALREADY_IN_GROUP_S); if (group2) { // tell the player that they were invited but it failed as they were already in a group WorldPackets::Party::PartyInvite partyInvite; partyInvite.Initialize(GetPlayer(), packet.ProposedRoles, false); player->GetSession()->SendPacket(partyInvite.Write()); } return; } if (group) { // not have permissions for invite if (!group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID())) { SendPartyResult(PARTY_OP_INVITE, "", ERR_NOT_LEADER); return; } // not have place if (group->IsFull()) { SendPartyResult(PARTY_OP_INVITE, "", ERR_GROUP_FULL); return; } } // ok, but group not exist, start a new group // but don't create and save the group to the DB until // at least one person joins if (!group) { group = new Group; // new group: if can't add then delete if (!group->AddLeaderInvite(GetPlayer())) { delete group; return; } if (!group->AddInvite(player)) { delete group; return; } } else { // already existed group: if can't add then just leave if (!group->AddInvite(player)) { return; } } WorldPackets::Party::PartyInvite partyInvite; partyInvite.Initialize(GetPlayer(), packet.ProposedRoles, true); player->GetSession()->SendPacket(partyInvite.Write()); SendPartyResult(PARTY_OP_INVITE, player->GetName(), ERR_PARTY_RESULT_OK); }
void WorldSession::HandleGroupInviteOpcode( WorldPacket & recv_data ) { std::string membername; recv_data >> membername; recv_data.read_skip<uint32>(); // roles mask? // attempt add selected player // cheating if(!normalizePlayerName(membername)) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_BAD_PLAYER_NAME_S); return; } Player *player = sObjectMgr.GetPlayer(membername.c_str()); // no player if(!player) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_BAD_PLAYER_NAME_S); return; } // can't group with if(!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_GROUP) && GetPlayer()->GetTeam() != player->GetTeam()) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_PLAYER_WRONG_FACTION); return; } if(GetPlayer()->GetInstanceId() != 0 && player->GetInstanceId() != 0 && GetPlayer()->GetInstanceId() != player->GetInstanceId() && GetPlayer()->GetMapId() == player->GetMapId()) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_TARGET_NOT_IN_INSTANCE_S); return; } // just ignore us if(player->GetSocial()->HasIgnore(GetPlayer()->GetObjectGuid())) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_IGNORING_YOU_S); return; } Group *group = GetPlayer()->GetGroup(); if( group && group->isBGGroup() ) group = GetPlayer()->GetOriginalGroup(); if(group && group->isRaidGroup() && !player->GetAllowLowLevelRaid() && (player->getLevel() < sWorld.getConfig(CONFIG_UINT32_MIN_LEVEL_FOR_RAID))) { SendPartyResult(PARTY_OP_INVITE, "", ERR_RAID_DISALLOWED_BY_LEVEL); return; } Group *group2 = player->GetGroup(); if( group2 && group2->isBGGroup() ) group2 = player->GetOriginalGroup(); // player already in another group or invited if( group2 || player->GetGroupInvite() ) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_ALREADY_IN_GROUP_S); if (group2) { // tell the player that they were invited but it failed as they were already in a group WorldPacket data(SMSG_GROUP_INVITE, 10); // guess size data << uint8(0); // invited/already in group flag data << GetPlayer()->GetName(); // max len 48 data << uint32(0); // unk data << uint8(0); // count data << uint32(0); // unk player->GetSession()->SendPacket(&data); } return; } if(group) { // not have permissions for invite if (!group->IsLeader(GetPlayer()->GetObjectGuid()) && !group->IsAssistant(GetPlayer()->GetObjectGuid())) { SendPartyResult(PARTY_OP_INVITE, "", ERR_NOT_LEADER); return; } // not have place if(group->IsFull()) { SendPartyResult(PARTY_OP_INVITE, "", ERR_GROUP_FULL); return; } } // ok, but group not exist, start a new group // but don't create and save the group to the DB until // at least one person joins if(!group) { group = new Group; // new group: if can't add then delete if(!group->AddLeaderInvite(GetPlayer())) { delete group; return; } if(!group->AddInvite(player)) { delete group; return; } } else { // already existing group: if can't add then just leave if(!group->AddInvite(player)) { return; } } // ok, we do it WorldPacket data(SMSG_GROUP_INVITE, 10); // guess size data << uint8(1); // invited/already in group flag data << GetPlayer()->GetName(); // max len 48 data << uint32(0); // unk data << uint8(0); // count //for(int i = 0; i < count; ++i) // data << uint32(0); data << uint32(0); // unk player->GetSession()->SendPacket(&data); SendPartyResult(PARTY_OP_INVITE, membername, ERR_PARTY_RESULT_OK); }
////////////////////////////////////////////////////////////// /// This function handles CMSG_GROUP_INVITE ////////////////////////////////////////////////////////////// void WorldSession::HandleGroupInviteOpcode(WorldPacket & recv_data) { CHECK_INWORLD_RETURN; CHECK_PACKET_SIZE(recv_data, 1); WorldPacket data(100); std::string membername; Group* group = NULL; recv_data >> membername; if(_player->HasBeenInvited()) return; Player* player = objmgr.GetPlayer(membername.c_str(), false); if(player == NULL) { SendPartyCommandResult(_player, 0, membername, ERR_PARTY_CANNOT_FIND); return; } if(player == _player) { return; } if (player->GetMapId() == 750 || _player->GetMapId() == 750) return; if(_player->InGroup() && !_player->IsGroupLeader()) { SendPartyCommandResult(_player, 0, "", ERR_PARTY_YOU_ARE_NOT_LEADER); return; } group = _player->GetGroup(); if(group != NULL) { if(group->IsFull()) { SendPartyCommandResult(_player, 0, "", ERR_PARTY_IS_FULL); return; } } if(player->InGroup()) { SendPartyCommandResult(_player, player->GetGroup()->GetGroupType(), membername, ERR_PARTY_ALREADY_IN_GROUP); data.SetOpcode(SMSG_GROUP_INVITE); data << uint8(0); data << GetPlayer()->GetName(); player->GetSession()->SendPacket(&data); return; } if(player->GetTeam() != _player->GetTeam() && _player->GetSession()->GetPermissionCount() == 0 && !sWorld.interfaction_group) { SendPartyCommandResult(_player, 0, membername, ERR_PARTY_WRONG_FACTION); return; } if(player->HasBeenInvited()) { SendPartyCommandResult(_player, 0, membername, ERR_PARTY_ALREADY_IN_GROUP); return; } if(player->Social_IsIgnoring(_player->GetLowGUID())) { SendPartyCommandResult(_player, 0, membername, ERR_PARTY_IS_IGNORING_YOU); return; } if(player->HasFlag(PLAYER_FLAGS, PLAYER_FLAG_GM) && !_player->GetSession()->HasPermissions()) { SendPartyCommandResult(_player, 0, membername, ERR_PARTY_CANNOT_FIND); return; } data.SetOpcode(SMSG_GROUP_INVITE); data << uint8(1); data << GetPlayer()->GetName(); player->GetSession()->SendPacket(&data); SendPartyCommandResult(_player, 0, membername, ERR_PARTY_NO_ERROR); // 16/08/06 - change to guid to prevent very unlikely event of a crash in deny, etc player->SetInviter(_player->GetLowGUID()); }
void WorldSession::HandleGroupInviteOpcode(WorldPacket& recvData) { TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GROUP_INVITE"); ObjectGuid crossRealmGuid; // unused recvData.read_skip<uint32>(); // Non-zero in cross realm invites recvData.read_skip<uint32>(); // Always 0 crossRealmGuid[2] = recvData.ReadBit(); crossRealmGuid[7] = recvData.ReadBit(); uint8 realmLen = recvData.ReadBits(9); crossRealmGuid[3] = recvData.ReadBit(); uint8 nameLen = recvData.ReadBits(10); crossRealmGuid[5] = recvData.ReadBit(); crossRealmGuid[4] = recvData.ReadBit(); crossRealmGuid[6] = recvData.ReadBit(); crossRealmGuid[0] = recvData.ReadBit(); crossRealmGuid[1] = recvData.ReadBit(); recvData.ReadByteSeq(crossRealmGuid[4]); recvData.ReadByteSeq(crossRealmGuid[7]); recvData.ReadByteSeq(crossRealmGuid[6]); std::string memberName, realmName; memberName = recvData.ReadString(nameLen); realmName = recvData.ReadString(realmLen); // unused recvData.ReadByteSeq(crossRealmGuid[1]); recvData.ReadByteSeq(crossRealmGuid[0]); recvData.ReadByteSeq(crossRealmGuid[5]); recvData.ReadByteSeq(crossRealmGuid[3]); recvData.ReadByteSeq(crossRealmGuid[2]); // attempt add selected player // cheating if (!normalizePlayerName(memberName)) { SendPartyResult(PARTY_OP_INVITE, memberName, ERR_BAD_PLAYER_NAME_S); return; } Player* player = sObjectAccessor->FindPlayerByName(memberName); // no player if (!player) { SendPartyResult(PARTY_OP_INVITE, memberName, ERR_BAD_PLAYER_NAME_S); return; } // restrict invite to GMs if (!sWorld->getBoolConfig(CONFIG_ALLOW_GM_GROUP) && !GetPlayer()->IsGameMaster() && player->IsGameMaster()) { SendPartyResult(PARTY_OP_INVITE, memberName, ERR_BAD_PLAYER_NAME_S); return; } // can't group with if (!GetPlayer()->IsGameMaster() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP) && GetPlayer()->GetTeam() != player->GetTeam()) { SendPartyResult(PARTY_OP_INVITE, memberName, ERR_PLAYER_WRONG_FACTION); return; } if (GetPlayer()->GetInstanceId() != 0 && player->GetInstanceId() != 0 && GetPlayer()->GetInstanceId() != player->GetInstanceId() && GetPlayer()->GetMapId() == player->GetMapId()) { SendPartyResult(PARTY_OP_INVITE, memberName, ERR_TARGET_NOT_IN_INSTANCE_S); return; } // just ignore us if (player->GetInstanceId() != 0 && player->GetDungeonDifficulty() != GetPlayer()->GetDungeonDifficulty()) { SendPartyResult(PARTY_OP_INVITE, memberName, ERR_IGNORING_YOU_S); return; } if (player->GetSocial()->HasIgnore(GetPlayer()->GetGUIDLow())) { SendPartyResult(PARTY_OP_INVITE, memberName, ERR_IGNORING_YOU_S); return; } ObjectGuid invitedGuid = player->GetGUID(); Group* group = GetPlayer()->GetGroup(); if (group && group->isBGGroup()) group = GetPlayer()->GetOriginalGroup(); Group* group2 = player->GetGroup(); if (group2 && group2->isBGGroup()) group2 = player->GetOriginalGroup(); // player already in another group or invited if (group2 || player->GetGroupInvite()) { SendPartyResult(PARTY_OP_INVITE, memberName, ERR_ALREADY_IN_GROUP_S); if (group2) { // tell the player that they were invited but it failed as they were already in a group WorldPacket data(SMSG_GROUP_INVITE, 45); data.WriteBit(0); data.WriteBit(invitedGuid[0]); data.WriteBit(invitedGuid[3]); data.WriteBit(invitedGuid[2]); data.WriteBit(0); // Inverse already in group data.WriteBit(invitedGuid[6]); data.WriteBit(invitedGuid[5]); data.WriteBits(0, 9); // Realm name data.WriteBit(invitedGuid[4]); data.WriteBits(GetPlayer()->GetName().size(), 7); // Inviter name length data.WriteBits(0, 24); // Count 2 data.WriteBit(0); data.WriteBit(invitedGuid[1]); data.WriteBit(invitedGuid[7]); data.FlushBits(); data.WriteByteSeq(invitedGuid[1]); data.WriteByteSeq(invitedGuid[4]); data << int32(getMSTime()); data << int32(0); data << int32(0); data.WriteByteSeq(invitedGuid[6]); data.WriteByteSeq(invitedGuid[0]); data.WriteByteSeq(invitedGuid[2]); data.WriteByteSeq(invitedGuid[3]); // for count2 { int32(0) } data.WriteByteSeq(invitedGuid[5]); // data.append(realm name); data.WriteByteSeq(invitedGuid[7]); data.WriteString(GetPlayer()->GetName()); // inviter name data << int32(0); player->GetSession()->SendPacket(&data); } return; } if (group) { // not have permissions for invite if (!group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID())) { SendPartyResult(PARTY_OP_INVITE, "", ERR_NOT_LEADER); return; } // not have place if (group->IsFull()) { SendPartyResult(PARTY_OP_INVITE, "", ERR_GROUP_FULL); return; } } // ok, but group not exist, start a new group // but don't create and save the group to the DB until // at least one person joins if (!group) { group = new Group; // new group: if can't add then delete if (!group->AddLeaderInvite(GetPlayer())) { delete group; return; } if (!group->AddInvite(player)) { delete group; return; } } else { // already existed group: if can't add then just leave if (!group->AddInvite(player)) { return; } } // ok, we do it WorldPacket data(SMSG_GROUP_INVITE, 45); data.WriteBit(0); data.WriteBit(invitedGuid[0]); data.WriteBit(invitedGuid[3]); data.WriteBit(invitedGuid[2]); data.WriteBit(1); // Inverse already in group data.WriteBit(invitedGuid[6]); data.WriteBit(invitedGuid[5]); data.WriteBits(0, 9); // Realm name data.WriteBit(invitedGuid[4]); data.WriteBits(GetPlayer()->GetName().size(), 7); // Inviter name length data.WriteBits(0, 24); // Count 2 data.WriteBit(0); data.WriteBit(invitedGuid[1]); data.WriteBit(invitedGuid[7]); data.FlushBits(); data.WriteByteSeq(invitedGuid[1]); data.WriteByteSeq(invitedGuid[4]); data << int32(getMSTime()); data << int32(0); data << int32(0); data.WriteByteSeq(invitedGuid[6]); data.WriteByteSeq(invitedGuid[0]); data.WriteByteSeq(invitedGuid[2]); data.WriteByteSeq(invitedGuid[3]); // for count2 { int32(0) } data.WriteByteSeq(invitedGuid[5]); // data.append(realm name); data.WriteByteSeq(invitedGuid[7]); data.WriteString(GetPlayer()->GetName()); data << int32(0); player->GetSession()->SendPacket(&data); SendPartyResult(PARTY_OP_INVITE, memberName, ERR_PARTY_RESULT_OK); }
void WorldSession::HandleGroupInviteOpcode(WorldPacket& recvData) { TC_LOG_DEBUG("network", "WORLD: Received CMSG_GROUP_INVITE"); std::string membername; recvData >> membername; recvData.read_skip<uint32>(); // attempt add selected player // cheating if (!normalizePlayerName(membername)) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_BAD_PLAYER_NAME_S); return; } Player* invitingPlayer = GetPlayer(); Player* invitedPlayer = ObjectAccessor::FindPlayerByName(membername); // no player if (!invitedPlayer) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_BAD_PLAYER_NAME_S); return; } // player trying to invite himself (most likely cheating) if (invitedPlayer == invitingPlayer) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_BAD_PLAYER_NAME_S); return; } // restrict invite to GMs if (!sWorld->getBoolConfig(CONFIG_ALLOW_GM_GROUP) && !invitingPlayer->IsGameMaster() && invitedPlayer->IsGameMaster()) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_BAD_PLAYER_NAME_S); return; } // can't group with if (!invitingPlayer->IsGameMaster() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP) && invitingPlayer->GetTeam() != invitedPlayer->GetTeam()) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_PLAYER_WRONG_FACTION); return; } if (invitingPlayer->GetInstanceId() != 0 && invitedPlayer->GetInstanceId() != 0 && invitingPlayer->GetInstanceId() != invitedPlayer->GetInstanceId() && invitingPlayer->GetMapId() == invitedPlayer->GetMapId()) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_TARGET_NOT_IN_INSTANCE_S); return; } // just ignore us if (invitedPlayer->GetInstanceId() != 0 && invitedPlayer->GetDungeonDifficulty() != invitingPlayer->GetDungeonDifficulty()) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_IGNORING_YOU_S); return; } if (invitedPlayer->GetSocial()->HasIgnore(invitingPlayer->GetGUID())) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_IGNORING_YOU_S); return; } if (!invitedPlayer->GetSocial()->HasFriend(invitingPlayer->GetGUID()) && invitingPlayer->getLevel() < sWorld->getIntConfig(CONFIG_PARTY_LEVEL_REQ)) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_INVITE_RESTRICTED); return; } Group* group = invitingPlayer->GetGroup(); if (group && group->isBGGroup()) group = invitingPlayer->GetOriginalGroup(); if (!group) group = invitingPlayer->GetGroupInvite(); Group* group2 = invitedPlayer->GetGroup(); if (group2 && group2->isBGGroup()) group2 = invitedPlayer->GetOriginalGroup(); // player already in another group or invited if (group2 || invitedPlayer->GetGroupInvite()) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_ALREADY_IN_GROUP_S); if (group2) { // tell the player that they were invited but it failed as they were already in a group WorldPacket data(SMSG_GROUP_INVITE, 10); // guess size data << uint8(0); // invited/already in group flag data << invitingPlayer->GetName(); // max len 48 data << uint32(0); // unk data << uint8(0); // count data << uint32(0); // unk invitedPlayer->SendDirectMessage(&data); } return; } if (group) { // not have permissions for invite if (!group->IsLeader(invitingPlayer->GetGUID()) && !group->IsAssistant(invitingPlayer->GetGUID())) { if (group->IsCreated()) SendPartyResult(PARTY_OP_INVITE, "", ERR_NOT_LEADER); return; } // not have place if (group->IsFull()) { SendPartyResult(PARTY_OP_INVITE, "", ERR_GROUP_FULL); return; } } // ok, but group not exist, start a new group // but don't create and save the group to the DB until // at least one person joins if (!group) { group = new Group(); // new group: if can't add then delete if (!group->AddLeaderInvite(invitingPlayer)) { delete group; return; } if (!group->AddInvite(invitedPlayer)) { group->RemoveAllInvites(); delete group; return; } } else { // already existed group: if can't add then just leave if (!group->AddInvite(invitedPlayer)) { return; } } // ok, we do it WorldPacket data(SMSG_GROUP_INVITE, 10); // guess size data << uint8(1); // invited/already in group flag data << invitingPlayer->GetName(); // max len 48 data << uint32(0); // unk data << uint8(0); // count data << uint32(0); // unk invitedPlayer->SendDirectMessage(&data); SendPartyResult(PARTY_OP_INVITE, membername, ERR_PARTY_RESULT_OK); }