mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-24 06:06:23 +00:00
Revert Visibility Notifier changes (#17682)
* Revert "fix(Core/Grid): Implement missing GridUnload setting (#17569)" This reverts commit79b39f9655. * Revert "fix(Core/Grid): Address bugs and performance issues introduced by visibility notifier implementation (#17480)" This reverts commit60e27511c5. * Revert "fix(Core): GridCleanUpDelay Log (#17436)" This reverts commit90b16ca065. * Revert "feat(Core/Grids): Implement visibility notifier (#15919)" This reverts commit2779833768.
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include "CellImpl.h"
|
||||
#include "Chat.h"
|
||||
#include "Creature.h"
|
||||
#include "DynamicVisibility.h"
|
||||
#include "GameObjectAI.h"
|
||||
#include "GameTime.h"
|
||||
#include "GridNotifiers.h"
|
||||
@@ -64,7 +65,7 @@ constexpr float VisibilityDistances[AsUnderlyingType(VisibilityDistanceType::Max
|
||||
VISIBILITY_DISTANCE_SMALL,
|
||||
VISIBILITY_DISTANCE_LARGE,
|
||||
VISIBILITY_DISTANCE_GIGANTIC,
|
||||
MAX_VISIBILITY_DISTANCE
|
||||
VISIBILITY_DISTANCE_INFINITE
|
||||
};
|
||||
|
||||
Object::Object() : m_PackGUID(sizeof(uint64) + 1)
|
||||
@@ -248,10 +249,7 @@ void Object::SendUpdateToPlayer(Player* player)
|
||||
UpdateData upd;
|
||||
WorldPacket packet;
|
||||
|
||||
if (player->HaveAtClient(this))
|
||||
BuildValuesUpdateBlockForPlayer(&upd, player);
|
||||
else
|
||||
BuildCreateUpdateBlockForPlayer(&upd, player);
|
||||
BuildCreateUpdateBlockForPlayer(&upd, player);
|
||||
upd.BuildPacket(&packet);
|
||||
player->GetSession()->SendPacket(&packet);
|
||||
}
|
||||
@@ -1050,7 +1048,7 @@ void MovementInfo::OutDebug()
|
||||
}
|
||||
|
||||
WorldObject::WorldObject(bool isWorldObject) : WorldLocation(),
|
||||
LastUsedScriptID(0), m_name(""), m_isActive(false), m_isFarVisible(false), m_visibilityDistanceOverride(), m_isWorldObject(isWorldObject), m_zoneScript(nullptr),
|
||||
LastUsedScriptID(0), m_name(""), m_isActive(false), m_visibilityDistanceOverride(), m_isWorldObject(isWorldObject), m_zoneScript(nullptr),
|
||||
_zoneId(0), _areaId(0), _floorZ(INVALID_HEIGHT), _outdoors(false), _liquidData(), _updatePositionData(false), m_transport(nullptr),
|
||||
m_currMap(nullptr), m_InstanceId(0), m_phaseMask(PHASEMASK_NORMAL), m_useCombinedPhases(true), m_notifyflags(0), m_executed_notifies(0)
|
||||
{
|
||||
@@ -1107,6 +1105,8 @@ void WorldObject::setActive(bool on)
|
||||
map->AddToActive(this->ToCreature());
|
||||
else if (GetTypeId() == TYPEID_DYNAMICOBJECT)
|
||||
map->AddToActive((DynamicObject*)this);
|
||||
else if (GetTypeId() == TYPEID_GAMEOBJECT)
|
||||
map->AddToActive((GameObject*)this);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1114,17 +1114,11 @@ void WorldObject::setActive(bool on)
|
||||
map->RemoveFromActive(this->ToCreature());
|
||||
else if (GetTypeId() == TYPEID_DYNAMICOBJECT)
|
||||
map->RemoveFromActive((DynamicObject*)this);
|
||||
else if (GetTypeId() == TYPEID_GAMEOBJECT)
|
||||
map->RemoveFromActive((GameObject*)this);
|
||||
}
|
||||
}
|
||||
|
||||
void WorldObject::SetFarVisible(bool on)
|
||||
{
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
return;
|
||||
|
||||
m_isFarVisible = on;
|
||||
}
|
||||
|
||||
void WorldObject::SetVisibilityDistanceOverride(VisibilityDistanceType type)
|
||||
{
|
||||
ASSERT(type < VisibilityDistanceType::Max);
|
||||
@@ -1140,9 +1134,6 @@ void WorldObject::CleanupsBeforeDelete(bool /*finalCleanup*/)
|
||||
{
|
||||
if (IsInWorld())
|
||||
RemoveFromWorld();
|
||||
|
||||
if (Transport* transport = GetTransport())
|
||||
transport->RemovePassenger(this, true);
|
||||
}
|
||||
|
||||
void WorldObject::_Create(ObjectGuid::LowType guidlow, HighGuid guidhigh, uint32 phaseMask)
|
||||
@@ -1635,9 +1626,9 @@ float WorldObject::GetGridActivationRange() const
|
||||
{
|
||||
if (ToPlayer()->GetCinematicMgr()->IsOnCinematic())
|
||||
{
|
||||
return std::max(DEFAULT_VISIBILITY_INSTANCE, GetMap()->GetVisibilityRange());
|
||||
return DEFAULT_VISIBILITY_INSTANCE;
|
||||
}
|
||||
return IsInWintergrasp() ? VISIBILITY_DISTANCE_LARGE : GetMap()->GetVisibilityRange();
|
||||
return IsInWintergrasp() ? VISIBILITY_DIST_WINTERGRASP : GetMap()->GetVisibilityRange();
|
||||
}
|
||||
else if (ToCreature())
|
||||
{
|
||||
@@ -1653,12 +1644,29 @@ float WorldObject::GetGridActivationRange() const
|
||||
|
||||
float WorldObject::GetVisibilityRange() const
|
||||
{
|
||||
if (IsVisibilityOverridden() && !ToPlayer())
|
||||
if (IsVisibilityOverridden() && GetTypeId() == TYPEID_UNIT)
|
||||
{
|
||||
return *m_visibilityDistanceOverride;
|
||||
else if (IsFarVisible() && !ToPlayer())
|
||||
return MAX_VISIBILITY_DISTANCE;
|
||||
}
|
||||
else if (GetTypeId() == TYPEID_GAMEOBJECT)
|
||||
{
|
||||
{
|
||||
if (IsInWintergrasp())
|
||||
{
|
||||
return VISIBILITY_DIST_WINTERGRASP + VISIBILITY_INC_FOR_GOBJECTS;
|
||||
}
|
||||
else if (IsVisibilityOverridden())
|
||||
{
|
||||
return *m_visibilityDistanceOverride;
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetMap()->GetVisibilityRange() + VISIBILITY_INC_FOR_GOBJECTS;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
return IsInWintergrasp() ? VISIBILITY_DISTANCE_LARGE : GetMap()->GetVisibilityRange();
|
||||
return IsInWintergrasp() ? VISIBILITY_DIST_WINTERGRASP : GetMap()->GetVisibilityRange();
|
||||
}
|
||||
|
||||
float WorldObject::GetSightRange(WorldObject const* target) const
|
||||
@@ -1667,19 +1675,44 @@ float WorldObject::GetSightRange(WorldObject const* target) const
|
||||
{
|
||||
if (ToPlayer())
|
||||
{
|
||||
if (target && target->IsVisibilityOverridden() && !target->ToPlayer())
|
||||
return *target->m_visibilityDistanceOverride;
|
||||
else if (target && target->IsFarVisible() && !target->ToPlayer())
|
||||
return MAX_VISIBILITY_DISTANCE;
|
||||
else if (ToPlayer()->GetCinematicMgr()->IsOnCinematic())
|
||||
return DEFAULT_VISIBILITY_INSTANCE;
|
||||
else
|
||||
return IsInWintergrasp() ? VISIBILITY_DISTANCE_LARGE : GetMap()->GetVisibilityRange();
|
||||
if (target)
|
||||
{
|
||||
if (target->IsVisibilityOverridden() && target->GetTypeId() == TYPEID_UNIT)
|
||||
{
|
||||
return *target->m_visibilityDistanceOverride;
|
||||
}
|
||||
else if (target->GetTypeId() == TYPEID_GAMEOBJECT)
|
||||
{
|
||||
if (IsInWintergrasp() && target->IsInWintergrasp())
|
||||
{
|
||||
return VISIBILITY_DIST_WINTERGRASP + VISIBILITY_INC_FOR_GOBJECTS;
|
||||
}
|
||||
else if (target->IsVisibilityOverridden())
|
||||
{
|
||||
return *target->m_visibilityDistanceOverride;
|
||||
}
|
||||
else if (ToPlayer()->GetCinematicMgr()->IsOnCinematic())
|
||||
{
|
||||
return DEFAULT_VISIBILITY_INSTANCE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetMap()->GetVisibilityRange() + VISIBILITY_INC_FOR_GOBJECTS;
|
||||
}
|
||||
}
|
||||
|
||||
return IsInWintergrasp() && target->IsInWintergrasp() ? VISIBILITY_DIST_WINTERGRASP : GetMap()->GetVisibilityRange();
|
||||
}
|
||||
return IsInWintergrasp() ? VISIBILITY_DIST_WINTERGRASP : GetMap()->GetVisibilityRange();
|
||||
}
|
||||
else if (ToCreature())
|
||||
{
|
||||
return ToCreature()->m_SightDistance;
|
||||
}
|
||||
else
|
||||
{
|
||||
return SIGHT_RANGE_UNIT;
|
||||
}
|
||||
}
|
||||
|
||||
if (ToDynObject() && isActiveObject())
|
||||
@@ -2044,8 +2077,11 @@ void Unit::BuildHeartBeatMsg(WorldPacket* data) const
|
||||
BuildMovementPacket(data);
|
||||
}
|
||||
|
||||
void WorldObject::SendMessageToSetInRange(WorldPacket const* data, float dist, bool /*self*/, Player const* skipped_rcvr) const
|
||||
void WorldObject::SendMessageToSetInRange(WorldPacket const* data, float dist, bool /*self*/, bool includeMargin, Player const* skipped_rcvr) const
|
||||
{
|
||||
dist += GetObjectSize();
|
||||
if (includeMargin)
|
||||
dist += VISIBILITY_COMPENSATION; // pussywizard: to ensure everyone receives all important packets
|
||||
Acore::MessageDistDeliverer notifier(this, data, dist, false, skipped_rcvr);
|
||||
Cell::VisitWorldObjects(this, notifier, dist);
|
||||
}
|
||||
@@ -2192,8 +2228,7 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!IsGridLoaded(pos.GetPositionX(), pos.GetPositionY()))
|
||||
EnsureGridLoaded(Cell(pos.GetPositionX(), pos.GetPositionY()));
|
||||
EnsureGridLoaded(Cell(pos.GetPositionX(), pos.GetPositionY()));
|
||||
if (!summon->Create(GenerateLowGuid<HighGuid::Unit>(), this, phase, entry, vehId, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()))
|
||||
{
|
||||
delete summon;
|
||||
@@ -2866,8 +2901,8 @@ void WorldObject::DestroyForNearbyPlayers()
|
||||
return;
|
||||
|
||||
std::list<Player*> targets;
|
||||
Acore::AnyPlayerInObjectRangeCheck check(this, GetVisibilityRange(), false);
|
||||
Acore::PlayerListSearcher<Acore::AnyPlayerInObjectRangeCheck> searcher(this, targets, check);
|
||||
Acore::AnyPlayerInObjectRangeCheck check(this, GetVisibilityRange() + VISIBILITY_COMPENSATION, false);
|
||||
Acore::PlayerListSearcherWithSharedVision<Acore::AnyPlayerInObjectRangeCheck> searcher(this, targets, check);
|
||||
Cell::VisitWorldObjects(this, searcher, GetVisibilityRange());
|
||||
for (std::list<Player*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
|
||||
{
|
||||
@@ -2887,7 +2922,7 @@ void WorldObject::DestroyForNearbyPlayers()
|
||||
}
|
||||
}
|
||||
|
||||
void WorldObject::UpdateObjectVisibility(bool /*forced*/)
|
||||
void WorldObject::UpdateObjectVisibility(bool /*forced*/, bool /*fromUpdate*/)
|
||||
{
|
||||
//updates object's visibility for nearby players
|
||||
Acore::VisibleChangesNotifier notifier(*this);
|
||||
@@ -2896,7 +2931,28 @@ void WorldObject::UpdateObjectVisibility(bool /*forced*/)
|
||||
|
||||
void WorldObject::AddToNotify(uint16 f)
|
||||
{
|
||||
m_notifyflags |= f;
|
||||
if (!(m_notifyflags & f))
|
||||
if (Unit* u = ToUnit())
|
||||
{
|
||||
if (f & NOTIFY_VISIBILITY_CHANGED)
|
||||
{
|
||||
uint32 EVENT_VISIBILITY_DELAY = u->FindMap() ? DynamicVisibilityMgr::GetVisibilityNotifyDelay(u->FindMap()->GetEntry()->map_type) : 1000;
|
||||
|
||||
uint32 diff = getMSTimeDiff(u->m_last_notify_mstime, GameTime::GetGameTimeMS().count());
|
||||
if (diff >= EVENT_VISIBILITY_DELAY / 2)
|
||||
EVENT_VISIBILITY_DELAY /= 2;
|
||||
else
|
||||
EVENT_VISIBILITY_DELAY -= diff;
|
||||
u->m_delayed_unit_relocation_timer = EVENT_VISIBILITY_DELAY;
|
||||
u->m_last_notify_mstime = GameTime::GetGameTimeMS().count() + EVENT_VISIBILITY_DELAY - 1;
|
||||
}
|
||||
else if (f & NOTIFY_AI_RELOCATION)
|
||||
{
|
||||
u->m_delayed_unit_ai_notify_timer = u->FindMap() ? DynamicVisibilityMgr::GetAINotifyDelay(u->FindMap()->GetEntry()->map_type) : 500;
|
||||
}
|
||||
|
||||
m_notifyflags |= f;
|
||||
}
|
||||
}
|
||||
|
||||
struct WorldObjectChangeAccumulator
|
||||
@@ -2949,7 +3005,7 @@ struct WorldObjectChangeAccumulator
|
||||
source = iter->GetSource();
|
||||
ObjectGuid guid = source->GetCasterGUID();
|
||||
|
||||
if (guid.IsPlayer())
|
||||
if (guid)
|
||||
{
|
||||
//Caster may be nullptr if DynObj is in removelist
|
||||
if (Player* caster = ObjectAccessor::FindPlayer(guid))
|
||||
|
||||
@@ -379,23 +379,14 @@ class MovableMapObject
|
||||
template<class T> friend class RandomMovementGenerator;
|
||||
|
||||
protected:
|
||||
MovableMapObject() : _moveState(MAP_OBJECT_CELL_MOVE_NONE)
|
||||
{
|
||||
_newPosition.Relocate(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
MovableMapObject() = default;
|
||||
|
||||
private:
|
||||
Cell _currentCell;
|
||||
[[nodiscard]] Cell const& GetCurrentCell() const { return _currentCell; }
|
||||
void SetCurrentCell(Cell const& cell) { _currentCell = cell; }
|
||||
|
||||
MapObjectCellMoveState _moveState;
|
||||
Position _newPosition;
|
||||
void SetNewCellPosition(float x, float y, float z, float o)
|
||||
{
|
||||
_moveState = MAP_OBJECT_CELL_MOVE_ACTIVE;
|
||||
_newPosition.Relocate(x, y, z, o);
|
||||
}
|
||||
Cell _currentCell;
|
||||
MapObjectCellMoveState _moveState{MAP_OBJECT_CELL_MOVE_NONE};
|
||||
};
|
||||
|
||||
class WorldObject : public Object, public WorldLocation
|
||||
@@ -488,9 +479,9 @@ public:
|
||||
|
||||
virtual void CleanupsBeforeDelete(bool finalCleanup = true); // used in destructor or explicitly before mass creature delete to remove cross-references to already deleted units
|
||||
|
||||
virtual void SendMessageToSet(WorldPacket const* data, bool self) const { if (IsInWorld()) SendMessageToSetInRange(data, GetVisibilityRange(), self); } // pussywizard!
|
||||
virtual void SendMessageToSetInRange(WorldPacket const* data, float dist, bool /*self*/, Player const* skipped_rcvr = nullptr) const; // pussywizard!
|
||||
virtual void SendMessageToSet(WorldPacket const* data, Player const* skipped_rcvr) const { if (IsInWorld()) SendMessageToSetInRange(data, GetVisibilityRange(), false, skipped_rcvr); } // pussywizard!
|
||||
virtual void SendMessageToSet(WorldPacket const* data, bool self) const { if (IsInWorld()) SendMessageToSetInRange(data, GetVisibilityRange(), self, true); } // pussywizard!
|
||||
virtual void SendMessageToSetInRange(WorldPacket const* data, float dist, bool /*self*/, bool includeMargin = false, Player const* skipped_rcvr = nullptr) const; // pussywizard!
|
||||
virtual void SendMessageToSet(WorldPacket const* data, Player const* skipped_rcvr) const { if (IsInWorld()) SendMessageToSetInRange(data, GetVisibilityRange(), false, true, skipped_rcvr); } // pussywizard!
|
||||
|
||||
virtual uint8 getLevelForTarget(WorldObject const* /*target*/) const { return 1; }
|
||||
|
||||
@@ -547,7 +538,7 @@ public:
|
||||
void GetDeadCreatureListInGrid(std::list<Creature*>& lList, float maxSearchRange, bool alive = false) const;
|
||||
|
||||
void DestroyForNearbyPlayers();
|
||||
virtual void UpdateObjectVisibility(bool forced = true);
|
||||
virtual void UpdateObjectVisibility(bool forced = true, bool fromUpdate = false);
|
||||
void BuildUpdate(UpdateDataMapType& data_map, UpdatePlayerSet& player_set) override;
|
||||
void GetCreaturesWithEntryInRange(std::list<Creature*>& creatureList, float radius, uint32 entry);
|
||||
|
||||
@@ -569,7 +560,6 @@ public:
|
||||
[[nodiscard]] bool isActiveObject() const { return m_isActive; }
|
||||
void setActive(bool isActiveObject);
|
||||
[[nodiscard]] bool IsFarVisible() const { return m_isFarVisible; }
|
||||
void SetFarVisible(bool on);
|
||||
[[nodiscard]] bool IsVisibilityOverridden() const { return m_visibilityDistanceOverride.has_value(); }
|
||||
void SetVisibilityDistanceOverride(VisibilityDistanceType type);
|
||||
void SetWorldObject(bool apply);
|
||||
@@ -578,7 +568,7 @@ public:
|
||||
|
||||
[[nodiscard]] bool IsInWintergrasp() const
|
||||
{
|
||||
return GetMapId() == 571 && GetZoneId() == 4197;
|
||||
return GetMapId() == 571 && GetPositionX() > 3733.33331f && GetPositionX() < 5866.66663f && GetPositionY() > 1599.99999f && GetPositionY() < 4799.99997f;
|
||||
}
|
||||
|
||||
#ifdef MAP_BASED_RAND_GEN
|
||||
|
||||
@@ -23,18 +23,23 @@
|
||||
#define CONTACT_DISTANCE 0.5f
|
||||
#define INTERACTION_DISTANCE 5.5f
|
||||
#define ATTACK_DISTANCE 5.0f
|
||||
#define VISIBILITY_COMPENSATION 15.0f // increase searchers
|
||||
#define INSPECT_DISTANCE 28.0f
|
||||
#define VISIBILITY_INC_FOR_GOBJECTS 30.0f // pussywizard
|
||||
#define SPELL_SEARCHER_COMPENSATION 30.0f // increase searchers size in case we have large npc near cell border
|
||||
#define TRADE_DISTANCE 11.11f
|
||||
#define MAX_VISIBILITY_DISTANCE SIZE_OF_GRIDS // max distance for visible objects, experimental
|
||||
#define MAX_VISIBILITY_DISTANCE 250.0f // max distance for visible objects, experimental
|
||||
#define SIGHT_RANGE_UNIT 50.0f
|
||||
#define MAX_SEARCHER_DISTANCE 150.0f // pussywizard: replace the use of MAX_VISIBILITY_DISTANCE in searchers, because MAX_VISIBILITY_DISTANCE is quite too big for this purpose
|
||||
#define VISIBILITY_DISTANCE_INFINITE 533.0f
|
||||
#define VISIBILITY_DISTANCE_GIGANTIC 400.0f
|
||||
#define VISIBILITY_DISTANCE_LARGE 200.0f
|
||||
#define VISIBILITY_DISTANCE_NORMAL 100.0f
|
||||
#define VISIBILITY_DISTANCE_SMALL 50.0f
|
||||
#define VISIBILITY_DISTANCE_TINY 25.0f
|
||||
#define DEFAULT_VISIBILITY_DISTANCE VISIBILITY_DISTANCE_NORMAL // default visible distance, 100 yards on continents
|
||||
#define DEFAULT_VISIBILITY_DISTANCE 100.0f // default visible distance, 100 yards on continents
|
||||
#define DEFAULT_VISIBILITY_INSTANCE 170.0f // default visible distance in instances, 170 yards
|
||||
#define VISIBILITY_DIST_WINTERGRASP 175.0f
|
||||
#define DEFAULT_VISIBILITY_BGARENAS 533.0f // default visible distance in BG/Arenas, roughly 533 yards
|
||||
|
||||
#define DEFAULT_WORLD_OBJECT_SIZE 0.388999998569489f // player size, also currently used (correctly?) for any non Unit world objects
|
||||
|
||||
@@ -134,7 +134,6 @@ class ObjectGuid
|
||||
ObjectGuid(HighGuid hi, uint32 entry, LowType counter) : _guid(counter ? uint64(counter) | (uint64(entry) << 24) | (uint64(hi) << 48) : 0) { }
|
||||
ObjectGuid(HighGuid hi, LowType counter) : _guid(counter ? uint64(counter) | (uint64(hi) << 48) : 0) { }
|
||||
|
||||
operator uint64() const { return _guid; }
|
||||
PackedGuidReader ReadAsPacked() { return PackedGuidReader(*this); }
|
||||
|
||||
void Set(uint64 guid) { _guid = guid; }
|
||||
|
||||
Reference in New Issue
Block a user