mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-13 03:28:19 +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_Pos = TempPos;
|
||||||
m_Dir = normalize(TempDir);
|
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_Bounces++;
|
||||||
m_WasTele = false;
|
m_WasTele = false;
|
||||||
|
|
|
@ -126,8 +126,12 @@ void CLaser::DoBounce()
|
||||||
m_Pos = TempPos;
|
m_Pos = TempPos;
|
||||||
m_Dir = normalize(TempDir);
|
m_Dir = normalize(TempDir);
|
||||||
|
|
||||||
if(!m_TuneZone)
|
const float Distance = distance(m_From, m_Pos);
|
||||||
m_Energy -= distance(m_From, m_Pos) + GameServer()->Tuning()->m_LaserBounceCost;
|
// Prevent infinite bounces
|
||||||
|
if(Distance == 0.0f)
|
||||||
|
m_Energy = -1;
|
||||||
|
else if(!m_TuneZone)
|
||||||
|
m_Energy -= Distance + GameServer()->Tuning()->m_LaserBounceCost;
|
||||||
else
|
else
|
||||||
m_Energy -= distance(m_From, m_Pos) + GameServer()->TuningList()[m_TuneZone].m_LaserBounceCost;
|
m_Energy -= distance(m_From, m_Pos) + GameServer()->TuningList()[m_TuneZone].m_LaserBounceCost;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue