Skip to content

Commit

Permalink
fix possible crash when PROT removes spark on disabled elements
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob1 committed May 11, 2015
1 parent aa85455 commit dd102c1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/simulation/elements/PROT.cpp
Expand Up @@ -55,11 +55,17 @@ int Element_PROT::update(UPDATE_FUNC_ARGS)
switch (utype)
{
case PT_SPRK:
{
//remove active sparks
sim->part_change_type(under>>8, x, y, parts[under>>8].ctype);
parts[under>>8].life = 44 + parts[under>>8].life;
parts[under>>8].ctype = 0;
int sparked = parts[under>>8].ctype;
if (sparked >= 0 && sparked < PT_NUM && sim->elements[sparked].Enabled)
{
sim->part_change_type(under>>8, x, y, sparked);
parts[under>>8].life = 44 + parts[under>>8].life;
parts[under>>8].ctype = 0;
}
break;
}
case PT_DEUT:
if ((-((int)sim->pv[y / CELL][x / CELL] - 4) + (parts[under>>8].life / 100)) > rand() % 200)
{
Expand Down

0 comments on commit dd102c1

Please sign in to comment.