Core/Cleanup:

* move repeating code into separate method for storing locale strings in ObjectMgr (copy/paste sucks, you know)
* fix 'signed/unsigned' warnings (at least in VS)
* fix some other warnings and cleanup relative code

--HG--
branch : trunk
This commit is contained in:
azazel committed 2010-08-26 15:54:56 +06:00
1 parent 6036166716
commit 5fa14f58dc
23 files changed
+195 -379

No files matched your search

+34 -33
View File
@@ -1091,12 +1091,12 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 dama
// Spell weapon based damage CAN BE crit & blocked at same time
if (blocked)
{
damageInfo->blocked = uint32(pVictim->GetShieldBlockValue());
damageInfo->blocked = pVictim->GetShieldBlockValue();
//double blocked amount if block is critical
if (pVictim->isBlockCritical())
damageInfo->blocked+=damageInfo->blocked;
if (damage < damageInfo->blocked)
damageInfo->blocked = damage;
damageInfo->blocked += damageInfo->blocked;
if (damage < int32(damageInfo->blocked))
damageInfo->blocked = uint32(damage);
damage -= damageInfo->blocked;
}
@@ -1941,7 +1941,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim, SpellSchoolMask schoolMask, DamageEff
pVictim->CastCustomSpell(pVictim, 66235, &healAmount, NULL, NULL, true);
pVictim->ToPlayer()->AddSpellCooldown(66235,0,time(NULL) + 120);
}
else if (remainingHealth < allowedHealth)
else if (remainingHealth < int32(allowedHealth))
{
// Reduce damage that brings us under 35% (or full damage if we are already under 35%) by x%
uint32 damageToReduce = (pVictim->GetHealth() < allowedHealth)
@@ -2203,7 +2203,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim, SpellSchoolMask schoolMask, DamageEff
RemainingDamage += auraAbsorbMod * TotalAbsorb / 100;
// Apply death prevention spells effects
if (preventDeathSpell && RemainingDamage >= pVictim->GetHealth())
if (preventDeathSpell && RemainingDamage >= int32(pVictim->GetHealth()))
{
switch(preventDeathSpell->SpellFamilyName)
{
@@ -2930,44 +2930,44 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell)
if (Player *modOwner = GetSpellModOwner())
modOwner->ApplySpellMod(spell->Id, SPELLMOD_RESIST_MISS_CHANCE, modHitChance);
// Increase from attacker SPELL_AURA_MOD_INCREASES_SPELL_PCT_TO_HIT auras
modHitChance+=GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_INCREASES_SPELL_PCT_TO_HIT, schoolMask);
modHitChance += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_INCREASES_SPELL_PCT_TO_HIT, schoolMask);
// Chance hit from victim SPELL_AURA_MOD_ATTACKER_SPELL_HIT_CHANCE auras
modHitChance+= pVictim->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_ATTACKER_SPELL_HIT_CHANCE, schoolMask);
modHitChance += pVictim->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_ATTACKER_SPELL_HIT_CHANCE, schoolMask);
// Reduce spell hit chance for Area of effect spells from victim SPELL_AURA_MOD_AOE_AVOIDANCE aura
if (IsAreaOfEffectSpell(spell))
modHitChance-=pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_AOE_AVOIDANCE);
modHitChance -= pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_AOE_AVOIDANCE);
int32 HitChance = modHitChance * 100;
// Increase hit chance from attacker SPELL_AURA_MOD_SPELL_HIT_CHANCE and attacker ratings
HitChance += int32(m_modSpellHitChance*100.0f);
HitChance += int32(m_modSpellHitChance * 100.0f);
// Decrease hit chance from victim rating bonus
if (pVictim->GetTypeId() == TYPEID_PLAYER)
HitChance -= int32(pVictim->ToPlayer()->GetRatingBonusValue(CR_HIT_TAKEN_SPELL)*100.0f);
HitChance -= int32(pVictim->ToPlayer()->GetRatingBonusValue(CR_HIT_TAKEN_SPELL) * 100.0f);
if (HitChance < 100)
HitChance = 100;
if (HitChance < 100)
HitChance = 100;
else if (HitChance > 10000)
HitChance = 10000;
int32 tmp = 10000 - HitChance;
uint32 rand = urand(0,10000);
int32 rand = irand(0, 10000);
if (rand < tmp)
return SPELL_MISS_MISS;
// Chance resist mechanic (select max value from every mechanic spell effect)
int32 resist_chance = pVictim->GetMechanicResistChance(spell)*100;
int32 resist_chance = pVictim->GetMechanicResistChance(spell) * 100;
tmp += resist_chance;
// Chance resist debuff
if (!IsPositiveSpell(spell->Id))
{
bool bNegativeAura = false;
for (uint8 I = 0; I < 3; I++)
for (uint8 i = 0; i < 3; ++i)
{
if (spell->EffectApplyAuraName[I] != 0)
if (spell->EffectApplyAuraName[i] != 0)
{
bNegativeAura = true;
break;
@@ -2986,10 +2986,10 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell)
return SPELL_MISS_RESIST;
// cast by caster in front of victim
if (pVictim->HasInArc(M_PI,this) || pVictim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION))
if (pVictim->HasInArc(M_PI, this) || pVictim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION))
{
int32 deflect_chance = pVictim->GetTotalAuraModifier(SPELL_AURA_DEFLECT_SPELLS)*100;
tmp+=deflect_chance;
int32 deflect_chance = pVictim->GetTotalAuraModifier(SPELL_AURA_DEFLECT_SPELLS) * 100;
tmp += deflect_chance;
if (rand < tmp)
return SPELL_MISS_DEFLECT;
}
@@ -5481,12 +5481,13 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
case 25988:
{
// return damage % to attacker but < 50% own total health
basepoints0 = int32((triggerAmount* damage) /100);
basepoints0 = int32((triggerAmount * damage) /100);
if (basepoints0 > GetMaxHealth()/2)
basepoints0 = GetMaxHealth()/2;
int32 halfMaxHealth = int32(CountPctFromMaxHealth(50));
if (basepoints0 > halfMaxHealth)
basepoints0 = halfMaxHealth;
sLog.outDebug("DEBUG LINE: Data about Eye for an Eye ID %u, damage taken %u, unit max health %u, damage done %u", dummySpell->Id, damage, GetMaxHealth(),basepoints0);
sLog.outDebug("DEBUG LINE: Data about Eye for an Eye ID %u, damage taken %u, unit max health %u, damage done %u", dummySpell->Id, damage, GetMaxHealth(), basepoints0);
triggered_spell_id = 25997;
@@ -6179,7 +6180,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
if (procSpell && procSpell->Id == 27285)
return false;
// if damage is more than need or target die from damage deal finish spell
if (triggeredByAura->GetAmount() <= damage || GetHealth() <= damage)
if (triggeredByAura->GetAmount() <= int32(damage) || GetHealth() <= damage)
{
// remember guid before aura delete
uint64 casterGuid = triggeredByAura->GetCasterGUID();
@@ -6198,10 +6199,10 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
return true;
}
// Seed of Corruption (Mobs cast) - no die req
if (dummySpell->SpellFamilyFlags.IsEqual(0,0,0) && dummySpell->SpellIconID == 1932)
if (dummySpell->SpellFamilyFlags.IsEqual(0, 0, 0) && dummySpell->SpellIconID == 1932)
{
// if damage is more than need deal finish spell
if (triggeredByAura->GetAmount() <= damage)
if (triggeredByAura->GetAmount() <= int32(damage))
{
// remember guid before aura delete
uint64 casterGuid = triggeredByAura->GetCasterGUID();
@@ -12130,7 +12131,7 @@ bool Unit::canDetectInvisibilityOf(Unit const* u) const
uint32 invLevel = 0;
Unit::AuraEffectList const& iAuras = u->GetAuraEffectsByType(SPELL_AURA_MOD_INVISIBILITY);
for (Unit::AuraEffectList::const_iterator itr = iAuras.begin(); itr != iAuras.end(); ++itr)
if (uint8((*itr)->GetMiscValue()) == i && invLevel < (*itr)->GetAmount())
if (uint8((*itr)->GetMiscValue()) == i && int32(invLevel) < (*itr)->GetAmount())
invLevel = (*itr)->GetAmount();
// find invisibility detect level
@@ -12143,7 +12144,7 @@ bool Unit::canDetectInvisibilityOf(Unit const* u) const
{
Unit::AuraEffectList const& dAuras = GetAuraEffectsByType(SPELL_AURA_MOD_INVISIBILITY_DETECTION);
for (Unit::AuraEffectList::const_iterator itr = dAuras.begin(); itr != dAuras.end(); ++itr)
if (uint8((*itr)->GetMiscValue()) == i && detectLevel < (*itr)->GetAmount())
if (uint8((*itr)->GetMiscValue()) == i && int32(detectLevel) < (*itr)->GetAmount())
detectLevel = (*itr)->GetAmount();
}
@@ -12237,12 +12238,12 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced)
stack_bonus = GetTotalAuraMultiplier(SPELL_AURA_MOD_VEHICLE_SPEED_ALWAYS);
// for some spells this mod is applied on vehicle owner
uint32 owner_speed_mod = 0;
int32 owner_speed_mod = 0;
if (Unit * owner = GetCharmer())
owner_speed_mod = owner->GetMaxPositiveAuraModifier(SPELL_AURA_MOD_INCREASE_VEHICLE_FLIGHT_SPEED);
main_speed_mod = main_speed_mod>owner_speed_mod ? main_speed_mod : owner_speed_mod;
main_speed_mod = std::max(main_speed_mod, owner_speed_mod);
}
else if (IsMounted())
{
@@ -12924,7 +12925,7 @@ void Unit::IncrDiminishing(DiminishingGroup group)
{
if (i->DRGroup != group)
continue;
if (i->hitCount < GetDiminishingReturnsMaxLevel(group))
if (int32(i->hitCount) < GetDiminishingReturnsMaxLevel(group))
i->hitCount += 1;
return;
}
@@ -14246,7 +14247,7 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit * pTarget, uint32 procFlag,
{
int32 damageLeft = triggeredByAura->GetAmount();
// No damage left
if (damageLeft < damage)
if (damageLeft < int32(damage))
i->aura->Remove();
else
triggeredByAura->SetAmount(damageLeft - damage);