diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp index 7e2417593..c70492091 100644 --- a/src/game/CharacterHandler.cpp +++ b/src/game/CharacterHandler.cpp @@ -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); diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 2d174e42d..090f394d6 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -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(); } } diff --git a/src/game/MovementHandler.cpp b/src/game/MovementHandler.cpp index e9653c178..4620556cd 100644 --- a/src/game/MovementHandler.cpp +++ b/src/game/MovementHandler.cpp @@ -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; } diff --git a/src/game/NPCHandler.cpp b/src/game/NPCHandler.cpp index 6d74f770e..d0451cd0d 100644 --- a/src/game/NPCHandler.cpp +++ b/src/game/NPCHandler.cpp @@ -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); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index aeff05df8..e89b34f9c 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -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()); +} \ No newline at end of file diff --git a/src/game/Player.h b/src/game/Player.h index 501495b29..4aa32bcb5 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -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 ClientGUIDs; @@ -2530,6 +2526,13 @@ class MANGOS_DLL_SPEC Player : public Unit GridReference 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; diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index d61815e16..c899656aa 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -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); diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp index 3ee5a7faa..a9d0e1cb2 100644 --- a/src/game/WorldSession.cpp +++ b/src/game/WorldSession.cpp @@ -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? } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 3110b0863..4561b4e59 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8962" + #define REVISION_NR "8963" #endif // __REVISION_NR_H__