diff options
| author | jackpoz <giacomopoz@gmail.com> | 2014-08-21 16:56:11 +0200 |
|---|---|---|
| committer | jackpoz <giacomopoz@gmail.com> | 2014-08-23 19:56:41 +0200 |
| commit | 7fe7f30521503559dc8aee9f3127e11111f8ccc4 (patch) | |
| tree | f4a75f563e89957d43cef93253bfc300ecf57339 /src/server/game | |
| parent | f5f9df0483fbf847eb9ee4e6ec4ecc6cf66d3a47 (diff) | |
Core/Misc: Fix some -Wconversion warnings
Diffstat (limited to 'src/server/game')
33 files changed, 118 insertions, 118 deletions
diff --git a/src/server/game/AI/CoreAI/PetAI.cpp b/src/server/game/AI/CoreAI/PetAI.cpp index 4bce9113082..603c34e2403 100644 --- a/src/server/game/AI/CoreAI/PetAI.cpp +++ b/src/server/game/AI/CoreAI/PetAI.cpp @@ -236,7 +236,7 @@ void PetAI::UpdateAI(uint32 diff) SpellCastTargets targets; targets.SetUnitTarget(target); - if (!me->HasInArc(M_PI, target)) + if (!me->HasInArc(float(M_PI), target)) { me->SetInFront(target); if (target && target->GetTypeId() == TYPEID_PLAYER) diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index c19ed4ff54b..722f86a2392 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -1613,7 +1613,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u break; float attackDistance = float(e.action.setRangedMovement.distance); - float attackAngle = float(e.action.setRangedMovement.angle) / 180.0f * M_PI; + float attackAngle = float(e.action.setRangedMovement.angle) / 180.0f * float(M_PI); ObjectList* targets = GetTargets(e, unit); if (targets) diff --git a/src/server/game/Battlefield/Battlefield.cpp b/src/server/game/Battlefield/Battlefield.cpp index b04d0d360ee..b7ecd4b1e24 100644 --- a/src/server/game/Battlefield/Battlefield.cpp +++ b/src/server/game/Battlefield/Battlefield.cpp @@ -909,7 +909,7 @@ void BfCapturePoint::SendChangePhase() // send this too, sometimes the slider disappears, dunno why :( SendUpdateWorldState(capturePoint->GetGOInfo()->capturePoint.worldState1, 1); // send these updates to only the ones in this objective - SendUpdateWorldState(capturePoint->GetGOInfo()->capturePoint.worldstate2, (uint32) ceil((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f)); + SendUpdateWorldState(capturePoint->GetGOInfo()->capturePoint.worldstate2, (uint32) std::ceil((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f)); // send this too, sometimes it resets :S SendUpdateWorldState(capturePoint->GetGOInfo()->capturePoint.worldstate3, m_neutralValuePct); } diff --git a/src/server/game/Battlegrounds/ArenaTeam.cpp b/src/server/game/Battlegrounds/ArenaTeam.cpp index 2ca60534f30..1bc83cccaa0 100644 --- a/src/server/game/Battlegrounds/ArenaTeam.cpp +++ b/src/server/game/Battlegrounds/ArenaTeam.cpp @@ -604,7 +604,7 @@ uint32 ArenaTeam::GetPoints(uint32 memberRating) points = 344; } else - points = 1511.26f / (1.0f + 1639.28f * exp(-0.00412f * (float)rating)); + points = 1511.26f / (1.0f + 1639.28f * std::exp(-0.00412f * float(rating))); // Type penalties for teams < 5v5 if (Type == ARENA_TEAM_2v2) @@ -649,7 +649,7 @@ float ArenaTeam::GetChanceAgainst(uint32 ownRating, uint32 opponentRating) { // Returns the chance to win against a team with the given rating, used in the rating adjustment calculation // ELO system - return 1.0f / (1.0f + exp(log(10.0f) * (float)((float)opponentRating - (float)ownRating) / 650.0f)); + return 1.0f / (1.0f + std::exp(std::log(10.0f) * (float(opponentRating) - float(ownRating)) / 650.0f)); } int32 ArenaTeam::GetMatchmakerRatingMod(uint32 ownRating, uint32 opponentRating, bool won /*, float& confidence_factor*/) diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp index 15c72b6ac00..95a4642acd7 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp @@ -712,7 +712,7 @@ WorldSafeLocsEntry const* BattlegroundSA::GetClosestGraveYard(Player* player) safeloc = BG_SA_GYEntries[BG_SA_DEFENDER_LAST_GY]; closest = sWorldSafeLocsStore.LookupEntry(safeloc); - nearest = sqrt((closest->x - x)*(closest->x - x) + (closest->y - y)*(closest->y - y) + (closest->z - z)*(closest->z - z)); + nearest = std::sqrt((closest->x - x)*(closest->x - x) + (closest->y - y)*(closest->y - y) + (closest->z - z)*(closest->z - z)); for (uint8 i = BG_SA_RIGHT_CAPTURABLE_GY; i < BG_SA_MAX_GY; i++) { @@ -720,7 +720,7 @@ WorldSafeLocsEntry const* BattlegroundSA::GetClosestGraveYard(Player* player) continue; ret = sWorldSafeLocsStore.LookupEntry(BG_SA_GYEntries[i]); - dist = sqrt((ret->x - x)*(ret->x - x) + (ret->y - y)*(ret->y - y) + (ret->z - z)*(ret->z - z)); + dist = std::sqrt((ret->x - x)*(ret->x - x) + (ret->y - y)*(ret->y - y) + (ret->z - z)*(ret->z - z)); if (dist < nearest) { closest = ret; diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index c04f2845110..ba94a99c8dd 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -1076,7 +1076,7 @@ void Creature::SelectLevel() float basedamage = stats->GenerateBaseDamage(cInfo); float weaponBaseMinDamage = basedamage; - float weaponBaseMaxDamage = basedamage * 1.5; + float weaponBaseMaxDamage = basedamage * 1.5f; SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, weaponBaseMinDamage); SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, weaponBaseMaxDamage); diff --git a/src/server/game/Entities/Creature/CreatureGroups.cpp b/src/server/game/Entities/Creature/CreatureGroups.cpp index 14a76ae07ce..f02543a60af 100644 --- a/src/server/game/Entities/Creature/CreatureGroups.cpp +++ b/src/server/game/Entities/Creature/CreatureGroups.cpp @@ -107,7 +107,7 @@ void FormationMgr::LoadCreatureFormations() if (group_member->leaderGUID != memberGUID) { group_member->follow_dist = fields[2].GetFloat(); - group_member->follow_angle = fields[3].GetFloat() * M_PI / 180; + group_member->follow_angle = fields[3].GetFloat() * float(M_PI) / 180; } else { @@ -218,7 +218,7 @@ void CreatureGroup::LeaderMoveTo(float x, float y, float z) if (!m_leader) return; - float pathangle = atan2(m_leader->GetPositionY() - y, m_leader->GetPositionX() - x); + float pathangle = std::atan2(m_leader->GetPositionY() - y, m_leader->GetPositionX() - x); for (CreatureGroupMemberType::iterator itr = m_members.begin(); itr != m_members.end(); ++itr) { @@ -229,9 +229,9 @@ void CreatureGroup::LeaderMoveTo(float x, float y, float z) if (itr->second->point_1) { if (m_leader->GetCurrentWaypointID() == itr->second->point_1) - itr->second->follow_angle = (2 * M_PI) - itr->second->follow_angle; + itr->second->follow_angle = (2 * float(M_PI)) - itr->second->follow_angle; if (m_leader->GetCurrentWaypointID() == itr->second->point_2) - itr->second->follow_angle = (2 * M_PI) + itr->second->follow_angle; + itr->second->follow_angle = (2 * float(M_PI)) + itr->second->follow_angle; } float angle = itr->second->follow_angle; diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index c8c0eaefb27..3c33159cf1e 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -1261,7 +1261,7 @@ void GameObject::Use(Unit* user) // the object orientation + 1/2 pi // every slot will be on that straight line - float orthogonalOrientation = GetOrientation()+M_PI*0.5f; + float orthogonalOrientation = GetOrientation() + float(M_PI) * 0.5f; // find nearest slot bool found_free_slot = false; for (ChairSlotAndUser::iterator itr = ChairListSlots.begin(); itr != ChairListSlots.end(); ++itr) @@ -1826,7 +1826,7 @@ bool GameObject::IsInRange(float x, float y, float z, float radius) const float dx = x - GetPositionX(); float dy = y - GetPositionY(); float dz = z - GetPositionZ(); - float dist = sqrt(dx*dx + dy*dy); + float dist = std::sqrt(dx*dx + dy*dy); //! Check if the distance between the 2 objects is 0, can happen if both objects are on the same position. //! The code below this check wont crash if dist is 0 because 0/0 in float operations is valid, and returns infinite if (G3D::fuzzyEq(dist, 0.0f)) diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index c96b6e31c61..77f318066a2 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -1023,11 +1023,11 @@ bool Position::operator==(Position const &a) bool Position::HasInLine(WorldObject const* target, float width) const { - if (!HasInArc(M_PI, target)) + if (!HasInArc(float(M_PI), target)) return false; width += target->GetObjectSize(); float angle = GetRelativeAngle(target); - return fabs(sin(angle)) * GetExactDist2d(target->GetPositionX(), target->GetPositionY()) < width; + return std::fabs(std::sin(angle)) * GetExactDist2d(target->GetPositionX(), target->GetPositionY()) < width; } std::string Position::ToString() const @@ -1207,7 +1207,7 @@ InstanceScript* WorldObject::GetInstanceScript() float WorldObject::GetDistanceZ(const WorldObject* obj) const { - float dz = fabs(GetPositionZ() - obj->GetPositionZ()); + float dz = std::fabs(GetPositionZ() - obj->GetPositionZ()); float sizefactor = GetObjectSize() + obj->GetObjectSize(); float dist = dz - sizefactor; return (dist > 0 ? dist : 0); @@ -1430,7 +1430,7 @@ bool WorldObject::IsInRange3d(float x, float y, float z, float minRange, float m void Position::RelocateOffset(const Position & offset) { - m_positionX = GetPositionX() + (offset.GetPositionX() * std::cos(GetOrientation()) + offset.GetPositionY() * std::sin(GetOrientation() + M_PI)); + m_positionX = GetPositionX() + (offset.GetPositionX() * std::cos(GetOrientation()) + offset.GetPositionY() * std::sin(GetOrientation() + float(M_PI))); m_positionY = GetPositionY() + (offset.GetPositionY() * std::cos(GetOrientation()) + offset.GetPositionX() * std::sin(GetOrientation())); m_positionZ = GetPositionZ() + offset.GetPositionZ(); SetOrientation(GetOrientation() + offset.GetOrientation()); @@ -1461,8 +1461,8 @@ float Position::GetAngle(const float x, const float y) const float dx = x - GetPositionX(); float dy = y - GetPositionY(); - float ang = atan2(dy, dx); - ang = (ang >= 0) ? ang : 2 * M_PI + ang; + float ang = std::atan2(dy, dx); + ang = (ang >= 0) ? ang : 2 * float(M_PI) + ang; return ang; } @@ -1471,7 +1471,7 @@ void Position::GetSinCos(const float x, const float y, float &vsin, float &vcos) float dx = GetPositionX() - x; float dy = GetPositionY() - y; - if (fabs(dx) < 0.001f && fabs(dy) < 0.001f) + if (std::fabs(dx) < 0.001f && std::fabs(dy) < 0.001f) { float angle = (float)rand_norm()*static_cast<float>(2*M_PI); vcos = std::cos(angle); @@ -1479,7 +1479,7 @@ void Position::GetSinCos(const float x, const float y, float &vsin, float &vcos) } else { - float dist = sqrt((dx*dx) + (dy*dy)); + float dist = std::sqrt((dx*dx) + (dy*dy)); vcos = dx / dist; vsin = dy / dist; } @@ -1499,8 +1499,8 @@ bool Position::HasInArc(float arc, const Position* obj, float border) const // move angle to range -pi ... +pi angle = NormalizeOrientation(angle); - if (angle > M_PI) - angle -= 2.0f*M_PI; + if (angle > float(M_PI)) + angle -= 2.0f * float(M_PI); float lborder = -1 * (arc/border); // in range -pi..0 float rborder = (arc/border); // in range 0..pi @@ -1534,7 +1534,7 @@ bool WorldObject::isInFront(WorldObject const* target, float arc) const bool WorldObject::isInBack(WorldObject const* target, float arc) const { - return !HasInArc(2 * M_PI - arc, target); + return !HasInArc(2 * float(M_PI) - arc, target); } void WorldObject::GetRandomPoint(const Position &pos, float distance, float &rand_x, float &rand_y, float &rand_z) const @@ -1837,7 +1837,7 @@ bool WorldObject::CanDetectStealthOf(WorldObject const* obj) const if (distance < combatReach) return true; - if (!HasInArc(M_PI, obj)) + if (!HasInArc(float(M_PI), obj)) return false; GameObject const* go = ToGameObject(); @@ -2504,7 +2504,7 @@ void WorldObject::GetNearPoint(WorldObject const* /*searcher*/, float &x, float float first_z = z; // loop in a circle to look for a point in LoS using small steps - for (float angle = M_PI / 8; angle < M_PI * 2; angle += M_PI / 8) + for (float angle = float(M_PI) / 8; angle < float(M_PI) * 2; angle += float(M_PI) / 8) { GetNearPoint2D(x, y, distance2d + searcher_size, absAngle + angle); z = GetPositionZ(); @@ -2574,20 +2574,20 @@ void WorldObject::MovePosition(Position &pos, float dist, float angle) ground = GetMap()->GetHeight(GetPhaseMask(), destx, desty, MAX_HEIGHT, true); floor = GetMap()->GetHeight(GetPhaseMask(), destx, desty, pos.m_positionZ, true); - destz = fabs(ground - pos.m_positionZ) <= fabs(floor - pos.m_positionZ) ? ground : floor; + destz = std::fabs(ground - pos.m_positionZ) <= std::fabs(floor - pos.m_positionZ) ? ground : floor; float step = dist/10.0f; for (uint8 j = 0; j < 10; ++j) { // do not allow too big z changes - if (fabs(pos.m_positionZ - destz) > 6) + if (std::fabs(pos.m_positionZ - destz) > 6) { destx -= step * std::cos(angle); desty -= step * std::sin(angle); ground = GetMap()->GetHeight(GetPhaseMask(), destx, desty, MAX_HEIGHT, true); floor = GetMap()->GetHeight(GetPhaseMask(), destx, desty, pos.m_positionZ, true); - destz = fabs(ground - pos.m_positionZ) <= fabs(floor - pos.m_positionZ) ? ground : floor; + destz = std::fabs(ground - pos.m_positionZ) <= std::fabs(floor - pos.m_positionZ) ? ground : floor; } // we have correct destz now else @@ -2608,7 +2608,7 @@ float NormalizeZforCollision(WorldObject* obj, float x, float y, float z) { float ground = obj->GetMap()->GetHeight(obj->GetPhaseMask(), x, y, MAX_HEIGHT, true); float floor = obj->GetMap()->GetHeight(obj->GetPhaseMask(), x, y, z + 2.0f, true); - float helper = fabs(ground - z) <= fabs(floor - z) ? ground : floor; + float helper = std::fabs(ground - z) <= std::fabs(floor - z) ? ground : floor; if (z > helper) // must be above ground { if (Unit* unit = obj->ToUnit()) @@ -2623,7 +2623,7 @@ float NormalizeZforCollision(WorldObject* obj, float x, float y, float z) if (liquid_status.level > z) // z is underwater return z; else - return fabs(liquid_status.level - z) <= fabs(helper - z) ? liquid_status.level : helper; + return std::fabs(liquid_status.level - z) <= std::fabs(helper - z) ? liquid_status.level : helper; } } return helper; @@ -2652,7 +2652,7 @@ void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float // move back a bit destx -= CONTACT_DISTANCE * std::cos(angle); desty -= CONTACT_DISTANCE * std::sin(angle); - dist = sqrt((pos.m_positionX - destx)*(pos.m_positionX - destx) + (pos.m_positionY - desty)*(pos.m_positionY - desty)); + dist = std::sqrt((pos.m_positionX - destx)*(pos.m_positionX - destx) + (pos.m_positionY - desty)*(pos.m_positionY - desty)); } // check dynamic collision @@ -2663,7 +2663,7 @@ void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float { destx -= CONTACT_DISTANCE * std::cos(angle); desty -= CONTACT_DISTANCE * std::sin(angle); - dist = sqrt((pos.m_positionX - destx)*(pos.m_positionX - destx) + (pos.m_positionY - desty)*(pos.m_positionY - desty)); + dist = std::sqrt((pos.m_positionX - destx)*(pos.m_positionX - destx) + (pos.m_positionY - desty)*(pos.m_positionY - desty)); } float step = dist / 10.0f; @@ -2671,7 +2671,7 @@ void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float for (uint8 j = 0; j < 10; ++j) { // do not allow too big z changes - if (fabs(pos.m_positionZ - destz) > 6.0f) + if (std::fabs(pos.m_positionZ - destz) > 6.0f) { destx -= step * std::cos(angle); desty -= step * std::sin(angle); diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index 13f4dd13a83..cdc61f8b2ff 100644 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -206,7 +206,7 @@ class Object void BuildFieldsUpdate(Player*, UpdateDataMapType &) const; void SetFieldNotifyFlag(uint16 flag) { _fieldNotifyFlags |= flag; } - void RemoveFieldNotifyFlag(uint16 flag) { _fieldNotifyFlags &= ~flag; } + void RemoveFieldNotifyFlag(uint16 flag) { _fieldNotifyFlags &= uint16(~flag); } // FG: some hacky helpers void ForceValuesUpdateAtIndex(uint32); @@ -352,19 +352,19 @@ struct Position float GetExactDist2dSq(float x, float y) const { float dx = m_positionX - x; float dy = m_positionY - y; return dx*dx + dy*dy; } float GetExactDist2d(const float x, const float y) const - { return sqrt(GetExactDist2dSq(x, y)); } + { return std::sqrt(GetExactDist2dSq(x, y)); } float GetExactDist2dSq(Position const* pos) const { float dx = m_positionX - pos->m_positionX; float dy = m_positionY - pos->m_positionY; return dx*dx + dy*dy; } float GetExactDist2d(Position const* pos) const - { return sqrt(GetExactDist2dSq(pos)); } + { return std::sqrt(GetExactDist2dSq(pos)); } float GetExactDistSq(float x, float y, float z) const { float dz = m_positionZ - z; return GetExactDist2dSq(x, y) + dz*dz; } float GetExactDist(float x, float y, float z) const - { return sqrt(GetExactDistSq(x, y, z)); } + { return std::sqrt(GetExactDistSq(x, y, z)); } float GetExactDistSq(Position const* pos) const { float dx = m_positionX - pos->m_positionX; float dy = m_positionY - pos->m_positionY; float dz = m_positionZ - pos->m_positionZ; return dx*dx + dy*dy + dz*dz; } float GetExactDist(Position const* pos) const - { return sqrt(GetExactDistSq(pos)); } + { return std::sqrt(GetExactDistSq(pos)); } void GetPositionOffsetTo(Position const & endPos, Position & retOffset) const; @@ -395,11 +395,11 @@ struct Position if (o < 0) { float mod = o *-1; - mod = fmod(mod, 2.0f * static_cast<float>(M_PI)); + mod = std::fmod(mod, 2.0f * static_cast<float>(M_PI)); mod = -mod + 2.0f * static_cast<float>(M_PI); return mod; } - return fmod(o, 2.0f * static_cast<float>(M_PI)); + return std::fmod(o, 2.0f * static_cast<float>(M_PI)); } }; ByteBuffer& operator>>(ByteBuffer& buf, Position::PositionXYZOStreamer const& streamer); @@ -639,8 +639,8 @@ class WorldObject : public Object, public WorldLocation bool IsInRange(WorldObject const* obj, float minRange, float maxRange, bool is3D = true) const; bool IsInRange2d(float x, float y, float minRange, float maxRange) const; bool IsInRange3d(float x, float y, float z, float minRange, float maxRange) const; - bool isInFront(WorldObject const* target, float arc = M_PI) const; - bool isInBack(WorldObject const* target, float arc = M_PI) const; + bool isInFront(WorldObject const* target, float arc = float(M_PI)) const; + bool isInBack(WorldObject const* target, float arc = float(M_PI)) const; bool IsInBetween(WorldObject const* obj1, WorldObject const* obj2, float size = 0) const; diff --git a/src/server/game/Entities/Object/ObjectPosSelector.cpp b/src/server/game/Entities/Object/ObjectPosSelector.cpp index fa7c5dffafa..da2049ac62f 100644 --- a/src/server/game/Entities/Object/ObjectPosSelector.cpp +++ b/src/server/game/Entities/Object/ObjectPosSelector.cpp @@ -21,7 +21,7 @@ ObjectPosSelector::ObjectPosSelector(float x, float y, float size, float dist) : m_center_x(x), m_center_y(y), m_size(size), m_dist(dist) { - m_anglestep = acos(m_dist/(m_dist+2*m_size)); + m_anglestep = std::acos(m_dist/(m_dist+2*m_size)); m_nextUsedPos[USED_POS_PLUS] = m_UsedPosLists[USED_POS_PLUS].end(); m_nextUsedPos[USED_POS_MINUS] = m_UsedPosLists[USED_POS_MINUS].end(); diff --git a/src/server/game/Entities/Object/ObjectPosSelector.h b/src/server/game/Entities/Object/ObjectPosSelector.h index 5bac179880f..44b85dae3dd 100644 --- a/src/server/game/Entities/Object/ObjectPosSelector.h +++ b/src/server/game/Entities/Object/ObjectPosSelector.h @@ -60,10 +60,10 @@ struct ObjectPosSelector float angle_step2 = GetAngle(nextUsedPos.second); float next_angle = nextUsedPos.first; - if (nextUsedPos.second.sign * sign < 0) // last node from diff. list (-pi+alpha) - next_angle = 2*M_PI-next_angle; // move to positive + if (nextUsedPos.second.sign * sign < 0) // last node from diff. list (-pi+alpha) + next_angle = 2 * float(M_PI) - next_angle; // move to positive - return fabs(angle)+angle_step2 <= next_angle; + return std::fabs(angle) + angle_step2 <= next_angle; } bool CheckOriginal() const @@ -105,7 +105,7 @@ struct ObjectPosSelector // next possible angle angle = m_smallStepAngle[uptype] + m_anglestep * sign; - if (fabs(angle) > M_PI) + if (std::fabs(angle) > float(M_PI)) { m_smallStepOk[uptype] = false; return false; @@ -113,7 +113,7 @@ struct ObjectPosSelector if (m_smallStepNextUsedPos[uptype]) { - if (fabs(angle) >= m_smallStepNextUsedPos[uptype]->first) + if (std::fabs(angle) >= m_smallStepNextUsedPos[uptype]->first) { m_smallStepOk[uptype] = false; return false; @@ -136,7 +136,7 @@ struct ObjectPosSelector UsedPosList::value_type const* nextUsedPos(UsedPosType uptype); // angle from used pos to next possible free pos - float GetAngle(UsedPos const& usedPos) const { return acos(m_dist/(usedPos.dist+usedPos.size+m_size)); } + float GetAngle(UsedPos const& usedPos) const { return std::acos(m_dist/(usedPos.dist+usedPos.size+m_size)); } float m_center_x; float m_center_y; diff --git a/src/server/game/Entities/Pet/PetDefines.h b/src/server/game/Entities/Pet/PetDefines.h index f590bef233e..67435c30577 100644 --- a/src/server/game/Entities/Pet/PetDefines.h +++ b/src/server/game/Entities/Pet/PetDefines.h @@ -75,6 +75,6 @@ enum PetTalk }; #define PET_FOLLOW_DIST 1.0f -#define PET_FOLLOW_ANGLE (M_PI/2) +#define PET_FOLLOW_ANGLE float(M_PI/2) #endif diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 357e1a34c09..122eff6ba3a 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -1662,7 +1662,7 @@ void Player::Update(uint32 p_time) } } //120 degrees of radiant range - else if (!HasInArc(2*M_PI/3, victim)) + else if (!HasInArc(2 * float(M_PI) / 3, victim)) { setAttackTimer(BASE_ATTACK, 100); if (m_swingErrorMsg != 2) // send single time (client auto repeat) @@ -1690,7 +1690,7 @@ void Player::Update(uint32 p_time) { if (!IsWithinMeleeRange(victim)) setAttackTimer(OFF_ATTACK, 100); - else if (!HasInArc(2*M_PI/3, victim)) + else if (!HasInArc(2 * float(M_PI) / 3, victim)) setAttackTimer(OFF_ATTACK, 100); else { @@ -2586,7 +2586,7 @@ void Player::Regenerate(Powers power) return; addvalue += m_powerFraction[power]; - uint32 integerValue = uint32(fabs(addvalue)); + uint32 integerValue = uint32(std::fabs(addvalue)); if (addvalue < 0.0f) { @@ -7185,7 +7185,7 @@ bool Player::RewardHonor(Unit* victim, uint32 groupsize, int32 honor, bool pvpto else victim_guid = 0; // Don't show HK: <rank> message, only log. - honor_f = ceil(Trinity::Honor::hk_honor_at_level_f(k_level) * (v_level - k_grey) / (k_level - k_grey)); + honor_f = std::ceil(Trinity::Honor::hk_honor_at_level_f(k_level) * (v_level - k_grey) / (k_level - k_grey)); // count the number of playerkills in one day ApplyModUInt32Value(PLAYER_FIELD_KILLS, 1, true); @@ -8909,7 +8909,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type) loot->FillLoot(1, LootTemplates_Creature, this, true); // It may need a better formula // Now it works like this: lvl10: ~6copper, lvl70: ~9silver - bones->loot.gold = uint32(urand(50, 150) * 0.016f * pow(float(pLevel)/5.76f, 2.5f) * sWorld->getRate(RATE_DROP_MONEY)); + bones->loot.gold = uint32(urand(50, 150) * 0.016f * std::pow(float(pLevel) / 5.76f, 2.5f) * sWorld->getRate(RATE_DROP_MONEY)); } if (bones->lootRecipient != this) diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp index 367ccd34cdb..e7633d1f097 100644 --- a/src/server/game/Entities/Transport/Transport.cpp +++ b/src/server/game/Entities/Transport/Transport.cpp @@ -206,7 +206,7 @@ void Transport::Update(uint32 diff) G3D::Vector3 pos, dir; _currentFrame->Spline->evaluate_percent(_currentFrame->Index, t, pos); _currentFrame->Spline->evaluate_derivative(_currentFrame->Index, t, dir); - UpdatePosition(pos.x, pos.y, pos.z, atan2(dir.y, dir.x) + M_PI); + UpdatePosition(pos.x, pos.y, pos.z, std::atan2(dir.y, dir.x) + float(M_PI)); } else { diff --git a/src/server/game/Entities/Unit/StatSystem.cpp b/src/server/game/Entities/Unit/StatSystem.cpp index bac2a8ef856..94f0a90be2f 100644 --- a/src/server/game/Entities/Unit/StatSystem.cpp +++ b/src/server/game/Entities/Unit/StatSystem.cpp @@ -878,7 +878,7 @@ void Player::UpdateManaRegen() { float Intellect = GetStat(STAT_INTELLECT); // Mana regen from spirit and intellect - float power_regen = sqrt(Intellect) * OCTRegenMPPerSpirit(); + float power_regen = std::sqrt(Intellect) * OCTRegenMPPerSpirit(); // Apply PCT bonus from SPELL_AURA_MOD_POWER_REGEN_PERCENT aura on spirit base regen power_regen *= GetTotalAuraMultiplierByMiscValue(SPELL_AURA_MOD_POWER_REGEN_PERCENT, POWER_MANA); diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index a42836682bb..aed06441dd7 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -62,7 +62,7 @@ #include "WorldPacket.h" #include "WorldSession.h" -#include <math.h> +#include <cmath> float baseMoveSpeed[MAX_MOVE_TYPE] = { @@ -1363,7 +1363,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss) // If this is a creature and it attacks from behind it has a probability to daze it's victim if ((damageInfo->hitOutCome == MELEE_HIT_CRIT || damageInfo->hitOutCome == MELEE_HIT_CRUSHING || damageInfo->hitOutCome == MELEE_HIT_NORMAL || damageInfo->hitOutCome == MELEE_HIT_GLANCING) && - GetTypeId() != TYPEID_PLAYER && !ToCreature()->IsControlledByPlayer() && !victim->HasInArc(M_PI, this) + GetTypeId() != TYPEID_PLAYER && !ToCreature()->IsControlledByPlayer() && !victim->HasInArc(float(M_PI), this) && (victim->GetTypeId() == TYPEID_PLAYER || !victim->ToCreature()->isWorldBoss())&& !victim->IsVehicle()) { // -probability is between 0% and 40% @@ -1377,7 +1377,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss) uint32 VictimDefense=victim->GetDefenseSkillValue(); uint32 AttackerMeleeSkill=GetUnitMeleeSkill(); - Probability *= AttackerMeleeSkill/(float)VictimDefense*0.16; + Probability *= AttackerMeleeSkill/(float)VictimDefense*0.16f; if (Probability < 0) Probability = 0; @@ -1489,14 +1489,14 @@ uint32 Unit::CalcArmorReducedDamage(Unit* victim, const uint32 damage, SpellInfo { if ((*j)->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL && (*j)->IsAffectedOnSpell(spellInfo)) - armor = floor(AddPct(armor, -(*j)->GetAmount())); + armor = std::floor(AddPct(armor, -(*j)->GetAmount())); } AuraEffectList const& resIgnoreAuras = GetAuraEffectsByType(SPELL_AURA_MOD_IGNORE_TARGET_RESIST); for (AuraEffectList::const_iterator j = resIgnoreAuras.begin(); j != resIgnoreAuras.end(); ++j) { if ((*j)->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL) - armor = floor(AddPct(armor, -(*j)->GetAmount())); + armor = std::floor(AddPct(armor, -(*j)->GetAmount())); } // Apply Player CR_ARMOR_PENETRATION rating and buffs from stances\specializations etc. @@ -1607,7 +1607,7 @@ uint32 Unit::CalcSpellResistance(Unit* victim, SpellSchoolMask schoolMask, Spell float discreteResistProbability[11]; for (uint32 i = 0; i < 11; ++i) { - discreteResistProbability[i] = 0.5f - 2.5f * fabs(0.1f * i - averageResist); + discreteResistProbability[i] = 0.5f - 2.5f * std::fabs(0.1f * i - averageResist); if (discreteResistProbability[i] < 0.0f) discreteResistProbability[i] = 0.0f; } @@ -2032,7 +2032,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit* victim, WeaponAttackT // Dodge chance // only players can't dodge if attacker is behind - if (victim->GetTypeId() == TYPEID_PLAYER && !victim->HasInArc(M_PI, this) && !victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION)) + if (victim->GetTypeId() == TYPEID_PLAYER && !victim->HasInArc(float(M_PI), this) && !victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION)) { TC_LOG_DEBUG("entities.unit", "RollMeleeOutcomeAgainst: attack came from behind and victim was a player."); } @@ -2061,7 +2061,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit* victim, WeaponAttackT // parry & block chances // check if attack comes from behind, nobody can parry or block if attacker is behind - if (!victim->HasInArc(M_PI, this) && !victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION)) + if (!victim->HasInArc(float(M_PI), this) && !victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION)) TC_LOG_DEBUG("entities.unit", "RollMeleeOutcomeAgainst: attack came from behind."); else { @@ -2244,7 +2244,7 @@ bool Unit::isSpellBlocked(Unit* victim, SpellInfo const* spellProto, WeaponAttac if (spellProto && spellProto->Attributes & SPELL_ATTR0_IMPOSSIBLE_DODGE_PARRY_BLOCK) return false; - if (victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION) || victim->HasInArc(M_PI, this)) + if (victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION) || victim->HasInArc(float(M_PI), this)) { // Check creatures flags_extra for disable block if (victim->GetTypeId() == TYPEID_UNIT && @@ -2375,7 +2375,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* victim, SpellInfo const* spellInfo canDodge = false; // only if in front - if (victim->HasInArc(M_PI, this) || victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION)) + if (victim->HasInArc(float(M_PI), this) || victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION)) { int32 deflect_chance = victim->GetTotalAuraModifier(SPELL_AURA_DEFLECT_SPELLS) * 100; tmp += deflect_chance; @@ -2386,7 +2386,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* victim, SpellInfo const* spellInfo } // Check for attack from behind - if (!victim->HasInArc(M_PI, this)) + if (!victim->HasInArc(float(M_PI), this)) { if (!victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION)) { @@ -2567,7 +2567,7 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit* victim, SpellInfo const* spellInfo return SPELL_MISS_RESIST; // cast by caster in front of victim - if (victim->HasInArc(M_PI, this) || victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION)) + if (victim->HasInArc(float(M_PI), this) || victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION)) { int32 deflect_chance = victim->GetTotalAuraModifier(SPELL_AURA_DEFLECT_SPELLS) * 100; tmp += deflect_chance; @@ -3143,7 +3143,7 @@ bool Unit::isInFrontInMap(Unit const* target, float distance, float arc) const bool Unit::isInBackInMap(Unit const* target, float distance, float arc) const { - return IsWithinDistInMap(target, distance) && !HasInArc(2 * M_PI - arc, target); + return IsWithinDistInMap(target, distance) && !HasInArc(2 * float(M_PI) - arc, target); } bool Unit::isInAccessiblePlaceFor(Creature const* c) const @@ -11545,7 +11545,7 @@ float Unit::GetPPMProcChance(uint32 WeaponSpeed, float PPM, const SpellInfo* spe if (Player* modOwner = GetSpellModOwner()) modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_PROC_PER_MINUTE, PPM); - return floor((WeaponSpeed * PPM) / 600.0f); // result is chance in percents (probability = Speed_in_sec * (PPM / 60)) + return std::floor((WeaponSpeed * PPM) / 600.0f); // result is chance in percents (probability = Speed_in_sec * (PPM / 60)) } void Unit::Mount(uint32 mount, uint32 VehicleId, uint32 creatureEntry) @@ -16734,7 +16734,7 @@ uint32 Unit::GetModelForTotem(PlayerTotemType totemType) void Unit::JumpTo(float speedXY, float speedZ, bool forward) { - float angle = forward ? 0 : M_PI; + float angle = forward ? 0 : float(M_PI); if (GetTypeId() == TYPEID_UNIT) GetMotionMaster()->MoveJumpTo(angle, speedXY, speedZ); else diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 2e8d93ec995..a18bc3b0848 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1908,8 +1908,8 @@ class Unit : public WorldObject uint32 CalculateDamage(WeaponAttackType attType, bool normalized, bool addTotalPct); float GetAPMultiplier(WeaponAttackType attType, bool normalized); - bool isInFrontInMap(Unit const* target, float distance, float arc = M_PI) const; - bool isInBackInMap(Unit const* target, float distance, float arc = M_PI) const; + bool isInFrontInMap(Unit const* target, float distance, float arc = float(M_PI)) const; + bool isInBackInMap(Unit const* target, float distance, float arc = float(M_PI)) const; // Visibility system bool IsVisible() const; diff --git a/src/server/game/Grids/GridDefines.h b/src/server/game/Grids/GridDefines.h index 013d0ef5794..7989828e858 100644 --- a/src/server/game/Grids/GridDefines.h +++ b/src/server/game/Grids/GridDefines.h @@ -198,8 +198,8 @@ namespace Trinity int x_val = int(x_offset + CENTER_GRID_CELL_ID + 0.5f); int y_val = int(y_offset + CENTER_GRID_CELL_ID + 0.5f); - x_off = (float(x_offset) - x_val + CENTER_GRID_CELL_ID) * SIZE_OF_GRID_CELL; - y_off = (float(y_offset) - y_val + CENTER_GRID_CELL_ID) * SIZE_OF_GRID_CELL; + x_off = (float(x_offset) - float(x_val) + CENTER_GRID_CELL_ID) * SIZE_OF_GRID_CELL; + y_off = (float(y_offset) - float(y_val) + CENTER_GRID_CELL_ID) * SIZE_OF_GRID_CELL; return CellCoord(x_val, y_val); } diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp index baa20f76a40..b6c508e9e4c 100644 --- a/src/server/game/Handlers/MiscHandler.cpp +++ b/src/server/game/Handlers/MiscHandler.cpp @@ -877,9 +877,9 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recvData) float dz = player->GetPositionZ() - atEntry->z; float dx = rotPlayerX - atEntry->x; float dy = rotPlayerY - atEntry->y; - if ((fabs(dx) > atEntry->box_x / 2 + delta) || - (fabs(dy) > atEntry->box_y / 2 + delta) || - (fabs(dz) > atEntry->box_z / 2 + delta)) + if ((std::fabs(dx) > atEntry->box_x / 2 + delta) || + (std::fabs(dy) > atEntry->box_y / 2 + delta) || + (std::fabs(dz) > atEntry->box_z / 2 + delta)) { TC_LOG_DEBUG("network", "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) too far (1/2 box X: %f 1/2 box Y: %f 1/2 box Z: %f rotatedPlayerX: %f rotatedPlayerY: %f dZ:%f), ignore Area Trigger ID: %u", player->GetName().c_str(), player->GetGUIDLow(), atEntry->box_x/2, atEntry->box_y/2, atEntry->box_z/2, rotPlayerX, rotPlayerY, dz, triggerId); diff --git a/src/server/game/Handlers/MovementHandler.cpp b/src/server/game/Handlers/MovementHandler.cpp index 6fedc481a14..64d0ae36e7a 100644 --- a/src/server/game/Handlers/MovementHandler.cpp +++ b/src/server/game/Handlers/MovementHandler.cpp @@ -467,7 +467,7 @@ void WorldSession::HandleForceSpeedChangeAck(WorldPacket &recvData) return; } - if (!_player->GetTransport() && fabs(_player->GetSpeed(move_type) - newspeed) > 0.01f) + if (!_player->GetTransport() && std::fabs(_player->GetSpeed(move_type) - newspeed) > 0.01f) { if (_player->GetSpeed(move_type) > newspeed) // must be greater - just correct { diff --git a/src/server/game/Loot/LootMgr.h b/src/server/game/Loot/LootMgr.h index 09809d50b10..09905572aae 100644 --- a/src/server/game/Loot/LootMgr.h +++ b/src/server/game/Loot/LootMgr.h @@ -136,7 +136,7 @@ struct LootStoreItem // Constructor, converting ChanceOrQuestChance -> (chance, needs_quest) // displayid is filled in IsValid() which must be called after LootStoreItem(uint32 _itemid, float _chanceOrQuestChance, uint16 _lootmode, uint8 _group, int32 _mincountOrRef, uint8 _maxcount) - : itemid(_itemid), chance(fabs(_chanceOrQuestChance)), mincountOrRef(_mincountOrRef), lootmode(_lootmode), + : itemid(_itemid), chance(std::fabs(_chanceOrQuestChance)), mincountOrRef(_mincountOrRef), lootmode(_lootmode), group(_group), needs_quest(_chanceOrQuestChance < 0), maxcount(_maxcount) { } diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index 47cb7504fb8..243a931d463 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -2171,7 +2171,7 @@ float Map::GetHeight(float x, float y, float z, bool checkVMap /*= true*/, float // we are already under the surface or vmap height above map heigt // or if the distance of the vmap height is less the land height distance - if (z < mapHeight || vmapHeight > mapHeight || fabs(mapHeight-z) > fabs(vmapHeight-z)) + if (z < mapHeight || vmapHeight > mapHeight || std::fabs(mapHeight - z) > std::fabs(vmapHeight - z)) return vmapHeight; else return mapHeight; // better use .map surface height diff --git a/src/server/game/Maps/TransportMgr.cpp b/src/server/game/Maps/TransportMgr.cpp index 28869d264c4..a177965b99f 100644 --- a/src/server/game/Maps/TransportMgr.cpp +++ b/src/server/game/Maps/TransportMgr.cpp @@ -139,7 +139,7 @@ void TransportMgr::GeneratePath(GameObjectTemplate const* goInfo, TransportTempl KeyFrame k(node_i); G3D::Vector3 h; orientationSpline.evaluate_derivative(i + 1, 0.0f, h); - k.InitialOrientation = Position::NormalizeOrientation(atan2(h.y, h.x) + M_PI); + k.InitialOrientation = Position::NormalizeOrientation(std::atan2(h.y, h.x) + float(M_PI)); keyFrames.push_back(k); splinePath.push_back(G3D::Vector3(node_i.x, node_i.y, node_i.z)); @@ -213,7 +213,7 @@ void TransportMgr::GeneratePath(GameObjectTemplate const* goInfo, TransportTempl for (size_t j = start; j < i + extra; ++j) { keyFrames[j].Index = j - start + 1; - keyFrames[j].DistFromPrev = spline->length(j - start, j + 1 - start); + keyFrames[j].DistFromPrev = float(spline->length(j - start, j + 1 - start)); if (j > 0) keyFrames[j - 1].NextDistFromPrev = keyFrames[j].DistFromPrev; keyFrames[j].Spline = spline; @@ -276,22 +276,22 @@ void TransportMgr::GeneratePath(GameObjectTemplate const* goInfo, TransportTempl if (keyFrames[i].DistSinceStop < keyFrames[i].DistUntilStop) // is still accelerating { // calculate accel+brake time for this short segment - float segment_time = 2.0f * sqrt((keyFrames[i].DistUntilStop + keyFrames[i].DistSinceStop) / accel); + float segment_time = 2.0f * std::sqrt((keyFrames[i].DistUntilStop + keyFrames[i].DistSinceStop) / accel); // substract acceleration time - keyFrames[i].TimeTo = segment_time - sqrt(2 * keyFrames[i].DistSinceStop / accel); + keyFrames[i].TimeTo = segment_time - std::sqrt(2 * keyFrames[i].DistSinceStop / accel); } else // slowing down - keyFrames[i].TimeTo = sqrt(2 * keyFrames[i].DistUntilStop / accel); + keyFrames[i].TimeTo = std::sqrt(2 * keyFrames[i].DistUntilStop / accel); } else if (keyFrames[i].DistSinceStop < accel_dist) // still accelerating (but will reach full speed) { // calculate accel + cruise + brake time for this long segment float segment_time = (keyFrames[i].DistUntilStop + keyFrames[i].DistSinceStop) / speed + (speed / accel); // substract acceleration time - keyFrames[i].TimeTo = segment_time - sqrt(2 * keyFrames[i].DistSinceStop / accel); + keyFrames[i].TimeTo = segment_time - std::sqrt(2 * keyFrames[i].DistSinceStop / accel); } else if (keyFrames[i].DistUntilStop < accel_dist) // already slowing down (but reached full speed) - keyFrames[i].TimeTo = sqrt(2 * keyFrames[i].DistUntilStop / accel); + keyFrames[i].TimeTo = std::sqrt(2 * keyFrames[i].DistUntilStop / accel); else // at full speed keyFrames[i].TimeTo = (keyFrames[i].DistUntilStop / speed) + (0.5f * speed / accel); } diff --git a/src/server/game/Movement/MotionMaster.cpp b/src/server/game/Movement/MotionMaster.cpp index 55f745d993b..4ba742e9397 100644 --- a/src/server/game/Movement/MotionMaster.cpp +++ b/src/server/game/Movement/MotionMaster.cpp @@ -345,7 +345,7 @@ void MotionMaster::MoveKnockbackFrom(float srcX, float srcY, float speedXY, floa float dist = 2 * moveTimeHalf * speedXY; float max_height = -Movement::computeFallElevation(moveTimeHalf, false, -speedZ); - _owner->GetNearPoint(_owner, x, y, z, _owner->GetObjectSize(), dist, _owner->GetAngle(srcX, srcY) + M_PI); + _owner->GetNearPoint(_owner, x, y, z, _owner->GetObjectSize(), dist, _owner->GetAngle(srcX, srcY) + float(M_PI)); Movement::MoveSplineInit init(_owner); init.MoveTo(x, y, z); @@ -399,7 +399,7 @@ void MotionMaster::MoveFall(uint32 id /*=0*/) } // Abort too if the ground is very near - if (fabs(_owner->GetPositionZ() - tz) < 0.1f) + if (std::fabs(_owner->GetPositionZ() - tz) < 0.1f) return; if (_owner->GetTypeId() == TYPEID_PLAYER) diff --git a/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp index 95c342b70b3..dbe8c8b0329 100644 --- a/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp @@ -61,7 +61,7 @@ void RandomMovementGenerator<Creature>::_setRandomLocation(Creature* creature) if (is_air_ok) // 3D system above ground and above water (flying mode) { // Limit height change - const float distanceZ = float(rand_norm()) * sqrtf(travelDistZ)/2.0f; + const float distanceZ = float(rand_norm()) * std::sqrt(travelDistZ)/2.0f; destZ = respZ + distanceZ; float levelZ = map->GetWaterOrGroundLevel(destX, destY, destZ-2.0f); @@ -73,24 +73,24 @@ void RandomMovementGenerator<Creature>::_setRandomLocation(Creature* creature) else // 2D only { // 10.0 is the max that vmap high can check (MAX_CAN_FALL_DISTANCE) - travelDistZ = travelDistZ >= 100.0f ? 10.0f : sqrtf(travelDistZ); + travelDistZ = travelDistZ >= 100.0f ? 10.0f : std::sqrt(travelDistZ); // The fastest way to get an accurate result 90% of the time. // Better result can be obtained like 99% accuracy with a ray light, but the cost is too high and the code is too long. destZ = map->GetHeight(creature->GetPhaseMask(), destX, destY, respZ+travelDistZ-2.0f, false); - if (fabs(destZ - respZ) > travelDistZ) // Map check + if (std::fabs(destZ - respZ) > travelDistZ) // Map check { // Vmap Horizontal or above destZ = map->GetHeight(creature->GetPhaseMask(), destX, destY, respZ - 2.0f, true); - if (fabs(destZ - respZ) > travelDistZ) + if (std::fabs(destZ - respZ) > travelDistZ) { // Vmap Higher destZ = map->GetHeight(creature->GetPhaseMask(), destX, destY, respZ+travelDistZ-2.0f, true); // let's forget this bad coords where a z cannot be find and retry at next tick - if (fabs(destZ - respZ) > travelDistZ) + if (std::fabs(destZ - respZ) > travelDistZ) return; } } diff --git a/src/server/game/Movement/Spline/MoveSpline.cpp b/src/server/game/Movement/Spline/MoveSpline.cpp index 7291c6849c5..d3fa03c1238 100644 --- a/src/server/game/Movement/Spline/MoveSpline.cpp +++ b/src/server/game/Movement/Spline/MoveSpline.cpp @@ -47,7 +47,7 @@ Location MoveSpline::ComputePosition() const if (splineflags.final_angle) c.orientation = facing.angle; else if (splineflags.final_point) - c.orientation = atan2(facing.f.y - c.y, facing.f.x - c.x); + c.orientation = std::atan2(facing.f.y - c.y, facing.f.x - c.x); //nothing to do for MoveSplineFlag::Final_Target flag } else @@ -56,7 +56,7 @@ Location MoveSpline::ComputePosition() const { Vector3 hermite; spline.evaluate_derivative(point_Idx, u, hermite); - c.orientation = atan2(hermite.y, hermite.x); + c.orientation = std::atan2(hermite.y, hermite.x); } if (splineflags.orientationInversed) @@ -226,7 +226,7 @@ bool MoveSplineInitArgs::_checkPathBounds() const for (uint32 i = 1; i < path.size()-1; ++i) { offset = path[i] - middle; - if (fabs(offset.x) >= MAX_OFFSET || fabs(offset.y) >= MAX_OFFSET || fabs(offset.z) >= MAX_OFFSET) + if (std::fabs(offset.x) >= MAX_OFFSET || std::fabs(offset.y) >= MAX_OFFSET || std::fabs(offset.z) >= MAX_OFFSET) { TC_LOG_ERROR("misc", "MoveSplineInitArgs::_checkPathBounds check failed"); return false; diff --git a/src/server/game/Movement/Spline/MovementTypedefs.h b/src/server/game/Movement/Spline/MovementTypedefs.h index 635c43757be..031ec729949 100644 --- a/src/server/game/Movement/Spline/MovementTypedefs.h +++ b/src/server/game/Movement/Spline/MovementTypedefs.h @@ -69,7 +69,7 @@ namespace Movement typedef counter<uint32, 0xFFFFFFFF> UInt32Counter; - extern double gravity; + extern float gravity; extern UInt32Counter splineIdGen; } diff --git a/src/server/game/Movement/Spline/MovementUtil.cpp b/src/server/game/Movement/Spline/MovementUtil.cpp index 375859263ab..7e63f029fd4 100644 --- a/src/server/game/Movement/Spline/MovementUtil.cpp +++ b/src/server/game/Movement/Spline/MovementUtil.cpp @@ -17,12 +17,12 @@ */ #include "MoveSplineFlag.h" -#include <math.h> +#include <cmath> #include <string> namespace Movement { - double gravity = 19.29110527038574; + float gravity = static_cast<float>(19.29110527038574); UInt32Counter splineIdGen; /// Velocity bounds that makes fall speed limited @@ -45,14 +45,14 @@ namespace Movement if (path_length >= terminal_safeFall_length) time = (path_length - terminal_safeFall_length) / terminalSafefallVelocity + terminal_safeFall_fallTime; else - time = sqrtf(2.0f * path_length / gravity); + time = std::sqrt(2.0f * path_length / gravity); } else { if (path_length >= terminal_length) time = (path_length - terminal_length) / terminalVelocity + terminal_fallTime; else - time = sqrtf(2.0f * path_length / gravity); + time = std::sqrt(2.0f * path_length / gravity); } return time; diff --git a/src/server/game/Movement/Spline/Spline.cpp b/src/server/game/Movement/Spline/Spline.cpp index 6424afc5d6e..b8a028b6fc0 100644 --- a/src/server/game/Movement/Spline/Spline.cpp +++ b/src/server/game/Movement/Spline/Spline.cpp @@ -165,7 +165,7 @@ float SplineBase::SegLengthCatmullRom(index_type index) const curPos = nextPos = p[1]; index_type i = 1; - double length = 0; + float length = 0; while (i <= STEPS_PER_SEGMENT) { C_Evaluate(p, float(i) / float(STEPS_PER_SEGMENT), s_catmullRomCoeffs, nextPos); @@ -188,7 +188,7 @@ float SplineBase::SegLengthBezier3(index_type index) const curPos = nextPos; index_type i = 1; - double length = 0; + float length = 0; while (i <= STEPS_PER_SEGMENT) { C_Evaluate(p, float(i) / float(STEPS_PER_SEGMENT), s_Bezier3Coeffs, nextPos); diff --git a/src/server/game/Movement/Waypoints/Path.h b/src/server/game/Movement/Waypoints/Path.h index 4c275cbc15d..c7e701c49ad 100644 --- a/src/server/game/Movement/Waypoints/Path.h +++ b/src/server/game/Movement/Waypoints/Path.h @@ -63,7 +63,7 @@ class Path float xd = node.x - prev.x; float yd = node.y - prev.y; float zd = node.z - prev.z; - len += sqrtf(xd*xd + yd*yd + zd*zd); + len += std::sqrt(xd*xd + yd*yd + zd*zd); } return len; } @@ -80,7 +80,7 @@ class Path float xd = x - node.x; float yd = y - node.y; float zd = z - node.z; - len += sqrtf(xd*xd + yd*yd + zd*zd); + len += std::sqrt(xd*xd + yd*yd + zd*zd); } return len; diff --git a/src/server/game/Pools/PoolMgr.h b/src/server/game/Pools/PoolMgr.h index d1fcadd40de..dd24cceae07 100644 --- a/src/server/game/Pools/PoolMgr.h +++ b/src/server/game/Pools/PoolMgr.h @@ -33,7 +33,7 @@ struct PoolObject { uint32 guid; float chance; - PoolObject(uint32 _guid, float _chance): guid(_guid), chance(fabs(_chance)) { } + PoolObject(uint32 _guid, float _chance) : guid(_guid), chance(std::fabs(_chance)) { } }; class Pool // for Pool of Pool case diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index cb555bf2954..0f79c4d0780 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -824,7 +824,7 @@ void Spell::SelectSpellTargets() else if (m_spellInfo->Speed > 0.0f) { float dist = m_caster->GetDistance(*m_targets.GetDstPos()); - m_delayMoment = (uint64) floor(dist / m_spellInfo->Speed * 1000.0f); + m_delayMoment = (uint64) std::floor(dist / m_spellInfo->Speed * 1000.0f); } } } @@ -1099,7 +1099,7 @@ void Spell::SelectImplicitConeTargets(SpellEffIndex effIndex, SpellImplicitTarge SpellTargetObjectTypes objectType = targetType.GetObjectType(); SpellTargetCheckTypes selectionType = targetType.GetCheckType(); ConditionList* condList = m_spellInfo->Effects[effIndex].ImplicitTargetConditions; - float coneAngle = M_PI/2; + float coneAngle = float(M_PI) / 2; float radius = m_spellInfo->Effects[effIndex].CalcRadius(m_caster) * m_spellValue->RadiusMod; if (uint32 containerTypeMask = GetSearcherTypeMask(objectType, condList)) @@ -1472,7 +1472,7 @@ void Spell::SelectImplicitChainTargets(SpellEffIndex effIndex, SpellImplicitTarg float tangent(float x) { - x = tan(x); + x = std::tan(x); //if (x < std::numeric_limits<float>::max() && x > -std::numeric_limits<float>::max()) return x; //if (x >= std::numeric_limits<float>::max()) return std::numeric_limits<float>::max(); //if (x <= -std::numeric_limits<float>::max()) return -std::numeric_limits<float>::max(); @@ -1577,7 +1577,7 @@ void Spell::SelectImplicitTrajTargets(SpellEffIndex effIndex) float sqrt1 = b * b + 4 * a * height; if (sqrt1 > 0) { - sqrt1 = sqrt(sqrt1); + sqrt1 = std::sqrt(sqrt1); dist = (sqrt1 - b) / (2 * a); CHECK_DIST; } @@ -1586,7 +1586,7 @@ void Spell::SelectImplicitTrajTargets(SpellEffIndex effIndex) float sqrt2 = b * b + 4 * a * height; if (sqrt2 > 0) { - sqrt2 = sqrt(sqrt2); + sqrt2 = std::sqrt(sqrt2); dist = (sqrt2 - b) / (2 * a); CHECK_DIST; @@ -1615,7 +1615,7 @@ void Spell::SelectImplicitTrajTargets(SpellEffIndex effIndex) DEBUG_TRAJ(TC_LOG_ERROR("spells", "Initial %f %f %f %f %f", x, y, z, distSq, sizeSq);) if (distSq > sizeSq) { - float factor = 1 - sqrt(sizeSq / distSq); + float factor = 1 - std::sqrt(sizeSq / distSq); x += factor * ((*itr)->GetPositionX() - x); y += factor * ((*itr)->GetPositionY() - y); z += factor * ((*itr)->GetPositionZ() - z); @@ -2076,7 +2076,7 @@ void Spell::AddUnitTarget(Unit* target, uint32 effectMask, bool checkIfValid /*= if (dist < 5.0f) dist = 5.0f; - targetInfo.timeDelay = (uint64) floor(dist / m_spellInfo->Speed * 1000.0f); + targetInfo.timeDelay = (uint64)std::floor(dist / m_spellInfo->Speed * 1000.0f); // Calculate minimum incoming time if (m_delayMoment == 0 || m_delayMoment > targetInfo.timeDelay) |
