mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
[7372] Cleanup BattleGround::GetClosestGraveYard related code.
This commit is contained in:
parent
f454ddf6d0
commit
9983286280
8 changed files with 41 additions and 29 deletions
|
|
@ -1514,3 +1514,8 @@ void BattleGround::SetBgRaid( uint32 TeamID, Group *bg_raid )
|
|||
if(bg_raid) bg_raid->SetBattlegroundGroup(this);
|
||||
old_raid = bg_raid;
|
||||
}
|
||||
|
||||
WorldSafeLocsEntry const* BattleGround::GetClosestGraveYard( Player* player )
|
||||
{
|
||||
return objmgr.GetClosestGraveYard( player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), player->GetTeam() );
|
||||
}
|
||||
|
|
@ -426,7 +426,7 @@ class BattleGround
|
|||
virtual void EventPlayerCapturedFlag(Player* /*player*/) {}
|
||||
|
||||
/* Death related */
|
||||
virtual WorldSafeLocsEntry const* GetClosestGraveYard(float /*x*/, float /*y*/, float /*z*/, uint32 /*team*/) { return NULL; }
|
||||
virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player);
|
||||
|
||||
virtual void AddPlayer(Player *plr); // must be implemented in BG subclass
|
||||
|
||||
|
|
|
|||
|
|
@ -409,15 +409,16 @@ void BattleGroundAB::_NodeDeOccupied(uint8 node)
|
|||
if( !ghost_list.empty() )
|
||||
{
|
||||
WorldSafeLocsEntry const *ClosestGrave = NULL;
|
||||
Player *plr;
|
||||
for (std::vector<uint64>::const_iterator itr = ghost_list.begin(); itr != ghost_list.end(); ++itr)
|
||||
{
|
||||
plr = objmgr.GetPlayer(*itr);
|
||||
Player* plr = objmgr.GetPlayer(*itr);
|
||||
if (!plr)
|
||||
continue;
|
||||
if( !ClosestGrave )
|
||||
ClosestGrave = GetClosestGraveYard(plr->GetPositionX(), plr->GetPositionY(), plr->GetPositionZ(), plr->GetTeam());
|
||||
|
||||
if (!ClosestGrave) // cache
|
||||
ClosestGrave = GetClosestGraveYard(plr);
|
||||
|
||||
if (ClosestGrave)
|
||||
plr->TeleportTo(GetMapId(), ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, plr->GetOrientation());
|
||||
}
|
||||
}
|
||||
|
|
@ -603,9 +604,9 @@ void BattleGroundAB::Reset()
|
|||
DelCreature(i);
|
||||
}
|
||||
|
||||
WorldSafeLocsEntry const* BattleGroundAB::GetClosestGraveYard(float x, float y, float /*z*/, uint32 team)
|
||||
WorldSafeLocsEntry const* BattleGroundAB::GetClosestGraveYard(Player* player)
|
||||
{
|
||||
uint8 teamIndex = GetTeamIndexByTeamId(team);
|
||||
uint8 teamIndex = GetTeamIndexByTeamId(player->GetTeam());
|
||||
|
||||
// Is there any occupied node for this team?
|
||||
std::vector<uint8> nodes;
|
||||
|
|
@ -617,13 +618,16 @@ WorldSafeLocsEntry const* BattleGroundAB::GetClosestGraveYard(float x, float y,
|
|||
// If so, select the closest node to place ghost on
|
||||
if( !nodes.empty() )
|
||||
{
|
||||
float plr_x = player->GetPositionX();
|
||||
float plr_y = player->GetPositionY();
|
||||
|
||||
float mindist = 999999.0f;
|
||||
for (uint8 i = 0; i < nodes.size(); ++i)
|
||||
{
|
||||
WorldSafeLocsEntry const*entry = sWorldSafeLocsStore.LookupEntry( BG_AB_GraveyardIds[nodes[i]] );
|
||||
if( !entry )
|
||||
continue;
|
||||
float dist = (entry->x - x)*(entry->x - x)+(entry->y - y)*(entry->y - y);
|
||||
float dist = (entry->x - plr_x)*(entry->x - plr_x)+(entry->y - plr_y)*(entry->y - plr_y);
|
||||
if( mindist > dist )
|
||||
{
|
||||
mindist = dist;
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ class BattleGroundAB : public BattleGround
|
|||
void HandleAreaTrigger(Player *Source, uint32 Trigger);
|
||||
virtual bool SetupBattleGround();
|
||||
virtual void Reset();
|
||||
virtual WorldSafeLocsEntry const* GetClosestGraveYard(float x, float y, float z, uint32 team);
|
||||
virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player);
|
||||
|
||||
/* Scorekeeping */
|
||||
virtual void UpdatePlayerScore(Player *Source, uint32 type, uint32 value);
|
||||
|
|
|
|||
|
|
@ -885,16 +885,16 @@ void BattleGroundEY::FillInitialWorldStates(WorldPacket& data)
|
|||
data << uint32(0xc0d) << uint32(0x17b);
|
||||
}
|
||||
|
||||
WorldSafeLocsEntry const *BattleGroundEY::GetClosestGraveYard(float x, float y, float z, uint32 team)
|
||||
WorldSafeLocsEntry const *BattleGroundEY::GetClosestGraveYard(Player* player)
|
||||
{
|
||||
uint32 g_id = 0;
|
||||
|
||||
if(team == ALLIANCE)
|
||||
g_id = EY_GRAVEYARD_MAIN_ALLIANCE;
|
||||
else if(team == HORDE)
|
||||
g_id = EY_GRAVEYARD_MAIN_HORDE;
|
||||
else
|
||||
return NULL;
|
||||
switch(player->GetTeam())
|
||||
{
|
||||
case ALLIANCE: g_id = EY_GRAVEYARD_MAIN_ALLIANCE; break;
|
||||
case HORDE: g_id = EY_GRAVEYARD_MAIN_HORDE; break;
|
||||
default: return NULL;
|
||||
}
|
||||
|
||||
float distance, nearestDistance;
|
||||
|
||||
|
|
@ -909,19 +909,24 @@ WorldSafeLocsEntry const *BattleGroundEY::GetClosestGraveYard(float x, float y,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
distance = (entry->x - x)*(entry->x - x) + (entry->y - y)*(entry->y - y) + (entry->z - z)*(entry->z - z);
|
||||
float plr_x = player->GetPositionX();
|
||||
float plr_y = player->GetPositionY();
|
||||
float plr_z = player->GetPositionZ();
|
||||
|
||||
|
||||
distance = (entry->x - plr_x)*(entry->x - plr_x) + (entry->y - plr_y)*(entry->y - plr_y) + (entry->z - plr_z)*(entry->z - plr_z);
|
||||
nearestDistance = distance;
|
||||
|
||||
for(uint8 i = 0; i < EY_POINTS_MAX; ++i)
|
||||
{
|
||||
if(m_PointOwnedByTeam[i]==team && m_PointState[i]==EY_POINT_UNDER_CONTROL)
|
||||
if(m_PointOwnedByTeam[i]==player->GetTeam() && m_PointState[i]==EY_POINT_UNDER_CONTROL)
|
||||
{
|
||||
entry = sWorldSafeLocsStore.LookupEntry(m_CapturingPointTypes[i].GraveYardId);
|
||||
if(!entry)
|
||||
sLog.outError("BattleGroundEY: Not found graveyard: %u",m_CapturingPointTypes[i].GraveYardId);
|
||||
else
|
||||
{
|
||||
distance = (entry->x - x)*(entry->x - x) + (entry->y - y)*(entry->y - y) + (entry->z - z)*(entry->z - z);
|
||||
distance = (entry->x - plr_x)*(entry->x - plr_x) + (entry->y - plr_y)*(entry->y - plr_y) + (entry->z - plr_z)*(entry->z - plr_z);
|
||||
if(distance < nearestDistance)
|
||||
{
|
||||
nearestDistance = distance;
|
||||
|
|
|
|||
|
|
@ -315,7 +315,7 @@ class BattleGroundEY : public BattleGround
|
|||
void HandleBuffUse(uint64 const& buff_guid);
|
||||
void HandleAreaTrigger(Player *Source, uint32 Trigger);
|
||||
void HandleKillPlayer(Player *player, Player *killer);
|
||||
virtual WorldSafeLocsEntry const* GetClosestGraveYard(float x, float y, float z, uint32 team);
|
||||
virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player);
|
||||
virtual bool SetupBattleGround();
|
||||
virtual void Reset();
|
||||
void UpdateTeamScore(uint32 Team);
|
||||
|
|
|
|||
|
|
@ -4261,11 +4261,9 @@ void Player::RepopAtGraveyard()
|
|||
WorldSafeLocsEntry const *ClosestGrave = NULL;
|
||||
|
||||
// Special handle for battleground maps
|
||||
if( GetBattleGroundTypeId() == BATTLEGROUND_AB || GetBattleGroundTypeId() == BATTLEGROUND_EY )
|
||||
if( BattleGround *bg = GetBattleGround() )
|
||||
ClosestGrave = bg->GetClosestGraveYard(GetPositionX(), GetPositionY(), GetPositionZ(), GetTeam());
|
||||
|
||||
if(!ClosestGrave)
|
||||
ClosestGrave = bg->GetClosestGraveYard(this);
|
||||
else
|
||||
ClosestGrave = objmgr.GetClosestGraveYard( GetPositionX(), GetPositionY(), GetPositionZ(), GetMapId(), GetTeam() );
|
||||
|
||||
// stop countdown until repop
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "7371"
|
||||
#define REVISION_NR "7372"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue