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/Entities/Object | |
| parent | f5f9df0483fbf847eb9ee4e6ec4ecc6cf66d3a47 (diff) | |
Core/Misc: Fix some -Wconversion warnings
Diffstat (limited to 'src/server/game/Entities/Object')
| -rw-r--r-- | src/server/game/Entities/Object/Object.cpp | 42 | ||||
| -rw-r--r-- | src/server/game/Entities/Object/Object.h | 18 | ||||
| -rw-r--r-- | src/server/game/Entities/Object/ObjectPosSelector.cpp | 2 | ||||
| -rw-r--r-- | src/server/game/Entities/Object/ObjectPosSelector.h | 12 |
4 files changed, 37 insertions, 37 deletions
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; |
