From 67132c99251ea75893284c97ed77ae02e2770bb2 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Sat, 28 Apr 2018 11:45:16 -0400 Subject: [PATCH] fix another out of bounds crash relating to stasis wall --- src/simulation/Simulation.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index c73ccd945..22f43c708 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -5040,6 +5040,7 @@ void Simulation::RecalcFreeParticles(bool do_life_dec) t = parts[i].type; x = (int)(parts[i].x+0.5f); y = (int)(parts[i].y+0.5f); + bool inBounds = false; if (x>=0 && y>=0 && x0 && (elem_properties&PROP_LIFE_DEC) && !(bmap[y/CELL][x/CELL] == WL_STASIS && emap[y/CELL][x/CELL]<8)) + if (parts[i].life>0 && (elem_properties&PROP_LIFE_DEC) && !(inBounds && bmap[y/CELL][x/CELL] == WL_STASIS && emap[y/CELL][x/CELL]<8)) { // automatically decrease life parts[i].life--; @@ -5082,7 +5084,7 @@ void Simulation::RecalcFreeParticles(bool do_life_dec) continue; } } - else if (parts[i].life<=0 && (elem_properties&PROP_LIFE_KILL) && !(bmap[y/CELL][x/CELL] == WL_STASIS && emap[y/CELL][x/CELL]<8)) + else if (parts[i].life<=0 && (elem_properties&PROP_LIFE_KILL) && !(inBounds && bmap[y/CELL][x/CELL] == WL_STASIS && emap[y/CELL][x/CELL]<8)) { // kill if no life kill_part(i);