Skip to content
Permalink
Browse files

Core/Grids: Correctly address Brazier crash issue

based on work done by talamortis

Co-Authored-By: Lee <talamortis@users.noreply.github.com>
  • Loading branch information...
AbraKabastard and talamortis committed May 27, 2019
1 parent 2842890 commit e930e114f32b5c02f3f09c53ae96af9bcc2afb7b
Showing with 64 additions and 103 deletions.
  1. +1 −0 sql/updates/world/2019_05_27_brazier.sql
  2. +45 −31 src/game/GridNotifiers.cpp
  3. +18 −72 src/game/Object.h
@@ -0,0 +1 @@
UPDATE `gameobject_template` SET `data2` = 2048 WHERE `entry` = 185968;
@@ -40,10 +40,25 @@ VisibleNotifier::SendToSelf()
{
vis_guids.erase((*itr)->GetGUID());

i_player.UpdateVisibilityOf((*itr), i_data, i_visibleNow);

if (!(*itr)->isNeedNotify(NOTIFY_VISIBILITY_CHANGED))
(*itr)->UpdateVisibilityOf(&i_player);
switch ((*itr)->GetTypeId())
{
case TYPEID_GAMEOBJECT:
i_player.UpdateVisibilityOf((*itr)->ToGameObject(), i_data, i_visibleNow);
break;
case TYPEID_PLAYER:
i_player.UpdateVisibilityOf((*itr)->ToPlayer(), i_data, i_visibleNow);
if (!(*itr)->isNeedNotify(NOTIFY_VISIBILITY_CHANGED))
(*itr)->ToPlayer()->UpdateVisibilityOf(&i_player);
break;
case TYPEID_UNIT:
i_player.UpdateVisibilityOf((*itr)->ToCreature(), i_data, i_visibleNow);
break;
case TYPEID_DYNAMICOBJECT:
i_player.UpdateVisibilityOf((*itr)->ToDynObject(), i_data, i_visibleNow);
break;
default:
break;
}
}
}

@@ -54,9 +69,9 @@ VisibleNotifier::SendToSelf()

if (IS_PLAYER_GUID(*it))
{
Player* plr = ObjectAccessor::FindPlayer(*it, true);
if (plr && !plr->isNeedNotify(NOTIFY_VISIBILITY_CHANGED))
plr->UpdateVisibilityOf(&i_player);
Player* player = ObjectAccessor::FindPlayer(*it, true);
if (player && !player->isNeedNotify(NOTIFY_VISIBILITY_CHANGED))
player->UpdateVisibilityOf(&i_player);
}
}

@@ -71,8 +86,7 @@ VisibleNotifier::SendToSelf()
i_player.SendAuraDurationsForTarget(*it);
}

void
VisibleChangesNotifier::Visit(PlayerMapType& m)
void VisibleChangesNotifier::Visit(PlayerMapType& m)
{
for (PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
{
@@ -81,33 +95,35 @@ VisibleChangesNotifier::Visit(PlayerMapType& m)

iter->GetSource()->UpdateVisibilityOf(&i_object);

if (!iter->GetSource()->GetSharedVisionList().empty())
if (iter->GetSource()->HasSharedVision())
{
for (SharedVisionList::const_iterator i = iter->GetSource()->GetSharedVisionList().begin();
i != iter->GetSource()->GetSharedVisionList().end(); ++i)
i != iter->GetSource()->GetSharedVisionList().end(); ++i)
{
if ((*i)->m_seer == iter->GetSource())
(*i)->UpdateVisibilityOf(&i_object);
}
}
}
}

void
VisibleChangesNotifier::Visit(CreatureMapType& m)
void VisibleChangesNotifier::Visit(CreatureMapType& m)
{
for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
if (!iter->GetSource()->GetSharedVisionList().empty())
if (iter->GetSource()->HasSharedVision())
for (SharedVisionList::const_iterator i = iter->GetSource()->GetSharedVisionList().begin();
i != iter->GetSource()->GetSharedVisionList().end(); ++i)
i != iter->GetSource()->GetSharedVisionList().end(); ++i)
if ((*i)->m_seer == iter->GetSource())
(*i)->UpdateVisibilityOf(&i_object);
}

void
VisibleChangesNotifier::Visit(DynamicObjectMapType& m)
void VisibleChangesNotifier::Visit(DynamicObjectMapType& m)
{
for (DynamicObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
if (iter->GetSource()->GetTypeId() == TYPEID_PLAYER) // better check to see if the target it a player.
if (Player* caster = (Player*)iter->GetSource()->GetCaster())
if (caster->m_seer == iter->GetSource())
caster->UpdateVisibilityOf(&i_object);
if (Unit* caster = iter->GetSource()->GetCaster())
if (Player* player = caster->ToPlayer())
if (player->m_seer == iter->GetSource())
player->UpdateVisibilityOf(&i_object);
}

inline void CreatureUnitRelocationWorker(Creature* c, Unit* u)
@@ -332,7 +348,7 @@ void MessageDistDeliverer::Visit(PlayerMapType& m)
continue;

// Send packet to all who are sharing the player's vision
if (!target->GetSharedVisionList().empty())
if (target->HasSharedVision())
{
SharedVisionList::const_iterator i = target->GetSharedVisionList().begin();
for (; i != target->GetSharedVisionList().end(); ++i)
@@ -357,10 +373,10 @@ void MessageDistDeliverer::Visit(CreatureMapType& m)
continue;

// Send packet to all who are sharing the creature's vision
if (!target->GetSharedVisionList().empty())
if (target->HasSharedVision())
{
SharedVisionList::const_iterator i = iter->GetSource()->GetSharedVisionList().begin();
for (; i != iter->GetSource()->GetSharedVisionList().end(); ++i)
SharedVisionList::const_iterator i = target->GetSharedVisionList().begin();
for (; i != target->GetSharedVisionList().end(); ++i)
if ((*i)->m_seer == target)
SendPacket(*i);
}
@@ -378,12 +394,12 @@ void MessageDistDeliverer::Visit(DynamicObjectMapType& m)
if (target->GetExactDist2dSq(i_source) > i_distSq)
continue;

if (target->GetTypeId() == TYPEID_PLAYER)
if (Unit* caster = target->GetCaster())
{
// Send packet back to the caster if the caster has vision of dynamic object
Player* caster = target->GetCaster()->ToPlayer();
if (caster && caster->m_seer == target)
SendPacket(caster);
Player* player = caster->ToPlayer();
if (player && player->m_seer == target)
SendPacket(player);
}
}
}
@@ -392,10 +408,8 @@ template<class T> void
ObjectUpdater::Visit(GridRefManager<T>& m)
{
for (typename GridRefManager<T>::iterator iter = m.begin(); iter != m.end(); ++iter)
{
if (iter->GetSource()->IsInWorld())
iter->GetSource()->Update(i_timeDiff);
}
}

bool CannibalizeObjectCheck::operator()(Corpse* u)
@@ -174,62 +174,23 @@ class Object
ClearUpdateMask(true);
}

const uint64& GetGUID() const
{
return GetUInt64Value(0);
}
uint32 GetGUIDLow() const
{
return GUID_LOPART(GetUInt64Value(0));
}
uint32 GetGUIDMid() const
{
return GUID_ENPART(GetUInt64Value(0));
}
uint32 GetGUIDHigh() const
{
return GUID_HIPART(GetUInt64Value(0));
}
PackedGuid const& GetPackGUID() const
{
return m_PackGUID;
}
ObjectGuid const& GetObjectGUID() const
{
return GetGuidValue(OBJECT_FIELD_GUID);
}
uint64 GetGUID() const { return GetUInt64Value(0); }
uint32 GetGUIDLow() const { return GUID_LOPART(GetUInt64Value(0)); }
uint32 GetGUIDMid() const { return GUID_ENPART(GetUInt64Value(0)); }
uint32 GetGUIDHigh() const { return GUID_HIPART(GetUInt64Value(0)); }
PackedGuid const& GetPackGUID() const { return m_PackGUID; }
ObjectGuid const& GetObjectGUID() const { return GetGuidValue(OBJECT_FIELD_GUID); }

std::string GetGuidStr() const
{
return GetObjectGUID().GetString();
}
std::string GetGuidStr() const { return GetObjectGUID().GetString(); }

uint32 GetEntry() const
{
return GetUInt32Value(OBJECT_FIELD_ENTRY);
}
void SetEntry(uint32 entry)
{
SetUInt32Value(OBJECT_FIELD_ENTRY, entry);
}
uint32 GetEntry() const { return GetUInt32Value(OBJECT_FIELD_ENTRY); }
void SetEntry(uint32 entry) { SetUInt32Value(OBJECT_FIELD_ENTRY, entry); }

float GetObjectScale() const
{
return GetFloatValue(OBJECT_FIELD_SCALE_X);
}
void SetObjectScale(float scale)
{
SetFloatValue(OBJECT_FIELD_SCALE_X, scale);
}
float GetObjectScale() const { return GetFloatValue(OBJECT_FIELD_SCALE_X); }
void SetObjectScale(float scale) { SetFloatValue(OBJECT_FIELD_SCALE_X, scale); }

uint8 GetTypeId() const
{
return m_objectTypeId;
}
bool isType(uint16 mask) const
{
return (mask & m_objectType);
}
uint8 GetTypeId() const { return m_objectTypeId; }
bool isType(uint16 mask) const { return (mask & m_objectType); }

virtual void BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) const;
void SendUpdateToPlayer(Player* player);
@@ -854,10 +815,7 @@ class WorldObject : public Object, public WorldLocation
virtual void SetMap(Map* map);
virtual void ResetMap();
Map* GetMap() const { ASSERT(m_currMap); return m_currMap; }
Map* FindMap() const
{
return m_currMap;
}
Map* FindMap() const { return m_currMap; }
//used to check all object's GetMap() calls when object is not in world!

//this function should be removed in nearest time...
@@ -897,18 +855,9 @@ class WorldObject : public Object, public WorldLocation
void BuildUpdate(UpdateDataMapType&) override;

//relocation and visibility system functions
void AddToNotify(uint16 f)
{
m_notifyflags |= f;
}
bool isNeedNotify(uint16 f) const
{
return m_notifyflags & f;
}
uint16 GetNotifyFlags() const
{
return m_notifyflags;
}
void AddToNotify(uint16 f) { m_notifyflags |= f; }
bool isNeedNotify(uint16 f) const { return (m_notifyflags & f) != 0; }
uint16 GetNotifyFlags() const { return m_notifyflags; }
bool NotifyExecuted(uint16 f) const
{
return m_executed_notifies & f;
@@ -923,10 +872,7 @@ class WorldObject : public Object, public WorldLocation
m_executed_notifies = 0;
}

bool isActiveObject() const
{
return m_isActive;
}
bool isActiveObject() const { return m_isActive; }
void setActive(bool isActiveObject);
bool IsVisibilityOverridden() const { return m_visibilityDistanceOverride != 0; }
void SetVisibilityDistanceOverride(VisibilityDistanceType type);

0 comments on commit e930e11

Please sign in to comment.
You can’t perform that action at this time.