diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index f067331444e..adb94e68e74 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -547,7 +547,7 @@ void CCharacter::FireWeapon(bool EarlyFire) else LaserReach = TuningList()[m_TuneZone].m_LaserReach; - new CLaser(&GameServer()->m_World, m_Pos, Direction, LaserReach, m_pPlayer->GetCid(), WEAPON_SHOTGUN); + new CLaser(&GameServer()->m_World, m_Pos, Direction, LaserReach, m_pPlayer->GetCid(), WEAPON_SHOTGUN, EarlyFire); GameServer()->CreateSound(m_Pos, SOUND_SHOTGUN_FIRE, TeamMask()); // NOLINT(clang-analyzer-unix.Malloc) } break; @@ -592,7 +592,7 @@ void CCharacter::FireWeapon(bool EarlyFire) else LaserReach = TuningList()[m_TuneZone].m_LaserReach; - new CLaser(GameWorld(), m_Pos, Direction, LaserReach, m_pPlayer->GetCid(), WEAPON_LASER); + new CLaser(GameWorld(), m_Pos, Direction, LaserReach, m_pPlayer->GetCid(), WEAPON_LASER, EarlyFire); GameServer()->CreateSound(m_Pos, SOUND_LASER_FIRE, TeamMask()); // NOLINT(clang-analyzer-unix.Malloc) } break; @@ -686,6 +686,7 @@ void CCharacter::OnPredictedInput(CNetObj_PlayerInput *pNewInput) // copy new input mem_copy(&m_Input, pNewInput, sizeof(m_Input)); + m_NumInputs++; // it is not allowed to aim in the center if(m_Input.m_TargetX == 0 && m_Input.m_TargetY == 0) @@ -722,7 +723,6 @@ void CCharacter::WeaponTick() { mem_copy(&m_LatestPrevInput, &m_LatestInput, sizeof(m_LatestInput)); mem_copy(&m_LatestInput, &m_Input, sizeof(m_LatestInput)); - m_NumInputs++; // it is not allowed to aim in the center if(m_LatestInput.m_TargetX == 0 && m_LatestInput.m_TargetY == 0) diff --git a/src/game/server/entities/laser.cpp b/src/game/server/entities/laser.cpp index 6c393c5b748..6ab73ebd42c 100644 --- a/src/game/server/entities/laser.cpp +++ b/src/game/server/entities/laser.cpp @@ -11,7 +11,7 @@ #include #include -CLaser::CLaser(CGameWorld *pGameWorld, vec2 Pos, vec2 Direction, float StartEnergy, int Owner, int Type) : +CLaser::CLaser(CGameWorld *pGameWorld, vec2 Pos, vec2 Direction, float StartEnergy, int Owner, int Type, bool EarlyTick) : CEntity(pGameWorld, CGameWorld::ENTTYPE_LASER) { m_Pos = Pos; @@ -32,7 +32,7 @@ CLaser::CLaser(CGameWorld *pGameWorld, vec2 Pos, vec2 Direction, float StartEner m_BelongsToPracticeTeam = pOwnerChar && pOwnerChar->Teams()->IsPractice(pOwnerChar->Team()); GameWorld()->InsertEntity(this); - DoBounce(); + DoBounce(EarlyTick); } bool CLaser::HitCharacter(vec2 From, vec2 To) @@ -97,9 +97,11 @@ bool CLaser::HitCharacter(vec2 From, vec2 To) return true; } -void CLaser::DoBounce() +void CLaser::DoBounce(bool EarlyTick) { m_EvalTick = Server()->Tick(); + if(EarlyTick) + m_EvalTick--; if(m_Energy < 0) { diff --git a/src/game/server/entities/laser.h b/src/game/server/entities/laser.h index 736789c0c43..cc1d38ff6c9 100644 --- a/src/game/server/entities/laser.h +++ b/src/game/server/entities/laser.h @@ -8,7 +8,14 @@ class CLaser : public CEntity { public: - CLaser(CGameWorld *pGameWorld, vec2 Pos, vec2 Direction, float StartEnergy, int Owner, int Type); + CLaser( + CGameWorld *pGameWorld, + vec2 Pos, + vec2 Direction, + float StartEnergy, + int Owner, + int Type, + bool EarlyTick = false); virtual void Reset() override; virtual void Tick() override; @@ -20,7 +27,7 @@ class CLaser : public CEntity protected: bool HitCharacter(vec2 From, vec2 To); - void DoBounce(); + void DoBounce(bool EarlyTick = false); private: vec2 m_From;