mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Merge #2027
2027: Distance can't be negative r=def- a=fokkonaut This removes code duplication and D can never be negative: ```template<typename T> inline T distance(const vector2_base<T> &a, const vector2_base<T> &b) { return length(a-b); } inline float length(const vector2_base<float> &a) { return sqrtf(a.x*a.x + a.y*a.y); }``` Co-authored-by: fokkonaut <35420825+fokkonaut@users.noreply.github.com>
This commit is contained in:
commit
19779ccf94
|
@ -494,15 +494,7 @@ void CCharacterCore::Move()
|
|||
if((!(pCharCore->m_Super || m_Super) && (m_Solo || pCharCore->m_Solo || !pCharCore->m_Collision || pCharCore->m_NoCollision || (m_Id != -1 && !m_pTeams->CanCollide(m_Id, p)))))
|
||||
continue;
|
||||
float D = distance(Pos, pCharCore->m_Pos);
|
||||
if(D < 28.0f && D > 0.0f)
|
||||
{
|
||||
if(a > 0.0f)
|
||||
m_Pos = LastPos;
|
||||
else if(distance(NewPos, pCharCore->m_Pos) > D)
|
||||
m_Pos = NewPos;
|
||||
return;
|
||||
}
|
||||
else if(D <= 0.001f && D >= -0.001f)
|
||||
if((D < 28.0f && D > 0.0f) || (D <= 0.001f && D >= 0.f))
|
||||
{
|
||||
if(a > 0.0f)
|
||||
m_Pos = LastPos;
|
||||
|
|
Loading…
Reference in a new issue