mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-23 10:26:28 +01:00
Core/Entities: Phase Rework (main commit)
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
#include "ObjectAccessor.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Pet.h"
|
||||
#include "PhasingHandler.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "Transport.h"
|
||||
#include "Vehicle.h"
|
||||
@@ -536,8 +537,7 @@ bool Map::AddPlayerToMap(Player* player)
|
||||
|
||||
player->m_clientGUIDs.clear();
|
||||
player->UpdateObjectVisibility(false);
|
||||
|
||||
player->SendUpdatePhasing();
|
||||
PhasingHandler::SendToPlayer(player);
|
||||
|
||||
if (player->IsAlive())
|
||||
ConvertCorpseToBones(player->GetGUID());
|
||||
@@ -600,8 +600,6 @@ bool Map::AddToMap(T* obj)
|
||||
if (obj->isActiveObject())
|
||||
AddToActive(obj);
|
||||
|
||||
obj->RebuildTerrainSwaps();
|
||||
|
||||
//something, such as vehicle, needs to be update immediately
|
||||
//also, trigger needs to cast spell, if not update, cannot see visual
|
||||
obj->UpdateObjectVisibilityOnCreate();
|
||||
@@ -2239,12 +2237,12 @@ inline GridMap* Map::GetGrid(float x, float y)
|
||||
return GridMaps[gx][gy];
|
||||
}
|
||||
|
||||
float Map::GetWaterOrGroundLevel(std::set<uint32> const& phases, float x, float y, float z, float* ground /*= nullptr*/, bool /*swim = false*/) const
|
||||
float Map::GetWaterOrGroundLevel(PhaseShift const& phaseShift, float x, float y, float z, float* ground /*= nullptr*/, bool /*swim = false*/) const
|
||||
{
|
||||
if (const_cast<Map*>(this)->GetGrid(x, y))
|
||||
{
|
||||
// we need ground level (including grid height version) for proper return water level in point
|
||||
float ground_z = GetHeight(phases, x, y, z, true, 50.0f);
|
||||
float ground_z = GetHeight(phaseShift, x, y, z, true, 50.0f);
|
||||
if (ground)
|
||||
*ground = ground_z;
|
||||
|
||||
@@ -2629,24 +2627,24 @@ float Map::GetWaterLevel(float x, float y) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Map::isInLineOfSight(float x1, float y1, float z1, float x2, float y2, float z2, std::set<uint32> const& phases, LineOfSightChecks checks, VMAP::ModelIgnoreFlags ignoreFlags) const
|
||||
bool Map::isInLineOfSight(PhaseShift const& phaseShift, float x1, float y1, float z1, float x2, float y2, float z2, LineOfSightChecks checks, VMAP::ModelIgnoreFlags ignoreFlags) const
|
||||
{
|
||||
if ((checks & LINEOFSIGHT_CHECK_VMAP)
|
||||
&& !VMAP::VMapFactory::createOrGetVMapManager()->isInLineOfSight(GetId(), x1, y1, z1, x2, y2, z2, ignoreFlags))
|
||||
return false;
|
||||
if (sWorld->getBoolConfig(CONFIG_CHECK_GOBJECT_LOS) && (checks & LINEOFSIGHT_CHECK_GOBJECT)
|
||||
&& !_dynamicTree.isInLineOfSight({x1, y1, z1}, {x2, y2, z2}, phases))
|
||||
&& !_dynamicTree.isInLineOfSight({x1, y1, z1}, {x2, y2, z2}, phaseShift))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Map::getObjectHitPos(std::set<uint32> const& phases, float x1, float y1, float z1, float x2, float y2, float z2, float& rx, float& ry, float& rz, float modifyDist)
|
||||
bool Map::getObjectHitPos(PhaseShift const& phaseShift, float x1, float y1, float z1, float x2, float y2, float z2, float& rx, float& ry, float& rz, float modifyDist)
|
||||
{
|
||||
G3D::Vector3 startPos(x1, y1, z1);
|
||||
G3D::Vector3 dstPos(x2, y2, z2);
|
||||
|
||||
G3D::Vector3 resultPos;
|
||||
bool result = _dynamicTree.getObjectHitPos(phases, startPos, dstPos, resultPos, modifyDist);
|
||||
bool result = _dynamicTree.getObjectHitPos(startPos, dstPos, resultPos, modifyDist, phaseShift);
|
||||
|
||||
rx = resultPos.x;
|
||||
ry = resultPos.y;
|
||||
@@ -2654,9 +2652,9 @@ bool Map::getObjectHitPos(std::set<uint32> const& phases, float x1, float y1, fl
|
||||
return result;
|
||||
}
|
||||
|
||||
float Map::GetHeight(std::set<uint32> const& phases, float x, float y, float z, bool vmap /*= true*/, float maxSearchDist /*= DEFAULT_HEIGHT_SEARCH*/) const
|
||||
float Map::GetHeight(PhaseShift const& phaseShift, float x, float y, float z, bool vmap /*= true*/, float maxSearchDist /*= DEFAULT_HEIGHT_SEARCH*/) const
|
||||
{
|
||||
return std::max<float>(GetHeight(x, y, z, vmap, maxSearchDist), GetGameObjectFloor(phases, x, y, z, maxSearchDist));
|
||||
return std::max<float>(GetHeight(x, y, z, vmap, maxSearchDist), GetGameObjectFloor(phaseShift, x, y, z, maxSearchDist));
|
||||
}
|
||||
|
||||
bool Map::IsInWater(float x, float y, float pZ, LiquidData* data) const
|
||||
@@ -2703,6 +2701,7 @@ void Map::SendInitSelf(Player* player)
|
||||
if (Transport* transport = player->GetTransport())
|
||||
{
|
||||
transport->BuildCreateUpdateBlockForPlayer(&data, player);
|
||||
player->m_visibleTransports.insert(transport->GetGUID());
|
||||
}
|
||||
|
||||
// build data for self presence in world at own client (one time for map)
|
||||
@@ -2710,9 +2709,9 @@ void Map::SendInitSelf(Player* player)
|
||||
|
||||
// build other passengers at transport also (they always visible and marked as visible and will not send at visibility update at add to map
|
||||
if (Transport* transport = player->GetTransport())
|
||||
for (Transport::PassengerSet::const_iterator itr = transport->GetPassengers().begin(); itr != transport->GetPassengers().end(); ++itr)
|
||||
if (player != (*itr) && player->HaveAtClient(*itr))
|
||||
(*itr)->BuildCreateUpdateBlockForPlayer(&data, player);
|
||||
for (WorldObject* passenger : transport->GetPassengers())
|
||||
if (player != passenger && player->HaveAtClient(passenger))
|
||||
passenger->BuildCreateUpdateBlockForPlayer(&data, player);
|
||||
|
||||
WorldPacket packet;
|
||||
data.BuildPacket(&packet);
|
||||
@@ -2723,9 +2722,14 @@ void Map::SendInitTransports(Player* player)
|
||||
{
|
||||
// Hack to send out transports
|
||||
UpdateData transData(player->GetMapId());
|
||||
for (TransportsContainer::const_iterator i = _transports.begin(); i != _transports.end(); ++i)
|
||||
if (*i != player->GetTransport() && player->IsInPhase(*i))
|
||||
(*i)->BuildCreateUpdateBlockForPlayer(&transData, player);
|
||||
for (Transport* transport : _transports)
|
||||
{
|
||||
if (transport != player->GetTransport() && player->IsInPhase(transport))
|
||||
{
|
||||
transport->BuildCreateUpdateBlockForPlayer(&transData, player);
|
||||
player->m_visibleTransports.insert(transport->GetGUID());
|
||||
}
|
||||
}
|
||||
|
||||
WorldPacket packet;
|
||||
transData.BuildPacket(&packet);
|
||||
@@ -2736,28 +2740,33 @@ void Map::SendRemoveTransports(Player* player)
|
||||
{
|
||||
// Hack to send out transports
|
||||
UpdateData transData(player->GetMapId());
|
||||
for (TransportsContainer::const_iterator i = _transports.begin(); i != _transports.end(); ++i)
|
||||
if (*i != player->GetTransport())
|
||||
(*i)->BuildOutOfRangeUpdateBlock(&transData);
|
||||
for (Transport* transport : _transports)
|
||||
{
|
||||
if (transport != player->GetTransport())
|
||||
{
|
||||
transport->BuildOutOfRangeUpdateBlock(&transData);
|
||||
player->m_visibleTransports.erase(transport->GetGUID());
|
||||
}
|
||||
}
|
||||
|
||||
WorldPacket packet;
|
||||
transData.BuildPacket(&packet);
|
||||
player->GetSession()->SendPacket(&packet);
|
||||
}
|
||||
|
||||
void Map::SendUpdateTransportVisibility(Player* player, std::set<uint32> const& previousPhases)
|
||||
void Map::SendUpdateTransportVisibility(Player* player)
|
||||
{
|
||||
// Hack to send out transports
|
||||
UpdateData transData(player->GetMapId());
|
||||
for (TransportsContainer::const_iterator i = _transports.begin(); i != _transports.end(); ++i)
|
||||
for (Transport* transport : _transports)
|
||||
{
|
||||
if (*i == player->GetTransport())
|
||||
continue;
|
||||
|
||||
if (player->IsInPhase(*i) && !Trinity::Containers::Intersects(previousPhases.begin(), previousPhases.end(), (*i)->GetPhases().begin(), (*i)->GetPhases().end()))
|
||||
(*i)->BuildCreateUpdateBlockForPlayer(&transData, player);
|
||||
else if (!player->IsInPhase(*i))
|
||||
(*i)->BuildOutOfRangeUpdateBlock(&transData);
|
||||
if (player->IsInPhase(transport))
|
||||
{
|
||||
if (player->m_visibleTransports.find(transport->GetGUID()) == player->m_visibleTransports.end())
|
||||
transport->BuildCreateUpdateBlockForPlayer(&transData, player);
|
||||
}
|
||||
else if (player->m_visibleTransports.find(transport->GetGUID()) != player->m_visibleTransports.end())
|
||||
transport->BuildOutOfRangeUpdateBlock(&transData);
|
||||
}
|
||||
|
||||
WorldPacket packet;
|
||||
@@ -3775,8 +3784,8 @@ void Map::LoadCorpseData()
|
||||
continue;
|
||||
}
|
||||
|
||||
for (auto phaseId : phases[guid])
|
||||
corpse->SetInPhase(phaseId, false, true);
|
||||
for (uint32 phaseId : phases[guid])
|
||||
PhasingHandler::AddPhase(corpse, phaseId, false);
|
||||
|
||||
AddCorpse(corpse);
|
||||
} while (result->NextRow());
|
||||
@@ -3861,7 +3870,7 @@ Corpse* Map::ConvertCorpseToBones(ObjectGuid const& ownerGuid, bool insignia /*=
|
||||
if (corpse->GetUInt32Value(CORPSE_FIELD_ITEM + i))
|
||||
bones->SetUInt32Value(CORPSE_FIELD_ITEM + i, 0);
|
||||
|
||||
bones->CopyPhaseFrom(corpse);
|
||||
PhasingHandler::InheritPhaseShift(bones, corpse);
|
||||
|
||||
AddCorpse(bones);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user