mirror of
https://github.com/mangosfour/server.git
synced 2025-12-16 22:37:02 +00:00
[11322] Get rid of redundant CalculateSpellDuration calls, calculate once in Spell::prepare
Also fix despawn time calculation of dynamic objects.
This commit is contained in:
parent
28375e295e
commit
0dfcbf8051
4 changed files with 16 additions and 25 deletions
|
|
@ -388,6 +388,7 @@ Spell::Spell( Unit* caster, SpellEntry const *info, bool triggered, ObjectGuid o
|
||||||
m_powerCost = 0; // setup to correct value in Spell::prepare, don't must be used before.
|
m_powerCost = 0; // setup to correct value in Spell::prepare, don't must be used before.
|
||||||
m_casttime = 0; // setup to correct value in Spell::prepare, don't must be used before.
|
m_casttime = 0; // setup to correct value in Spell::prepare, don't must be used before.
|
||||||
m_timer = 0; // will set to cast time in prepare
|
m_timer = 0; // will set to cast time in prepare
|
||||||
|
m_duration = 0;
|
||||||
|
|
||||||
m_needAliveTargetMask = 0;
|
m_needAliveTargetMask = 0;
|
||||||
|
|
||||||
|
|
@ -2812,6 +2813,7 @@ void Spell::prepare(SpellCastTargets const* targets, Aura* triggeredByAura)
|
||||||
|
|
||||||
// calculate cast time (calculated after first CheckCast check to prevent charge counting for first CheckCast fail)
|
// calculate cast time (calculated after first CheckCast check to prevent charge counting for first CheckCast fail)
|
||||||
m_casttime = GetSpellCastTime(m_spellInfo, this);
|
m_casttime = GetSpellCastTime(m_spellInfo, this);
|
||||||
|
m_duration = CalculateSpellDuration(m_spellInfo, m_caster);
|
||||||
|
|
||||||
// set timer base at cast time
|
// set timer base at cast time
|
||||||
ReSetTimer();
|
ReSetTimer();
|
||||||
|
|
@ -3153,15 +3155,10 @@ void Spell::cast(bool skipCheck)
|
||||||
void Spell::handle_immediate()
|
void Spell::handle_immediate()
|
||||||
{
|
{
|
||||||
// start channeling if applicable
|
// start channeling if applicable
|
||||||
if(IsChanneledSpell(m_spellInfo))
|
if (IsChanneledSpell(m_spellInfo) && m_duration > 0)
|
||||||
{
|
|
||||||
int32 duration = CalculateSpellDuration(m_spellInfo, m_caster);
|
|
||||||
|
|
||||||
if (duration > 0)
|
|
||||||
{
|
{
|
||||||
m_spellState = SPELL_STATE_CASTING;
|
m_spellState = SPELL_STATE_CASTING;
|
||||||
SendChannelStart(duration);
|
SendChannelStart(m_duration);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// process immediate effects (items, ground, etc.) also initialize some variables
|
// process immediate effects (items, ground, etc.) also initialize some variables
|
||||||
|
|
|
||||||
|
|
@ -513,6 +513,7 @@ class Spell
|
||||||
WeaponAttackType m_attackType; // For weapon based attack
|
WeaponAttackType m_attackType; // For weapon based attack
|
||||||
uint32 m_powerCost; // Calculated spell cost initialized only in Spell::prepare
|
uint32 m_powerCost; // Calculated spell cost initialized only in Spell::prepare
|
||||||
int32 m_casttime; // Calculated spell cast time initialized only in Spell::prepare
|
int32 m_casttime; // Calculated spell cast time initialized only in Spell::prepare
|
||||||
|
int32 m_duration;
|
||||||
bool m_canReflect; // can reflect this spell?
|
bool m_canReflect; // can reflect this spell?
|
||||||
bool m_autoRepeat;
|
bool m_autoRepeat;
|
||||||
uint8 m_runesState;
|
uint8 m_runesState;
|
||||||
|
|
|
||||||
|
|
@ -3995,9 +3995,8 @@ void Spell::EffectPersistentAA(SpellEffectIndex eff_idx)
|
||||||
if (Player* modOwner = m_caster->GetSpellModOwner())
|
if (Player* modOwner = m_caster->GetSpellModOwner())
|
||||||
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RADIUS, radius);
|
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RADIUS, radius);
|
||||||
|
|
||||||
int32 duration = GetSpellDuration(m_spellInfo);
|
|
||||||
DynamicObject* dynObj = new DynamicObject;
|
DynamicObject* dynObj = new DynamicObject;
|
||||||
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, radius))
|
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, m_duration, radius))
|
||||||
{
|
{
|
||||||
delete dynObj;
|
delete dynObj;
|
||||||
return;
|
return;
|
||||||
|
|
@ -4514,19 +4513,15 @@ void Spell::DoSummon(SpellEffectIndex eff_idx)
|
||||||
uint32 level = m_caster->getLevel();
|
uint32 level = m_caster->getLevel();
|
||||||
Pet* spawnCreature = new Pet(SUMMON_PET);
|
Pet* spawnCreature = new Pet(SUMMON_PET);
|
||||||
|
|
||||||
int32 duration = CalculateSpellDuration(m_spellInfo, m_caster);
|
|
||||||
|
|
||||||
if (m_caster->GetTypeId()==TYPEID_PLAYER && spawnCreature->LoadPetFromDB((Player*)m_caster,pet_entry))
|
if (m_caster->GetTypeId()==TYPEID_PLAYER && spawnCreature->LoadPetFromDB((Player*)m_caster,pet_entry))
|
||||||
{
|
{
|
||||||
// Summon in dest location
|
// Summon in dest location
|
||||||
if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION)
|
if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION)
|
||||||
spawnCreature->Relocate(m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, -m_caster->GetOrientation());
|
spawnCreature->Relocate(m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, -m_caster->GetOrientation());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// set timer for unsummon
|
// set timer for unsummon
|
||||||
if (duration > 0)
|
if (m_duration > 0)
|
||||||
spawnCreature->SetDuration(duration);
|
spawnCreature->SetDuration(m_duration);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -4549,8 +4544,8 @@ void Spell::DoSummon(SpellEffectIndex eff_idx)
|
||||||
spawnCreature->SetSummonPoint(pos);
|
spawnCreature->SetSummonPoint(pos);
|
||||||
|
|
||||||
// set timer for unsummon
|
// set timer for unsummon
|
||||||
if (duration > 0)
|
if (m_duration > 0)
|
||||||
spawnCreature->SetDuration(duration);
|
spawnCreature->SetDuration(m_duration);
|
||||||
|
|
||||||
spawnCreature->SetOwnerGuid(m_caster->GetObjectGuid());
|
spawnCreature->SetOwnerGuid(m_caster->GetObjectGuid());
|
||||||
spawnCreature->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
|
spawnCreature->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
|
||||||
|
|
@ -4966,7 +4961,6 @@ void Spell::DoSummonGuardian(SpellEffectIndex eff_idx, uint32 forceFaction)
|
||||||
float center_z = m_targets.m_destZ;
|
float center_z = m_targets.m_destZ;
|
||||||
|
|
||||||
float radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[eff_idx]));
|
float radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[eff_idx]));
|
||||||
int32 duration = CalculateSpellDuration(m_spellInfo, m_caster);
|
|
||||||
|
|
||||||
int32 amount = damage > 0 ? damage : 1;
|
int32 amount = damage > 0 ? damage : 1;
|
||||||
|
|
||||||
|
|
@ -5003,8 +4997,8 @@ void Spell::DoSummonGuardian(SpellEffectIndex eff_idx, uint32 forceFaction)
|
||||||
|
|
||||||
spawnCreature->SetSummonPoint(pos);
|
spawnCreature->SetSummonPoint(pos);
|
||||||
|
|
||||||
if (duration > 0)
|
if (m_duration > 0)
|
||||||
spawnCreature->SetDuration(duration);
|
spawnCreature->SetDuration(m_duration);
|
||||||
|
|
||||||
//spawnCreature->SetName(""); // generated by client
|
//spawnCreature->SetName(""); // generated by client
|
||||||
spawnCreature->SetOwnerGuid(m_caster->GetObjectGuid());
|
spawnCreature->SetOwnerGuid(m_caster->GetObjectGuid());
|
||||||
|
|
@ -7637,8 +7631,7 @@ void Spell::DoSummonTotem(SpellEffectIndex eff_idx, uint8 slot_dbc)
|
||||||
pTotem->SetOwner(m_caster);
|
pTotem->SetOwner(m_caster);
|
||||||
pTotem->SetTypeBySummonSpell(m_spellInfo); // must be after Create call where m_spells initialized
|
pTotem->SetTypeBySummonSpell(m_spellInfo); // must be after Create call where m_spells initialized
|
||||||
|
|
||||||
int32 duration = CalculateSpellDuration(m_spellInfo, m_caster);
|
pTotem->SetDuration(m_duration);
|
||||||
pTotem->SetDuration(duration);
|
|
||||||
|
|
||||||
if (damage) // if not spell info, DB values used
|
if (damage) // if not spell info, DB values used
|
||||||
{
|
{
|
||||||
|
|
@ -7664,7 +7657,7 @@ void Spell::DoSummonTotem(SpellEffectIndex eff_idx, uint8 slot_dbc)
|
||||||
WorldPacket data(SMSG_TOTEM_CREATED, 1 + 8 + 4 + 4);
|
WorldPacket data(SMSG_TOTEM_CREATED, 1 + 8 + 4 + 4);
|
||||||
data << uint8(slot);
|
data << uint8(slot);
|
||||||
data << pTotem->GetObjectGuid();
|
data << pTotem->GetObjectGuid();
|
||||||
data << uint32(duration);
|
data << uint32(m_duration);
|
||||||
data << uint32(m_spellInfo->Id);
|
data << uint32(m_spellInfo->Id);
|
||||||
((Player*)m_caster)->SendDirectMessage(&data);
|
((Player*)m_caster)->SendDirectMessage(&data);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "11321"
|
#define REVISION_NR "11322"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue