Core/Dungeon Finder: After a new player have been found for a existing LFG group, teleport player to any of the players inside dungeon not to the entrance. Also do not teleport players inside dungeon to entrance
--HG-- branch : trunk
This commit is contained in:
@@ -1811,7 +1811,8 @@ void LFGMgr::UpdateBoot(Player* plr, bool accept)
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="Player*">Player</param>
|
/// <param name="Player*">Player</param>
|
||||||
/// <param name="bool">Teleport out</param>
|
/// <param name="bool">Teleport out</param>
|
||||||
void LFGMgr::TeleportPlayer(Player* plr, bool out)
|
/// <param name="bool">Automatic or manual teleport</param>
|
||||||
|
void LFGMgr::TeleportPlayer(Player* plr, bool out, bool fromOpcode /*= false*/)
|
||||||
{
|
{
|
||||||
sLog.outError("DEBUG:LFGMgr::TeleportPlayer: [" UI64FMTD "] is being teleported %s", plr->GetGUID(), out ? "out" : "in");
|
sLog.outError("DEBUG:LFGMgr::TeleportPlayer: [" UI64FMTD "] is being teleported %s", plr->GetGUID(), out ? "out" : "in");
|
||||||
if (out)
|
if (out)
|
||||||
@@ -1821,32 +1822,84 @@ void LFGMgr::TeleportPlayer(Player* plr, bool out)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!plr->isAlive())
|
// TODO Add support for LFG_TELEPORTERROR_FATIGUE
|
||||||
|
LfgTeleportError error = LFG_TELEPORTERROR_OK;
|
||||||
|
Group* grp = plr->GetGroup();
|
||||||
|
|
||||||
|
if (!grp || !grp->isLFGGroup()) // should never happen, but just in case...
|
||||||
|
error = LFG_TELEPORTERROR_INVALID_LOCATION;
|
||||||
|
else if (!plr->isAlive())
|
||||||
|
error = LFG_TELEPORTERROR_PLAYER_DEAD;
|
||||||
|
else if (plr->IsFalling() || plr->hasUnitState(UNIT_STAT_JUMPING))
|
||||||
|
error = LFG_TELEPORTERROR_FALLING;
|
||||||
|
else
|
||||||
{
|
{
|
||||||
plr->GetSession()->SendLfgTeleportError(LFG_TELEPORTERROR_PLAYER_DEAD);
|
LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(grp->GetLfgDungeonEntry());
|
||||||
return;
|
|
||||||
|
if (!dungeon)
|
||||||
|
error = LFG_TELEPORTERROR_INVALID_LOCATION;
|
||||||
|
else if (plr->GetMapId() != uint32(dungeon->map)) // Do not teleport players in dungeon to the entrance
|
||||||
|
{
|
||||||
|
uint32 mapid = 0;
|
||||||
|
float x = 0;
|
||||||
|
float y = 0;
|
||||||
|
float z = 0;
|
||||||
|
float orientation = 0;
|
||||||
|
|
||||||
|
if (!fromOpcode)
|
||||||
|
{
|
||||||
|
Player *plrg;
|
||||||
|
// Select a player inside to be teleported to
|
||||||
|
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL && !mapid; itr = itr->next())
|
||||||
|
{
|
||||||
|
plrg = itr->getSource();
|
||||||
|
if (plrg && plrg != plr && plrg->GetMapId() == uint32(dungeon->map))
|
||||||
|
{
|
||||||
|
mapid = plrg->GetMapId();
|
||||||
|
x = plrg->GetPositionX();
|
||||||
|
y = plrg->GetPositionY();
|
||||||
|
z = plrg->GetPositionZ();
|
||||||
|
orientation = plrg->GetOrientation();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plr->IsFalling() || plr->hasUnitState(UNIT_STAT_JUMPING))
|
if (!mapid)
|
||||||
{
|
{
|
||||||
plr->GetSession()->SendLfgTeleportError(LFG_TELEPORTERROR_FALLING);
|
AreaTrigger const* at = sObjectMgr.GetMapEntranceTrigger(dungeon->map);
|
||||||
return;
|
if (!at)
|
||||||
|
error = LFG_TELEPORTERROR_INVALID_LOCATION;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mapid = at->target_mapId;
|
||||||
|
x = at->target_X;
|
||||||
|
y = at->target_Y;
|
||||||
|
z = at->target_Z;
|
||||||
|
orientation = at->target_Orientation;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Add support for LFG_TELEPORTERROR_FATIGUE and LFG_TELEPORTERROR_INVALID_LOCATION
|
if (error == LFG_TELEPORTERROR_OK)
|
||||||
if (Group* grp = plr->GetGroup())
|
|
||||||
if (LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(grp->GetLfgDungeonEntry()))
|
|
||||||
if (AreaTrigger const* at = sObjectMgr.GetMapEntranceTrigger(dungeon->map))
|
|
||||||
{
|
{
|
||||||
if (!plr->GetMap()->IsDungeon() && !plr->GetMap()->IsRaid())
|
if (!plr->GetMap()->IsDungeon() && !plr->GetMap()->IsRaid())
|
||||||
plr->SetBattlegroundEntryPoint();
|
plr->SetBattlegroundEntryPoint();
|
||||||
|
|
||||||
|
if (plr->TeleportTo(mapid, x, y, z, orientation))
|
||||||
|
{
|
||||||
plr->RemoveAurasByType(SPELL_AURA_MOUNTED);
|
plr->RemoveAurasByType(SPELL_AURA_MOUNTED);
|
||||||
// TODO: Teleport to group
|
|
||||||
if (plr->TeleportTo(at->target_mapId, at->target_X, at->target_Y, at->target_Z, at->target_Orientation))
|
|
||||||
plr->CastSpell(plr, LFG_SPELL_LUCK_OF_THE_DRAW, false);
|
plr->CastSpell(plr, LFG_SPELL_LUCK_OF_THE_DRAW, false);
|
||||||
else
|
|
||||||
sLog.outError("LfgMgr::TeleportPlayer: Failed to teleport [" UI64FMTD "] to map %u: ", plr->GetGUID(), at->target_mapId);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
error = LFG_TELEPORTERROR_INVALID_LOCATION;
|
||||||
|
sLog.outError("LfgMgr::TeleportPlayer: Failed to teleport [" UI64FMTD "] to map %u: ", plr->GetGUID(), mapid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error != LFG_TELEPORTERROR_OK)
|
||||||
|
plr->GetSession()->SendLfgTeleportError(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ enum LfgLockStatusType
|
|||||||
|
|
||||||
enum LfgTeleportError
|
enum LfgTeleportError
|
||||||
{
|
{
|
||||||
//LFG_TELEPORTERROR_UNK1 = 0, // No reaction
|
LFG_TELEPORTERROR_OK = 0, // Internal use
|
||||||
LFG_TELEPORTERROR_PLAYER_DEAD = 1,
|
LFG_TELEPORTERROR_PLAYER_DEAD = 1,
|
||||||
LFG_TELEPORTERROR_FALLING = 2,
|
LFG_TELEPORTERROR_FALLING = 2,
|
||||||
//LFG_TELEPORTERROR_UNK2 = 3, // You can't do that right now
|
//LFG_TELEPORTERROR_UNK2 = 3, // You can't do that right now
|
||||||
@@ -252,7 +252,7 @@ class LFGMgr
|
|||||||
void Join(Player* plr);
|
void Join(Player* plr);
|
||||||
void Leave(Player* plr, Group* grp = NULL);
|
void Leave(Player* plr, Group* grp = NULL);
|
||||||
void OfferContinue(Group* grp);
|
void OfferContinue(Group* grp);
|
||||||
void TeleportPlayer(Player* plr, bool out);
|
void TeleportPlayer(Player* plr, bool out, bool fromOpcode = false);
|
||||||
void UpdateProposal(uint32 proposalId, uint32 lowGuid, bool accept);
|
void UpdateProposal(uint32 proposalId, uint32 lowGuid, bool accept);
|
||||||
void UpdateBoot(Player* plr, bool accept);
|
void UpdateBoot(Player* plr, bool accept);
|
||||||
void UpdateRoleCheck(Group* grp, Player* plr = NULL);
|
void UpdateRoleCheck(Group* grp, Player* plr = NULL);
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ void WorldSession::HandleLfgTeleportOpcode(WorldPacket &recv_data)
|
|||||||
recv_data >> out;
|
recv_data >> out;
|
||||||
|
|
||||||
sLog.outDebug("CMSG_LFG_TELEPORT [" UI64FMTD "] out: %u", GetPlayer()->GetGUID(), out ? 1 : 0);
|
sLog.outDebug("CMSG_LFG_TELEPORT [" UI64FMTD "] out: %u", GetPlayer()->GetGUID(), out ? 1 : 0);
|
||||||
sLFGMgr.TeleportPlayer(GetPlayer(), out);
|
sLFGMgr.TeleportPlayer(GetPlayer(), out, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket &/*recv_data*/)
|
void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket &/*recv_data*/)
|
||||||
|
|||||||
Reference in New Issue
Block a user