Skip to content

Commit

Permalink
Fix domain errors in func_tank_of
Browse files Browse the repository at this point in the history
  • Loading branch information
SamVanheer committed Sep 19, 2022
1 parent 344ae91 commit 78b267b
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/game/server/entities/func_tank_of.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,22 +757,27 @@ void COFFuncTank::TrackTarget()
// If barrel is offset, add in additional rotation
void COFFuncTank::AdjustAnglesForBarrel(Vector& angles, float distance)
{
float r2, d2;


if (m_barrelPos.y != 0 || m_barrelPos.z != 0)
{
distance -= m_barrelPos.z;
d2 = distance * distance;
const float d2 = distance * distance;
if (0 != m_barrelPos.y)
{
r2 = m_barrelPos.y * m_barrelPos.y;
angles.y += (180.0 / M_PI) * atan2(m_barrelPos.y, sqrt(d2 - r2));
const float r2 = m_barrelPos.y * m_barrelPos.y;

if (d2 > r2)
{
angles.y += (180.0 / M_PI) * atan2(m_barrelPos.y, sqrt(d2 - r2));
}
}
if (0 != m_barrelPos.z)
{
r2 = m_barrelPos.z * m_barrelPos.z;
angles.x += (180.0 / M_PI) * atan2(-m_barrelPos.z, sqrt(d2 - r2));
const float r2 = m_barrelPos.z * m_barrelPos.z;

if (d2 > r2)
{
angles.x += (180.0 / M_PI) * atan2(-m_barrelPos.z, sqrt(d2 - r2));
}
}
}
}
Expand Down

0 comments on commit 78b267b

Please sign in to comment.