Minor code cleanup in dragger.cpp

This commit is contained in:
def 2020-11-04 23:09:22 +01:00
parent 5a9d93f160
commit 2c3000ba81

View file

@ -57,10 +57,9 @@ void CDragger::Move()
continue; continue;
} }
int Res = int Res =
m_NW ? GameServer()->Collision()->IntersectNoLaserNW(m_Pos, m_NW ?
Temp->m_Pos, 0, 0) : GameServer()->Collision()->IntersectNoLaserNW(m_Pos, Temp->m_Pos, 0, 0) :
GameServer()->Collision()->IntersectNoLaser(m_Pos, GameServer()->Collision()->IntersectNoLaser(m_Pos, Temp->m_Pos, 0, 0);
Temp->m_Pos, 0, 0);
if(Res == 0) if(Res == 0)
{ {
@ -81,9 +80,10 @@ void CDragger::Move()
} }
if(!m_Target) if(!m_Target)
{
m_Target = Id != -1 ? TempEnts[Id] : 0; m_Target = Id != -1 ? TempEnts[Id] : 0;
}
if(m_Target) else
{ {
for(auto &SoloEnt : m_SoloEnts) for(auto &SoloEnt : m_SoloEnts)
{ {
@ -95,38 +95,38 @@ void CDragger::Move()
void CDragger::Drag() void CDragger::Drag()
{ {
if(m_Target) if(!m_Target)
return;
CCharacter *Target = m_Target;
for(int i = -1; i < MAX_CLIENTS; i++)
{ {
CCharacter *Target = m_Target; if(i >= 0)
Target = m_SoloEnts[i];
for(int i = -1; i < MAX_CLIENTS; i++) if(!Target)
continue;
int Res = 0;
if(!m_NW)
Res = GameServer()->Collision()->IntersectNoLaser(m_Pos,
Target->m_Pos, 0, 0);
else
Res = GameServer()->Collision()->IntersectNoLaserNW(m_Pos,
Target->m_Pos, 0, 0);
if(Res || length(m_Pos - Target->m_Pos) > g_Config.m_SvDraggerRange)
{ {
if(i >= 0) Target = 0;
Target = m_SoloEnts[i]; if(i == -1)
m_Target = 0;
if(!Target)
continue;
int Res = 0;
if(!m_NW)
Res = GameServer()->Collision()->IntersectNoLaser(m_Pos,
Target->m_Pos, 0, 0);
else else
Res = GameServer()->Collision()->IntersectNoLaserNW(m_Pos, m_SoloEnts[i] = 0;
Target->m_Pos, 0, 0); }
if(Res || length(m_Pos - Target->m_Pos) > g_Config.m_SvDraggerRange) else if(length(m_Pos - Target->m_Pos) > 28)
{ {
Target = 0; vec2 Temp = Target->Core()->m_Vel + (normalize(m_Pos - Target->m_Pos) * m_Strength);
if(i == -1) Target->Core()->m_Vel = ClampVel(Target->m_MoveRestrictions, Temp);
m_Target = 0;
else
m_SoloEnts[i] = 0;
}
else if(length(m_Pos - Target->m_Pos) > 28)
{
vec2 Temp = Target->Core()->m_Vel + (normalize(m_Pos - Target->m_Pos) * m_Strength);
Target->Core()->m_Vel = ClampVel(Target->m_MoveRestrictions, Temp);
}
} }
} }
} }