Skip to content

Commit

Permalink
fix obscure division by 0 issue that only QuanTech would ever be affe…
Browse files Browse the repository at this point in the history
…cted by
  • Loading branch information
jacob1 committed Apr 3, 2018
1 parent 9f1d676 commit f812d71
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/simulation/elements/MERC.cpp
Expand Up @@ -48,7 +48,11 @@ Element_MERC::Element_MERC()
int Element_MERC::update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, trade, np;
const int absorbScale = 10000;// max number of particles that can be condensed into one
// Max number of particles that can be condensed into one
const int absorbScale = 10000;
// Obscure division by 0 fix
if (parts[i].temp + 1 == 0)
parts[i].temp = 0;
int maxtmp = ((absorbScale/(parts[i].temp + 1))-1);
if ((absorbScale%((int)parts[i].temp+1))>rand()%((int)parts[i].temp+1))
maxtmp ++;
Expand Down

0 comments on commit f812d71

Please sign in to comment.