diff options
| author | ModoX <moardox@gmail.com> | 2021-10-16 01:17:47 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-16 01:17:47 +0200 |
| commit | 68c2fc8ff58d9ad272e8e17391a6bb6c3743923b (patch) | |
| tree | 85740e804fd85a94634ee6295e378e674eb920ba /src/server/game | |
| parent | 82b3a409db4dfe689c84234f3ae427369325bf0b (diff) | |
Core/Characters: Made homebind location a WorldLocation (this implicitly adds orientation) (#27055)
Diffstat (limited to 'src/server/game')
| -rw-r--r-- | src/server/game/DungeonFinding/LFGScripts.cpp | 2 | ||||
| -rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 69 | ||||
| -rw-r--r-- | src/server/game/Entities/Player/Player.h | 5 | ||||
| -rw-r--r-- | src/server/game/Handlers/BattleGroundHandler.cpp | 2 | ||||
| -rw-r--r-- | src/server/game/Handlers/CharacterHandler.cpp | 2 | ||||
| -rw-r--r-- | src/server/game/Handlers/MovementHandler.cpp | 4 | ||||
| -rw-r--r-- | src/server/game/Maps/Map.cpp | 2 | ||||
| -rw-r--r-- | src/server/game/Server/WorldSession.cpp | 2 | ||||
| -rw-r--r-- | src/server/game/Spells/Spell.cpp | 2 | ||||
| -rw-r--r-- | src/server/game/Spells/SpellEffects.cpp | 6 |
10 files changed, 46 insertions, 50 deletions
diff --git a/src/server/game/DungeonFinding/LFGScripts.cpp b/src/server/game/DungeonFinding/LFGScripts.cpp index 33af552210c..baf095bc816 100644 --- a/src/server/game/DungeonFinding/LFGScripts.cpp +++ b/src/server/game/DungeonFinding/LFGScripts.cpp @@ -86,7 +86,7 @@ void LFGPlayerScript::OnMapChanged(Player* player) { sLFGMgr->LeaveLfg(player->GetGUID()); player->RemoveAurasDueToSpell(LFG_SPELL_LUCK_OF_THE_DRAW); - player->TeleportTo(player->m_homebindMapId, player->m_homebindX, player->m_homebindY, player->m_homebindZ, 0.0f); + player->TeleportTo(player->m_homebind); TC_LOG_ERROR("lfg", "LFGPlayerScript::OnMapChanged, Player %s (%s) is in LFG dungeon map but does not have a valid group! " "Teleporting to homebind.", player->GetName().c_str(), player->GetGUID().ToString().c_str()); return; diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index d0cd1db0260..f5a9d9d356a 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -303,11 +303,7 @@ Player::Player(WorldSession* session) : Unit(true), m_sceneMgr(this) m_playerMovingMe = this; m_seer = this; - m_homebindMapId = 0; m_homebindAreaId = 0; - m_homebindX = 0; - m_homebindY = 0; - m_homebindZ = 0; m_contestedPvPTimer = 0; @@ -4803,7 +4799,7 @@ void Player::RepopAtGraveyard() } } else if (GetPositionZ() < GetMap()->GetMinHeight(GetPhaseShift(), GetPositionX(), GetPositionY())) - TeleportTo(m_homebindMapId, m_homebindX, m_homebindY, m_homebindZ, GetOrientation()); + TeleportTo(m_homebind); RemovePlayerFlag(PLAYER_FLAGS_IS_OUT_OF_BOUNDS); } @@ -17681,26 +17677,26 @@ bool Player::LoadPositionFromDB(uint32& mapid, float& x, float& y, float& z, flo void Player::SetHomebind(WorldLocation const& loc, uint32 areaId) { - loc.GetPosition(m_homebindX, m_homebindY, m_homebindZ); - m_homebindMapId = loc.GetMapId(); + m_homebind.WorldRelocate(loc); m_homebindAreaId = areaId; // update sql homebind CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_PLAYER_HOMEBIND); - stmt->setUInt16(0, m_homebindMapId); + stmt->setUInt16(0, m_homebind.GetMapId()); stmt->setUInt16(1, m_homebindAreaId); - stmt->setFloat (2, m_homebindX); - stmt->setFloat (3, m_homebindY); - stmt->setFloat (4, m_homebindZ); - stmt->setUInt64(5, GetGUID().GetCounter()); + stmt->setFloat (2, m_homebind.GetPositionX()); + stmt->setFloat (3, m_homebind.GetPositionY()); + stmt->setFloat (4, m_homebind.GetPositionZ()); + stmt->setFloat (5, m_homebind.GetOrientation()); + stmt->setUInt64(6, GetGUID().GetCounter()); CharacterDatabase.Execute(stmt); } void Player::SendBindPointUpdate() const { WorldPackets::Misc::BindPointUpdate packet; - packet.BindPosition = Position(m_homebindX, m_homebindY, m_homebindZ); - packet.BindMapID = m_homebindMapId; + packet.BindPosition = Position(m_homebind.GetPositionX(), m_homebind.GetPositionY(), m_homebind.GetPositionZ()); + packet.BindMapID = m_homebind.GetMapId(); packet.BindAreaID = m_homebindAreaId; SendDirectMessage(packet.Write()); } @@ -18043,7 +18039,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder* holder) SetRaidDifficultyID(CheckLoadedRaidDifficultyID(fields.raidDifficulty)); SetLegacyRaidDifficultyID(CheckLoadedLegacyRaidDifficultyID(fields.legacyRaidDifficulty)); -#define RelocateToHomebind(){ mapId = m_homebindMapId; instanceId = 0; Relocate(m_homebindX, m_homebindY, m_homebindZ); } +#define RelocateToHomebind(){ instanceId = 0; WorldRelocate(m_homebind); } _LoadGroup(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_GROUP)); @@ -20265,21 +20261,19 @@ bool Player::_LoadHomeBind(PreparedQueryResult result) } bool ok = false; - // SELECT mapId, zoneId, posX, posY, posZ FROM character_homebind WHERE guid = ? + // 0 1 2 3 4 5 + // SELECT mapId, zoneId, posX, posY, posZ, orientation FROM character_homebind WHERE guid = ? if (result) { Field* fields = result->Fetch(); - m_homebindMapId = fields[0].GetUInt16(); + m_homebind.WorldRelocate(fields[0].GetUInt16(), fields[2].GetFloat(), fields[3].GetFloat(), fields[4].GetFloat(), fields[5].GetFloat()); m_homebindAreaId = fields[1].GetUInt16(); - m_homebindX = fields[2].GetFloat(); - m_homebindY = fields[3].GetFloat(); - m_homebindZ = fields[4].GetFloat(); - MapEntry const* bindMapEntry = sMapStore.LookupEntry(m_homebindMapId); + MapEntry const* bindMapEntry = sMapStore.LookupEntry(m_homebind.GetMapId()); // accept saved data only for valid position (and non instanceable), and accessable - if (MapManager::IsValidMapCoord(m_homebindMapId, m_homebindX, m_homebindY, m_homebindZ) && + if (MapManager::IsValidMapCoord(m_homebind) && !bindMapEntry->Instanceable() && GetSession()->GetExpansion() >= bindMapEntry->Expansion()) ok = true; else @@ -20294,11 +20288,12 @@ bool Player::_LoadHomeBind(PreparedQueryResult result) { CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PLAYER_HOMEBIND); stmt->setUInt64(0, GetGUID().GetCounter()); - stmt->setUInt16(1, m_homebindMapId); + stmt->setUInt16(1, m_homebind.GetMapId()); stmt->setUInt16(2, m_homebindAreaId); - stmt->setFloat(3, m_homebindX); - stmt->setFloat(4, m_homebindY); - stmt->setFloat(5, m_homebindZ); + stmt->setFloat(3, m_homebind.GetPositionX()); + stmt->setFloat(4, m_homebind.GetPositionY()); + stmt->setFloat(5, m_homebind.GetPositionZ()); + stmt->setFloat(6, m_homebind.GetOrientation()); CharacterDatabase.Execute(stmt); }; @@ -20306,13 +20301,18 @@ bool Player::_LoadHomeBind(PreparedQueryResult result) { PlayerInfo::CreatePosition const& createPosition = m_createMode == PlayerCreateMode::NPE && info->createPositionNPE ? info->createPositionNPE.get() : info->createPosition; - m_homebindMapId = createPosition.Loc.GetMapId(); - createPosition.Loc.GetPosition(m_homebindX, m_homebindY, m_homebindZ); + m_homebind.m_mapId = createPosition.Loc.GetMapId(); if (createPosition.TransportGuid) + { if (Transport* transport = HashMapHolder<Transport>::Find(ObjectGuid::Create<HighGuid::Transport>(*createPosition.TransportGuid))) - transport->CalculatePassengerPosition(m_homebindX, m_homebindY, m_homebindZ); + { + float orientation = m_homebind.GetOrientation(); + transport->CalculatePassengerPosition(m_homebind.m_positionX, m_homebind.m_positionY, m_homebind.m_positionZ, &orientation); + m_homebind.SetOrientation(orientation); + } + } - m_homebindAreaId = sMapMgr->GetAreaId(PhasingHandler::GetEmptyPhaseShift(), m_homebindMapId, m_homebindX, m_homebindY, m_homebindZ); + m_homebindAreaId = sMapMgr->GetAreaId(PhasingHandler::GetEmptyPhaseShift(), m_homebind); saveHomebindToDb(); ok = true; @@ -20326,15 +20326,14 @@ bool Player::_LoadHomeBind(PreparedQueryResult result) ASSERT(loc, "Missing fallback graveyard location for faction %u", uint32(GetTeamId())); - m_homebindMapId = loc->Loc.GetMapId(); + m_homebind.WorldRelocate(loc->Loc); m_homebindAreaId = sMapMgr->GetAreaId(PhasingHandler::GetEmptyPhaseShift(), loc->Loc); - loc->Loc.GetPosition(m_homebindX, m_homebindY, m_homebindZ); saveHomebindToDb(); } - TC_LOG_DEBUG("entities.player", "Player::_LoadHomeBind: Setting home position (MapID: %u, AreaID: %u, X: %f, Y: %f, Z: %f) of player '%s' (%s)", - m_homebindMapId, m_homebindAreaId, m_homebindX, m_homebindY, m_homebindZ, GetName().c_str(), GetGUID().ToString().c_str()); + TC_LOG_DEBUG("entities.player", "Player::_LoadHomeBind: Setting home position (MapID: %u, AreaID: %u, X: %f, Y: %f, Z: %f O: %f) of player '%s' (%s)", + m_homebind.GetMapId(), m_homebindAreaId, m_homebind.GetPositionX(), m_homebind.GetPositionY(), m_homebind.GetPositionZ(), m_homebind.GetOrientation(), GetName().c_str(), GetGUID().ToString().c_str()); return true; } @@ -23700,7 +23699,7 @@ void Player::SetBattlegroundEntryPoint() } if (m_bgData.joinPos.m_mapId == MAPID_INVALID) // In error cases use homebind position - m_bgData.joinPos = WorldLocation(m_homebindMapId, m_homebindX, m_homebindY, m_homebindZ, 0.0f); + m_bgData.joinPos.WorldRelocate(m_homebind); } void Player::SetBGTeam(uint32 team) diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index f7fe8d05403..f35b5430973 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -2360,11 +2360,8 @@ class TC_GAME_API Player : public Unit, public GridObject<Player> void SendPlayerBound(ObjectGuid const& binderGuid, uint32 areaId) const; // Homebind coordinates - uint32 m_homebindMapId; + WorldLocation m_homebind; uint16 m_homebindAreaId; - float m_homebindX; - float m_homebindY; - float m_homebindZ; uint8 GetStartLevel(uint8 race, uint8 playerClass, Optional<int32> characterTemplateId) const; diff --git a/src/server/game/Handlers/BattleGroundHandler.cpp b/src/server/game/Handlers/BattleGroundHandler.cpp index d1409b24626..8d13e4e2195 100644 --- a/src/server/game/Handlers/BattleGroundHandler.cpp +++ b/src/server/game/Handlers/BattleGroundHandler.cpp @@ -668,5 +668,5 @@ void WorldSession::HandleHearthAndResurrect(WorldPackets::Battleground::HearthAn _player->BuildPlayerRepop(); _player->ResurrectPlayer(1.0f); - _player->TeleportTo(_player->m_homebindMapId, _player->m_homebindX, _player->m_homebindY, _player->m_homebindZ, _player->GetOrientation()); + _player->TeleportTo(_player->m_homebind); } diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp index 3ed1240bdba..5412042cdc7 100644 --- a/src/server/game/Handlers/CharacterHandler.cpp +++ b/src/server/game/Handlers/CharacterHandler.cpp @@ -1162,7 +1162,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->TeleportTo(pCurrChar->m_homebind); } ObjectAccessor::AddObject(pCurrChar); diff --git a/src/server/game/Handlers/MovementHandler.cpp b/src/server/game/Handlers/MovementHandler.cpp index ddc0ce9d1d0..b3816631ddc 100644 --- a/src/server/game/Handlers/MovementHandler.cpp +++ b/src/server/game/Handlers/MovementHandler.cpp @@ -87,7 +87,7 @@ void WorldSession::HandleMoveWorldportAck() if (!newMap || newMap->CannotEnter(GetPlayer())) { TC_LOG_ERROR("network", "Map %d (%s) could not be created for %s (%s), porting player to homebind", loc.GetMapId(), newMap ? newMap->GetMapName() : "Unknown", GetPlayer()->GetGUID().ToString().c_str(), GetPlayer()->GetName().c_str()); - GetPlayer()->TeleportTo(GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation()); + GetPlayer()->TeleportTo(GetPlayer()->m_homebind); return; } @@ -112,7 +112,7 @@ void WorldSession::HandleMoveWorldportAck() GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().ToString().c_str(), loc.GetMapId(), newMap ? newMap->GetMapName() : "Unknown"); GetPlayer()->ResetMap(); GetPlayer()->SetMap(oldMap); - GetPlayer()->TeleportTo(GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation()); + GetPlayer()->TeleportTo(GetPlayer()->m_homebind); return; } diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index ac4760f72fc..b9449317587 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -1765,7 +1765,7 @@ void Map::RemoveAllPlayers() { // this is happening for bg TC_LOG_ERROR("maps", "Map::UnloadAll: player %s is still in map %u during unload, this should not happen!", player->GetName().c_str(), GetId()); - player->TeleportTo(player->m_homebindMapId, player->m_homebindX, player->m_homebindY, player->m_homebindZ, player->GetOrientation()); + player->TeleportTo(player->m_homebind); } } } diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp index 328f2c394d6..c023813114a 100644 --- a/src/server/game/Server/WorldSession.cpp +++ b/src/server/game/Server/WorldSession.cpp @@ -532,7 +532,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->TeleportTo(_player->m_homebind); sOutdoorPvPMgr->HandlePlayerLeaveZone(_player, _player->GetZoneId()); diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index f7dbd915d07..90efc980ffb 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -1296,7 +1296,7 @@ void Spell::SelectImplicitCasterDestTargets(SpellEffectInfo const& spellEffectIn break; case TARGET_DEST_HOME: if (Player* playerCaster = m_caster->ToPlayer()) - dest = SpellDestination(playerCaster->m_homebindX, playerCaster->m_homebindY, playerCaster->m_homebindZ, playerCaster->GetOrientation(), playerCaster->m_homebindMapId); + dest = SpellDestination(playerCaster->m_homebind); break; case TARGET_DEST_DB: if (SpellTargetPosition const* st = sSpellMgr->GetSpellTargetPosition(m_spellInfo->Id, spellEffectInfo.EffectIndex)) diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 92c1bb4a249..03f5dd2aa55 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -3611,7 +3611,7 @@ void Spell::EffectStuck() return; } - player->TeleportTo(player->m_homebindMapId, player->m_homebindX, player->m_homebindY, player->m_homebindZ, player->GetOrientation(), TELE_TO_SPELL); + player->TeleportTo(player->m_homebind, TELE_TO_SPELL); // Stuck spell trigger Hearthstone cooldown SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(8690, GetCastDifficulty()); @@ -5364,8 +5364,8 @@ void Spell::EffectBind() player->SetHomebind(homeLoc, areaId); player->SendBindPointUpdate(); - TC_LOG_DEBUG("spells", "EffectBind: New homebind X: %f, Y: %f, Z: %f, MapId: %u, AreaId: %u", - homeLoc.GetPositionX(), homeLoc.GetPositionY(), homeLoc.GetPositionZ(), homeLoc.GetMapId(), areaId); + TC_LOG_DEBUG("spells", "EffectBind: New homebind X: %f, Y: %f, Z: %f O: %f, MapId: %u, AreaId: %u", + homeLoc.GetPositionX(), homeLoc.GetPositionY(), homeLoc.GetPositionZ(), homeLoc.GetOrientation(), homeLoc.GetMapId(), areaId); // zone update player->SendPlayerBound(m_caster->GetGUID(), areaId); |
