fix(Core/Graveyard): prevent non-death knights from getting ported to… (#8206)

This commit is contained in:
Skjalf
2021-10-07 08:07:23 -03:00
committed by GitHub
parent c358bd5f79
commit 29c94e5455
7 changed files with 41 additions and 19 deletions

View File

@@ -1998,7 +1998,7 @@ void Battleground::SetBgRaid(TeamId teamId, Group* bg_raid)
GraveyardStruct const* Battleground::GetClosestGraveyard(Player* player)
{
return sGraveyard->GetClosestGraveyard(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), player->GetBgTeamId());
return sGraveyard->GetClosestGraveyard(player, player->GetBgTeamId());
}
void Battleground::StartTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry)

View File

@@ -4782,7 +4782,7 @@ void Player::RepopAtGraveyard()
if (sBattlefieldMgr->GetBattlefieldToZoneId(GetZoneId()))
ClosestGrave = sBattlefieldMgr->GetBattlefieldToZoneId(GetZoneId())->GetClosestGraveyard(this);
else
ClosestGrave = sGraveyard->GetClosestGraveyard(GetPositionX(), GetPositionY(), GetPositionZ(), GetMapId(), GetTeamId());
ClosestGrave = sGraveyard->GetClosestGraveyard(this, GetTeamId());
}
// stop countdown until repop
@@ -10502,7 +10502,7 @@ void Player::SetEntryPoint()
if (GetMap()->IsDungeon())
{
if (const GraveyardStruct* entry = sGraveyard->GetClosestGraveyard(GetPositionX(), GetPositionY(), GetPositionZ(), GetMapId(), GetTeamId()))
if (const GraveyardStruct* entry = sGraveyard->GetClosestGraveyard(this, GetTeamId()))
m_entryPointData.joinPos = WorldLocation(entry->Map, entry->x, entry->y, entry->z, 0.0f);
}
else if (!GetMap()->IsBattlegroundOrArena())

View File

@@ -573,7 +573,7 @@ void WorldSession::HandleMovementOpcodes(WorldPacket& recvData)
}
else if (!plrMover->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_IS_OUT_OF_BOUNDS))
{
GraveyardStruct const* grave = sGraveyard->GetClosestGraveyard(plrMover->GetPositionX(), plrMover->GetPositionY(), plrMover->GetPositionZ(), plrMover->GetMapId(), plrMover->GetTeamId());
GraveyardStruct const* grave = sGraveyard->GetClosestGraveyard(plrMover, plrMover->GetTeamId());
if (grave)
{
plrMover->TeleportTo(grave->Map, grave->x, grave->y, grave->z, plrMover->GetOrientation());

View File

@@ -421,12 +421,9 @@ void WorldSession::SendSpiritResurrect()
// get corpse nearest graveyard
GraveyardStruct const* corpseGrave = nullptr;
WorldLocation corpseLocation = _player->GetCorpseLocation();
if (_player->HasCorpse())
{
corpseGrave = sGraveyard->GetClosestGraveyard(corpseLocation.GetPositionX(), corpseLocation.GetPositionY(),
corpseLocation.GetPositionZ(), corpseLocation.GetMapId(), _player->GetTeamId());
}
// Search for any graveyards near the player's corpse.
corpseGrave = sGraveyard->GetClosestGraveyard(_player, _player->GetTeamId(), _player->HasCorpse());
// now can spawn bones
_player->SpawnCorpseBones();
@@ -434,7 +431,7 @@ void WorldSession::SendSpiritResurrect()
// teleport to nearest from corpse graveyard, if different from nearest to player ghost
if (corpseGrave)
{
GraveyardStruct const* ghostGrave = sGraveyard->GetClosestGraveyard(_player->GetPositionX(), _player->GetPositionY(), _player->GetPositionZ(), _player->GetMapId(), _player->GetTeamId());
GraveyardStruct const* ghostGrave = sGraveyard->GetClosestGraveyard(_player, _player->GetTeamId());
if (corpseGrave != ghostGrave)
_player->TeleportTo(corpseGrave->Map, corpseGrave->x, corpseGrave->y, corpseGrave->z, _player->GetOrientation());

View File

@@ -93,16 +93,28 @@ GraveyardStruct const* Graveyard::GetDefaultGraveyard(TeamId teamId)
return sGraveyard->GetGraveyard(teamId == TEAM_HORDE ? HORDE_GRAVEYARD : ALLIANCE_GRAVEYARD);
}
GraveyardStruct const* Graveyard::GetClosestGraveyard(float x, float y, float z, uint32 MapId, TeamId teamId)
GraveyardStruct const* Graveyard::GetClosestGraveyard(Player* player, TeamId teamId, bool nearCorpse)
{
WorldLocation loc = player->GetWorldLocation();
if (nearCorpse)
{
loc = player->GetCorpseLocation();
}
uint32 mapId = loc.GetMapId();
float x = loc.GetPositionX();
float y = loc.GetPositionY();
float z = loc.GetPositionZ();
// search for zone associated closest graveyard
uint32 zoneId = sMapMgr->GetZoneId(PHASEMASK_NORMAL, MapId, x, y, z);
uint32 zoneId = player->GetZoneId();
if (!zoneId)
{
if (z > -500)
{
LOG_ERROR("sql.sql", "ZoneId not found for map %u coords (%f, %f, %f)", MapId, x, y, z);
LOG_ERROR("sql.sql", "ZoneId not found for map %u coords (%f, %f, %f)", mapId, x, y, z);
return GetDefaultGraveyard(teamId);
}
}
@@ -115,7 +127,7 @@ GraveyardStruct const* Graveyard::GetClosestGraveyard(float x, float y, float z,
// if mapId != graveyard.mapId (ghost in instance) and search any graveyard associated
// then check faction
GraveyardMapBounds range = GraveyardStore.equal_range(zoneId);
MapEntry const* map = sMapStore.LookupEntry(MapId);
MapEntry const* map = sMapStore.LookupEntry(mapId);
// not need to check validity of map object; MapId _MUST_ be valid here
if (range.first == range.second && !map->IsBattlegroundOrArena())
@@ -137,7 +149,7 @@ GraveyardStruct const* Graveyard::GetClosestGraveyard(float x, float y, float z,
// some where other
GraveyardStruct const* entryFar = nullptr;
MapEntry const* mapEntry = sMapStore.LookupEntry(MapId);
MapEntry const* mapEntry = sMapStore.LookupEntry(mapId);
for (; range.first != range.second; ++range.first)
{
@@ -154,8 +166,20 @@ GraveyardStruct const* Graveyard::GetClosestGraveyard(float x, float y, float z,
if (data.teamId != TEAM_NEUTRAL && teamId != TEAM_NEUTRAL && data.teamId != teamId)
continue;
// Skip Archerus graveyards if the player isn't a Death Knight.
enum DeathKnightGraveyards
{
GRAVEYARD_EBON_HOLD = 1369,
GRAVEYARD_ARCHERUS = 1405
};
if (player->getClass() != CLASS_DEATH_KNIGHT && (data.safeLocId == GRAVEYARD_EBON_HOLD || data.safeLocId == GRAVEYARD_ARCHERUS))
{
continue;
}
// find now nearest graveyard at other map
if (MapId != entry->Map)
if (mapId != entry->Map)
{
// if find graveyard at different map from where entrance placed (or no entrance data), use any first
if (!mapEntry

View File

@@ -19,6 +19,7 @@
#define _GAMEGRAVEYARD_H_
#include "Common.h"
#include "Player.h"
#include "SharedDefines.h"
#include <map>
#include <unordered_map>
@@ -54,7 +55,7 @@ public:
GraveyardStruct const* GetGraveyard(uint32 ID) const;
GraveyardStruct const* GetGraveyard(const std::string& name) const;
GraveyardStruct const* GetDefaultGraveyard(TeamId teamId);
GraveyardStruct const* GetClosestGraveyard(float x, float y, float z, uint32 MapId, TeamId teamId);
GraveyardStruct const* GetClosestGraveyard(Player* player, TeamId teamId, bool nearCorpse = false);
GraveyardData const* FindGraveyardData(uint32 id, uint32 zone);
GraveyardContainer const& GetGraveyardData() const { return _graveyardStore; }
bool AddGraveyardLink(uint32 id, uint32 zoneId, TeamId teamId, bool persist = true);

View File

@@ -1377,7 +1377,7 @@ public:
Player* player = handler->GetSession()->GetPlayer();
uint32 zone_id = player->GetZoneId();
GraveyardStruct const* graveyard = sGraveyard->GetClosestGraveyard(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), teamId);
GraveyardStruct const* graveyard = sGraveyard->GetClosestGraveyard(player, teamId);
if (graveyard)
{