From 6b497afba497c4e61d7d6d9940d63c97533917a3 Mon Sep 17 00:00:00 2001 From: def Date: Sun, 13 Mar 2022 00:02:42 +0100 Subject: [PATCH 1/2] Don't allow infinite shotgun bounce (fixes #4809) --- src/game/client/prediction/entities/laser.cpp | 7 ++++++- src/game/server/entities/laser.cpp | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/game/client/prediction/entities/laser.cpp b/src/game/client/prediction/entities/laser.cpp index a04d97a7f..05e0fd8ae 100644 --- a/src/game/client/prediction/entities/laser.cpp +++ b/src/game/client/prediction/entities/laser.cpp @@ -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; diff --git a/src/game/server/entities/laser.cpp b/src/game/server/entities/laser.cpp index 17e3f0f05..bb22a7d54 100644 --- a/src/game/server/entities/laser.cpp +++ b/src/game/server/entities/laser.cpp @@ -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; From cd87fc1ef7599a7f7d48ffaac1166e468845bec2 Mon Sep 17 00:00:00 2001 From: def Date: Mon, 28 Mar 2022 00:35:39 +0200 Subject: [PATCH 2/2] Fix move_sqlite (fixes #4902) --- scripts/move_sqlite.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/move_sqlite.py b/scripts/move_sqlite.py index f999292ab..88482c6c5 100755 --- a/scripts/move_sqlite.py +++ b/scripts/move_sqlite.py @@ -36,7 +36,7 @@ def transfer(file_from, file_to): conn_from = sqlite3.connect(file_from, isolation_level='EXCLUSIVE') for line in conn_from.iterdump(): cursor_to.execute(line) - print(line) + print(line.encode('utf-8')) cursor_to.close() conn_to.commit() conn_to.close()