More Target cleanup

This commit is contained in:
Jupeyy 2020-10-17 19:02:58 +02:00
parent 28ee13949b
commit fa8b8b9324
4 changed files with 13 additions and 3 deletions

View file

@ -1227,8 +1227,8 @@ void CCharacter::Read(CNetObj_Character *pChar, CNetObj_DDNetCharacter *pExtende
mem_zero(&m_SavedInput, sizeof(m_SavedInput));
m_Input.m_Direction = m_SavedInput.m_Direction = m_Core.m_Direction;
m_Input.m_Hook = m_SavedInput.m_Hook = (m_Core.m_HookState != HOOK_IDLE);
m_Input.m_TargetX = cosf(pChar->m_Angle / 256.0f);
m_Input.m_TargetY = sinf(pChar->m_Angle / 256.0f);
m_Input.m_TargetX = m_SavedInput.m_TargetX = cosf(pChar->m_Angle / 256.0f) * 256.0f;
m_Input.m_TargetY = m_SavedInput.m_TargetY = sinf(pChar->m_Angle / 256.0f) * 256.0f;
}
// in most cases the reload timer can be determined from the last attack tick

View file

@ -118,7 +118,15 @@ public:
void SetNinjaActivationTick(int ActivationTick) { m_Ninja.m_ActivationTick = ActivationTick; };
void SetNinjaCurrentMoveTime(int CurrentMoveTime) { m_Ninja.m_CurrentMoveTime = CurrentMoveTime; };
int GetCID() { return m_ID; }
void SetInput(CNetObj_PlayerInput *pNewInput) { m_LatestInput = m_Input = *pNewInput; };
void SetInput(CNetObj_PlayerInput *pNewInput)
{
m_LatestInput = m_Input = *pNewInput;
// it is not allowed to aim in the center
if(m_Input.m_TargetX == 0 && m_Input.m_TargetY == 0)
{
m_Input.m_TargetY = m_LatestInput.m_TargetY = -1;
}
};
int GetJumped() { return m_Core.m_Jumped; }
int GetAttackTick() { return m_AttackTick; }
int GetStrongWeakID() { return m_StrongWeakID; }

View file

@ -475,6 +475,7 @@ void CGameWorld::NetObjEnd(int LocalID)
pHookedChar->m_Pos = pHookedChar->m_Core.m_Pos = pChar->m_Core.m_HookPos;
pHookedChar->m_Core.m_Vel = vec2(0, 0);
mem_zero(&pHookedChar->m_SavedInput, sizeof(pHookedChar->m_SavedInput));
pHookedChar->m_SavedInput.m_TargetY = -1;
pHookedChar->m_KeepHooked = true;
pHookedChar->m_MarkedForDestroy = false;
}

View file

@ -56,6 +56,7 @@ bool CCharacter::Spawn(CPlayer *pPlayer, vec2 Pos)
m_Pos = Pos;
mem_zero(&m_LatestPrevPrevInput, sizeof(m_LatestPrevPrevInput));
m_LatestPrevPrevInput.m_TargetY = -1;
m_SpawnTick = Server()->Tick();
m_WeaponChangeTick = Server()->Tick();
Antibot()->OnSpawn(m_pPlayer->GetCID());