From b5bc4ad3d2af996ceb84f6f40b090468f703b3a8 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Sat, 18 Nov 2017 17:11:46 -0500 Subject: [PATCH] potential crash on exit fix (can't tell if it actually fixes it or if it is related) --- src/simulation/Air.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/simulation/Air.cpp b/src/simulation/Air.cpp index 6769346ee0..9bb04cec4f 100644 --- a/src/simulation/Air.cpp +++ b/src/simulation/Air.cpp @@ -358,20 +358,25 @@ void Air::RecalculateBlockAirMaps() for (int i = 0; i <= sim.parts_lastActiveIndex; i++) { int type = sim.parts[i].type; + if (!type) + continue; // Real TTAN would only block if there was enough TTAN // but it would be more expensive and complicated to actually check that // so just block for a frame, if it wasn't supposed to block it will continue allowing air next frame if (type == PT_TTAN) { int x = ((int)(sim.parts[i].x+0.5f))/CELL, y = ((int)(sim.parts[i].y+0.5f))/CELL; - bmap_blockair[y][x] = 1; - bmap_blockairh[y][x] = 0x8; + if (sim.InBounds(x, y)) + { + bmap_blockair[y][x] = 1; + bmap_blockairh[y][x] = 0x8; + } } // mostly accurate insulator blocking, besides checking GEL else if ((type == PT_HSWC && sim.parts[i].life != 10) || sim.elements[type].HeatConduct <= (rand()%250)) { int x = ((int)(sim.parts[i].x+0.5f))/CELL, y = ((int)(sim.parts[i].y+0.5f))/CELL; - if (!(bmap_blockairh[y][x]&0x8)) + if (sim.InBounds(x, y) && !(bmap_blockairh[y][x]&0x8)) bmap_blockairh[y][x]++; } }