mirror of
https://github.com/araxiaonline/TrinityCore2.git
synced 2026-06-17 13:29:41 -04:00
*Massive cleanup (\n\n -> \n, *\n -> \n, cleanup for(...) to for (...), and some other cleanups by hand)
*Fix a possible crash in Spell::DoAllEffectOnTarget --HG-- branch : trunk
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "Common.h"
|
||||
#include "UpdateMask.h"
|
||||
#include "Opcodes.h"
|
||||
@@ -27,17 +26,13 @@
|
||||
#include "GridNotifiers.h"
|
||||
#include "CellImpl.h"
|
||||
#include "GridNotifiersImpl.h"
|
||||
|
||||
DynamicObject::DynamicObject() : WorldObject()
|
||||
{
|
||||
m_objectType |= TYPEMASK_DYNAMICOBJECT;
|
||||
m_objectTypeId = TYPEID_DYNAMICOBJECT;
|
||||
|
||||
m_updateFlag = (UPDATEFLAG_HIGHGUID | UPDATEFLAG_HAS_POSITION);
|
||||
|
||||
m_valuesCount = DYNAMICOBJECT_END;
|
||||
}
|
||||
|
||||
void DynamicObject::AddToWorld()
|
||||
{
|
||||
///- Register the dynamicObject for guid lookup
|
||||
@@ -47,7 +42,6 @@ void DynamicObject::AddToWorld()
|
||||
WorldObject::AddToWorld();
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicObject::RemoveFromWorld()
|
||||
{
|
||||
///- Remove the dynamicObject from the accessor
|
||||
@@ -69,7 +63,6 @@ void DynamicObject::RemoveFromWorld()
|
||||
ObjectAccessor::Instance().RemoveObject(this);
|
||||
}
|
||||
}
|
||||
|
||||
bool DynamicObject::Create(uint32 guidlow, Unit *caster, uint32 spellId, uint32 effMask, const Position &pos, int32 duration, float radius, bool active)
|
||||
{
|
||||
SetMap(caster->GetMap());
|
||||
@@ -79,9 +72,7 @@ bool DynamicObject::Create(uint32 guidlow, Unit *caster, uint32 spellId, uint32
|
||||
sLog.outError("DynamicObject (spell %u eff %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)",spellId,effMask,GetPositionX(),GetPositionY());
|
||||
return false;
|
||||
}
|
||||
|
||||
WorldObject::_Create(guidlow, HIGHGUID_DYNAMICOBJECT, caster->GetPhaseMask());
|
||||
|
||||
SetEntry(spellId);
|
||||
SetFloatValue( OBJECT_FIELD_SCALE_X, 1 );
|
||||
SetUInt64Value( DYNAMICOBJECT_CASTER, caster->GetGUID() );
|
||||
@@ -92,23 +83,19 @@ bool DynamicObject::Create(uint32 guidlow, Unit *caster, uint32 spellId, uint32
|
||||
SetFloatValue( DYNAMICOBJECT_POS_Y, pos.m_positionY );
|
||||
SetFloatValue( DYNAMICOBJECT_POS_Z, pos.m_positionZ );
|
||||
SetUInt32Value( DYNAMICOBJECT_CASTTIME, getMSTime() ); // new 2.4.0
|
||||
|
||||
m_aliveDuration = duration;
|
||||
m_radius = radius;
|
||||
m_effMask = effMask;
|
||||
m_spellId = spellId;
|
||||
m_updateTimer = 0;
|
||||
|
||||
m_isWorldObject = active;
|
||||
return true;
|
||||
}
|
||||
|
||||
Unit* DynamicObject::GetCaster() const
|
||||
{
|
||||
// can be not found in some cases
|
||||
return ObjectAccessor::GetUnit(*this, GetCasterGUID());
|
||||
}
|
||||
|
||||
void DynamicObject::Update(uint32 p_time)
|
||||
{
|
||||
// caster can be not in world at time dynamic object update, but dynamic object not yet deleted in Unit destructor
|
||||
@@ -118,14 +105,11 @@ void DynamicObject::Update(uint32 p_time)
|
||||
Delete();
|
||||
return;
|
||||
}
|
||||
|
||||
bool deleteThis = false;
|
||||
|
||||
if(m_aliveDuration > int32(p_time))
|
||||
m_aliveDuration -= p_time;
|
||||
else
|
||||
deleteThis = true;
|
||||
|
||||
/*
|
||||
// have radius and work as persistent effect
|
||||
if(m_radius)
|
||||
@@ -135,18 +119,14 @@ void DynamicObject::Update(uint32 p_time)
|
||||
Cell cell(p);
|
||||
cell.data.Part.reserved = ALL_DISTRICT;
|
||||
cell.SetNoCreate();
|
||||
|
||||
MaNGOS::DynamicObjectUpdater notifier(*this, caster);
|
||||
|
||||
TypeContainerVisitor<MaNGOS::DynamicObjectUpdater, WorldTypeMapContainer > world_object_notifier(notifier);
|
||||
TypeContainerVisitor<MaNGOS::DynamicObjectUpdater, GridTypeMapContainer > grid_object_notifier(notifier);
|
||||
|
||||
CellLock<GridReadGuard> cell_lock(cell, p);
|
||||
cell_lock->Visit(cell_lock, world_object_notifier, *GetMap(), *this, m_radius);
|
||||
cell_lock->Visit(cell_lock, grid_object_notifier, *GetMap(), *this, m_radius);
|
||||
}
|
||||
*/
|
||||
|
||||
if (m_effMask)
|
||||
{
|
||||
if (m_updateTimer < p_time)
|
||||
@@ -156,21 +136,18 @@ void DynamicObject::Update(uint32 p_time)
|
||||
m_updateTimer = 500; // is this official-like?
|
||||
} else m_updateTimer -= p_time;
|
||||
}
|
||||
|
||||
if (deleteThis)
|
||||
{
|
||||
caster->RemoveDynObjectWithGUID(GetGUID());
|
||||
Delete();
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicObject::Delete()
|
||||
{
|
||||
SendObjectDeSpawnAnim(GetGUID());
|
||||
RemoveFromWorld();
|
||||
AddObjectToRemoveList();
|
||||
}
|
||||
|
||||
void DynamicObject::Delay(int32 delaytime)
|
||||
{
|
||||
m_aliveDuration -= delaytime;
|
||||
@@ -178,7 +155,6 @@ void DynamicObject::Delay(int32 delaytime)
|
||||
if (*iunit)
|
||||
(*iunit)->DelayAura(m_spellId, GetCaster()->GetGUID(), delaytime);
|
||||
}
|
||||
|
||||
bool DynamicObject::isVisibleForInState(Player const* u, bool inVisibleList) const
|
||||
{
|
||||
return IsInWorld() && u->IsInWorld()
|
||||
|
||||
Reference in New Issue
Block a user