void CBattleground::OnPlayerPushed(Player * plr) { if( plr->GetGroup() && !Rated() ) plr->GetGroup()->RemovePlayer(plr->m_playerInfo); plr->ProcessPendingUpdates(&plr->GetMapMgr()->m_updateBuildBuffer, &plr->GetMapMgr()->m_compressionBuffer); if( plr->GetGroup() == NULL && !plr->m_isGmInvisible ) m_groups[plr->m_bgTeam]->AddMember( plr->m_playerInfo ); }
void CBattleground::OnPlayerPushed(Player * plr) { if( plr->GetGroup() && !Rated() ) plr->GetGroup()->RemovePlayer(plr->m_playerInfo); plr->ProcessPendingUpdates(); if( plr->GetGroup() == NULL ) { if ( plr->m_isGmInvisible == false ) //do not join invisible gm's into bg groups. m_groups[plr->m_bgTeam]->AddMember( plr->m_playerInfo ); } }
void Arena::OnAddPlayer(PlayerPointer plr) { plr->m_deathVision = true; if( plr->m_isGmInvisible ) return; // remove all buffs (exclude talents, include flasks) for(uint32 x=0;x<MAX_AURAS;x++) { if(plr->m_auras[x]) { if(plr->m_auras[x] && !plr->m_auras[x]->GetSpellProto()->DurationIndex && plr->m_auras[x]->GetSpellProto()->Flags4 & CAN_PERSIST_AND_CASTED_WHILE_DEAD) continue; else { plr->m_auras[x]->Remove(); } } } plr->GetItemInterface()->RemoveAllConjured(); plr->ResetAllCooldowns(); if( !m_started ) plr->CastSpell(plr, ARENA_PREPARATION, true); m_playersCount[plr->GetTeam()]++; UpdatePlayerCounts(); /* Add the green/gold team flag */ AuraPointer aura(new Aura(dbcSpell.LookupEntry(32724+plr->m_bgTeam), -1, plr, plr)); plr->AddAura(aura); /* Set FFA PvP Flag */ plr->SetFFAPvPFlag(); hashmap_put(m_playersAlive, plr->GetLowGUID(), (any_t)1); if(Rated()) { // Store the players who join so that we can change their rating even if they leave before arena finishes hashmap_put(m_players2[plr->GetTeam()], plr->GetLowGUID(), (any_t)1); if(m_teams[plr->GetTeam()] == -1 && plr->m_playerInfo && plr->m_playerInfo->arenaTeam[m_arenateamtype] != NULL) { m_teams[plr->GetTeam()] = plr->m_playerInfo->arenaTeam[m_arenateamtype]->m_id; } } }
void Arena::OnAddPlayer(Player* plr) { plr->m_deathVision = true; if( plr->m_isGmInvisible ) return; // remove all buffs (exclude talents, include flasks) plr->m_AuraInterface.RemoveAllExpiringAuras(); plr->GetItemInterface()->RemoveAllConjured(); plr->ResetAllCooldowns(); if( !m_started ) plr->CastSpell(plr, ARENA_PREPARATION, true); m_playersCount[plr->GetTeam()]++; UpdatePlayerCounts(); /* Add the green/gold team flag */ Aura* aura(new Aura(dbcSpell.LookupEntry(32724+plr->m_bgTeam), -1, plr, plr)); plr->AddAura(aura); /* Set FFA PvP Flag */ plr->SetFFAPvPFlag(); m_playersAlive.insert(plr->GetLowGUID()); if(Rated()) { // Store the players who join so that we can change their rating even if they leave before arena finishes m_players2[plr->GetTeam()].insert(plr->GetLowGUID()); if(m_teams[plr->GetTeam()] == -1 && plr->m_playerInfo && plr->m_playerInfo->arenaTeam[m_arenateamtype] != NULL) { m_teams[plr->GetTeam()] = plr->m_playerInfo->arenaTeam[m_arenateamtype]->m_id; } } }
void CBattleground::PortPlayer(Player * plr, bool skip_teleport /* = false*/) { m_mainLock.Acquire(); if(m_ended) { sChatHandler.SystemMessage(plr->GetSession(), "You cannot join this battleground as it has already ended."); BattlegroundManager.SendBattlefieldStatus(plr, 0, 0, 0, 0, 0,0); plr->m_pendingBattleground = 0; m_mainLock.Release(); return; } if( plr->m_bgTeam > 1 ) plr->m_bgTeam = plr->GetTeam(); m_pendPlayers[plr->m_bgTeam].erase(plr->GetLowGUID()); if(m_players[plr->m_bgTeam].find(plr->GetLowGUID()) != m_players[plr->m_bgTeam].end()) { m_mainLock.Release(); return; } if ( plr->m_isGmInvisible == false ) { //Do not let everyone know an invisible gm has joined. WorldPacket data(SMSG_BATTLEGROUND_PLAYER_JOINED, 8); data << plr->GetGUID(); DistributePacketToAll(&data); } m_players[plr->m_bgTeam].insert(plr->GetLowGUID()); /* remove from any auto queue remove events */ sEventMgr.RemoveEvents(plr, EVENT_BATTLEGROUND_QUEUE_UPDATE); if( !skip_teleport ) { if( plr->IsInWorld() ) plr->RemoveFromWorld(); } plr->m_pendingBattleground = 0; plr->m_bg = this; if(!plr->IsPvPFlagged()) plr->SetPvPFlag(); /* Reset the score */ memset(&plr->m_bgScore, 0, sizeof(BGScore)); /* send him the world states */ SendWorldStates(plr); /* update pvp data */ UpdatePvPData(); /* add the player to the group */ if(plr->GetGroup() && !Rated()) { // remove them from their group plr->GetGroup()->RemovePlayer( plr->m_playerInfo ); } if(!m_countdownStage) { m_countdownStage = 1; sEventMgr.AddEvent(this, &CBattleground::EventCountdown, EVENT_BATTLEGROUND_COUNTDOWN, 30000, 0,0); sEventMgr.ModifyEventTimeLeft(this, EVENT_BATTLEGROUND_COUNTDOWN, 10000); } sEventMgr.RemoveEvents(this, EVENT_BATTLEGROUND_CLOSE); OnAddPlayer(plr); if(!skip_teleport) { /* This is where we actually teleport the player to the battleground. */ plr->SafeTeleport(m_mapMgr,GetStartingCoords(plr->m_bgTeam)); BattlegroundManager.SendBattlefieldStatus(plr, 3, m_type, m_id, (uint32)UNIXTIME - m_startTime, m_mapMgr->GetMapId(),Rated()); // Elapsed time is the last argument } m_mainLock.Release(); }
void CBattleground::AddPlayer(Player * plr, uint32 team) { m_mainLock.Acquire(); plr->m_bgTeam = team; /* This is called when the player is added, not when they port. So, they're essentially still queued, but not inside the bg yet */ m_pendPlayers[team].insert(plr->GetLowGUID()); /* Send a packet telling them that they can enter */ BattlegroundManager.SendBattlefieldStatus(plr, 2, m_type, m_id, 120000, m_mapMgr->GetMapId(),Rated()); // You will be removed from the queue in 2 minutes. /* Add an event to remove them in 2 minutes time. */ sEventMgr.AddEvent(plr, &Player::RemoveFromBattlegroundQueue, EVENT_BATTLEGROUND_QUEUE_UPDATE, 120000, 1,0); plr->m_pendingBattleground = this; m_mainLock.Release(); }
void CBattleground::BuildPvPUpdateDataPacket(WorldPacket * data) { data->Initialize(MSG_PVP_LOG_DATA); data->reserve(10*(m_players[0].size()+m_players[1].size())+50); BGScore * bs; if(m_type >= BATTLEGROUND_ARENA_2V2 && m_type <= BATTLEGROUND_ARENA_5V5) { if(!m_ended) { return; } *data << uint8(1); if(!Rated()) { *data << uint32(0x61272A5C); *data << uint8(0); *data << uint32(m_players[0].size() + m_players[1].size()); *data << uint8(0); } else { /* Grab some arena teams */ ArenaTeam * teams[2] = {NULL,NULL}; for(uint32 i = 0; i < 2; ++i) { for(set<uint32>::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr) { Player *plr = objmgr.GetPlayer(*itr); if( plr != NULL ) { teams[i] = plr->m_arenaTeams[ ((Arena*)this)->GetArenaTeamType() ]; if( teams[i] != NULL ) break; } } } if(teams[0]) { *data << uint32(teams[0]->m_id); *data << uint32(0); *data << teams[0]->m_name; } else { *data << uint32(0x61272A5C); *data << uint32(0); *data << uint8(0); } if(teams[1]) { *data << uint32(teams[1]->m_id); *data << uint32(0); *data << teams[1]->m_name; } else { *data << uint32(m_players[0].size() + m_players[1].size()); *data << uint32(0); *data << uint8(0); } } *data << uint8(1); *data << uint8(m_winningteam); *data << uint32(m_players[0].size() + m_players[1].size()); for(uint32 i = 0; i < 2; ++i) { for(set<uint32>::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr) { Player *plr = objmgr.GetPlayer(*itr); if( plr != NULL ) { *data << plr->GetGUID(); bs = &plr->m_bgScore; *data << bs->KillingBlows; // would this be correct? if( Rated() ) { *data << uint8(plr->m_bgTeam); } else { *data << uint32(0); // w *data << uint32(0); // t *data << uint32(0); // f } *data << uint32(1); // count of values after this *data << uint32(bs->Misc1); // rating change } } } } else { *data << uint8(0); if(m_ended) { *data << uint8(1); *data << uint8(m_winningteam); } else *data << uint8(0); // If the game has ended - this will be 1 *data << uint32(m_players[0].size() + m_players[1].size()); for(uint32 i = 0; i < 2; ++i) { for(set<uint32>::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr) { Player *plr = objmgr.GetPlayer(*itr); if( plr != NULL ) { *data << plr->GetGUID(); bs = &plr->m_bgScore; *data << bs->KillingBlows; *data << bs->HonorableKills; *data << bs->Deaths; *data << bs->BonusHonor; *data << bs->DamageDone; *data << bs->HealingDone; *data << uint32(0x2); *data << bs->Misc1; *data << bs->Misc2; } } } } }
void CBattleground::BuildPvPUpdateDataPacket(WorldPacket * data) { data->Initialize(MSG_PVP_LOG_DATA); data->reserve(10*(m_players[0].size()+m_players[1].size())+50); BGScore * bs; if(m_type >= BATTLEGROUND_ARENA_2V2 && m_type <= BATTLEGROUND_ARENA_5V5) { if(!m_ended) { return; } // Is arena? *data << uint8(1); if(!Rated()) { *data << uint32(3000+1+1); *data << uint32(0); *data << uint8(0); *data << uint32(3000+1+1); *data << uint32(0); *data << uint8(0); } else { /* Grab some arena teams */ ArenaTeam * teams[2] = {NULL,NULL}; for(uint32 i = 0; i < 2; ++i) { for(set<Player*>::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr) { teams[i] = (*itr)->m_playerInfo->arenaTeam[ ((Arena*)this)->GetArenaTeamType() ]; if(teams[i]) break; } } // team id, rating?, name if(teams[0]) { *data << uint32(teams[0]->m_id); *data << uint32(0); *data << teams[0]->m_name; } else { *data << uint32(0); *data << uint32(0); *data << uint8(0); } if(teams[1]) { *data << uint32(teams[1]->m_id); *data << uint32(0); *data << teams[1]->m_name; } else { *data << uint32(0); *data << uint32(0); *data << uint8(0); } } *data << uint8(1); *data << uint8(m_losingteam); *data << uint32(m_players[0].size() + m_players[1].size()); for(uint32 i = 0; i < 2; ++i) { for(set<Player*>::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr) { *data << (*itr)->GetGUID(); bs = &(*itr)->m_bgScore; *data << bs->KillingBlows; *data << uint8((*itr)->m_bgTeam); *data << bs->DamageDone; *data << bs->HealingDone; *data << uint32(1); // count of values after this *data << uint32(0); // rating change // NOT RLY! LOL! } } } else { *data << uint8(0); if(m_ended) { *data << uint8(1); *data << uint8(m_losingteam); } else *data << uint8(0); // If the game has ended - this will be 1 *data << uint32(m_players[0].size() + m_players[1].size()); uint32 fcount = BGPvPDataFieldCount[GetType()]; for(uint32 i = 0; i < 2; ++i) { for(set<Player*>::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr) { *data << (*itr)->GetGUID(); bs = &(*itr)->m_bgScore; *data << bs->KillingBlows; *data << bs->HonorableKills; *data << bs->Deaths; *data << bs->BonusHonor; *data << bs->DamageDone; *data << bs->HealingDone; *data << fcount; for(uint32 j = 0; j < fcount; ++j) *data << bs->MiscData[j]; } } } }
void CBattleground::BuildPvPUpdateDataPacket(WorldPacket* data) { ARCEMU_ASSERT(data != NULL); data->Initialize(MSG_PVP_LOG_DATA); data->reserve(10 * (m_players[0].size() + m_players[1].size()) + 50); BGScore* bs; if(IS_ARENA(m_type)) { if(!m_ended) { return; } *data << uint8(1); //In 3.1 this should be the uint32(negative rating), uint32(positive rating), uint32(0)[<-this is the new field in 3.1], and a name if available / which is a null-terminated string, and we send an uint8(0), so we provide a zero length name string / if(!Rated()) { *data << uint32(0) << uint32(0) << uint32(0) << uint8(0); *data << uint32(0) << uint32(0) << uint32(0) << uint8(0); } else { /* Grab some arena teams */ ArenaTeam** teams = TO< Arena* >(this)->GetTeams(); if(teams[0]) { *data << uint32(0) << uint32(3000 + m_deltaRating[0]) << uint32(0) << uint8(0); } else { *data << uint32(0) << uint32(0) << uint32(0) << uint8(0); } if(teams[1]) { *data << uint32(0) << uint32(3000 + m_deltaRating[1]) << uint32(0) << uint8(0); } else { *data << uint32(0) << uint32(0) << uint32(0) << uint8(0); } } *data << uint8(1); *data << uint8(m_winningteam); *data << uint32((m_players[0].size() + m_players[1].size()) - m_invisGMs); for(uint32 i = 0; i < 2; ++i) { for(set<Player*>::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr) { if((*itr)->m_isGmInvisible)continue; *data << (*itr)->GetGUID(); bs = &(*itr)->m_bgScore; *data << bs->KillingBlows; *data << uint8((*itr)->m_bgTeam); *data << bs->DamageDone; *data << bs->HealingDone; *data << uint32(0); } } } else { *data << uint8(0); if(m_ended) { *data << uint8(1); *data << uint8(m_winningteam ? 0 : 1); } else *data << uint8(0); // If the game has ended - this will be 1 *data << uint32((m_players[0].size() + m_players[1].size()) - m_invisGMs); uint32 FieldCount = GetFieldCount(GetType()); for(uint32 i = 0; i < 2; ++i) { for(set<Player*>::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr) { ARCEMU_ASSERT(*itr != NULL); if((*itr)->m_isGmInvisible) continue; *data << (*itr)->GetGUID(); bs = &(*itr)->m_bgScore; *data << bs->KillingBlows; *data << bs->HonorableKills; *data << bs->Deaths; *data << bs->BonusHonor; *data << bs->DamageDone; *data << bs->HealingDone; *data << FieldCount; for(uint32 x = 0; x < FieldCount; ++x) *data << bs->MiscData[x]; } } } }
void CBattleground::PortPlayer(Player* plr, bool skip_teleport /* = false*/) { m_mainLock.Acquire(); if(m_ended) { sChatHandler.SystemMessage(plr->GetSession(), plr->GetSession()->LocalizedWorldSrv(WORLDSTRING_JOIN_BG_ENDED)); BattlegroundManager.SendBattlefieldStatus(plr, BGSTATUS_NOFLAGS, 0, 0, 0, 0, 0); plr->m_pendingBattleground = NULL; m_mainLock.Release(); return; } m_pendPlayers[plr->m_bgTeam].erase(plr->GetLowGUID()); if(m_players[plr->m_bgTeam].find(plr) != m_players[plr->m_bgTeam].end()) { m_mainLock.Release(); return; } plr->FullHPMP(); plr->SetTeam(plr->m_bgTeam); if(plr->m_isGmInvisible == false) { //Do not let everyone know an invisible gm has joined. WorldPacket data(SMSG_BATTLEGROUND_PLAYER_JOINED, 8); data << plr->GetGUID(); DistributePacketToTeam(&data, plr->m_bgTeam); } else { m_invisGMs++; } m_players[plr->m_bgTeam].insert(plr); /* remove from any auto queue remove events */ sEventMgr.RemoveEvents(plr, EVENT_BATTLEGROUND_QUEUE_UPDATE); if(!skip_teleport) { if(plr->IsInWorld()) plr->RemoveFromWorld(); } plr->m_pendingBattleground = NULL; plr->m_bg = this; if(!plr->IsPvPFlagged()) plr->SetPvPFlag(); plr->RemoveAurasByInterruptFlag(AURA_INTERRUPT_ON_PVP_ENTER); /* Reset the score */ memset(&plr->m_bgScore, 0, sizeof(BGScore)); /* update pvp data */ UpdatePvPData(); /* add the player to the group */ if(plr->GetGroup() && !Rated()) { // remove them from their group plr->GetGroup()->RemovePlayer(plr->getPlayerInfo()); } if(!m_countdownStage) { m_countdownStage = 1; sEventMgr.AddEvent(this, &CBattleground::EventCountdown, EVENT_BATTLEGROUND_COUNTDOWN, 30000, 0, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT); sEventMgr.ModifyEventTimeLeft(this, EVENT_BATTLEGROUND_COUNTDOWN, 10000); } sEventMgr.RemoveEvents(this, EVENT_BATTLEGROUND_CLOSE); if(!skip_teleport) { /* This is where we actually teleport the player to the battleground. */ plr->SafeTeleport(m_mapMgr, GetStartingCoords(plr->m_bgTeam)); BattlegroundManager.SendBattlefieldStatus(plr, BGSTATUS_TIME, m_type, m_id, (uint32)UNIXTIME - m_startTime, m_mapMgr->GetMapId(), Rated()); // Elapsed time is the last argument } else { /* If we are not ported, call this immediatelly, otherwise its called after teleportation in Player::OnPushToWorld */ OnAddPlayer(plr); } m_mainLock.Release(); }