Core/Refactor: Fix alot of Possible loss of fraction warnings
This commit is contained in:
@@ -23,8 +23,8 @@ namespace Framework.Constants
|
|||||||
//Grids
|
//Grids
|
||||||
public const int MaxGrids = 64;
|
public const int MaxGrids = 64;
|
||||||
public const float SizeofGrids = 533.33333f;
|
public const float SizeofGrids = 533.33333f;
|
||||||
public const float CenterGridCellId = (MaxCells * MaxGrids / 2);
|
public const int CenterGridCellId = (MaxCells * MaxGrids / 2);
|
||||||
public const float CenterGridId = (MaxGrids / 2);
|
public const int CenterGridId = (MaxGrids / 2);
|
||||||
public const float CenterGridOffset = (SizeofGrids / 2);
|
public const float CenterGridOffset = (SizeofGrids / 2);
|
||||||
public const float CenterGridCellOffset = (SizeofCells / 2);
|
public const float CenterGridCellOffset = (SizeofCells / 2);
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public static class MathFunctions
|
|||||||
/// Returns the clamped value.
|
/// Returns the clamped value.
|
||||||
/// result = (EpsilonF > Abs(value-calmpedValue)) ? calmpedValue : value;
|
/// result = (EpsilonF > Abs(value-calmpedValue)) ? calmpedValue : value;
|
||||||
/// </returns>
|
/// </returns>
|
||||||
/// <remarks><see cref="MathFunctions.EpsilonF"/> is used for tolerance.</remarks>
|
/// <remarks><see cref="MathFunctions.Epsilon"/> is used for tolerance.</remarks>
|
||||||
public static float Clamp(float value, float calmpedValue)
|
public static float Clamp(float value, float calmpedValue)
|
||||||
{
|
{
|
||||||
return (Epsilon > Math.Abs(value - calmpedValue)) ? calmpedValue : value;
|
return (Epsilon > Math.Abs(value - calmpedValue)) ? calmpedValue : value;
|
||||||
@@ -81,10 +81,10 @@ public static class MathFunctions
|
|||||||
static double eps(double a, double b)
|
static double eps(double a, double b)
|
||||||
{
|
{
|
||||||
double aa = Math.Abs(a) + 1.0;
|
double aa = Math.Abs(a) + 1.0;
|
||||||
if (aa == double.PositiveInfinity)
|
if (double.IsPositiveInfinity(aa))
|
||||||
return double.Epsilon;
|
return double.Epsilon;
|
||||||
else
|
|
||||||
return double.Epsilon * aa;
|
return double.Epsilon * aa;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float lerp(float a, float b, float f)
|
public static float lerp(float a, float b, float f)
|
||||||
|
|||||||
@@ -1174,7 +1174,7 @@ namespace Game.BattleFields
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get the difference of numbers
|
// get the difference of numbers
|
||||||
float fact_diff = (m_activePlayers[TeamId.Alliance].Count - m_activePlayers[TeamId.Horde].Count) * diff / 1000;
|
float fact_diff = ((float)m_activePlayers[TeamId.Alliance].Count - m_activePlayers[TeamId.Horde].Count) * diff / 1000;
|
||||||
if (MathFunctions.fuzzyEq(fact_diff, 0.0f))
|
if (MathFunctions.fuzzyEq(fact_diff, 0.0f))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@@ -930,9 +930,9 @@ namespace Game.BattleFields
|
|||||||
if (alliancePlayers != 0 && hordePlayers != 0)
|
if (alliancePlayers != 0 && hordePlayers != 0)
|
||||||
{
|
{
|
||||||
if (alliancePlayers < hordePlayers)
|
if (alliancePlayers < hordePlayers)
|
||||||
newStack = (int)(((float)(hordePlayers / alliancePlayers) - 1) * 4); // positive, should cast on alliance
|
newStack = (int)((((float)hordePlayers / alliancePlayers) - 1) * 4); // positive, should cast on alliance
|
||||||
else if (alliancePlayers > hordePlayers)
|
else if (alliancePlayers > hordePlayers)
|
||||||
newStack = (int)((1 - (float)(alliancePlayers / hordePlayers)) * 4); // negative, should cast on horde
|
newStack = (int)((1 - ((float)alliancePlayers / hordePlayers)) * 4); // negative, should cast on horde
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newStack == m_tenacityStack)
|
if (newStack == m_tenacityStack)
|
||||||
|
|||||||
@@ -83,16 +83,17 @@ namespace Game.Collision
|
|||||||
{
|
{
|
||||||
return base.Equals(obj);
|
return base.Equals(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
{
|
{
|
||||||
return base.GetHashCode();
|
return x.GetHashCode() ^ y.GetHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Cell ComputeCell(float fx, float fy)
|
public static Cell ComputeCell(float fx, float fy)
|
||||||
{
|
{
|
||||||
Cell c = new Cell();
|
Cell c = new Cell();
|
||||||
c.x = (int)(fx * (1.0f / CELL_SIZE) + (CELL_NUMBER / 2));
|
c.x = (int)(fx * (1.0f / CELL_SIZE) + (CELL_NUMBER / 2f));
|
||||||
c.y = (int)(fy * (1.0f / CELL_SIZE) + (CELL_NUMBER / 2));
|
c.y = (int)(fy * (1.0f / CELL_SIZE) + (CELL_NUMBER / 2f));
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -146,9 +146,9 @@ namespace Game.DataStorage
|
|||||||
float xDiff = nextTarget.locations.X - lastTarget.locations.X;
|
float xDiff = nextTarget.locations.X - lastTarget.locations.X;
|
||||||
float yDiff = nextTarget.locations.Y - lastTarget.locations.Y;
|
float yDiff = nextTarget.locations.Y - lastTarget.locations.Y;
|
||||||
float zDiff = nextTarget.locations.Z - lastTarget.locations.Z;
|
float zDiff = nextTarget.locations.Z - lastTarget.locations.Z;
|
||||||
x = lastTarget.locations.X + (xDiff * (timeDiffThis / timeDiffTarget));
|
x = lastTarget.locations.X + (xDiff * ((float)timeDiffThis / timeDiffTarget));
|
||||||
y = lastTarget.locations.Y + (yDiff * (timeDiffThis / timeDiffTarget));
|
y = lastTarget.locations.Y + (yDiff * ((float)timeDiffThis / timeDiffTarget));
|
||||||
z = lastTarget.locations.Z + (zDiff * (timeDiffThis / timeDiffTarget));
|
z = lastTarget.locations.Z + (zDiff * ((float)timeDiffThis / timeDiffTarget));
|
||||||
}
|
}
|
||||||
float xDiff1 = x - thisCam.locations.X;
|
float xDiff1 = x - thisCam.locations.X;
|
||||||
float yDiff1 = y - thisCam.locations.Y;
|
float yDiff1 = y - thisCam.locations.Y;
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ namespace Game.Entities
|
|||||||
|
|
||||||
float GetProgress()
|
float GetProgress()
|
||||||
{
|
{
|
||||||
return GetTimeSinceCreated() < GetTimeToTargetScale() ? GetTimeSinceCreated() / GetTimeToTargetScale() : 1.0f;
|
return GetTimeSinceCreated() < GetTimeToTargetScale() ? (float)GetTimeSinceCreated() / GetTimeToTargetScale() : 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateTargetList()
|
void UpdateTargetList()
|
||||||
@@ -655,7 +655,7 @@ namespace Game.Entities
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float currentTimePercent = _movementTime / GetTimeToTarget();
|
float currentTimePercent = (float)_movementTime / GetTimeToTarget();
|
||||||
|
|
||||||
if (currentTimePercent <= 0.0f)
|
if (currentTimePercent <= 0.0f)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -2318,7 +2318,7 @@ namespace Game.Entities
|
|||||||
if (getLevel() < levelForTarget)
|
if (getLevel() < levelForTarget)
|
||||||
return 1.0f;
|
return 1.0f;
|
||||||
|
|
||||||
return GetMaxHealthByLevel(levelForTarget) / GetCreateHealth();
|
return (float)GetMaxHealthByLevel(levelForTarget) / GetCreateHealth();
|
||||||
}
|
}
|
||||||
|
|
||||||
float GetBaseDamageForLevel(uint level)
|
float GetBaseDamageForLevel(uint level)
|
||||||
|
|||||||
@@ -161,8 +161,8 @@ namespace Game.Entities
|
|||||||
float xDiff = nextPosition.posX - lastPosition.posX;
|
float xDiff = nextPosition.posX - lastPosition.posX;
|
||||||
float yDiff = nextPosition.posY - lastPosition.posY;
|
float yDiff = nextPosition.posY - lastPosition.posY;
|
||||||
float zDiff = nextPosition.posZ - lastPosition.posZ;
|
float zDiff = nextPosition.posZ - lastPosition.posZ;
|
||||||
Position interPosition = new Position(lastPosition.posX + (xDiff * (interDiff / timeDiff)), lastPosition.posY +
|
Position interPosition = new Position(lastPosition.posX + (xDiff * ((float)interDiff / timeDiff)), lastPosition.posY +
|
||||||
(yDiff * (interDiff / timeDiff)), lastPosition.posZ + (zDiff * (interDiff / timeDiff)));
|
(yDiff * ((float)interDiff / timeDiff)), lastPosition.posZ + (zDiff * ((float)interDiff / timeDiff)));
|
||||||
|
|
||||||
// Advance (at speed) to this position. The remote sight object is used
|
// Advance (at speed) to this position. The remote sight object is used
|
||||||
// to send update information to player in cinematic
|
// to send update information to player in cinematic
|
||||||
|
|||||||
@@ -3772,7 +3772,7 @@ namespace Game.Entities
|
|||||||
ulong price = 0;
|
ulong price = 0;
|
||||||
if (crItem.IsGoldRequired(pProto) && pProto.GetBuyPrice() > 0) //Assume price cannot be negative (do not know why it is int32)
|
if (crItem.IsGoldRequired(pProto) && pProto.GetBuyPrice() > 0) //Assume price cannot be negative (do not know why it is int32)
|
||||||
{
|
{
|
||||||
float buyPricePerItem = pProto.GetBuyPrice() / pProto.GetBuyCount();
|
float buyPricePerItem = (float)pProto.GetBuyPrice() / pProto.GetBuyCount();
|
||||||
ulong maxCount = (ulong)(PlayerConst.MaxMoneyAmount / buyPricePerItem);
|
ulong maxCount = (ulong)(PlayerConst.MaxMoneyAmount / buyPricePerItem);
|
||||||
if (count > maxCount)
|
if (count > maxCount)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1104,7 +1104,7 @@ namespace Game.Entities
|
|||||||
var mAPbyArmor = GetAuraEffectsByType(AuraType.ModAttackPowerOfArmor);
|
var mAPbyArmor = GetAuraEffectsByType(AuraType.ModAttackPowerOfArmor);
|
||||||
foreach (var iter in mAPbyArmor)
|
foreach (var iter in mAPbyArmor)
|
||||||
// always: ((*i).GetModifier().m_miscvalue == 1 == SPELL_SCHOOL_MASK_NORMAL)
|
// always: ((*i).GetModifier().m_miscvalue == 1 == SPELL_SCHOOL_MASK_NORMAL)
|
||||||
attPowerMod += GetArmor() / iter.GetAmount();
|
attPowerMod += (int)(GetArmor() / iter.GetAmount());
|
||||||
}
|
}
|
||||||
|
|
||||||
SetUInt32Value(index, (uint)base_attPower); //UNIT_FIELD_(RANGED)_ATTACK_POWER field
|
SetUInt32Value(index, (uint)base_attPower); //UNIT_FIELD_(RANGED)_ATTACK_POWER field
|
||||||
|
|||||||
@@ -548,8 +548,8 @@ namespace Game.Entities
|
|||||||
if (pInfo == null)
|
if (pInfo == null)
|
||||||
SetCreateHealth(30 + 30 * petlevel);
|
SetCreateHealth(30 + 30 * petlevel);
|
||||||
float bonusDmg = GetOwner().SpellBaseDamageBonusDone(SpellSchoolMask.Nature) * 0.15f;
|
float bonusDmg = GetOwner().SpellBaseDamageBonusDone(SpellSchoolMask.Nature) * 0.15f;
|
||||||
SetBaseWeaponDamage(WeaponAttackType.BaseAttack, WeaponDamageRange.MinDamage, petlevel * 2.5f - (petlevel / 2) + bonusDmg);
|
SetBaseWeaponDamage(WeaponAttackType.BaseAttack, WeaponDamageRange.MinDamage, petlevel * 2.5f - ((float)petlevel / 2) + bonusDmg);
|
||||||
SetBaseWeaponDamage(WeaponAttackType.BaseAttack, WeaponDamageRange.MaxDamage, petlevel * 2.5f + (petlevel / 2) + bonusDmg);
|
SetBaseWeaponDamage(WeaponAttackType.BaseAttack, WeaponDamageRange.MaxDamage, petlevel * 2.5f + ((float)petlevel / 2) + bonusDmg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 15352: //earth elemental 36213
|
case 15352: //earth elemental 36213
|
||||||
|
|||||||
@@ -784,7 +784,7 @@ namespace Game.Entities
|
|||||||
uint VictimDefense = victim.GetMaxSkillValueForLevel(this);
|
uint VictimDefense = victim.GetMaxSkillValueForLevel(this);
|
||||||
uint AttackerMeleeSkill = GetMaxSkillValueForLevel();
|
uint AttackerMeleeSkill = GetMaxSkillValueForLevel();
|
||||||
|
|
||||||
Probability *= (float)(AttackerMeleeSkill / VictimDefense * 0.16);
|
Probability *= (AttackerMeleeSkill / (float)VictimDefense * 0.16f);
|
||||||
|
|
||||||
if (Probability < 0)
|
if (Probability < 0)
|
||||||
Probability = 0;
|
Probability = 0;
|
||||||
@@ -1014,7 +1014,7 @@ namespace Game.Entities
|
|||||||
victim.ToCreature().LowerPlayerDamageReq(health < damage ? health : damage);
|
victim.ToCreature().LowerPlayerDamageReq(health < damage ? health : damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
damage /= (uint)victim.GetHealthMultiplierForTarget(this);
|
damage = (uint)(damage / victim.GetHealthMultiplierForTarget(this));
|
||||||
|
|
||||||
if (health <= damage)
|
if (health <= damage)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ namespace Game.Movement
|
|||||||
float t_passedf = MSToSec((uint)(time_point - effect_start_time));
|
float t_passedf = MSToSec((uint)(time_point - effect_start_time));
|
||||||
float t_durationf = MSToSec((uint)(Duration() - effect_start_time)); //client use not modified duration here
|
float t_durationf = MSToSec((uint)(Duration() - effect_start_time)); //client use not modified duration here
|
||||||
if (spell_effect_extra.HasValue && spell_effect_extra.Value.ParabolicCurveId != 0)
|
if (spell_effect_extra.HasValue && spell_effect_extra.Value.ParabolicCurveId != 0)
|
||||||
t_passedf *= Global.DB2Mgr.GetCurveValueAt(spell_effect_extra.Value.ParabolicCurveId, time_point / Duration());
|
t_passedf *= Global.DB2Mgr.GetCurveValueAt(spell_effect_extra.Value.ParabolicCurveId, (float)time_point / Duration());
|
||||||
|
|
||||||
el += (t_durationf - t_passedf) * 0.5f * vertical_acceleration * t_passedf;
|
el += (t_durationf - t_passedf) * 0.5f * vertical_acceleration * t_passedf;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -400,7 +400,7 @@ namespace Game.Network.Packets
|
|||||||
StationeryID = (int)mail.stationery;
|
StationeryID = (int)mail.stationery;
|
||||||
SentMoney = mail.money;
|
SentMoney = mail.money;
|
||||||
Flags = (int)mail.checkMask;
|
Flags = (int)mail.checkMask;
|
||||||
DaysLeft = (mail.expire_time - Time.UnixTime) / Time.Day;
|
DaysLeft = (float)(mail.expire_time - Time.UnixTime) / Time.Day;
|
||||||
MailTemplateID = (int)mail.mailTemplateId;
|
MailTemplateID = (int)mail.mailTemplateId;
|
||||||
Subject = mail.subject;
|
Subject = mail.subject;
|
||||||
Body = mail.body;
|
Body = mail.body;
|
||||||
|
|||||||
@@ -536,7 +536,7 @@ namespace Game.PvP
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get the difference of numbers
|
// get the difference of numbers
|
||||||
float fact_diff = (m_activePlayers[0].Count - m_activePlayers[1].Count) * diff / 1000;
|
float fact_diff = (float)(m_activePlayers[0].Count - m_activePlayers[1].Count) * diff / 1000;
|
||||||
if (fact_diff == 0.0f)
|
if (fact_diff == 0.0f)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ namespace Scripts.Spells.Warlock
|
|||||||
}
|
}
|
||||||
|
|
||||||
// You take ${$s2/3}% reduced damage
|
// You take ${$s2/3}% reduced damage
|
||||||
float damageReductionPct = effect1.GetAmount() / 3;
|
float damageReductionPct = (float)effect1.GetAmount() / 3;
|
||||||
// plus a random amount of up to ${$s2/3}% additional reduced damage
|
// plus a random amount of up to ${$s2/3}% additional reduced damage
|
||||||
damageReductionPct += RandomHelper.FRand(0.0f, damageReductionPct);
|
damageReductionPct += RandomHelper.FRand(0.0f, damageReductionPct);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user