mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge #6209
6209: Simplify ninja code r=def- a=Zwelf 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. ## Checklist - [ ] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test (especially base/) or added coverage to integration test - [ ] Considered possible null pointers and out of bounds array indexing - [ ] Changed no physics that affect existing maps - [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: Zwelf <zwelf@strct.cc>
This commit is contained in:
commit
9071a4a08f
|
@ -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()))
|
||||
|
|
|
@ -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()))
|
||||
|
|
Loading…
Reference in a new issue