aboutsummaryrefslogtreecommitdiff
path: root/src/game/TemporarySummon.cpp
diff options
context:
space:
mode:
authormaximius <none@none>2009-10-17 15:35:07 -0700
committermaximius <none@none>2009-10-17 15:35:07 -0700
commit26b5e033ffde3d161382fc9addbfa99738379641 (patch)
treea344f369ca32945f787a02dee35c3dbe342bed7e /src/game/TemporarySummon.cpp
parentf21f47005dcb6b76e1abc9f35fbcd03eed191bff (diff)
*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
Diffstat (limited to 'src/game/TemporarySummon.cpp')
-rw-r--r--src/game/TemporarySummon.cpp52
1 files changed, 0 insertions, 52 deletions
diff --git a/src/game/TemporarySummon.cpp b/src/game/TemporarySummon.cpp
index 0b31eea9707..05ae270dabd 100644
--- a/src/game/TemporarySummon.cpp
+++ b/src/game/TemporarySummon.cpp
@@ -17,13 +17,11 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-
#include "Log.h"
#include "ObjectAccessor.h"
#include "CreatureAI.h"
#include "ObjectMgr.h"
#include "TemporarySummon.h"
-
TempSummon::TempSummon(SummonPropertiesEntry const *properties, Unit *owner) :
Creature(), m_type(TEMPSUMMON_MANUAL_DESPAWN), m_timer(0), m_lifetime(0)
, m_Properties(properties)
@@ -31,16 +29,13 @@ Creature(), m_type(TEMPSUMMON_MANUAL_DESPAWN), m_timer(0), m_lifetime(0)
m_summonerGUID = owner ? owner->GetGUID() : 0;
m_unitTypeMask |= UNIT_MASK_SUMMON;
}
-
Unit* TempSummon::GetSummoner() const
{
return m_summonerGUID ? ObjectAccessor::GetUnit(*this, m_summonerGUID) : NULL;
}
-
void TempSummon::Update( uint32 diff )
{
Creature::Update(diff);
-
if (m_deathState == DEAD)
{
UnSummon();
@@ -57,7 +52,6 @@ void TempSummon::Update( uint32 diff )
UnSummon();
return;
}
-
m_timer -= diff;
break;
}
@@ -70,15 +64,12 @@ void TempSummon::Update( uint32 diff )
UnSummon();
return;
}
-
m_timer -= diff;
}
else if (m_timer != m_lifetime)
m_timer = m_lifetime;
-
break;
}
-
case TEMPSUMMON_CORPSE_TIMED_DESPAWN:
{
if ( m_deathState == CORPSE)
@@ -88,7 +79,6 @@ void TempSummon::Update( uint32 diff )
UnSummon();
return;
}
-
m_timer -= diff;
}
break;
@@ -101,7 +91,6 @@ void TempSummon::Update( uint32 diff )
UnSummon();
return;
}
-
break;
}
case TEMPSUMMON_DEAD_DESPAWN:
@@ -121,7 +110,6 @@ void TempSummon::Update( uint32 diff )
UnSummon();
return;
}
-
if (!isInCombat())
{
if (m_timer <= diff)
@@ -144,7 +132,6 @@ void TempSummon::Update( uint32 diff )
UnSummon();
return;
}
-
if (!isInCombat() && isAlive() )
{
if (m_timer <= diff)
@@ -165,19 +152,14 @@ void TempSummon::Update( uint32 diff )
break;
}
}
-
void TempSummon::InitStats(uint32 duration)
{
assert(!isPet());
-
m_timer = duration;
m_lifetime = duration;
-
if(m_type == TEMPSUMMON_MANUAL_DESPAWN)
m_type = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN;
-
Unit *owner = GetSummoner();
-
if(owner && isTrigger() && m_spells[0])
{
setFaction(owner->getFaction());
@@ -185,10 +167,8 @@ void TempSummon::InitStats(uint32 duration)
if(owner->GetTypeId() == TYPEID_PLAYER)
m_ControlledByPlayer = true;
}
-
if(!m_Properties)
return;
-
if(owner)
{
if(uint32 slot = m_Properties->Slot)
@@ -202,13 +182,11 @@ void TempSummon::InitStats(uint32 duration)
owner->m_SummonSlot[slot] = GetGUID();
}
}
-
if(m_Properties->Faction)
setFaction(m_Properties->Faction);
else if(IsVehicle()) // properties should be vehicle
setFaction(owner->getFaction());
}
-
void TempSummon::InitSummon()
{
Unit* owner = GetSummoner();
@@ -220,12 +198,10 @@ void TempSummon::InitSummon()
AI()->IsSummonedBy(owner);
}
}
-
void TempSummon::SetTempSummonType(TempSummonType type)
{
m_type = type;
}
-
void TempSummon::UnSummon()
{
//assert(!isPet());
@@ -235,19 +211,15 @@ void TempSummon::UnSummon()
assert(!IsInWorld());
return;
}
-
Unit* owner = GetSummoner();
if(owner && owner->GetTypeId() == TYPEID_UNIT && ((Creature*)owner)->IsAIEnabled)
((Creature*)owner)->AI()->SummonedCreatureDespawn(this);
-
AddObjectToRemoveList();
}
-
void TempSummon::RemoveFromWorld()
{
if(!IsInWorld())
return;
-
if(m_Properties)
{
if(uint32 slot = m_Properties->Slot)
@@ -259,17 +231,13 @@ void TempSummon::RemoveFromWorld()
}
}
}
-
//if(GetOwnerGUID())
// sLog.outError("Unit %u has owner guid when removed from world", GetEntry());
-
Creature::RemoveFromWorld();
}
-
void TempSummon::SaveToDB()
{
}
-
Minion::Minion(SummonPropertiesEntry const *properties, Unit *owner) : TempSummon(properties, owner)
, m_owner(owner)
{
@@ -277,33 +245,25 @@ Minion::Minion(SummonPropertiesEntry const *properties, Unit *owner) : TempSummo
m_unitTypeMask |= UNIT_MASK_MINION;
m_followAngle = PET_FOLLOW_ANGLE;
}
-
void Minion::InitStats(uint32 duration)
{
TempSummon::InitStats(duration);
-
SetReactState(REACT_PASSIVE);
-
SetCreatorGUID(m_owner->GetGUID());
setFaction(m_owner->getFaction());
-
m_owner->SetMinion(this, true);
}
-
void Minion::RemoveFromWorld()
{
if(!IsInWorld())
return;
-
m_owner->SetMinion(this, false);
TempSummon::RemoveFromWorld();
}
-
bool Minion::IsGuardianPet() const
{
return isPet() || m_Properties && m_Properties->Category == SUMMON_CATEGORY_PET;
}
-
Guardian::Guardian(SummonPropertiesEntry const *properties, Unit *owner) : Minion(properties, owner)
, m_bonusdamage(0)
{
@@ -314,50 +274,40 @@ Guardian::Guardian(SummonPropertiesEntry const *properties, Unit *owner) : Minio
InitCharmInfo();
}
}
-
void Guardian::InitStats(uint32 duration)
{
Minion::InitStats(duration);
-
InitStatsForLevel(m_owner->getLevel());
-
if(m_owner->GetTypeId() == TYPEID_PLAYER && HasUnitTypeMask(UNIT_MASK_CONTROLABLE_GUARDIAN))
m_charmInfo->InitCharmCreateSpells();
-
SetReactState(REACT_AGGRESSIVE);
}
-
void Guardian::InitSummon()
{
TempSummon::InitSummon();
-
if(m_owner->GetTypeId() == TYPEID_PLAYER
&& m_owner->GetMinionGUID() == GetGUID()
&& !m_owner->GetCharmGUID())
((Player*)m_owner)->CharmSpellInitialize();
}
-
Puppet::Puppet(SummonPropertiesEntry const *properties, Unit *owner) : Minion(properties, owner)
{
assert(owner->GetTypeId() == TYPEID_PLAYER);
m_owner = (Player*)owner;
m_unitTypeMask |= UNIT_MASK_PUPPET;
}
-
void Puppet::InitStats(uint32 duration)
{
Minion::InitStats(duration);
SetLevel(m_owner->getLevel());
SetReactState(REACT_PASSIVE);
}
-
void Puppet::InitSummon()
{
Minion::InitSummon();
if (!SetCharmedBy(m_owner, CHARM_TYPE_POSSESS))
assert(false);
}
-
void Puppet::Update(uint32 time)
{
Minion::Update(time);
@@ -371,12 +321,10 @@ void Puppet::Update(uint32 time)
}
}
}
-
void Puppet::RemoveFromWorld()
{
if(!IsInWorld())
return;
-
RemoveCharmedBy(NULL);
Minion::RemoveFromWorld();
}