Skip to content

Commit

Permalink
Fix potential crash when sparking ETRD
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob1 committed Feb 23, 2024
1 parent ea7cd41 commit 0310ac0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/simulation/elements/SPRK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ static int update(UPDATE_FUNC_ARGS)
if (parts[i].life==1)
{
auto nearp = Element_ETRD_nearestSparkablePart(sim, i);
if (nearp == -1)
break;
auto pavg = sim->parts_avg(i, nearp, PT_INSL);
if (nearp!=-1 && pavg!=PT_INSL && pavg!=PT_RSSS)
if (pavg != PT_INSL && pavg != PT_RSSS)
{
sim->CreateLine(x, y, (int)(parts[nearp].x+0.5f), (int)(parts[nearp].y+0.5f), PT_PLSM);
parts[i].life = 20;
Expand Down

0 comments on commit 0310ac0

Please sign in to comment.