From 689897ca3959d03d1e657c03aa8b5b403eaaea98 Mon Sep 17 00:00:00 2001 From: Arthur Dene Ice Date: Fri, 9 May 2014 16:15:13 -0700 Subject: [PATCH] explicit conversions of floats --- zone/attack.cpp | 6 +++--- zone/bot.cpp | 6 +++--- zone/effects.cpp | 2 +- zone/merc.cpp | 6 +++--- zone/pets.cpp | 4 ++-- zone/special_attacks.cpp | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/zone/attack.cpp b/zone/attack.cpp index cb42616fa..4d8e57afb 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -1276,7 +1276,7 @@ bool Client::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, b if(opts) { damage *= (int)opts->damage_percent; damage += opts->damage_flat; - hate *= opts->hate_percent; + hate = (uint32)(hate * opts->hate_percent); hate += opts->hate_flat; } @@ -1849,7 +1849,7 @@ bool NPC::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, bool } if(weapon->ElemDmgAmt){ - eleBane += (weapon->ElemDmgAmt * other->ResistSpell(weapon->ElemDmgType, 0, this) / 100); + eleBane = (uint16)(eleBane + weapon->ElemDmgAmt * other->ResistSpell(weapon->ElemDmgType, 0, this) / 100); } } @@ -3832,7 +3832,7 @@ void Mob::HealDamage(uint32 amount, Mob *caster, uint16 spell_id) if (caster && amount > 0) { if (caster->IsNPC() && !caster->IsPet()) { float npchealscale = caster->CastToNPC()->GetHealScale(); - amount = (static_cast(amount) * npchealscale) / 100.0f; + amount = (uint32)(amount * npchealscale) / 100.0f); } } diff --git a/zone/bot.cpp b/zone/bot.cpp index cdf11fa06..3b5013a62 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -1405,7 +1405,7 @@ int32 Bot::GenerateBaseHitPoints() if(level < 41) { - new_base_hp = (5 + (GetLevel() * hp_factor / 12) + ((NormalSTA - SoDPost255) * GetLevel() * hp_factor / 3600)); + new_base_hp = (int)(5 + (GetLevel() * hp_factor / 12) + ((NormalSTA - SoDPost255) * GetLevel() * hp_factor / 3600)); } else if(level < 81) { @@ -6550,9 +6550,9 @@ bool Bot::Attack(Mob* other, int Hand, bool FromRiposte, bool IsStrikethrough, b damage, min_hit, max_hit, GetSTR(), GetSkill(skillinuse), weapon_damage, GetLevel()); if(opts) { - damage *= opts->damage_percent; + damage = (int)(damage * opts->damage_percent); damage += opts->damage_flat; - hate *= opts->hate_percent; + hate = (uint32)(hate * opts->hate_percent); hate += opts->hate_flat; } diff --git a/zone/effects.cpp b/zone/effects.cpp index f2a8db2a6..cbe914524 100644 --- a/zone/effects.cpp +++ b/zone/effects.cpp @@ -447,7 +447,7 @@ int32 Client::GetActSpellCost(uint16 spell_id, int32 cost) PercentManaReduction += MakeRandomFloat(1, (double)focus_redux); } - cost -= (cost * (PercentManaReduction / 100)); + cost = (int32)(cost -(cost * (PercentManaReduction / 100))); // Gift of Mana - reduces spell cost to 1 mana if(focus_redux >= 100) { diff --git a/zone/merc.cpp b/zone/merc.cpp index c8c8da6fa..255489031 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -912,7 +912,7 @@ int32 Merc::CalcMaxHP() { max_hp += GroupLeadershipAAHealthEnhancement(); - max_hp += max_hp * ((spellbonuses.MaxHPChange + itembonuses.MaxHPChange) / 10000.0f); + max_hp = (int32)(max_hp + max_hp * ((spellbonuses.MaxHPChange + itembonuses.MaxHPChange) / 10000.0f)); if (cur_hp > max_hp) cur_hp = max_hp; @@ -2943,7 +2943,7 @@ int32 Merc::GetActSpellCost(uint16 spell_id, int32 cost) PercentManaReduction += MakeRandomFloat(1, (double)focus_redux); } - cost -= (cost * (PercentManaReduction / 100)); + cost = (int32)(cost - (cost * (PercentManaReduction / 100))); // Gift of Mana - reduces spell cost to 1 mana if(focus_redux >= 100) { @@ -4689,7 +4689,7 @@ void Merc::DoClassAttacks(Mob *target) { } } - classattack_timer.Start(reuse*HasteModifier/100); + classattack_timer.Start((uint32)(reuse*HasteModifier/1000)); } bool Merc::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, bool IsFromSpell, ExtraAttackOptions *opts) diff --git a/zone/pets.cpp b/zone/pets.cpp index 9c6ba2bf9..5b49cde6e 100644 --- a/zone/pets.cpp +++ b/zone/pets.cpp @@ -271,9 +271,9 @@ void Mob::MakePoweredPet(uint16 spell_id, const char* pettype, int16 petpower, float scale_power = (float)act_power / 100.0f; if(scale_power > 0) { - npc_type->max_hp *= (1 + scale_power); + npc_type->max_hp = (int32)(npc_type->max_hp *(1 + scale_power)); npc_type->cur_hp = npc_type->max_hp; - npc_type->AC *= (1 + scale_power); + npc_type->AC = (int16)(npc_type->AC * (1 + scale_power)); npc_type->level += 1 + ((int)act_power / 25); // gains an additional level for every 25 pet power npc_type->min_dmg = (npc_type->min_dmg * (1 + (scale_power / 2))); npc_type->max_dmg = (npc_type->max_dmg * (1 + (scale_power / 2))); diff --git a/zone/special_attacks.cpp b/zone/special_attacks.cpp index 54e70f3d0..dfa816bb2 100644 --- a/zone/special_attacks.cpp +++ b/zone/special_attacks.cpp @@ -917,8 +917,8 @@ void Mob::DoArcheryAttackDmg(Mob* other, const ItemInst* RangeWeapon, const Item if(dobonus) { - MaxDmg *= (float)2; - hate *= (float)2; + MaxDmg *= 2; + hate *= 2; MaxDmg = mod_archery_bonus_damage(MaxDmg, RangeWeapon); mlog(COMBAT__RANGED, "Ranger. Double damage success roll, doubling damage to %d", MaxDmg);