[8963] Make bindpoint field private and add required functions for use.

This commit is contained in:
VladimirMangos 2009-12-10 12:14:11 +03:00
parent 4a2dc2438c
commit ed7d561597
9 changed files with 31 additions and 21 deletions

View file

@ -698,7 +698,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder)
if(at)
pCurrChar->TeleportTo(at->target_mapId, at->target_X, at->target_Y, at->target_Z, pCurrChar->GetOrientation());
else
pCurrChar->TeleportTo(pCurrChar->m_homebindMapId, pCurrChar->m_homebindX, pCurrChar->m_homebindY, pCurrChar->m_homebindZ, pCurrChar->GetOrientation());
pCurrChar->TeleportToHomebind();
}
sObjectAccessor.AddObject(pCurrChar);

View file

@ -2617,7 +2617,7 @@ void InstanceMap::UnloadAll(bool pForce)
for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
{
Player* plr = itr->getSource();
plr->TeleportTo(plr->m_homebindMapId, plr->m_homebindX, plr->m_homebindY, plr->m_homebindZ, plr->GetOrientation());
plr->TeleportToHomebind();
}
}

View file

@ -55,7 +55,7 @@ void WorldSession::HandleMoveWorldportAckOpcode()
// stop teleportation else we would try this again and again in LogoutPlayer...
GetPlayer()->SetSemaphoreTeleportFar(false);
// and teleport the player to a valid place
GetPlayer()->TeleportTo(GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation());
GetPlayer()->TeleportToHomebind();
return;
}
@ -84,7 +84,7 @@ void WorldSession::HandleMoveWorldportAckOpcode()
sLog.outError("WorldSession::HandleMoveWorldportAckOpcode: player %s (%d) was teleported far but couldn't be added to map. (map:%u, x:%f, y:%f, "
"z:%f) We port him to his homebind instead..", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z);
// teleport the player home
GetPlayer()->TeleportTo(GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation());
GetPlayer()->TeleportToHomebind();
return;
}

View file

@ -410,13 +410,7 @@ void WorldSession::SendBindPoint(Creature *npc)
uint32 bindspell = 3286;
uint32 zone_id = _player->GetZoneId();
// update sql homebind
CharacterDatabase.PExecute("UPDATE character_homebind SET map = '%u', zone = '%u', position_x = '%f', position_y = '%f', position_z = '%f' WHERE guid = '%u'", _player->GetMapId(), zone_id, _player->GetPositionX(), _player->GetPositionY(), _player->GetPositionZ(), _player->GetGUIDLow());
_player->m_homebindMapId = _player->GetMapId();
_player->m_homebindZoneId = zone_id;
_player->m_homebindX = _player->GetPositionX();
_player->m_homebindY = _player->GetPositionY();
_player->m_homebindZ = _player->GetPositionZ();
_player->SetHomebindToCurrentPos();
// send spell for bind 3286 bind magic
npc->CastSpell(_player, bindspell, true);

View file

@ -21270,3 +21270,16 @@ bool Player::IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) c
}
return Unit::IsImmunedToSpellEffect(spellInfo, index);
}
void Player::SetHomebindToCurrentPos()
{
m_homebindMapId = GetMapId();
m_homebindZoneId = GetZoneId();
m_homebindX = GetPositionX();
m_homebindY = GetPositionY();
m_homebindZ = GetPositionZ();
// update sql homebind
CharacterDatabase.PExecute("UPDATE character_homebind SET map = '%u', zone = '%u', position_x = '%f', position_y = '%f', position_z = '%f' WHERE guid = '%u'",
m_homebindMapId, m_homebindZoneId, m_homebindX, m_homebindY, m_homebindZ, GetGUIDLow());
}

View file

@ -2165,13 +2165,9 @@ class MANGOS_DLL_SPEC Player : public Unit
float m_recallO;
void SaveRecallPosition();
// Homebind coordinates
uint32 m_homebindMapId;
uint16 m_homebindZoneId;
float m_homebindX;
float m_homebindY;
float m_homebindZ;
void SetHomebindToCurrentPos();
void RelocateToHomebind() { SetLocationMapId(m_homebindMapId); Relocate(m_homebindX,m_homebindY,m_homebindZ); }
void TeleportToHomebind(uint32 options = 0) { TeleportTo(m_homebindMapId, m_homebindX, m_homebindY, m_homebindZ, GetOrientation(),options); }
// currently visible objects at player client
typedef std::set<uint64> ClientGUIDs;
@ -2530,6 +2526,13 @@ class MANGOS_DLL_SPEC Player : public Unit
GridReference<Player> m_gridRef;
MapReference m_mapRef;
// Homebind coordinates
uint32 m_homebindMapId;
uint16 m_homebindZoneId;
float m_homebindX;
float m_homebindY;
float m_homebindZ;
uint32 m_lastFallTime;
float m_lastFallZ;

View file

@ -2340,7 +2340,7 @@ void Spell::EffectTeleportUnits(uint32 i)
if (unitTarget->GetTypeId() != TYPEID_PLAYER)
return;
((Player*)unitTarget)->TeleportTo(((Player*)unitTarget)->m_homebindMapId,((Player*)unitTarget)->m_homebindX,((Player*)unitTarget)->m_homebindY,((Player*)unitTarget)->m_homebindZ,unitTarget->GetOrientation(),unitTarget==m_caster ? TELE_TO_SPELL : 0);
((Player*)unitTarget)->TeleportToHomebind(unitTarget==m_caster ? TELE_TO_SPELL : 0);
return;
}
case TARGET_AREAEFFECT_INSTANT: // in all cases first TARGET_TABLE_X_Y_Z_COORDINATES
@ -5802,7 +5802,7 @@ void Spell::EffectStuck(uint32 /*i*/)
return;
// homebind location is loaded always
pTarget->TeleportTo(pTarget->m_homebindMapId,pTarget->m_homebindX,pTarget->m_homebindY,pTarget->m_homebindZ,pTarget->GetOrientation(), (unitTarget==m_caster ? TELE_TO_SPELL : 0));
pTarget->TeleportToHomebind(unitTarget==m_caster ? TELE_TO_SPELL : 0);
// Stuck spell trigger Hearthstone cooldown
SpellEntry const *spellInfo = sSpellStore.LookupEntry(8690);

View file

@ -355,7 +355,7 @@ void WorldSession::LogoutPlayer(bool Save)
///- Teleport to home if the player is in an invalid instance
if(!_player->m_InstanceValid && !_player->isGameMaster())
{
_player->TeleportTo(_player->m_homebindMapId, _player->m_homebindX, _player->m_homebindY, _player->m_homebindZ, _player->GetOrientation());
_player->TeleportToHomebind();
//this is a bad place to call for far teleport because we need player to be in world for successful logout
//maybe we should implement delayed far teleport logout?
}

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "8962"
#define REVISION_NR "8963"
#endif // __REVISION_NR_H__