diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index adb94e68e74..5e9edf75df6 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -514,11 +514,7 @@ void CCharacter::FireWeapon(bool EarlyFire) else Lifetime = (int)(Server()->TickSpeed() * TuningList()[m_TuneZone].m_GunLifetime); - int StartTick = Server()->Tick(); - if(EarlyFire) - StartTick--; - - new CProjectile( + CProjectile *Projectile = new CProjectile( GameWorld(), WEAPON_GUN, //Type m_pPlayer->GetCid(), //Owner @@ -528,11 +524,10 @@ void CCharacter::FireWeapon(bool EarlyFire) false, //Freeze false, //Explosive -1, //SoundImpact - MouseTarget, //InitDir - 0, - 0, - StartTick // StartTick + MouseTarget //InitDir ); + if(EarlyFire) + Projectile->SetStartTick(Server()->Tick() - 1); GameServer()->CreateSound(m_Pos, SOUND_GUN_FIRE, TeamMask()); // NOLINT(clang-analyzer-unix.Malloc) } @@ -547,7 +542,10 @@ 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, EarlyFire); + CLaser *Laser = new CLaser(&GameServer()->m_World, m_Pos, Direction, LaserReach, m_pPlayer->GetCid(), WEAPON_SHOTGUN); + if(EarlyFire) + Laser->SetEvalTick(Server()->Tick() - 1); + GameServer()->CreateSound(m_Pos, SOUND_SHOTGUN_FIRE, TeamMask()); // NOLINT(clang-analyzer-unix.Malloc) } break; @@ -560,11 +558,7 @@ void CCharacter::FireWeapon(bool EarlyFire) else Lifetime = (int)(Server()->TickSpeed() * TuningList()[m_TuneZone].m_GrenadeLifetime); - int StartTick = Server()->Tick(); - if(EarlyFire) - StartTick--; - - new CProjectile( + CProjectile *Projectile = new CProjectile( GameWorld(), WEAPON_GRENADE, //Type m_pPlayer->GetCid(), //Owner @@ -574,11 +568,10 @@ void CCharacter::FireWeapon(bool EarlyFire) false, //Freeze true, //Explosive SOUND_GRENADE_EXPLODE, //SoundImpact - MouseTarget, // MouseTarget - 0, - 0, - StartTick //StartTick + MouseTarget // MouseTarget ); + if(EarlyFire) + Projectile->SetStartTick(Server()->Tick() - 1); GameServer()->CreateSound(m_Pos, SOUND_GRENADE_FIRE, TeamMask()); } @@ -592,7 +585,10 @@ void CCharacter::FireWeapon(bool EarlyFire) else LaserReach = TuningList()[m_TuneZone].m_LaserReach; - new CLaser(GameWorld(), m_Pos, Direction, LaserReach, m_pPlayer->GetCid(), WEAPON_LASER, EarlyFire); + CLaser *Laser = new CLaser(GameWorld(), m_Pos, Direction, LaserReach, m_pPlayer->GetCid(), WEAPON_LASER); + if(EarlyFire) + Laser->SetEvalTick(Server()->Tick() - 1); + GameServer()->CreateSound(m_Pos, SOUND_LASER_FIRE, TeamMask()); // NOLINT(clang-analyzer-unix.Malloc) } break; diff --git a/src/game/server/entities/laser.cpp b/src/game/server/entities/laser.cpp index 6ab73ebd42c..0cce7add2ef 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, bool EarlyTick) : +CLaser::CLaser(CGameWorld *pGameWorld, vec2 Pos, vec2 Direction, float StartEnergy, int Owner, int Type) : CEntity(pGameWorld, CGameWorld::ENTTYPE_LASER) { m_Pos = Pos; @@ -32,7 +32,12 @@ CLaser::CLaser(CGameWorld *pGameWorld, vec2 Pos, vec2 Direction, float StartEner m_BelongsToPracticeTeam = pOwnerChar && pOwnerChar->Teams()->IsPractice(pOwnerChar->Team()); GameWorld()->InsertEntity(this); - DoBounce(EarlyTick); + DoBounce(); +} + +void CLaser::SetEvalTick(int Tick) +{ + m_EvalTick = Tick; } bool CLaser::HitCharacter(vec2 From, vec2 To) diff --git a/src/game/server/entities/laser.h b/src/game/server/entities/laser.h index cc1d38ff6c9..2524115c6a2 100644 --- a/src/game/server/entities/laser.h +++ b/src/game/server/entities/laser.h @@ -14,8 +14,7 @@ class CLaser : public CEntity vec2 Direction, float StartEnergy, int Owner, - int Type, - bool EarlyTick = false); + int Type); virtual void Reset() override; virtual void Tick() override; @@ -49,6 +48,9 @@ class CLaser : public CEntity bool m_TeleportCancelled; bool m_IsBlueTeleport; bool m_BelongsToPracticeTeam; + +public: + void SetEvalTick(int Tick); }; #endif diff --git a/src/game/server/entities/projectile.cpp b/src/game/server/entities/projectile.cpp index 1b25a70438d..33f351292a8 100644 --- a/src/game/server/entities/projectile.cpp +++ b/src/game/server/entities/projectile.cpp @@ -23,8 +23,7 @@ CProjectile::CProjectile( int SoundImpact, vec2 InitDir, int Layer, - int Number, - int StartTick) : + int Number) : CEntity(pGameWorld, CGameWorld::ENTTYPE_PROJECTILE) { m_Type = Type; @@ -35,10 +34,6 @@ CProjectile::CProjectile( //m_Damage = Damage; m_SoundImpact = SoundImpact; m_StartTick = Server()->Tick(); - - if(StartTick >= 0) - m_StartTick = StartTick; - m_Explosive = Explosive; m_Layer = Layer; @@ -54,6 +49,11 @@ CProjectile::CProjectile( GameWorld()->InsertEntity(this); } +void CProjectile::SetStartTick(int Tick) +{ + m_StartTick = Tick; +} + void CProjectile::Reset() { m_MarkedForDestroy = true; diff --git a/src/game/server/entities/projectile.h b/src/game/server/entities/projectile.h index 9228bb40eed..a323c12f16f 100644 --- a/src/game/server/entities/projectile.h +++ b/src/game/server/entities/projectile.h @@ -20,8 +20,7 @@ class CProjectile : public CEntity int SoundImpact, vec2 InitDir, int Layer = 0, - int Number = 0, - int StartTick = -1); + int Number = 0); vec2 GetPos(float Time); void FillInfo(CNetObj_Projectile *pProj); @@ -51,6 +50,7 @@ class CProjectile : public CEntity vec2 m_InitDir; public: + void SetStartTick(int Tick); void SetBouncing(int Value); bool FillExtraInfoLegacy(CNetObj_DDRaceProjectile *pProj); void FillExtraInfo(CNetObj_DDNetProjectile *pProj); diff --git a/src/game/server/player.h b/src/game/server/player.h index 74362950e6a..3dadc883c9e 100644 --- a/src/game/server/player.h +++ b/src/game/server/player.h @@ -59,7 +59,6 @@ class CPlayer void OnPlayerFreshInput(CNetObj_PlayerInput *pNewInput); void OnPlayerInput(CNetObj_PlayerInput *pNewInput); - void OnPredictedEarlyInput(CNetObj_PlayerInput *pNewInput); void OnDisconnect(); void KillCharacter(int Weapon = WEAPON_GAME, bool SendKillMsg = true);