Fix bounds checking for SING and make explosion pressure area smaller

Making the area smaller means a bit less pressure is generated, but it
does stop the pressure going through walls
This commit is contained in:
jacksonmj 2012-04-29 01:37:52 +01:00
parent 38057065c2
commit d7f798da60

View File

@ -15,21 +15,21 @@ int update_SING(UPDATE_FUNC_ARGS) {
if (y+CELL<YRES) if (y+CELL<YRES)
pv[y/CELL+1][x/CELL+1] += 0.1f*(singularity-pv[y/CELL+1][x/CELL+1]); pv[y/CELL+1][x/CELL+1] += 0.1f*(singularity-pv[y/CELL+1][x/CELL+1]);
} }
if (y+CELL>0 && pv[y/CELL-1][x/CELL]<singularity) if (y-CELL>=0 && pv[y/CELL-1][x/CELL]<singularity)
pv[y/CELL-1][x/CELL] += 0.1f*(singularity-pv[y/CELL-1][x/CELL]); pv[y/CELL-1][x/CELL] += 0.1f*(singularity-pv[y/CELL-1][x/CELL]);
if (x+CELL>0) if (x-CELL>=0)
{ {
pv[y/CELL][x/CELL-1] += 0.1f*(singularity-pv[y/CELL][x/CELL-1]); pv[y/CELL][x/CELL-1] += 0.1f*(singularity-pv[y/CELL][x/CELL-1]);
if (y+CELL>0) if (y-CELL>=0)
pv[y/CELL-1][x/CELL-1] += 0.1f*(singularity-pv[y/CELL-1][x/CELL-1]); pv[y/CELL-1][x/CELL-1] += 0.1f*(singularity-pv[y/CELL-1][x/CELL-1]);
} }
if (parts[i].life<1) { if (parts[i].life<1) {
//Pop! //Pop!
for (rx=-2; rx<3; rx++) { for (rx=-1; rx<2; rx++) {
crx = (x/CELL)+rx; crx = (x/CELL)+rx;
for (ry=-2; ry<3; ry++) { for (ry=-1; ry<2; ry++) {
cry = (y/CELL)+ry; cry = (y/CELL)+ry;
if (cry > 0 && crx > 0 && crx < (XRES/CELL) && cry < (YRES/CELL)) { if (cry >= 0 && crx >= 0 && crx < (XRES/CELL) && cry < (YRES/CELL)) {
pv[cry][crx] += (float)parts[i].tmp; pv[cry][crx] += (float)parts[i].tmp;
} }
} }