Skip to content

Commit

Permalink
potential crash on exit fix (can't tell if it actually fixes it or if…
Browse files Browse the repository at this point in the history
… it is related)
  • Loading branch information
jacob1 committed Nov 18, 2017
1 parent 1b19e04 commit b5bc4ad
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/simulation/Air.cpp
Expand Up @@ -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]++;
}
}
Expand Down

0 comments on commit b5bc4ad

Please sign in to comment.