void WorldSession::HandleArenaTeamLeaderOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_ARENA_TEAM_LEADER"); uint32 arenaTeamId; std::string name; recvData >> arenaTeamId; recvData >> name; // Check for valid arena team ArenaTeam* arenaTeam = sArenaTeamMgr->GetArenaTeamById(arenaTeamId); if (!arenaTeam) return; // Only captain can pass leadership if (arenaTeam->GetCaptain() != _player->GetGUID()) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", "", ERR_ARENA_TEAM_PERMISSIONS); return; } if (!normalizePlayerName(name)) return; // Check if team member exists ArenaTeamMember* member = arenaTeam->GetMember(name); if (!member) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", name, ERR_ARENA_TEAM_PLAYER_NOT_FOUND_S); return; } // Check if the target is already team captain if (arenaTeam->GetCaptain() == member->Guid) return; arenaTeam->SetCaptain(member->Guid); // Broadcast event arenaTeam->BroadcastEvent(ERR_ARENA_TEAM_LEADER_CHANGED_SSS, 0, 3, _player->GetName(), name, arenaTeam->GetName()); }
void WorldSession::HandleArenaTeamPromoteToCaptainOpcode(WorldPacket & recv_data) { sLog.outDebug("CMSG_ARENA_TEAM_PROMOTE_TO_CAPTAIN"); CHECK_PACKET_SIZE(recv_data, 4+1); uint32 ArenaTeamId; std::string name; recv_data >> ArenaTeamId; recv_data >> name; ArenaTeam *at = objmgr.GetArenaTeamById(ArenaTeamId); if(!at) // arena team not found return; if(at->GetCaptain() != _player->GetGUID()) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", "", ERR_ARENA_TEAM_PERMISSIONS); return; } if(!normalizePlayerName(name)) return; ArenaTeamMember* member = at->GetMember(name); if(!member) // member not found { SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", name, ERR_ARENA_TEAM_PLAYER_NOT_FOUND_S); return; } if(at->GetCaptain() == member->guid) // target player already captain return; at->SetCaptain(member->guid); // event WorldPacket data; BuildArenaTeamEventPacket(&data, ERR_ARENA_TEAM_LEADER_CHANGED_SSS, 3, _player->GetName(), name, at->GetName()); at->BroadcastPacket(&data); }
void WorldSession::HandleArenaTeamLeaderOpcode(WorldPacket & recv_data) { DEBUG_LOG("CMSG_ARENA_TEAM_LEADER"); uint32 ArenaTeamId; std::string name; recv_data >> ArenaTeamId; recv_data >> name; ArenaTeam *at = sObjectMgr.GetArenaTeamById(ArenaTeamId); if (!at) // arena team not found return; if (at->GetCaptainGuid() != _player->GetObjectGuid()) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", "", ERR_ARENA_TEAM_PERMISSIONS); return; } if (!normalizePlayerName(name)) return; ArenaTeamMember* member = at->GetMember(name); if (!member) // member not found { SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", name, ERR_ARENA_TEAM_PLAYER_NOT_FOUND_S); return; } if (at->GetCaptainGuid() == member->guid) // target player already captain return; at->SetCaptain(member->guid); // event at->BroadcastEvent(ERR_ARENA_TEAM_LEADER_CHANGED_SSS, _player->GetName(), name.c_str(), at->GetName().c_str()); }
static bool HandleArenaCaptainCommand(ChatHandler* handler, char const* args) { if (!*args) return false; char* idStr; char* nameStr; handler->extractOptFirstArg((char*)args, &idStr, &nameStr); if (!idStr) return false; uint32 teamId = atoi(idStr); if (!teamId) return false; Player* target; ObjectGuid targetGuid; if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid)) return false; ArenaTeam* arena = sArenaTeamMgr->GetArenaTeamById(teamId); if (!arena) { handler->PSendSysMessage(LANG_ARENA_ERROR_NOT_FOUND, teamId); handler->SetSentErrorMessage(true); return false; } if (!target) { handler->PSendSysMessage(LANG_PLAYER_NOT_EXIST_OR_OFFLINE, nameStr); handler->SetSentErrorMessage(true); return false; } if (arena->IsFighting()) { handler->SendSysMessage(LANG_ARENA_ERROR_COMBAT); handler->SetSentErrorMessage(true); return false; } if (!arena->IsMember(targetGuid)) { handler->PSendSysMessage(LANG_ARENA_ERROR_NOT_MEMBER, nameStr, arena->GetName().c_str()); handler->SetSentErrorMessage(true); return false; } if (arena->GetCaptain() == targetGuid) { handler->PSendSysMessage(LANG_ARENA_ERROR_CAPTAIN, nameStr, arena->GetName().c_str()); handler->SetSentErrorMessage(true); return false; } arena->SetCaptain(targetGuid); CharacterNameData const* oldCaptainNameData = sWorld->GetCharacterNameData(arena->GetCaptain()); if (!oldCaptainNameData) { handler->SetSentErrorMessage(true); return false; } handler->PSendSysMessage(LANG_ARENA_CAPTAIN, arena->GetName().c_str(), arena->GetId(), oldCaptainNameData->m_name.c_str(), target->GetName().c_str()); if (handler->GetSession()) TC_LOG_DEBUG("bg.arena", "GameMaster: %s [GUID: %u] promoted player: %s [GUID: %u] to leader of arena team \"%s\"[Id: %u]", handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUID().GetCounter(), target->GetName().c_str(), target->GetGUID().GetCounter(), arena->GetName().c_str(), arena->GetId()); else TC_LOG_DEBUG("bg.arena", "Console: promoted player: %s [GUID: %u] to leader of arena team \"%s\"[Id: %u]", target->GetName().c_str(), target->GetGUID().GetCounter(), arena->GetName().c_str(), arena->GetId()); return true; }