Fix walls for SING explosions

This commit is contained in:
jacksonmj 2011-06-18 00:42:12 +01:00 committed by Simon Robertshaw
parent fb79865186
commit 9d325dbb7c
2 changed files with 30 additions and 21 deletions

View File

@ -1,8 +1,9 @@
#include <element.h> #include <element.h>
int update_SING(UPDATE_FUNC_ARGS) { int update_SING(UPDATE_FUNC_ARGS) {
int r, rx, ry, cry, crx, rad, nxi, nxj, nb; int r, rx, ry, cry, crx, rad, nxi, nxj, nb, j, spawncount;
int singularity = -parts[i].life; int singularity = -parts[i].life;
float angle, v;
if (pv[y/CELL][x/CELL]<singularity) if (pv[y/CELL][x/CELL]<singularity)
pv[y/CELL][x/CELL] += 0.1f*(singularity-pv[y/CELL][x/CELL]); pv[y/CELL][x/CELL] += 0.1f*(singularity-pv[y/CELL][x/CELL]);
@ -33,26 +34,27 @@ int update_SING(UPDATE_FUNC_ARGS) {
} }
} }
} }
rad = (parts[i].tmp>255)?255:parts[i].tmp; spawncount = (parts[i].tmp>255)?255:parts[i].tmp;
if (rad>=1) { if (spawncount>=1)
rad = (int)(((float)rad)/8.0f); spawncount = spawncount/8;
} spawncount = spawncount*spawncount*M_PI;
if (rad>=1) { for (j=0;j<spawncount;j++)
for (nxj=-(rad+1); nxj<=(rad+1); nxj++) {
for (nxi=-(rad+1); nxi<=(rad+1); nxi++) if (rand()%2) {
if ((pow(nxi,2))/(pow((rad+1),2))+(pow(nxj,2))/(pow((rad+1),2))<=1) { nb = create_part(-3, x, y, PT_PHOT);
if (rand()%2) { } else {
nb = create_part(-1, x+nxi, y+nxj, PT_PHOT); nb = create_part(-3, x, y, PT_NEUT);
} else { }
nb = create_part(-1, x+nxi, y+nxj, PT_NEUT); if (nb!=-1) {
} parts[nb].life = (rand()%300);
if (nb!=-1) { parts[nb].temp = MAX_TEMP/2;
parts[nb].life = (rand()%300); angle = rand()*2.0f*M_PI/RAND_MAX;
parts[nb].temp = MAX_TEMP/2; v = (float)(rand())*5.0f/RAND_MAX;
parts[nb].vx = ((float)(rand()%100-50))/10.0f; parts[nb].vx = v*cosf(angle);
parts[nb].vy = ((float)(rand()%100-50))/10.0f; parts[nb].vy = v*sinf(angle);
} }
} else if (pfree==-1)
break;//if we've run out of particles, stop trying to create them - saves a lot of lag on "sing bomb" saves
} }
kill_part(i); kill_part(i);
return 1; return 1;

View File

@ -754,6 +754,13 @@ inline int create_part(int p, int x, int y, int t)//the function for creating a
i = pfree; i = pfree;
pfree = parts[i].life; pfree = parts[i].life;
} }
else if (p==-3)//skip pmap checks, e.g. for sing explosion
{
if (pfree == -1)
return -1;
i = pfree;
pfree = parts[i].life;
}
else else
i = p; i = p;