Ejemplo n.º 1
0
void CBattleground::RemovePlayer(Player * plr, bool logout)
{
	WorldPacket data(SMSG_BATTLEGROUND_PLAYER_LEFT, 30);
	data << plr->GetGUID();

	m_mainLock.Acquire();
	m_players[plr->m_bgTeam].erase(plr);
	DistributePacketToAll(&data);

	memset(&plr->m_bgScore, 0, sizeof(BGScore));
	OnRemovePlayer(plr);
	plr->m_bg = 0;

	/* are we in the group? */
	if(plr->GetGroup() == m_groups[plr->m_bgTeam])
		plr->GetGroup()->RemovePlayer( plr->m_playerInfo );

	// reset team
	plr->ResetTeam();

	/* revive the player if he is dead */
	if(!logout && !plr->isAlive())
	{
		plr->SetUInt32Value(UNIT_FIELD_HEALTH, plr->GetUInt32Value(UNIT_FIELD_MAXHEALTH));
		plr->ResurrectPlayer(NULL);
	}
	
	/* teleport out */
	if(!logout)
	{
		if(!IS_INSTANCE(plr->m_bgEntryPointMap))
		{
			LocationVector vec(plr->m_bgEntryPointX, plr->m_bgEntryPointY, plr->m_bgEntryPointZ, plr->m_bgEntryPointO);
			plr->SafeTeleport(plr->m_bgEntryPointMap, plr->m_bgEntryPointInstance, vec);
		}
		else
		{
			LocationVector vec(plr->GetBindPositionX(), plr->GetBindPositionY(), plr->GetBindPositionZ());
			plr->SafeTeleport(plr->GetBindMapId(), 0, vec);
		}

		BattlegroundManager.SendBattlefieldStatus(plr, 0, 0, 0, 0, 0,0);

		/* send some null world states */
		data.Initialize(SMSG_INIT_WORLD_STATES);
		data << uint32(plr->GetMapId()) << uint32(0) << uint32(0);
		plr->GetSession()->SendPacket(&data);
	}

	if(!m_ended && m_players[0].size() == 0 && m_players[1].size() == 0)
	{
		/* create an inactive event */
		sEventMgr.RemoveEvents(this, EVENT_BATTLEGROUND_CLOSE);						// 10mins
		sEventMgr.AddEvent(this, &CBattleground::Close, EVENT_BATTLEGROUND_CLOSE, 600000, 1,0);
	}

	plr->m_bgTeam=plr->GetTeam();
	m_mainLock.Release();
}
Ejemplo n.º 2
0
void PlayerManager::RemovePlayer( PlayerPtr Ptr, int32_t reason )
{
__ENTER_FUNCTION

	Assert( Ptr ) ;
	PlayerPtrList::TListIterator iter = std::remove(m_PlayerPtrList.Begin(), m_PlayerPtrList.End(), Ptr);
	if( iter != m_PlayerPtrList.End()) OnRemovePlayer(Ptr, reason);
	
__LEAVE_FUNCTION
}
Ejemplo n.º 3
0
void EntityManager::OnEvent(const Event& event)
{
   switch (event.GetType())
   {
      case EventType::CreateMainMenu:
         OnCreateMainMenu(dynamic_cast<const CreateMainMenuEvent&>(event));
         break;
      case EventType::CreateMainMenuItem:
         OnCreateMainMenuItem(dynamic_cast<const CreateMainMenuItemEvent&>(event));
         break;
//      case EventType::CreateMenuItemSelector:
//         OnCreateMenuItemSelector(dynamic_cast<const CreateMenuItemSelectorEvent&>(event));
//         break;
      case EventType::CreateArena:
         OnCreateArena(dynamic_cast<const CreateArenaEvent&>(event));
         break;
      case EventType::CreateScoreboard:
         OnCreateScoreboard(dynamic_cast<const CreateScoreboardEvent&>(event));
         break;
      case EventType::CreateWall:
         OnCreateWall(dynamic_cast<const CreateWallEvent&>(event));
         break;
      case EventType::CreateExtra:
         OnCreateExtra(dynamic_cast<const CreateExtraEvent&>(event));
         break;
      case EventType::CreateBomb:
         OnCreateBomb(dynamic_cast<const CreateBombEvent&>(event));
         break;
      case EventType::CreateExplosion:
         OnCreateExplosion(dynamic_cast<const CreateExplosionEvent&>(event));
         break;
      case EventType::CreatePlayer:
         OnCreatePlayer(dynamic_cast<const CreatePlayerEvent&>(event));
         break;

      case EventType::RemoveMainMenu:
         OnRemoveMainMenu(dynamic_cast<const RemoveMainMenuEvent&>(event));
         break;
      case EventType::RemoveMainMenuItem:
         OnRemoveMainMenuItem(dynamic_cast<const RemoveMainMenuItemEvent&>(event));
         break;
//      case EventType::RemoveMenuItemSelector:
//         OnRemoveMenuItemSelector(dynamic_cast<const RemoveMenuItemSelectorEvent&>(event));
//         break;
      case EventType::RemoveArena:
         OnRemoveArena(dynamic_cast<const RemoveArenaEvent&>(event));
         break;
      case EventType::RemoveScoreboard:
         OnRemoveScoreboard(dynamic_cast<const RemoveScoreboardEvent&>(event));
         break;
      case EventType::RemoveWall:
         OnRemoveWall(dynamic_cast<const RemoveWallEvent&>(event));
         break;
      case EventType::RemoveExtra:
         OnRemoveExtra(dynamic_cast<const RemoveExtraEvent&>(event));
         break;
      case EventType::RemoveBomb:
         OnRemoveBomb(dynamic_cast<const RemoveBombEvent&>(event));
         break;
      case EventType::RemoveExplosion:
         OnRemoveExplosion(dynamic_cast<const RemoveExplosionEvent&>(event));
         break;
      case EventType::RemovePlayer:
         OnRemovePlayer(dynamic_cast<const RemovePlayerEvent&>(event));
         break;

      default:
         break;
   }
}
Ejemplo n.º 4
0
void CBattleground::RemovePlayer(Player* plr, bool logout)
{
	m_mainLock.Acquire();

	WorldPacket data(SMSG_BATTLEGROUND_PLAYER_LEFT, 30);
	data << plr->GetGUID();
	if(plr->m_isGmInvisible == false)
	{
		//Don't show invisible gm's leaving the game.
		DistributePacketToAll(&data);
	}
	else
	{
		RemoveInvisGM();
	}

	// Call subclassed virtual method
	OnRemovePlayer(plr);

	// Clean-up
	plr->m_bg = NULL;
	plr->FullHPMP();
	m_players[plr->m_bgTeam].erase(plr);
	memset(&plr->m_bgScore, 0, sizeof(BGScore));

	/* are we in the group? */
	if(plr->GetGroup() == m_groups[plr->m_bgTeam])
		plr->GetGroup()->RemovePlayer(plr->getPlayerInfo());

	// reset team
	plr->ResetTeam();

	/* revive the player if he is dead */
	if(!plr->isAlive())
	{
		plr->SetHealth(plr->GetMaxHealth());
		plr->ResurrectPlayer();
	}

	/* remove buffs */
	plr->RemoveAura(32727); // Arena preparation
	plr->RemoveAura(44521); // BG preparation
	plr->RemoveAura(44535);
	plr->RemoveAura(21074);

	plr->Unroot();

	/* teleport out */
	if(!logout)
	{
		if(!m_ended && !plr->GetSession()->HasGMPermissions())
			plr->CastSpell(plr, BG_DESERTER, true);

		if(!IS_INSTANCE(plr->m_bgEntryPointMap))
		{
			LocationVector vec(plr->m_bgEntryPointX, plr->m_bgEntryPointY, plr->m_bgEntryPointZ, plr->m_bgEntryPointO);
			plr->SafeTeleport(plr->m_bgEntryPointMap, plr->m_bgEntryPointInstance, vec);
		}
		else
		{
			LocationVector vec(plr->GetBindPositionX(), plr->GetBindPositionY(), plr->GetBindPositionZ());
			plr->SafeTeleport(plr->GetBindMapId(), 0, vec);
		}

		BattlegroundManager.SendBattlefieldStatus(plr, BGSTATUS_NOFLAGS, 0, 0, 0, 0, 0);
	}

	if(/*!m_ended && */m_players[0].size() == 0 && m_players[1].size() == 0)
	{
		/* create an inactive event */
		sEventMgr.RemoveEvents(this, EVENT_BATTLEGROUND_CLOSE);                  // 10mins
		//sEventMgr.AddEvent(this, &CBattleground::Close, EVENT_BATTLEGROUND_CLOSE, 600000, 1,0); //this is BS..appears to be		the cause if the battleground crashes.
		this->Close();
	}

	plr->m_bgTeam = plr->GetTeam();

	m_mainLock.Release();
}