potential crash on exit fix (can't tell if it actually fixes it or if it is related)

This commit is contained in:
jacob1
2017-11-18 17:11:46 -05:00
parent 1b19e042b2
commit b5bc4ad3d2

View File

@@ -358,20 +358,25 @@ void Air::RecalculateBlockAirMaps()
for (int i = 0; i <= sim.parts_lastActiveIndex; i++) for (int i = 0; i <= sim.parts_lastActiveIndex; i++)
{ {
int type = sim.parts[i].type; int type = sim.parts[i].type;
if (!type)
continue;
// Real TTAN would only block if there was enough TTAN // Real TTAN would only block if there was enough TTAN
// but it would be more expensive and complicated to actually check that // 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 // so just block for a frame, if it wasn't supposed to block it will continue allowing air next frame
if (type == PT_TTAN) if (type == PT_TTAN)
{ {
int x = ((int)(sim.parts[i].x+0.5f))/CELL, y = ((int)(sim.parts[i].y+0.5f))/CELL; int x = ((int)(sim.parts[i].x+0.5f))/CELL, y = ((int)(sim.parts[i].y+0.5f))/CELL;
bmap_blockair[y][x] = 1; if (sim.InBounds(x, y))
bmap_blockairh[y][x] = 0x8; {
bmap_blockair[y][x] = 1;
bmap_blockairh[y][x] = 0x8;
}
} }
// mostly accurate insulator blocking, besides checking GEL // mostly accurate insulator blocking, besides checking GEL
else if ((type == PT_HSWC && sim.parts[i].life != 10) || sim.elements[type].HeatConduct <= (rand()%250)) 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; 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]++; bmap_blockairh[y][x]++;
} }
} }