Permalink
Browse files

fix potential infinite loop

  • Loading branch information...
Warboy1982 committed Jan 7, 2018
1 parent c3280c5 commit 0eb8d9cb484feda04b074c7f84a10b3863026db0
Showing with 2 additions and 1 deletion.
  1. +2 −1 src/Battlescape/ExplosionBState.cpp
@@ -112,7 +112,8 @@ void ExplosionBState::init()
int frameDelay = 0;
int counter = std::max(1, (_power/5) / 5);
_parent->getMap()->setBlastFlash(true);
for (int i = 0; i < _power/5; i++)
int lowerLimit = std::max(1, _power/5);
for (int i = 0; i < lowerLimit; i++)
{
int X = RNG::generate(-_power/2,_power/2);
int Y = RNG::generate(-_power/2,_power/2);

2 comments on commit 0eb8d9c

@maweki

This comment has been minimized.

Contributor

maweki replied Jan 10, 2018

Im trying to understand this. How was this a possible infinite loop before?

@Warboy1982

This comment has been minimized.

Collaborator

Warboy1982 replied Jan 10, 2018

the loop isn't here, it's spread across multiple files, this is merely the root cause.
when an explosion happens, the game tries to center the camera on the sprites of the explosion before it proceeds.
when an explosion happens and no sprites are added, the game ends up in an un-resolvable loop where it's trying to center the camera on something that doesn't exist.
this code change simply makes sure that at least one explosion sprite is added, allowing the game to proceed normally.

Please sign in to comment.