Skip to content

Commit

Permalink
[11787] Clean up some redundant GetSpellDuration calls
Browse files Browse the repository at this point in the history
  • Loading branch information
zergtmn committed Sep 5, 2011
1 parent 996d214 commit 0390d28
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
34 changes: 14 additions & 20 deletions src/game/SpellEffects.cpp
Expand Up @@ -1389,7 +1389,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx)
// set loot recipient, prevent re-use same target
pCreature->SetLootRecipient(m_caster);

pCreature->ForcedDespawn(GetSpellDuration(m_spellInfo));
pCreature->ForcedDespawn(m_duration);

// EFFECT_INDEX_2 has 0 miscvalue for effect 134, doing the killcredit here instead (only one known case exist where 0)
((Player*)m_caster)->KilledMonster(pCreature->GetCreatureInfo(), pCreature->GetObjectGuid());
Expand Down Expand Up @@ -1589,7 +1589,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx)
if (const SpellEntry *pSpell = sSpellStore.LookupEntry(45991))
{
unitTarget->CastSpell(unitTarget, pSpell, true);
((Creature*)unitTarget)->ForcedDespawn(GetSpellDuration(pSpell) + 1);
((Creature*)unitTarget)->ForcedDespawn(m_duration);
}

return;
Expand Down Expand Up @@ -4971,12 +4971,11 @@ void Spell::EffectAddFarsight(SpellEffectIndex eff_idx)
if(m_caster->GetTypeId() != TYPEID_PLAYER)
return;

int32 duration = GetSpellDuration(m_spellInfo);
DynamicObject* dynObj = new DynamicObject;

// set radius to 0: spell not expected to work as persistent aura
if(!dynObj->Create(m_caster->GetMap()->GenerateLocalLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster,
m_spellInfo->Id, eff_idx, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, 0, DYNAMIC_OBJECT_FARSIGHT_FOCUS))
m_spellInfo->Id, eff_idx, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, m_duration, 0, DYNAMIC_OBJECT_FARSIGHT_FOCUS))
{
delete dynObj;
return;
Expand Down Expand Up @@ -5014,8 +5013,7 @@ void Spell::DoSummonWild(SpellEffectIndex eff_idx, uint32 forceFaction)
float center_z = m_targets.m_destZ;

float radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[eff_idx]));
int32 duration = GetSpellDuration(m_spellInfo);
TempSummonType summonType = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_OR_DEAD_DESPAWN;
TempSummonType summonType = (m_duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_OR_DEAD_DESPAWN;

int32 amount = damage > 0 ? damage : 1;

Expand Down Expand Up @@ -5053,7 +5051,7 @@ void Spell::DoSummonWild(SpellEffectIndex eff_idx, uint32 forceFaction)
}
}

if(Creature *summon = m_caster->SummonCreature(creature_entry, px, py, pz, m_caster->GetOrientation(), summonType, duration))
if (Creature *summon = m_caster->SummonCreature(creature_entry, px, py, pz, m_caster->GetOrientation(), summonType, m_duration))
{
summon->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id);

Expand Down Expand Up @@ -6138,9 +6136,7 @@ void Spell::EffectSummonObjectWild(SpellEffectIndex eff_idx)
return;
}

int32 duration = GetSpellDuration(m_spellInfo);

pGameObj->SetRespawnTime(duration > 0 ? duration/IN_MILLISECONDS : 0);
pGameObj->SetRespawnTime(m_duration > 0 ? m_duration/IN_MILLISECONDS : 0);
pGameObj->SetSpellId(m_spellInfo->Id);

// Wild object not have owner and check clickable by players
Expand Down Expand Up @@ -7825,8 +7821,8 @@ void Spell::EffectDuel(SpellEffectIndex eff_idx)

pGameObj->SetUInt32Value(GAMEOBJECT_FACTION, m_caster->getFaction() );
pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel()+1 );
int32 duration = GetSpellDuration(m_spellInfo);
pGameObj->SetRespawnTime(duration > 0 ? duration/IN_MILLISECONDS : 0);

pGameObj->SetRespawnTime(m_duration > 0 ? m_duration/IN_MILLISECONDS : 0);
pGameObj->SetSpellId(m_spellInfo->Id);

m_caster->AddGameObject(pGameObj);
Expand Down Expand Up @@ -8048,7 +8044,7 @@ void Spell::EffectEnchantHeldItem(SpellEffectIndex eff_idx)
if (m_spellInfo->EffectMiscValue[eff_idx])
{
uint32 enchant_id = m_spellInfo->EffectMiscValue[eff_idx];
int32 duration = GetSpellDuration(m_spellInfo); // Try duration index first...
int32 duration = m_duration; // Try duration index first...
if(!duration)
duration = m_currentBasePoints[eff_idx]; // Base points after...
if(!duration)
Expand Down Expand Up @@ -8188,9 +8184,8 @@ void Spell::EffectSummonObject(SpellEffectIndex eff_idx)
return;
}

pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL,m_caster->getLevel());
int32 duration = GetSpellDuration(m_spellInfo);
pGameObj->SetRespawnTime(duration > 0 ? duration/IN_MILLISECONDS : 0);
pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel());
pGameObj->SetRespawnTime(m_duration > 0 ? m_duration/IN_MILLISECONDS : 0);
pGameObj->SetSpellId(m_spellInfo->Id);
m_caster->AddGameObject(pGameObj);

Expand Down Expand Up @@ -8521,9 +8516,8 @@ void Spell::DoSummonCritter(SpellEffectIndex eff_idx, uint32 forceFaction)
// some mini-pets have quests

// set timer for unsummon
int32 duration = GetSpellDuration(m_spellInfo);
if(duration > 0)
critter->SetDuration(duration);
if(m_duration > 0)
critter->SetDuration(m_duration);

m_caster->SetMiniPet(critter);

Expand Down Expand Up @@ -8797,7 +8791,7 @@ void Spell::EffectTransmitted(SpellEffectIndex eff_idx)
return;
}

int32 duration = GetSpellDuration(m_spellInfo);
int32 duration = m_duration;

switch(goinfo->type)
{
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "11786"
#define REVISION_NR "11787"
#endif // __REVISION_NR_H__

0 comments on commit 0390d28

Please sign in to comment.