void WorldSession::HandleArenaTeamDisbandOpcode(WorldPacket & recv_data) { sLog.outDebug("CMSG_ARENA_TEAM_DISBAND"); CHECK_PACKET_SIZE(recv_data, 4); uint32 ArenaTeamId; // arena team id recv_data >> ArenaTeamId; if (GetPlayer()->InArena()) return; ArenaTeam *at = sObjectMgr.GetArenaTeamById(ArenaTeamId); if (!at) return; if (at->GetCaptain() != _player->GetGUID()) return; if (at->IsFighting()) return; at->Disband(this); delete at; }
void WorldSession::HandleArenaTeamRemoveOpcode(WorldPacket & recvData) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_ARENA_TEAM_REMOVE"); #endif 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 remove members 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; } // Captain cannot be removed if (arenaTeam->GetCaptain() == member->Guid) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_QUIT_S, "", "", ERR_ARENA_TEAM_LEADER_LEAVE_S); return; } // Player cannot be removed during fights if (arenaTeam->IsFighting()) return; arenaTeam->DelMember(member->Guid, true); // Broadcast event arenaTeam->BroadcastEvent(ERR_ARENA_TEAM_REMOVE_SSS, 0, 3, name, arenaTeam->GetName(), _player->GetName()); }
void WorldSession::HandleArenaTeamLeaveOpcode(WorldPacket & recvData) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_ARENA_TEAM_LEAVE"); #endif uint32 arenaTeamId; recvData >> arenaTeamId; ArenaTeam* arenaTeam = sArenaTeamMgr->GetArenaTeamById(arenaTeamId); if (!arenaTeam) return; // Disallow leave team while in arena if (arenaTeam->IsFighting()) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_QUIT_S, "", "", ERR_ARENA_TEAM_INTERNAL); return; } // Team captain can't leave the team if other members are still present if (_player->GetGUID() == arenaTeam->GetCaptain() && arenaTeam->GetMembersSize() > 1) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_QUIT_S, "", "", ERR_ARENA_TEAM_LEADER_LEAVE_S); return; } // If team consists only of the captain, disband the team if (_player->GetGUID() == arenaTeam->GetCaptain()) { arenaTeam->Disband(this); delete arenaTeam; return; } else arenaTeam->DelMember(_player->GetGUID(), true); // Broadcast event arenaTeam->BroadcastEvent(ERR_ARENA_TEAM_LEAVE_SS, _player->GetGUID(), 2, _player->GetName().c_str(), arenaTeam->GetName(), ""); // Inform player who left SendArenaTeamCommandResult(ERR_ARENA_TEAM_QUIT_S, arenaTeam->GetName(), "", 0); }
static bool HandleArenaDisbandCommand(ChatHandler* handler, char const* args) { if (!*args) return false; uint32 teamId = atoi((char*)args); if (!teamId) return false; ArenaTeam* arena = sArenaTeamMgr->GetArenaTeamById(teamId); if (!arena) { handler->PSendSysMessage(LANG_ARENA_ERROR_NOT_FOUND, teamId); handler->SetSentErrorMessage(true); return false; } if (arena->IsFighting()) { handler->SendSysMessage(LANG_ARENA_ERROR_COMBAT); handler->SetSentErrorMessage(true); return false; } std::string name = arena->GetName(); arena->Disband(); if (handler->GetSession()) TC_LOG_DEBUG("bg.arena", "GameMaster: %s [GUID: %u] disbanded arena team type: %u [Id: %u].", handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUID().GetCounter(), arena->GetType(), teamId); else TC_LOG_DEBUG("bg.arena", "Console: disbanded arena team type: %u [Id: %u].", arena->GetType(), teamId); delete(arena); handler->PSendSysMessage(LANG_ARENA_DISBAND, name.c_str(), teamId); return true; }
void WorldSession::HandleArenaTeamLeaveOpcode(WorldPacket& recv_data) { DEBUG_LOG("CMSG_ARENA_TEAM_LEAVE"); uint32 ArenaTeamId; // arena team id recv_data >> ArenaTeamId; ArenaTeam* at = sObjectMgr.GetArenaTeamById(ArenaTeamId); if (!at) return; if (_player->GetObjectGuid() == at->GetCaptainGuid() && at->GetMembersSize() > 1) { // check for correctness SendArenaTeamCommandResult(ERR_ARENA_TEAM_QUIT_S, "", "", ERR_ARENA_TEAM_LEADER_LEAVE_S); return; } // arena team has only one member (=captain) if (_player->GetObjectGuid() == at->GetCaptainGuid()) { at->Disband(this); delete at; return; } // Player cannot be removed during fights if (at->IsFighting()) return; at->DelMember(_player->GetObjectGuid()); // event at->BroadcastEvent(ERR_ARENA_TEAM_LEAVE_SS, _player->GetObjectGuid(), _player->GetName(), at->GetName().c_str()); // send you are no longer member of team SendArenaTeamCommandResult(ERR_ARENA_TEAM_QUIT_S, at->GetName(), "", 0); }
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; }
static bool HandleArenaRenameCommand(ChatHandler* handler, char const* _args) { if (!*_args) return false; char* args = (char *)_args; char const* oldArenaStr = handler->extractQuotedArg(args); if (!oldArenaStr) { handler->SendSysMessage(LANG_BAD_VALUE); handler->SetSentErrorMessage(true); return false; } char const* newArenaStr = handler->extractQuotedArg(strtok(NULL, "")); if (!newArenaStr) { handler->SendSysMessage(LANG_BAD_VALUE); handler->SetSentErrorMessage(true); return false; } ArenaTeam* arena = sArenaTeamMgr->GetArenaTeamByName(oldArenaStr); if (!arena) { handler->PSendSysMessage(LANG_AREAN_ERROR_NAME_NOT_FOUND, oldArenaStr); handler->SetSentErrorMessage(true); return false; } if (sArenaTeamMgr->GetArenaTeamByName(newArenaStr)) { handler->PSendSysMessage(LANG_ARENA_ERROR_NAME_EXISTS, oldArenaStr); handler->SetSentErrorMessage(true); return false; } if (arena->IsFighting()) { handler->SendSysMessage(LANG_ARENA_ERROR_COMBAT); handler->SetSentErrorMessage(true); return false; } if (!arena->SetName(newArenaStr)) { handler->SendSysMessage(LANG_BAD_VALUE); handler->SetSentErrorMessage(true); return false; } handler->PSendSysMessage(LANG_ARENA_RENAME, arena->GetId(), oldArenaStr, newArenaStr); if (handler->GetSession()) TC_LOG_DEBUG("bg.arena", "GameMaster: %s [GUID: %u] rename arena team \"%s\"[Id: %u] to \"%s\"", handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUID().GetCounter(), oldArenaStr, arena->GetId(), newArenaStr); else TC_LOG_DEBUG("bg.arena", "Console: rename arena team \"%s\"[Id: %u] to \"%s\"", oldArenaStr, arena->GetId(), newArenaStr); return true; }