Merge branch 'master' into 303

Conflicts:
	src/game/Level2.cpp
	src/game/Pet.cpp
	src/game/Player.cpp
This commit is contained in:
tomrus88 2008-11-03 14:44:58 +03:00
commit 9cc6f1f3ec
32 changed files with 353 additions and 238 deletions

View file

@ -235,9 +235,11 @@ Unit::~Unit()
// set current spells as deletable
for (uint32 i = 0; i < CURRENT_MAX_SPELL; i++)
{
// spell may be safely deleted now
if (m_currentSpells[i]) m_currentSpells[i]->SetDeletable(true);
m_currentSpells[i] = NULL;
if (m_currentSpells[i])
{
m_currentSpells[i]->SetReferencedFromCurrent(false);
m_currentSpells[i] = NULL;
}
}
RemoveAllGameObjects();
@ -1663,56 +1665,60 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe
RemainingDamage -= currentAbsorb;
}
AuraList const& vSplitDamageFlat = pVictim->GetAurasByType(SPELL_AURA_SPLIT_DAMAGE_FLAT);
for(AuraList::const_iterator i = vSplitDamageFlat.begin(), next; i != vSplitDamageFlat.end() && RemainingDamage >= 0; i = next)
// only split damage if not damaing yourself
if(pVictim != this)
{
next = i; ++next;
AuraList const& vSplitDamageFlat = pVictim->GetAurasByType(SPELL_AURA_SPLIT_DAMAGE_FLAT);
for(AuraList::const_iterator i = vSplitDamageFlat.begin(), next; i != vSplitDamageFlat.end() && RemainingDamage >= 0; i = next)
{
next = i; ++next;
// check damage school mask
if(((*i)->GetModifier()->m_miscvalue & schoolMask)==0)
continue;
// check damage school mask
if(((*i)->GetModifier()->m_miscvalue & schoolMask)==0)
continue;
// Damage can be splitted only if aura has an alive caster
Unit *caster = (*i)->GetCaster();
if(!caster || caster == pVictim || !caster->IsInWorld() || !caster->isAlive())
continue;
// Damage can be splitted only if aura has an alive caster
Unit *caster = (*i)->GetCaster();
if(!caster || caster == pVictim || !caster->IsInWorld() || !caster->isAlive())
continue;
int32 currentAbsorb;
if (RemainingDamage >= (*i)->GetModifier()->m_amount)
currentAbsorb = (*i)->GetModifier()->m_amount;
else
currentAbsorb = RemainingDamage;
int32 currentAbsorb;
if (RemainingDamage >= (*i)->GetModifier()->m_amount)
currentAbsorb = (*i)->GetModifier()->m_amount;
else
currentAbsorb = RemainingDamage;
RemainingDamage -= currentAbsorb;
RemainingDamage -= currentAbsorb;
SendSpellNonMeleeDamageLog(caster, (*i)->GetSpellProto()->Id, currentAbsorb, schoolMask, 0, 0, false, 0, false);
SendSpellNonMeleeDamageLog(caster, (*i)->GetSpellProto()->Id, currentAbsorb, schoolMask, 0, 0, false, 0, false);
CleanDamage cleanDamage = CleanDamage(currentAbsorb, BASE_ATTACK, MELEE_HIT_NORMAL);
DealDamage(caster, currentAbsorb, &cleanDamage, DIRECT_DAMAGE, schoolMask, (*i)->GetSpellProto(), false);
}
CleanDamage cleanDamage = CleanDamage(currentAbsorb, BASE_ATTACK, MELEE_HIT_NORMAL);
DealDamage(caster, currentAbsorb, &cleanDamage, DIRECT_DAMAGE, schoolMask, (*i)->GetSpellProto(), false);
}
AuraList const& vSplitDamagePct = pVictim->GetAurasByType(SPELL_AURA_SPLIT_DAMAGE_PCT);
for(AuraList::const_iterator i = vSplitDamagePct.begin(), next; i != vSplitDamagePct.end() && RemainingDamage >= 0; i = next)
{
next = i; ++next;
AuraList const& vSplitDamagePct = pVictim->GetAurasByType(SPELL_AURA_SPLIT_DAMAGE_PCT);
for(AuraList::const_iterator i = vSplitDamagePct.begin(), next; i != vSplitDamagePct.end() && RemainingDamage >= 0; i = next)
{
next = i; ++next;
// check damage school mask
if(((*i)->GetModifier()->m_miscvalue & schoolMask)==0)
continue;
// check damage school mask
if(((*i)->GetModifier()->m_miscvalue & schoolMask)==0)
continue;
// Damage can be splitted only if aura has an alive caster
Unit *caster = (*i)->GetCaster();
if(!caster || caster == pVictim || !caster->IsInWorld() || !caster->isAlive())
continue;
// Damage can be splitted only if aura has an alive caster
Unit *caster = (*i)->GetCaster();
if(!caster || caster == pVictim || !caster->IsInWorld() || !caster->isAlive())
continue;
int32 splitted = int32(RemainingDamage * (*i)->GetModifier()->m_amount / 100.0f);
int32 splitted = int32(RemainingDamage * (*i)->GetModifier()->m_amount / 100.0f);
RemainingDamage -= splitted;
RemainingDamage -= splitted;
SendSpellNonMeleeDamageLog(caster, (*i)->GetSpellProto()->Id, splitted, schoolMask, 0, 0, false, 0, false);
SendSpellNonMeleeDamageLog(caster, (*i)->GetSpellProto()->Id, splitted, schoolMask, 0, 0, false, 0, false);
CleanDamage cleanDamage = CleanDamage(splitted, BASE_ATTACK, MELEE_HIT_NORMAL);
DealDamage(caster, splitted, &cleanDamage, DIRECT_DAMAGE, schoolMask, (*i)->GetSpellProto(), false);
CleanDamage cleanDamage = CleanDamage(splitted, BASE_ATTACK, MELEE_HIT_NORMAL);
DealDamage(caster, splitted, &cleanDamage, DIRECT_DAMAGE, schoolMask, (*i)->GetSpellProto(), false);
}
}
*absorb = damage - RemainingDamage - *resist;
@ -3150,7 +3156,7 @@ void Unit::_UpdateSpells( uint32 time )
{
if (m_currentSpells[i] && m_currentSpells[i]->getState() == SPELL_STATE_FINISHED)
{
m_currentSpells[i]->SetDeletable(true); // spell may be safely deleted now
m_currentSpells[i]->SetReferencedFromCurrent(false);
m_currentSpells[i] = NULL; // remove pointer
}
}
@ -3263,7 +3269,6 @@ void Unit::SetCurrentCastedSpell( Spell * pSpell )
uint32 CSpellType = pSpell->GetCurrentContainer();
pSpell->SetDeletable(false); // spell will not be deleted until gone from current pointers
if (pSpell == m_currentSpells[CSpellType]) return; // avoid breaking self
// break same type spell if it is not delayed
@ -3320,10 +3325,11 @@ void Unit::SetCurrentCastedSpell( Spell * pSpell )
// current spell (if it is still here) may be safely deleted now
if (m_currentSpells[CSpellType])
m_currentSpells[CSpellType]->SetDeletable(true);
m_currentSpells[CSpellType]->SetReferencedFromCurrent(false);
// set new current spell
m_currentSpells[CSpellType] = pSpell;
pSpell->SetReferencedFromCurrent(true);
}
void Unit::InterruptSpell(uint32 spellType, bool withDelayed)
@ -3341,7 +3347,7 @@ void Unit::InterruptSpell(uint32 spellType, bool withDelayed)
if (m_currentSpells[spellType]->getState() != SPELL_STATE_FINISHED)
m_currentSpells[spellType]->cancel();
m_currentSpells[spellType]->SetDeletable(true);
m_currentSpells[spellType]->SetReferencedFromCurrent(false);
m_currentSpells[spellType] = NULL;
}
}
@ -3377,7 +3383,7 @@ void Unit::InterruptNonMeleeSpells(bool withDelayed, uint32 spell_id)
if ( (m_currentSpells[CURRENT_GENERIC_SPELL]->getState() != SPELL_STATE_FINISHED) &&
(withDelayed || m_currentSpells[CURRENT_GENERIC_SPELL]->getState() != SPELL_STATE_DELAYED) )
m_currentSpells[CURRENT_GENERIC_SPELL]->cancel();
m_currentSpells[CURRENT_GENERIC_SPELL]->SetDeletable(true);
m_currentSpells[CURRENT_GENERIC_SPELL]->SetReferencedFromCurrent(false);
m_currentSpells[CURRENT_GENERIC_SPELL] = NULL;
}
@ -3391,7 +3397,7 @@ void Unit::InterruptNonMeleeSpells(bool withDelayed, uint32 spell_id)
if ( (m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->getState() != SPELL_STATE_FINISHED) &&
(withDelayed || m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->getState() != SPELL_STATE_DELAYED) )
m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->cancel();
m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->SetDeletable(true);
m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->SetReferencedFromCurrent(false);
m_currentSpells[CURRENT_AUTOREPEAT_SPELL] = NULL;
}
@ -3400,7 +3406,7 @@ void Unit::InterruptNonMeleeSpells(bool withDelayed, uint32 spell_id)
{
if (m_currentSpells[CURRENT_CHANNELED_SPELL]->getState() != SPELL_STATE_FINISHED)
m_currentSpells[CURRENT_CHANNELED_SPELL]->cancel();
m_currentSpells[CURRENT_CHANNELED_SPELL]->SetDeletable(true);
m_currentSpells[CURRENT_CHANNELED_SPELL]->SetReferencedFromCurrent(false);
m_currentSpells[CURRENT_CHANNELED_SPELL] = NULL;
}
}
@ -9839,7 +9845,7 @@ void Unit::CleanupsBeforeDelete()
if(m_uint32Values) // only for fully created object
{
InterruptNonMeleeSpells(true);
m_Events.KillAllEvents();
m_Events.KillAllEvents(false); // non-delatable (currently casted spells) will not deleted ans will deleated at call in Map::RemoveAllObjectsInRemoveList
CombatStop();
ClearComboPointHolders();
DeleteThreatList();