4813: Don't allow infinite shotgun bounce (fixes #4809) r=heinrich5991 a=def-

I hope this kind of physic isn't used anywhere, I couldn't trigger it without being stuck in wall.

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


4905: Fix move_sqlite (fixes #4902) r=heinrich5991 a=def-

<!-- What is the motivation for the changes of this pull request -->

## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: def <dennis@felsin9.de>
This commit is contained in:
bors[bot] 2022-04-28 12:11:05 +00:00 committed by GitHub
commit 6cce22d056
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 4 deletions

View file

@ -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()

View file

@ -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;

View file

@ -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;