mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Don't allow infinite shotgun bounce (fixes #4809)
This commit is contained in:
parent
4337bcf7de
commit
6b497afba4
|
@ -112,7 +112,12 @@ void CLaser::DoBounce()
|
|||
m_Pos = TempPos;
|
||||
m_Dir = normalize(TempDir);
|
||||
|
||||
m_Energy -= distance(m_From, m_Pos) + GetTuning(m_TuneZone)->m_LaserBounceCost;
|
||||
const float Distance = distance(m_From, m_Pos);
|
||||
// Prevent infinite bounces
|
||||
if(Distance == 0.0f)
|
||||
m_Energy = -1;
|
||||
else
|
||||
m_Energy -= Distance + GetTuning(m_TuneZone)->m_LaserBounceCost;
|
||||
|
||||
m_Bounces++;
|
||||
m_WasTele = false;
|
||||
|
|
|
@ -126,8 +126,12 @@ void CLaser::DoBounce()
|
|||
m_Pos = TempPos;
|
||||
m_Dir = normalize(TempDir);
|
||||
|
||||
if(!m_TuneZone)
|
||||
m_Energy -= distance(m_From, m_Pos) + GameServer()->Tuning()->m_LaserBounceCost;
|
||||
const float Distance = distance(m_From, m_Pos);
|
||||
// Prevent infinite bounces
|
||||
if(Distance == 0.0f)
|
||||
m_Energy = -1;
|
||||
else if(!m_TuneZone)
|
||||
m_Energy -= Distance + GameServer()->Tuning()->m_LaserBounceCost;
|
||||
else
|
||||
m_Energy -= distance(m_From, m_Pos) + GameServer()->TuningList()[m_TuneZone].m_LaserBounceCost;
|
||||
|
||||
|
|
Loading…
Reference in a new issue