Core/Misc: Fix some -Wconversion warnings

This commit is contained in:
jackpoz
2014-08-23 19:56:41 +02:00
parent f5f9df0483
commit 7fe7f30521
85 changed files with 207 additions and 206 deletions
@@ -72,11 +72,11 @@ void BIH::subdivide(int left, int right, std::vector<uint32> &tempTree, buildDat
axis = d.primaryAxis();
split = 0.5f * (gridBox.lo[axis] + gridBox.hi[axis]);
// partition L/R subsets
clipL = -G3D::inf();
clipR = G3D::inf();
clipL = -G3D::finf();
clipR = G3D::finf();
rightOrig = right; // save this for later
float nodeL = G3D::inf();
float nodeR = -G3D::inf();
float nodeL = G3D::finf();
float nodeR = -G3D::finf();
for (int i = left; i <= right;)
{
int obj = dat.indices[i];
@@ -187,13 +187,13 @@ void BIH::subdivide(int left, int right, std::vector<uint32> &tempTree, buildDat
stats.updateInner();
tempTree[nodeIndex + 0] = (prevAxis << 30) | nextIndex;
tempTree[nodeIndex + 1] = floatToRawIntBits(prevClip);
tempTree[nodeIndex + 2] = floatToRawIntBits(G3D::inf());
tempTree[nodeIndex + 2] = floatToRawIntBits(G3D::finf());
} else {
// create a node with a right child
// write leaf node
stats.updateInner();
tempTree[nodeIndex + 0] = (prevAxis << 30) | (nextIndex - 3);
tempTree[nodeIndex + 1] = floatToRawIntBits(-G3D::inf());
tempTree[nodeIndex + 1] = floatToRawIntBits(-G3D::finf());
tempTree[nodeIndex + 2] = floatToRawIntBits(prevClip);
}
// count stats for the unused leaf
+1 -1
View File
@@ -256,5 +256,5 @@ float DynamicMapTree::getHeight(float x, float y, float z, float maxSearchDist,
if (callback.didHit())
return v.z - maxSearchDist;
else
return -G3D::inf();
return -G3D::finf();
}
@@ -194,7 +194,7 @@ namespace VMAP
{
Vector3 pos = convertPositionToInternalRep(x, y, z);
float height = instanceTree->second->getHeight(pos, maxSearchDist);
if (!(height < G3D::inf()))
if (!(height < G3D::finf()))
return height = VMAP_INVALID_HEIGHT_VALUE; // No height
return height;
+1 -1
View File
@@ -225,7 +225,7 @@ namespace VMAP
float StaticMapTree::getHeight(const Vector3& pPos, float maxSearchDist) const
{
float height = G3D::inf();
float height = G3D::finf();
Vector3 dir = Vector3(0, 0, -1);
G3D::Ray ray(pPos, dir); // direction with length of 1
float maxDist = maxSearchDist;
+2 -2
View File
@@ -31,7 +31,7 @@ namespace VMAP
struct LocationInfo
{
LocationInfo(): hitInstance(nullptr), hitModel(nullptr), ground_Z(-G3D::inf()) { }
LocationInfo(): hitInstance(nullptr), hitModel(nullptr), ground_Z(-G3D::finf()) { }
const ModelInstance* hitInstance;
const GroupModel* hitModel;
float ground_Z;
@@ -89,7 +89,7 @@ namespace VMAP
struct AreaInfo
{
AreaInfo(): result(false), ground_Z(-G3D::inf()), flags(0), adtId(0),
AreaInfo(): result(false), ground_Z(-G3D::finf()), flags(0), adtId(0),
rootId(0), groupId(0) { }
bool result;
float ground_Z;
+1 -1
View File
@@ -46,7 +46,7 @@ namespace VMAP
float iScale;
void init()
{
iRotation = G3D::Matrix3::fromEulerAnglesZYX(G3D::pi()*iDir.y/180.f, G3D::pi()*iDir.x/180.f, G3D::pi()*iDir.z/180.f);
iRotation = G3D::Matrix3::fromEulerAnglesZYX(G3D::pif()*iDir.y/180.f, G3D::pif()*iDir.x/180.f, G3D::pif()*iDir.z/180.f);
}
G3D::Vector3 transform(const G3D::Vector3& pIn) const;
void moveToBasePos(const G3D::Vector3& pBasePos) { iPos -= pBasePos; }
@@ -166,7 +166,7 @@ bool GameObjectModel::intersectRay(const G3D::Ray& ray, float& MaxDist, bool Sto
return false;
float time = ray.intersectionTime(iBound);
if (time == G3D::inf())
if (time == G3D::finf())
return false;
// child bounds are defined in object space:
@@ -28,7 +28,7 @@ namespace VMAP
{
ModelInstance::ModelInstance(const ModelSpawn &spawn, WorldModel* model): ModelSpawn(spawn), iModel(model)
{
iInvRot = G3D::Matrix3::fromEulerAnglesZYX(G3D::pi()*iRot.y/180.f, G3D::pi()*iRot.x/180.f, G3D::pi()*iRot.z/180.f).inverse();
iInvRot = G3D::Matrix3::fromEulerAnglesZYX(G3D::pif()*iRot.y/180.f, G3D::pif()*iRot.x/180.f, G3D::pif()*iRot.z/180.f).inverse();
iInvScale = 1.f/iScale;
}
@@ -40,7 +40,7 @@ namespace VMAP
return false;
}
float time = pRay.intersectionTime(iBound);
if (time == G3D::inf())
if (time == G3D::finf())
{
// std::cout << "Ray does not hit '" << name << "'\n";
+3 -3
View File
@@ -42,7 +42,7 @@ namespace VMAP
const Vector3 p(ray.direction().cross(e2));
const float a = e1.dot(p);
if (fabs(a) < EPS) {
if (std::fabs(a) < EPS) {
// Determinant is ill-conditioned; abort early
return false;
}
@@ -388,7 +388,7 @@ namespace VMAP
return false;
GModelRayCallback callback(triangles, vertices);
Vector3 rPos = pos - 0.1f * down;
float dist = G3D::inf();
float dist = G3D::finf();
G3D::Ray ray(rPos, down);
bool hit = IntersectRay(ray, dist, false);
if (hit)
@@ -446,7 +446,7 @@ namespace VMAP
class WModelAreaCallback {
public:
WModelAreaCallback(const std::vector<GroupModel> &vals, const Vector3 &down):
prims(vals.begin()), hit(vals.end()), minVol(G3D::inf()), zDist(G3D::inf()), zVec(down) { }
prims(vals.begin()), hit(vals.end()), minVol(G3D::finf()), zDist(G3D::finf()), zVec(down) { }
std::vector<GroupModel>::const_iterator prims;
std::vector<GroupModel>::const_iterator hit;
float minVol;
+2 -2
View File
@@ -159,8 +159,8 @@ public:
//int Cycles = std::max((int)ceilf(max_dist/tMaxX),(int)ceilf(max_dist/tMaxY));
//int i = 0;
float tDeltaX = voxel * fabs(kx_inv);
float tDeltaY = voxel * fabs(ky_inv);
float tDeltaX = voxel * std::fabs(kx_inv);
float tDeltaY = voxel * std::fabs(ky_inv);
do
{
if (Node* node = nodes[cell.x][cell.y])
+1 -1
View File
@@ -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)
@@ -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)
+1 -1
View File
@@ -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);
}
+2 -2
View File
@@ -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*/)
@@ -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;
@@ -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);
@@ -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;
@@ -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))
+21 -21
View File
@@ -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);
+9 -9
View File
@@ -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;
@@ -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();
@@ -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;
+1 -1
View File
@@ -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
+5 -5
View File
@@ -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)
@@ -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
{
+1 -1
View File
@@ -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);
+15 -15
View File
@@ -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
+2 -2
View File
@@ -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;
+2 -2
View File
@@ -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);
}
+3 -3
View File
@@ -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);
+1 -1
View File
@@ -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
{
+1 -1
View File
@@ -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)
{ }
+1 -1
View File
@@ -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
+7 -7
View File
@@ -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);
}
+2 -2
View File
@@ -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)
@@ -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;
}
}
@@ -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;
@@ -69,7 +69,7 @@ namespace Movement
typedef counter<uint32, 0xFFFFFFFF> UInt32Counter;
extern double gravity;
extern float gravity;
extern UInt32Counter splineIdGen;
}
@@ -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;
+2 -2
View File
@@ -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);
+2 -2
View File
@@ -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;
+1 -1
View File
@@ -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
+7 -7
View File
@@ -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)
+3 -3
View File
@@ -1403,7 +1403,7 @@ public:
// place pet before player
float x, y, z;
player->GetClosePoint (x, y, z, creatureTarget->GetObjectSize(), CONTACT_DISTANCE);
pet->Relocate(x, y, z, M_PI-player->GetOrientation());
pet->Relocate(x, y, z, float(M_PI) - player->GetOrientation());
// set pet to defensive mode by default (some classes can't control controlled pets in fact).
pet->SetReactState(REACT_DEFENSIVE);
@@ -1458,8 +1458,8 @@ public:
FormationInfo* group_member;
group_member = new FormationInfo;
group_member->follow_angle = (creature->GetAngle(chr) - chr->GetOrientation()) * 180 / M_PI;
group_member->follow_dist = sqrtf(pow(chr->GetPositionX() - creature->GetPositionX(), int(2))+pow(chr->GetPositionY() - creature->GetPositionY(), int(2)));
group_member->follow_angle = (creature->GetAngle(chr) - chr->GetOrientation()) * 180 / float(M_PI);
group_member->follow_dist = std::sqrt(std::pow(chr->GetPositionX() - creature->GetPositionX(), 2.f) + std::pow(chr->GetPositionY() - creature->GetPositionY(), 2.f));
group_member->leaderGUID = leaderGUID;
group_member->groupAI = 0;
@@ -124,7 +124,7 @@ public:
float dist(float xa, float ya, float xb, float yb) // auxiliary method for distance
{
return sqrt((xa-xb)*(xa-xb) + (ya-yb)*(ya-yb));
return std::sqrt((xa-xb)*(xa-xb) + (ya-yb)*(ya-yb));
}
void Reset() override
@@ -328,7 +328,7 @@ public:
if (TailSweepTimer <= diff)
{
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
if (!me->HasInArc(M_PI, target))
if (!me->HasInArc(float(M_PI), target))
DoCast(target, SPELL_TAIL_SWEEP);
TailSweepTimer = 15000;
} else TailSweepTimer -= diff;
@@ -1290,7 +1290,7 @@ public:
if (BackwardLungeTimer <= diff)
{
Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true);
if (target && !me->HasInArc(M_PI, target))
if (target && !me->HasInArc(float(M_PI), target))
{
DoCast(target, SPELL_BACKWARD_LUNGE);
BackwardLungeTimer = urand(15000, 30000);
@@ -1191,8 +1191,8 @@ public:
bPointReached = false;
uiCheckTimer = 1000;
me->GetMotionMaster()->MovePoint(1, x, y, SHIELD_ORB_Z);
c += M_PI/32;
if (c >= 2*M_PI) c = 0;
c += float(M_PI)/32;
if (c >= 2 * float(M_PI)) c = 0;
}
else
{
@@ -188,7 +188,7 @@ class boss_janalai : public CreatureScript
{
if (isFlameBreathing)
{
if (!me->HasInArc(M_PI/6, target))
if (!me->HasInArc(float(M_PI) / 6, target))
damage = 0;
}
}
+8 -8
View File
@@ -193,7 +193,7 @@ class npc_winterfin_playmate : public CreatureScript
switch (phase)
{
case 1:
orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5, me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ());
orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + std::cos(me->GetOrientation()) * 5, me->GetPositionY() + std::sin(me->GetOrientation()) * 5, me->GetPositionZ());
orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_1);
timer = 3000;
break;
@@ -292,7 +292,7 @@ class npc_snowfall_glade_playmate : public CreatureScript
switch (phase)
{
case 1:
orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5, me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ());
orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + std::cos(me->GetOrientation()) * 5, me->GetPositionY() + std::sin(me->GetOrientation()) * 5, me->GetPositionZ());
orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_1);
timer = 5000;
break;
@@ -393,7 +393,7 @@ class npc_the_biggest_tree : public CreatureScript
switch (phase)
{
case 1:
orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5, me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ());
orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + std::cos(me->GetOrientation()) * 5, me->GetPositionY() + std::sin(me->GetOrientation()) * 5, me->GetPositionZ());
timer = 2000;
break;
case 2:
@@ -480,7 +480,7 @@ class npc_high_oracle_soo_roo : public CreatureScript
switch (phase)
{
case 1:
orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5, me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ());
orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + std::cos(me->GetOrientation()) * 5, me->GetPositionY() + std::sin(me->GetOrientation()) * 5, me->GetPositionZ());
orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_5);
timer = 3000;
break;
@@ -569,7 +569,7 @@ class npc_elder_kekek : public CreatureScript
switch (phase)
{
case 1:
orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5, me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ());
orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + std::cos(me->GetOrientation()) * 5, me->GetPositionY() + std::sin(me->GetOrientation()) * 5, me->GetPositionZ());
orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_4);
timer = 3000;
break;
@@ -658,7 +658,7 @@ class npc_the_etymidian : public CreatureScript
switch (phase)
{
case 1:
orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5, me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ());
orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + std::cos(me->GetOrientation()) * 5, me->GetPositionY() + std::sin(me->GetOrientation()) * 5, me->GetPositionZ());
orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_7);
timer = 5000;
break;
@@ -780,7 +780,7 @@ class npc_alexstraza_the_lifebinder : public CreatureScript
switch (phase)
{
case 1:
orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5, me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ());
orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + std::cos(me->GetOrientation()) * 5, me->GetPositionY() + std::sin(me->GetOrientation()) * 5, me->GetPositionZ());
orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_11);
timer = 5000;
break;
@@ -811,7 +811,7 @@ class npc_alexstraza_the_lifebinder : public CreatureScript
Reset();
return;
case 7:
orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5, me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ());
orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + std::cos(me->GetOrientation()) * 5, me->GetPositionY() + std::sin(me->GetOrientation()) * 5, me->GetPositionZ());
orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_11);
timer = 5000;
break;
@@ -280,8 +280,8 @@ public:
me->SummonCreature(NPC_WITHERED_BATTLE_BOAR, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation());
if (data > 0 && me->GetOrientation() < 4.0f)
me->SummonCreature(NPC_WITHERED_BATTLE_BOAR, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation());
me->SummonCreature(NPC_DEATHS_HEAD_GEOMANCER, me->GetPositionX() + (cos(me->GetOrientation() - (M_PI/2)) * 2), me->GetPositionY() + (sin(me->GetOrientation() - (M_PI/2)) * 2), me->GetPositionZ(), me->GetOrientation());
me->SummonCreature(NPC_WITHERED_QUILGUARD, me->GetPositionX() + (cos(me->GetOrientation() + (M_PI/2)) * 2), me->GetPositionY() + (sin(me->GetOrientation() + (M_PI/2)) * 2), me->GetPositionZ(), me->GetOrientation());
me->SummonCreature(NPC_DEATHS_HEAD_GEOMANCER, me->GetPositionX() + (std::cos(me->GetOrientation() - (float(M_PI) / 2)) * 2), me->GetPositionY() + (std::sin(me->GetOrientation() - (float(M_PI) / 2)) * 2), me->GetPositionZ(), me->GetOrientation());
me->SummonCreature(NPC_WITHERED_QUILGUARD, me->GetPositionX() + (std::cos(me->GetOrientation() + (float(M_PI) / 2)) * 2), me->GetPositionY() + (std::sin(me->GetOrientation() + (float(M_PI) / 2)) * 2), me->GetPositionZ(), me->GetOrientation());
}
else if (data == 7)
me->SummonCreature(NPC_PLAGUEMAW_THE_ROTTING, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation());
@@ -334,9 +334,9 @@ public:
{
//Set angle and cast
if (ClockWise)
me->SetOrientation(DarkGlareAngle + DarkGlareTick * M_PI / 35);
me->SetOrientation(DarkGlareAngle + DarkGlareTick * float(M_PI) / 35);
else
me->SetOrientation(DarkGlareAngle - DarkGlareTick * M_PI / 35);
me->SetOrientation(DarkGlareAngle - DarkGlareTick * float(M_PI) / 35);
me->StopMoving();
@@ -120,7 +120,7 @@ class boss_viscidus : public CreatureScript
uint8 NumGlobes = me->GetHealthPct() / 5.0f;
for (uint8 i = 0; i < NumGlobes; ++i)
{
float Angle = i * 2 * M_PI / NumGlobes;
float Angle = i * 2 * float(M_PI) / NumGlobes;
float X = ViscidusCoord.GetPositionX() + std::cos(Angle) * RoomRadius;
float Y = ViscidusCoord.GetPositionY() + std::sin(Angle) * RoomRadius;
float Z = -35.0f;
+1 -1
View File
@@ -386,7 +386,7 @@ class npc_troll_volunteer : public CreatureScript
}
me->SetDisplayId(trollmodel[urand(0, 39)]);
if (Player* player = me->GetOwner()->ToPlayer())
me->GetMotionMaster()->MoveFollow(player, 5.0f, float(rand_norm() + 1.0f) * M_PI / 3.0f * 4.0f);
me->GetMotionMaster()->MoveFollow(player, 5.0f, float(rand_norm() + 1.0f) * float(M_PI) / 3.0f * 4.0f);
}
void Reset() override
@@ -1258,7 +1258,7 @@ class go_wind_stone : public GameObjectScript
void SummonNPC(GameObject* go, Player* player, uint32 npc, uint32 spell)
{
go->CastSpell(player, spell);
TempSummon* summons = go->SummonCreature(npc, go->GetPositionX(), go->GetPositionY(), go->GetPositionZ(), player->GetOrientation() - M_PI, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 10 * 60 * 1000);
TempSummon* summons = go->SummonCreature(npc, go->GetPositionX(), go->GetPositionY(), go->GetPositionZ(), player->GetOrientation() - float(M_PI), TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 10 * 60 * 1000);
summons->CastSpell(summons, SPELL_SPAWN_IN, false);
switch (summons->GetEntry())
{
@@ -50,7 +50,7 @@ enum Misc
};
#define DATA_SPHERE_DISTANCE 25.0f
#define DATA_SPHERE_ANGLE_OFFSET M_PI / 2
#define DATA_SPHERE_ANGLE_OFFSET float(M_PI) / 2
#define DATA_GROUND_POSITION_Z 11.30809f
enum Yells
@@ -289,13 +289,13 @@ public:
switch (i)
{
case 0:
pAdd->GetMotionMaster()->MoveFollow(pBoss, 2.0f, M_PI);
pAdd->GetMotionMaster()->MoveFollow(pBoss, 2.0f, float(M_PI));
break;
case 1:
pAdd->GetMotionMaster()->MoveFollow(pBoss, 2.0f, M_PI / 2);
pAdd->GetMotionMaster()->MoveFollow(pBoss, 2.0f, float(M_PI) / 2);
break;
case 2:
pAdd->GetMotionMaster()->MoveFollow(pBoss, 2.0f, M_PI / 2 + M_PI);
pAdd->GetMotionMaster()->MoveFollow(pBoss, 2.0f, float(M_PI) / 2 + float(M_PI));
break;
}
}
@@ -531,8 +531,8 @@ struct npc_unleashed_ballAI : public ScriptedAI
float x0 = ToCCommonLoc[1].GetPositionX(), y0 = ToCCommonLoc[1].GetPositionY(), r = 47.0f;
float y = y0;
float x = frand(x0 - r, x0 + r);
float sq = pow(r, 2) - pow(x - x0, 2);
float rt = sqrtf(fabs(sq));
float sq = std::pow(r, 2.f) - std::pow(x - x0, 2.f);
float rt = std::sqrt(std::fabs(sq));
if (urand(0, 1))
y = y0 + rt;
else
@@ -756,7 +756,7 @@ class spell_valkyr_essences : public SpellScriptLoader
// Twin Vortex part
uint32 lightVortex = sSpellMgr->GetSpellIdForDifficulty(SPELL_LIGHT_VORTEX_DAMAGE, owner);
uint32 darkVortex = sSpellMgr->GetSpellIdForDifficulty(SPELL_DARK_VORTEX_DAMAGE, owner);
int32 stacksCount = int32(dmgInfo.GetSpellInfo()->Effects[EFFECT_0].CalcValue()) * 0.001 - 1;
int32 stacksCount = dmgInfo.GetSpellInfo()->Effects[EFFECT_0].CalcValue() / 1000 - 1;
if (lightVortex && darkVortex && stacksCount)
{
@@ -292,7 +292,7 @@ class boss_devourer_of_souls : public CreatureScript
beamAngle = me->GetOrientation();
beamAngleDiff = M_PI/30.0f; // PI/2 in 15 sec = PI/30 per tick
beamAngleDiff = float(M_PI)/30.0f; // PI/2 in 15 sec = PI/30 per tick
if (RAND(true, false))
beamAngleDiff = -beamAngleDiff;
@@ -205,8 +205,8 @@ enum EncounterActions
ACTION_SHIP_VISITS = 5
};
Position const SkybreakerAddsSpawnPos = { 15.91131f, 0.0f, 20.4628f, M_PI };
Position const OrgrimsHammerAddsSpawnPos = { 60.728395f, 0.0f, 38.93467f, M_PI };
Position const SkybreakerAddsSpawnPos = { 15.91131f, 0.0f, 20.4628f, float(M_PI) };
Position const OrgrimsHammerAddsSpawnPos = { 60.728395f, 0.0f, 38.93467f, float(M_PI) };
// Horde encounter
Position const SkybreakerTeleportPortal = { 6.666975f, 0.013001f, 20.87888f, 0.0f };
@@ -439,7 +439,7 @@ private:
Position SelectSpawnPoint() const
{
Position newPos;
float angle = frand(-M_PI * 0.5f, M_PI * 0.5f);
float angle = frand(float(-M_PI) * 0.5f, float(M_PI) * 0.5f);
newPos.m_positionX = _spawnPoint->GetPositionX() + 2.0f * std::cos(angle);
newPos.m_positionY = _spawnPoint->GetPositionY() + 2.0f * std::sin(angle);
newPos.m_positionZ = _spawnPoint->GetPositionZ();
@@ -1455,7 +1455,7 @@ struct npc_gunship_boarding_addAI : public gunship_npc_AI
if (Transport* destTransport = go->ToTransport())
destTransport->CalculatePassengerPosition(x, y, z, &o);
float angle = frand(0, M_PI * 2.0f);
float angle = frand(0, float(M_PI) * 2.0f);
x += 2.0f * std::cos(angle);
y += 2.0f * std::sin(angle);
@@ -674,7 +674,7 @@ class spell_marrowgar_bone_storm : public SpellScriptLoader
void RecalculateDamage()
{
SetHitDamage(int32(GetHitDamage() / std::max(sqrtf(GetHitUnit()->GetExactDist2d(GetCaster())), 1.0f)));
SetHitDamage(int32(GetHitDamage() / std::max(std::sqrt(GetHitUnit()->GetExactDist2d(GetCaster())), 1.0f)));
}
void Register() override
@@ -126,7 +126,7 @@ public:
{
float x, y, z, o;
me->GetHomePosition(x, y, z, o);
me->NearTeleportTo(x, y, z, o - G3D::halfPi());
me->NearTeleportTo(x, y, z, o - (float(M_PI) / 2));
me->GetMotionMaster()->Clear();
me->GetMotionMaster()->MoveIdle();
me->SetTarget(0);
@@ -1014,7 +1014,7 @@ public:
// Used to generate perfect cyclic movements (Enter Circle).
void FillCirclePath(Position const& centerPos, float radius, float z, Movement::PointsArray& path, bool clockwise)
{
float step = clockwise ? -M_PI / 8.0f : M_PI / 8.0f;
float step = clockwise ? float(-M_PI) / 8.0f : float(M_PI) / 8.0f;
float angle = centerPos.GetAngle(me->GetPositionX(), me->GetPositionY());
for (uint8 i = 0; i < 16; angle += step, ++i)
@@ -1326,7 +1326,7 @@ public:
private:
void FillCirclePath(Position const& centerPos, float radius, float z, Movement::PointsArray& path, bool clockwise)
{
float step = clockwise ? -M_PI / 9.0f : M_PI / 9.0f;
float step = clockwise ? float(-M_PI) / 9.0f : float(M_PI) / 9.0f;
float angle = centerPos.GetAngle(me->GetPositionX(), me->GetPositionY());
for (uint8 i = 0; i < 18; angle += step, ++i)
@@ -315,7 +315,7 @@ class spell_varos_energize_core_area_enemy : public SpellScriptLoader
for (std::list<WorldObject*>::iterator itr = targets.begin(); itr != targets.end();)
{
float angle = varos->GetAngle((*itr)->GetPositionX(), (*itr)->GetPositionY());
float diff = fabs(orientation - angle);
float diff = std::fabs(orientation - angle);
if (diff > 1.0f)
itr = targets.erase(itr);
@@ -359,7 +359,7 @@ class spell_varos_energize_core_area_entry : public SpellScriptLoader
for (std::list<WorldObject*>::iterator itr = targets.begin(); itr != targets.end();)
{
float angle = varos->GetAngle((*itr)->GetPositionX(), (*itr)->GetPositionY());
float diff = fabs(orientation - angle);
float diff = std::fabs(orientation - angle);
if (diff > 1.0f)
itr = targets.erase(itr);
@@ -526,7 +526,7 @@ class spell_general_vezax_saronite_vapors : public SpellScriptLoader
{
if (Unit* caster = GetCaster())
{
int32 mana = int32(aurEff->GetAmount() * pow(2.0f, GetStackAmount())); // mana restore - bp * 2^stackamount
int32 mana = int32(aurEff->GetAmount() * std::pow(2.0f, GetStackAmount())); // mana restore - bp * 2^stackamount
int32 damage = mana * 2;
caster->CastCustomSpell(GetTarget(), SPELL_SARONITE_VAPORS_ENERGIZE, &mana, NULL, NULL, true);
caster->CastCustomSpell(GetTarget(), SPELL_SARONITE_VAPORS_DAMAGE, &damage, NULL, NULL, true);
@@ -985,7 +985,7 @@ public:
if (!caster)
return;
int32 damage = int32(200 * pow(2.0f, GetStackAmount()));
int32 damage = int32(200 * std::pow(2.0f, GetStackAmount()));
caster->CastCustomSpell(caster, SPELL_BITING_COLD_DAMAGE, &damage, NULL, NULL, true);
if (caster->isMoving())
@@ -498,7 +498,7 @@ class spell_ulduar_squeezed_lifeless : public SpellScriptLoader
pos.m_positionX = 1756.25f + irand(-3, 3);
pos.m_positionY = -8.3f + irand(-3, 3);
pos.m_positionZ = 448.8f;
pos.SetOrientation(M_PI);
pos.SetOrientation(float(M_PI));
GetHitPlayer()->DestroyForNearbyPlayers();
GetHitPlayer()->ExitVehicle(&pos);
GetHitPlayer()->UpdateObjectVisibility(false);
@@ -839,7 +839,7 @@ class boss_sara : public CreatureScript
{
Position pos;
float radius = frand(25.0f, 50.0f);
float angle = frand(0.0f, 2.0f * M_PI);
float angle = frand(0.0f, 2.0f * float(M_PI));
pos.m_positionX = YoggSaronSpawnPos.GetPositionX() + radius * cosf(angle);
pos.m_positionY = YoggSaronSpawnPos.GetPositionY() + radius * sinf(angle);
pos.m_positionZ = me->GetMap()->GetHeight(me->GetPhaseMask(), pos.GetPositionX(), pos.GetPositionY(), YoggSaronSpawnPos.GetPositionZ() + 5.0f);
@@ -1119,7 +1119,7 @@ class npc_ominous_cloud : public CreatureScript
void FillCirclePath(Position const& centerPos, float radius, float z, Movement::PointsArray& path, bool clockwise)
{
float step = clockwise ? -M_PI / 8.0f : M_PI / 8.0f;
float step = clockwise ? float(-M_PI) / 8.0f : float(M_PI) / 8.0f;
float angle = centerPos.GetAngle(me->GetPositionX(), me->GetPositionY());
for (uint8 i = 0; i < 16; angle += step, ++i)
@@ -2502,7 +2502,7 @@ class spell_yogg_saron_empowered : public SpellScriptLoader // 64161
void OnPeriodic(AuraEffect const* /*aurEff*/)
{
Unit* target = GetTarget();
float stack = ceil((target->GetHealthPct() / 10) - 1);
float stack = std::ceil((target->GetHealthPct() / 10) - 1);
target->RemoveAurasDueToSpell(SPELL_EMPOWERED_BUFF);
if (stack)
@@ -718,7 +718,7 @@ public:
if (me->GetEntry() == NPC_LAKE_FROG)
{
me->AddAura(SPELL_FROG_LOVE, me);
me->GetMotionMaster()->MoveFollow(player, 0.3f, frand(M_PI/2, M_PI + (M_PI/2)));
me->GetMotionMaster()->MoveFollow(player, 0.3f, frand(float(M_PI) / 2, float(M_PI) + (float(M_PI) / 2)));
_following = true;
}
else if (me->GetEntry() == NPC_LAKE_FROG_QUEST)
@@ -410,7 +410,7 @@ public:
switch (phase)
{
case 1:
orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5, me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ());
orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + std::cos(me->GetOrientation()) * 5, me->GetPositionY() + std::sin(me->GetOrientation()) * 5, me->GetPositionZ());
orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_6);
timer = 5000;
break;
@@ -247,7 +247,7 @@ public:
break;
case EVENT_RECRUIT_2:
me->SetWalk(true);
me->GetMotionMaster()->MovePoint(0, me->GetPositionX() + (cos(_heading) * 10), me->GetPositionY() + (sin(_heading) * 10), me->GetPositionZ());
me->GetMotionMaster()->MovePoint(0, me->GetPositionX() + (std::cos(_heading) * 10), me->GetPositionY() + (std::sin(_heading) * 10), me->GetPositionZ());
me->DespawnOrUnsummon(5000);
break;
default:
@@ -244,8 +244,8 @@ public:
if (me->GetAuraCount(SPELL_SHADE_SOUL_CHANNEL_2) <= 3)
{
moveSpeed = (2.0 - (0.6 * me->GetAuraCount(SPELL_SHADE_SOUL_CHANNEL_2)));
me->SetSpeed(MOVE_WALK, moveSpeed / 2.5);
moveSpeed = (2.0f - (0.6f * me->GetAuraCount(SPELL_SHADE_SOUL_CHANNEL_2)));
me->SetSpeed(MOVE_WALK, moveSpeed / 2.5f);
me->SetSpeed(MOVE_RUN, (moveSpeed * 2) / 7);
me->ClearUnitState(UNIT_STATE_ROOT);
}
@@ -278,7 +278,7 @@ public:
if (me->IsWithinDistInMap(who, attackRadius))
{
// Check first that object is in an angle in front of this one before LoS check
if (me->HasInArc(M_PI/2.0f, who) && me->IsWithinLOSInMap(who))
if (me->HasInArc(float(M_PI) / 2.0f, who) && me->IsWithinLOSInMap(who))
{
AttackStart(who);
}
@@ -202,7 +202,7 @@ class boss_high_astromancer_solarian : public CreatureScript
{
float z = RAND(1.0f, -1.0f);
return (z*sqrt(radius*radius - (x - CENTER_X)*(x - CENTER_X)) + CENTER_Y);
return (z*std::sqrt(radius*radius - (x - CENTER_X)*(x - CENTER_X)) + CENTER_Y);
}
void UpdateAI(uint32 diff) override
@@ -179,7 +179,7 @@ class boss_warp_splinter : public CreatureScript
{
for (uint8 i = 0; i < 6; ++i)
{
float angle = (M_PI / 3) * i;
float angle = (float(M_PI) / 3) * i;
float X = Treant_Spawn_Pos_X + TREANT_SPAWN_DIST * std::cos(angle);
float Y = Treant_Spawn_Pos_Y + TREANT_SPAWN_DIST * std::sin(angle);
+1 -1
View File
@@ -1584,7 +1584,7 @@ class spell_gen_gift_of_naaru : public SpellScriptLoader
break;
}
int32 healTick = floor(heal / aurEff->GetTotalTicks());
int32 healTick = std::floor(heal / aurEff->GetTotalTicks());
amount += int32(std::max(healTick, 0));
}
+1 -1
View File
@@ -2456,7 +2456,7 @@ class spell_item_unusual_compass : public SpellScriptLoader
void HandleDummy(SpellEffIndex /* effIndex */)
{
Unit* caster = GetCaster();
caster->SetFacingTo(frand(0.0f, 2.0f * M_PI));
caster->SetFacingTo(frand(0.0f, 2.0f * float(M_PI)));
}
void Register() override
+1 -1
View File
@@ -2008,7 +2008,7 @@ class spell_q12308_escape_from_silverbrook_summon_worgen : public SpellScriptLoa
void ModDest(SpellDestination& dest)
{
float dist = GetSpellInfo()->Effects[EFFECT_0].CalcRadius(GetCaster());
float angle = frand(0.75f, 1.25f) * M_PI;
float angle = frand(0.75f, 1.25f) * float(M_PI);
Position pos = GetCaster()->GetNearPosition(dist, angle);
dest.Relocate(pos);
+1 -1
View File
@@ -583,7 +583,7 @@ class spell_warr_retaliation : public SpellScriptLoader
bool CheckProc(ProcEventInfo& eventInfo)
{
// check attack comes not from behind and warrior is not stunned
return GetTarget()->isInFront(eventInfo.GetActor(), M_PI) && !GetTarget()->HasUnitState(UNIT_STATE_STUNNED);
return GetTarget()->isInFront(eventInfo.GetActor(), float(M_PI)) && !GetTarget()->HasUnitState(UNIT_STATE_STUNNED);
}
void HandleEffectProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
+1 -1
View File
@@ -2233,7 +2233,7 @@ public:
if (GameObject* launcher = FindNearestLauncher())
{
launcher->SendCustomAnim(ANIM_GO_LAUNCH_FIREWORK);
me->SetOrientation(launcher->GetOrientation() + M_PI/2);
me->SetOrientation(launcher->GetOrientation() + float(M_PI) / 2);
}
else
return;
+2 -2
View File
@@ -26,7 +26,7 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <cmath>
#include <errno.h>
#include <signal.h>
#include <assert.h>
@@ -136,7 +136,7 @@ typedef std::vector<std::string> StringVector;
#endif
#ifndef M_PI
#define M_PI 3.14159265358979323846f
#define M_PI 3.14159265358979323846
#endif
#define MAX_QUERY_LEN 32*1024
+1
View File
@@ -50,6 +50,7 @@
#if PLATFORM == PLATFORM_WINDOWS
# define TRINITY_PATH_MAX MAX_PATH
# define _USE_MATH_DEFINES
# ifndef DECLSPEC_NORETURN
# define DECLSPEC_NORETURN __declspec(noreturn)
# endif //DECLSPEC_NORETURN
+1 -1
View File
@@ -31,7 +31,7 @@
#include <vector>
#include <cstring>
#include <time.h>
#include <math.h>
#include <cmath>
#include <boost/asio/buffer.hpp>
class MessageBuffer;
+1 -1
View File
@@ -27,7 +27,7 @@ inline uint32 getMSTime()
{
static const system_clock::time_point ApplicationStartTime = system_clock::now();
return duration_cast<milliseconds>(system_clock::now() - ApplicationStartTime).count();
return uint32(duration_cast<milliseconds>(system_clock::now() - ApplicationStartTime).count());
}
inline uint32 getMSTimeDiff(uint32 oldMSTime, uint32 newMSTime)
+3 -3
View File
@@ -618,7 +618,7 @@ class EventMap
if (!phase)
_phase = 0;
else if (phase <= 8)
_phase = (1 << (phase - 1));
_phase = uint8(1 << (phase - 1));
}
/**
@@ -629,7 +629,7 @@ class EventMap
void AddPhase(uint8 phase)
{
if (phase && phase <= 8)
_phase |= (1 << (phase - 1));
_phase |= uint8(1 << (phase - 1));
}
/**
@@ -640,7 +640,7 @@ class EventMap
void RemovePhase(uint8 phase)
{
if (phase && phase <= 8)
_phase &= ~(1 << (phase - 1));
_phase &= uint8(~(1 << (phase - 1)));
}
/**