mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-14 03:58:18 +00:00
Simplify ninja code
Reasoning this change is correct: * `OldPos` is set to `m_Pos` in line 260 * `m_Pos` is not modified in between line 260 and 272 (only `m_Core.m_Pos` gets modified) * Therefore line 269 `Dir = m_Pos - OldPos` is always `vec2(0.0, 0.0)`. * And line 271 `Center = OldPos + Dir * 0.5 = OldPos`. So we can pass `OldPos` to `FindEntities` in line 272. Using `OldPos` here instead of `m_Pos` makes it clear, that we use the position before the move, even though `m_Pos` also still holds the old value.
This commit is contained in:
parent
3be6edcc49
commit
e3147ce53d
|
@ -138,10 +138,8 @@ void CCharacter::HandleNinja()
|
||||||
// check if we Hit anything along the way
|
// check if we Hit anything along the way
|
||||||
{
|
{
|
||||||
CEntity *apEnts[MAX_CLIENTS];
|
CEntity *apEnts[MAX_CLIENTS];
|
||||||
vec2 Dir = m_Pos - OldPos;
|
|
||||||
float Radius = m_ProximityRadius * 2.0f;
|
float Radius = m_ProximityRadius * 2.0f;
|
||||||
vec2 Center = OldPos + Dir * 0.5f;
|
int Num = GameWorld()->FindEntities(OldPos, Radius, apEnts, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER);
|
||||||
int Num = GameWorld()->FindEntities(Center, Radius, apEnts, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER);
|
|
||||||
|
|
||||||
// check that we're not in solo part
|
// check that we're not in solo part
|
||||||
if(TeamsCore()->GetSolo(GetCID()))
|
if(TeamsCore()->GetSolo(GetCID()))
|
||||||
|
|
|
@ -266,10 +266,8 @@ void CCharacter::HandleNinja()
|
||||||
// check if we Hit anything along the way
|
// check if we Hit anything along the way
|
||||||
{
|
{
|
||||||
CEntity *apEnts[MAX_CLIENTS];
|
CEntity *apEnts[MAX_CLIENTS];
|
||||||
vec2 Dir = m_Pos - OldPos;
|
|
||||||
float Radius = GetProximityRadius() * 2.0f;
|
float Radius = GetProximityRadius() * 2.0f;
|
||||||
vec2 Center = OldPos + Dir * 0.5f;
|
int Num = GameServer()->m_World.FindEntities(OldPos, Radius, apEnts, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER);
|
||||||
int Num = GameServer()->m_World.FindEntities(Center, Radius, apEnts, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER);
|
|
||||||
|
|
||||||
// check that we're not in solo part
|
// check that we're not in solo part
|
||||||
if(Teams()->m_Core.GetSolo(m_pPlayer->GetCID()))
|
if(Teams()->m_Core.GetSolo(m_pPlayer->GetCID()))
|
||||||
|
|
Loading…
Reference in a new issue