void WorldSession::HandleArenaTeamInviteAcceptOpcode(WorldPacket & /*recv_data*/) { sLog.outDebug("CMSG_ARENA_TEAM_INVITE_ACCEPT"); // empty opcode ArenaTeam *at = sObjectMgr.GetArenaTeamById(_player->GetArenaTeamIdInvited()); if (!at) return; if (_player->GetArenaTeamIdFromDB(_player->GetGUIDLow(), at->GetType())) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S,"","",ERR_ALREADY_IN_ARENA_TEAM); // already in arena team that size return; } if (!sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && _player->GetTeam() != sObjectMgr.GetPlayerTeamByGUID(at->GetCaptain())) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S,"","",ERR_ARENA_TEAM_NOT_ALLIED);// not let enemies sign petition return; } if (!at->AddMember(_player->GetGUID())) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S,"","",ERR_ARENA_TEAM_INTERNAL);// arena team not found return; } // event WorldPacket data; BuildArenaTeamEventPacket(&data, ERR_ARENA_TEAM_JOIN_SS, 2, _player->GetName(), at->GetName(), ""); at->BroadcastPacket(&data); }
void WorldSession::HandleArenaTeamInviteOpcode(WorldPacket & recv_data) { sLog.outDebug("CMSG_ARENA_TEAM_INVITE"); uint32 ArenaTeamId; // arena team id std::string Invitedname; Player * player = NULL; recv_data >> ArenaTeamId >> Invitedname; if (!Invitedname.empty()) { if (!normalizePlayerName(Invitedname)) return; player = ObjectAccessor::Instance().FindPlayerByName(Invitedname.c_str()); } if (!player) SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", Invitedname, ERR_ARENA_TEAM_PLAYER_NOT_FOUND_S); if (player->getLevel() < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", player->GetName(), ERR_ARENA_TEAM_PLAYER_TO_LOW); ArenaTeam *arenateam = sObjectMgr.GetArenaTeamById(ArenaTeamId); if (!arenateam) SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", "", ERR_ARENA_TEAM_PLAYER_NOT_IN_TEAM); // OK result but not send invite if (player->GetSocial()->HasIgnore(GetPlayer()->GetGUIDLow())) if (!sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && player->GetTeam() != GetPlayer()->GetTeam()) SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", "", ERR_ARENA_TEAM_NOT_ALLIED); if (player->GetArenaTeamId(arenateam->GetSlot())) SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", player->GetName(), ERR_ALREADY_IN_ARENA_TEAM_S); if (player->GetArenaTeamIdInvited()) SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", player->GetName(), ERR_ALREADY_INVITED_TO_ARENA_TEAM_S); if (arenateam->GetMembersSize() >= arenateam->GetType() * 2) SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, arenateam->GetName(), "", ERR_ARENA_TEAM_FULL); return; sLog.outDebug("Player %s Invited %s to Join his ArenaTeam", GetPlayer()->GetName(), Invitedname.c_str()); player->SetArenaTeamIdInvited(arenateam->GetId()); WorldPacket data(SMSG_ARENA_TEAM_INVITE, (8+10)); data << GetPlayer()->GetName(); data << arenateam->GetName(); player->GetSession()->SendPacket(&data); sLog.outDebug("WORLD: Sent SMSG_ARENA_TEAM_INVITE"); }
void WorldSession::HandleArenaTeamInviteOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_ARENA_TEAM_INVITE"); uint32 arenaTeamId; // arena team id std::string invitedName; Player* player = NULL; recvData >> arenaTeamId >> invitedName; if (!invitedName.empty()) { if (!normalizePlayerName(invitedName)) return; player = sObjectAccessor->FindPlayerByName(invitedName.c_str()); } if (!player) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", invitedName, ERR_ARENA_TEAM_PLAYER_NOT_FOUND_S); return; } if (player->getLevel() < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", player->GetName(), ERR_ARENA_TEAM_TARGET_TOO_LOW_S); return; } ArenaTeam* arenaTeam = sArenaTeamMgr->GetArenaTeamById(arenaTeamId); if (!arenaTeam) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", "", ERR_ARENA_TEAM_PLAYER_NOT_IN_TEAM); return; } // OK result but don't send invite if (player->GetSocial()->HasIgnore(GetPlayer()->GetGUIDLow())) return; if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && player->GetTeam() != GetPlayer()->GetTeam()) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", "", ERR_ARENA_TEAM_NOT_ALLIED); return; } if (player->GetArenaTeamId(arenaTeam->GetSlot())) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", player->GetName(), ERR_ALREADY_IN_ARENA_TEAM_S); return; } if (player->GetArenaTeamIdInvited()) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", player->GetName(), ERR_ALREADY_INVITED_TO_ARENA_TEAM_S); return; } if (arenaTeam->GetMembersSize() >= arenaTeam->GetType() * 2) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, arenaTeam->GetName(), "", ERR_ARENA_TEAM_TOO_MANY_MEMBERS_S); return; } sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Player %s Invited %s to Join his ArenaTeam", GetPlayer()->GetName(), invitedName.c_str()); player->SetArenaTeamIdInvited(arenaTeam->GetId()); WorldPacket data(SMSG_ARENA_TEAM_INVITE, (8+10)); data << GetPlayer()->GetName(); data << arenaTeam->GetName(); player->GetSession()->SendPacket(&data); sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent SMSG_ARENA_TEAM_INVITE"); }
static bool HandleArenaCreateCommand(ChatHandler* handler, char const* args) { if (!*args) return false; Player* target; if (!handler->extractPlayerTarget(*args != '"' ? (char*)args : NULL, &target)) return false; char* tailStr = *args != '"' ? strtok(NULL, "") : (char*)args; if (!tailStr) return false; char* name = handler->extractQuotedArg(tailStr); if (!name) return false; char* typeStr = strtok(NULL, ""); if (!typeStr) return false; int8 type = atoi(typeStr); if (sArenaTeamMgr->GetArenaTeamByName(name)) { handler->PSendSysMessage(LANG_ARENA_ERROR_NAME_EXISTS, name); handler->SetSentErrorMessage(true); return false; } if (type == 2 || type == 3 || type == 5 ) { if (Player::GetArenaTeamIdFromDB(target->GetGUID(), type) != 0) { handler->PSendSysMessage(LANG_ARENA_ERROR_SIZE, target->GetName().c_str()); handler->SetSentErrorMessage(true); return false; } ArenaTeam* arena = new ArenaTeam(); if (!arena->Create(target->GetGUID(), type, name, 4293102085, 101, 4293253939, 4, 4284049911)) { delete arena; handler->SendSysMessage(LANG_BAD_VALUE); handler->SetSentErrorMessage(true); return false; } sArenaTeamMgr->AddArenaTeam(arena); handler->PSendSysMessage(LANG_ARENA_CREATE, arena->GetName().c_str(), arena->GetId(), arena->GetType(), arena->GetCaptain().GetCounter()); } else { handler->SendSysMessage(LANG_BAD_VALUE); handler->SetSentErrorMessage(true); return false; } return true; }
static bool HandleArenaLookupCommand(ChatHandler* handler, char const* args) { if (!*args) return false; std::string namepart = args; std::wstring wnamepart; if (!Utf8toWStr(namepart, wnamepart)) return false; wstrToLower(wnamepart); bool found = false; ArenaTeamMgr::ArenaTeamContainer::const_iterator i = sArenaTeamMgr->GetArenaTeamMapBegin(); for (; i != sArenaTeamMgr->GetArenaTeamMapEnd(); ++i) { ArenaTeam* arena = i->second; if (Utf8FitTo(arena->GetName(), wnamepart)) { if (handler->GetSession()) { handler->PSendSysMessage(LANG_ARENA_LOOKUP, arena->GetName().c_str(), arena->GetId(), arena->GetType(), arena->GetType()); found = true; continue; } } } if (!found) handler->PSendSysMessage(LANG_AREAN_ERROR_NAME_NOT_FOUND, namepart.c_str()); return true; }
static bool HandleArenaInfoCommand(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; } handler->PSendSysMessage(LANG_ARENA_INFO_HEADER, arena->GetName().c_str(), arena->GetId(), arena->GetRating(), arena->GetType(), arena->GetType()); for (ArenaTeam::MemberList::iterator itr = arena->m_membersBegin(); itr != arena->m_membersEnd(); ++itr) handler->PSendSysMessage(LANG_ARENA_INFO_MEMBERS, itr->Name.c_str(), itr->Guid.GetCounter(), itr->PersonalRating, (arena->GetCaptain() == itr->Guid ? "- Captain" : "")); return true; }
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::HandleArenaTeamAddMemberOpcode(WorldPacket & recv_data) { sLog.outDebug("CMSG_ARENA_TEAM_ADD_MEMBER"); //recv_data.hexlike(); CHECK_PACKET_SIZE(recv_data, 4+1); uint32 ArenaTeamId; // arena team id std::string Invitedname; Player * player = NULL; recv_data >> ArenaTeamId >> Invitedname; if(!Invitedname.empty()) { if(!normalizePlayerName(Invitedname)) return; player = ObjectAccessor::Instance().FindPlayerByName(Invitedname.c_str()); } if(!player) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", Invitedname, ERR_ARENA_TEAM_PLAYER_NOT_FOUND_S); return; } if(player->getLevel() < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) { //SendArenaTeamCommandResult(ARENA_TEAM_INVITE_SS,"",Invitedname,ARENA_TEAM_PLAYER_NOT_FOUND_S); // can't find related opcode SendNotification(LANG_HIS_ARENA_LEVEL_REQ_ERROR, player->GetName()); return; } ArenaTeam *arenateam = objmgr.GetArenaTeamById(ArenaTeamId); if(!arenateam) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", "", ERR_ARENA_TEAM_PLAYER_NOT_IN_TEAM); return; } // OK result but not send invite if(player->GetSocial()->HasIgnore(GetPlayer()->GetGUIDLow())) return; if (!sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && player->GetTeam() != GetPlayer()->GetTeam()) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", "", ERR_ARENA_TEAM_NOT_ALLIED); return; } if(player->GetArenaTeamId(arenateam->GetSlot())) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, player->GetName(), "", ERR_ALREADY_IN_ARENA_TEAM_S); return; } if(player->GetArenaTeamIdInvited()) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, player->GetName(), "", ERR_ALREADY_INVITED_TO_ARENA_TEAM_S); return; } if(arenateam->GetMembersSize() >= arenateam->GetType() * 2) { // should send an "arena team is full" or the likes message, I just don't know the proper values so... ERR_INTERNAL // SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", "", ERR_ARENA_TEAM_INTERNAL); SendNotification(LANG_YOUR_ARENA_TEAM_FULL, player->GetName()); return; } sLog.outDebug("Player %s Invited %s to Join his ArenaTeam", GetPlayer()->GetName(), Invitedname.c_str()); player->SetArenaTeamIdInvited(arenateam->GetId()); WorldPacket data(SMSG_ARENA_TEAM_INVITE, (8+10)); data << GetPlayer()->GetName(); data << arenateam->GetName(); player->GetSession()->SendPacket(&data); sLog.outDebug("WORLD: Sent SMSG_ARENA_TEAM_INVITE"); }