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:
Zwelf 2022-12-30 18:03:05 +01:00
parent 3be6edcc49
commit e3147ce53d
2 changed files with 2 additions and 6 deletions

View file

@ -138,10 +138,8 @@ void CCharacter::HandleNinja()
// check if we Hit anything along the way
{
CEntity *apEnts[MAX_CLIENTS];
vec2 Dir = m_Pos - OldPos;
float Radius = m_ProximityRadius * 2.0f;
vec2 Center = OldPos + Dir * 0.5f;
int Num = GameWorld()->FindEntities(Center, Radius, apEnts, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER);
int Num = GameWorld()->FindEntities(OldPos, Radius, apEnts, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER);
// check that we're not in solo part
if(TeamsCore()->GetSolo(GetCID()))

View file

@ -266,10 +266,8 @@ void CCharacter::HandleNinja()
// check if we Hit anything along the way
{
CEntity *apEnts[MAX_CLIENTS];
vec2 Dir = m_Pos - OldPos;
float Radius = GetProximityRadius() * 2.0f;
vec2 Center = OldPos + Dir * 0.5f;
int Num = GameServer()->m_World.FindEntities(Center, Radius, apEnts, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER);
int Num = GameServer()->m_World.FindEntities(OldPos, Radius, apEnts, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER);
// check that we're not in solo part
if(Teams()->m_Core.GetSolo(m_pPlayer->GetCID()))