summaryrefslogtreecommitdiff
path: root/src/powder.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/powder.c')
-rw-r--r--src/powder.c409
1 files changed, 207 insertions, 202 deletions
diff --git a/src/powder.c b/src/powder.c
index 2d2e099..9dca982 100644
--- a/src/powder.c
+++ b/src/powder.c
@@ -26,10 +26,10 @@ static int pn_junction_sprk(int x, int y, int pt)
{
unsigned r = pmap[y][x];
if((r & 0xFF) != pt)
- return 0;
+ return 0;
r >>= 8;
if(parts[r].type != pt)
- return 0;
+ return 0;
parts[r].ctype = pt;
parts[r].type = PT_SPRK;
@@ -42,16 +42,16 @@ static void photoelectric_effect(int nx, int ny)
unsigned r = pmap[ny][nx];
if((r&0xFF) == PT_PSCN) {
- if((pmap[ny][nx-1] & 0xFF) == PT_NSCN ||
- (pmap[ny][nx+1] & 0xFF) == PT_NSCN ||
- (pmap[ny-1][nx] & 0xFF) == PT_NSCN ||
- (pmap[ny+1][nx] & 0xFF) == PT_NSCN)
- pn_junction_sprk(nx, ny, PT_PSCN);
+ if((pmap[ny][nx-1] & 0xFF) == PT_NSCN ||
+ (pmap[ny][nx+1] & 0xFF) == PT_NSCN ||
+ (pmap[ny-1][nx] & 0xFF) == PT_NSCN ||
+ (pmap[ny+1][nx] & 0xFF) == PT_NSCN)
+ pn_junction_sprk(nx, ny, PT_PSCN);
}
}
/*
RETURN-value explenation
-1 = Swap
+1 = Swap
0 = No move/Bounce
2 = Both particles occupy the same space.
*/
@@ -69,16 +69,13 @@ static int eval_move(int pt, int nx, int ny, unsigned *rr)
*rr = r;
if((r&0xFF)==PT_VOID || (r&0xFF)==PT_BHOL)
- return 1;
-
- if(pt==PT_NEUT && (r&0xFF)==PT_GLAS)
- return 2;
+ return 1;
if(pt==PT_PHOT&&(
(r&0xFF)==PT_GLAS || (r&0xFF)==PT_PHOT ||
(r&0xFF)==PT_CLNE || (r&0xFF)==PT_PCLN ||
- (r&0xFF)==PT_GLOW ||
- (r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW || (r&0xFF)==PT_SLTW ||
+ (r&0xFF)==PT_GLOW || (r&0xFF)==PT_WATR ||
+ (r&0xFF)==PT_DSTW || (r&0xFF)==PT_SLTW ||
((r&0xFF)==PT_LCRY&&parts[r>>8].life > 5)))
return 2;
@@ -99,17 +96,19 @@ static int eval_move(int pt, int nx, int ny, unsigned *rr)
return 0;
if(pt == PT_PHOT)
- return 2;
-
- if(pt == PT_NEUT)
+ return 0;
+ if(pt == PT_NEUT)
return 1;
- if((r&0xFF) == PT_NEUT)
+ if(pt == PT_NEUT && (r&0xFF == PT_WATR||r&0xFF == PT_SLTW ||r&0xFF == PT_DSTW))
+ return 2;
+
+ if((r&0xFF) == PT_NEUT)
return 0;
-
- if (r && ((r&0xFF) >= PT_NUM || (ptypes[pt].weight <= ptypes[(r&0xFF)].weight)))
+
+ if (r && ((r&0xFF) >= PT_NUM || (ptypes[pt].weight <= ptypes[(r&0xFF)].weight)))
return 0;
-
-
+
+
return 1;
}
@@ -127,32 +126,38 @@ int try_move(int i, int x, int y, int nx, int ny)
/* half-silvered mirror */
if(!e && parts[i].type==PT_PHOT &&
- (((r&0xFF)==PT_BMTL && rand()<RAND_MAX/2) ||
- (pmap[y][x]&0xFF)==PT_BMTL))
- e = 2;
+ (((r&0xFF)==PT_BMTL && rand()<RAND_MAX/2) ||
+ (pmap[y][x]&0xFF)==PT_BMTL))
+ e = 2;
- if(!e) {
- if(!legacy_enable && parts[i].type==PT_PHOT) {
+ if(!e)
+ {
+ if(!legacy_enable && parts[i].type==PT_PHOT)
+ {
if((r & 0xFF) == PT_COAL || (r & 0xFF) == PT_BCOL)
parts[r>>8].temp = parts[i].temp;
+
if((r & 0xFF) < PT_NUM)
- parts[i].temp = parts[r>>8].temp =
- restrict_flt((parts[r>>8].temp+parts[i].temp)/2, MIN_TEMP, MAX_TEMP);
+ parts[i].temp = parts[r>>8].temp = restrict_flt((parts[r>>8].temp+parts[i].temp)/2, MIN_TEMP, MAX_TEMP);
}
return 0;
}
- if(e == 2) {
- if(parts[i].type == PT_PHOT && (r&0xFF)==PT_GLOW && !parts[r>>8].life)
- if(rand() < RAND_MAX/30) {
- parts[r>>8].life = 120;
- create_gain_photon(i);
- }
- if(parts[i].type == PT_NEUT && (r&0xFF)==PT_GLAS) {
- if(rand() < RAND_MAX/10)
- create_cherenkov_photon(i);
- }
+
+ if(e == 2)
+ {
+ if(parts[i].type == PT_PHOT && (r&0xFF)==PT_GLOW && !parts[r>>8].life)
+ if(rand() < RAND_MAX/30)
+ {
+ parts[r>>8].life = 120;
+ create_gain_photon(i);
+ }
+
+ if(parts[i].type == PT_NEUT && (r&0xFF)==PT_GLAS) {
+ if(rand() < RAND_MAX/10)
+ create_cherenkov_photon(i);
+ }
return 1;
- }
+ }
if((r&0xFF)==PT_VOID)
{
@@ -181,13 +186,13 @@ int try_move(int i, int x, int y, int nx, int ny)
return 0;
if(parts[i].type == PT_PHOT)
- return 1;
+ return 1;
e = r >> 8;
if(r && e<NPART)
{
- if(parts[e].type == PT_PHOT)
- return 1;
+ if(parts[e].type == PT_PHOT)
+ return 1;
parts[e].x += x-nx;
parts[e].y += y-ny;
@@ -327,7 +332,7 @@ int get_normal_interp(int pt, float x0, float y0, float dx, float dy, float *nx,
return 0;
if(pt == PT_PHOT)
- photoelectric_effect(x, y);
+ photoelectric_effect(x, y);
return get_normal(pt, x, y, dx, dy, nx, ny);
}
@@ -337,11 +342,11 @@ void kill_part(int i)
int x, y;
if(parts[i].type != PT_PHOT) {
- x = (int)(parts[i].x+0.5f);
- y = (int)(parts[i].y+0.5f);
+ x = (int)(parts[i].x+0.5f);
+ y = (int)(parts[i].y+0.5f);
- if(x>=0 && y>=0 && x<XRES && y<YRES)
- pmap[y][x] = 0;
+ if(x>=0 && y>=0 && x<XRES && y<YRES)
+ pmap[y][x] = 0;
}
parts[i].type = PT_NONE;
@@ -421,7 +426,7 @@ inline int create_part(int p, int x, int y, int t)
(pmap[y][x]&0xFF)!=PT_ETRD &&
(pmap[y][x]&0xFF)!=PT_BRMT &&
(pmap[y][x]&0xFF)!=PT_NBLE &&
- (pmap[y][x]&0xFF)!=PT_IRON &&
+ (pmap[y][x]&0xFF)!=PT_IRON &&
(pmap[y][x]&0xFF)!=PT_INWR)
return -1;
parts[pmap[y][x]>>8].type = PT_SPRK;
@@ -500,15 +505,15 @@ inline int create_part(int p, int x, int y, int t)
parts[i].vx = r*cosf(a);
parts[i].vy = r*sinf(a);
}
- if(t==PT_MORT)
- {
- parts[i].vx = 2;
- }
+ if(t==PT_MORT)
+ {
+ parts[i].vx = 2;
+ }
if(t==PT_PHOT)
{
- float a = (rand()%8) * 0.78540f;
+ float a = (rand()%8) * 0.78540f;
parts[i].life = 680;
- parts[i].ctype = 0x3FFFFFFF;
+ parts[i].ctype = 0x3FFFFFFF;
parts[i].vx = 3.0f*cosf(a);
parts[i].vy = 3.0f*sinf(a);
}
@@ -569,10 +574,10 @@ static void create_gain_photon(int pp)
lr = rand() % 2;
if(lr) {
- xx = parts[pp].x - 0.3*parts[pp].vy;
+ xx = parts[pp].x - 0.3*parts[pp].vy;
yy = parts[pp].y + 0.3*parts[pp].vx;
} else {
- xx = parts[pp].x + 0.3*parts[pp].vy;
+ xx = parts[pp].x + 0.3*parts[pp].vy;
yy = parts[pp].y - 0.3*parts[pp].vx;
}
@@ -580,10 +585,10 @@ static void create_gain_photon(int pp)
ny = (int)(yy + 0.5f);
if(nx<0 || ny<0 || nx>=XRES || ny>=YRES)
- return;
+ return;
if((pmap[ny][nx] & 0xFF) != PT_GLOW)
- return;
+ return;
pfree = parts[i].life;
@@ -614,10 +619,10 @@ static void create_cherenkov_photon(int pp)
nx = (int)(parts[pp].x + 0.5f);
ny = (int)(parts[pp].y + 0.5f);
if((pmap[ny][nx] & 0xFF) != PT_GLAS)
- return;
+ return;
if(hypotf(parts[pp].vx, parts[pp].vy) < 1.44f)
- return;
+ return;
pfree = parts[i].life;
@@ -632,11 +637,11 @@ static void create_cherenkov_photon(int pp)
parts[i].tmp = 0;
if(lr) {
- parts[i].vx = parts[pp].vx - 2.5f*parts[pp].vy;
- parts[i].vy = parts[pp].vy + 2.5f*parts[pp].vx;
+ parts[i].vx = parts[pp].vx - 2.5f*parts[pp].vy;
+ parts[i].vy = parts[pp].vy + 2.5f*parts[pp].vx;
} else {
- parts[i].vx = parts[pp].vx + 2.5f*parts[pp].vy;
- parts[i].vy = parts[pp].vy - 2.5f*parts[pp].vx;
+ parts[i].vx = parts[pp].vx + 2.5f*parts[pp].vy;
+ parts[i].vy = parts[pp].vy - 2.5f*parts[pp].vx;
}
/* photons have speed of light. no discussion. */
@@ -686,18 +691,18 @@ int get_wavelength_bin(int *wm)
int i, w0=30, wM=0;
if(!*wm)
- return -1;
+ return -1;
for(i=0; i<30; i++)
- if(*wm & (1<<i)) {
- if(i < w0)
- w0 = i;
- if(i > wM)
- wM = i;
- }
+ if(*wm & (1<<i)) {
+ if(i < w0)
+ w0 = i;
+ if(i > wM)
+ wM = i;
+ }
if(wM-w0 < 5)
- return (wM+w0)/2;
+ return (wM+w0)/2;
i = rand() % (wM-w0-3);
i += w0;
@@ -1288,67 +1293,67 @@ void update_particles_i(pixel *vid, int start, int inc)
}
}
}
- else if(t==PT_BMTL){
- if(parts[i].tmp>1){
- parts[i].tmp--;
- for(nx=-1; nx<2; nx++)
- for(ny=-1; ny<2; ny++)
- if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
- {
- r = pmap[y+ny][x+nx];
- if((r>>8)>=NPART || !r)
- continue;
- rt =parts[r>>8].type;
- if((rt==PT_METL || rt==PT_IRON) && 1>(rand()/(RAND_MAX/100)))
- {
- parts[r>>8].type=PT_BMTL;
- parts[r>>8].tmp=(parts[i].tmp<=7)?parts[i].tmp=1:parts[i].tmp-(rand()%5);//rand()/(RAND_MAX/300)+100;
- }
- }
- } else if(parts[i].tmp==1 && 1>rand()%1000){
- parts[i].tmp = 0;
- t = parts[i].type = PT_BRMT;
- }
- }
-
- else if(t==PT_IRON){
- for(nx=-1; nx<2; nx++)
- for(ny=-1; ny<2; ny++)
- if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
- {
- r = pmap[y+ny][x+nx];
- if((r>>8)>=NPART || !r)
- continue;
- if((((r&0xFF) == PT_SALT && 15>(rand()/(RAND_MAX/700))) ||
- ((r&0xFF) == PT_SLTW && 30>(rand()/(RAND_MAX/2000))) ||
- ((r&0xFF) == PT_WATR && 5 >(rand()/(RAND_MAX/6000))) ||
- ((r&0xFF) == PT_O2 && 2 >(rand()/(RAND_MAX/500))) ||
- ((r&0xFF) == PT_LO2))&&
- (!(parts[i].life))
- )
- {
- parts[i].type=PT_BMTL;
- parts[i].tmp=(rand()/(RAND_MAX/10))+20;
- }
- }
- }
- else if((t==PT_SPRK||parts[i].type==PT_SPRK) && parts[i].ctype==PT_IRON){
- for(nx=-1; nx<2; nx++)
- for(ny=-1; ny<2; ny++)
- if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
- {
- r = pmap[y+ny][x+nx];
- if((r>>8)>=NPART || !r)
- continue;
- if(((r&0xFF) == PT_DSTW && 30>(rand()/(RAND_MAX/1000))) ||
- ((r&0xFF) == PT_SLTW && 30>(rand()/(RAND_MAX/1000))) ||
- ((r&0xFF) == PT_WATR && 30>(rand()/(RAND_MAX/1000))))
- {
- parts[r>>8].type=PT_O2;
- //parts[r>>8].tmp=(rand()/(RAND_MAX/10))+20;
- }
- }
- }
+ else if(t==PT_BMTL) {
+ if(parts[i].tmp>1) {
+ parts[i].tmp--;
+ for(nx=-1; nx<2; nx++)
+ for(ny=-1; ny<2; ny++)
+ if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART || !r)
+ continue;
+ rt =parts[r>>8].type;
+ if((rt==PT_METL || rt==PT_IRON) && 1>(rand()/(RAND_MAX/100)))
+ {
+ parts[r>>8].type=PT_BMTL;
+ parts[r>>8].tmp=(parts[i].tmp<=7)?parts[i].tmp=1:parts[i].tmp-(rand()%5);//rand()/(RAND_MAX/300)+100;
+ }
+ }
+ } else if(parts[i].tmp==1 && 1>rand()%1000) {
+ parts[i].tmp = 0;
+ t = parts[i].type = PT_BRMT;
+ }
+ }
+
+ else if(t==PT_IRON) {
+ for(nx=-1; nx<2; nx++)
+ for(ny=-1; ny<2; ny++)
+ if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART || !r)
+ continue;
+ if((((r&0xFF) == PT_SALT && 15>(rand()/(RAND_MAX/700))) ||
+ ((r&0xFF) == PT_SLTW && 30>(rand()/(RAND_MAX/2000))) ||
+ ((r&0xFF) == PT_WATR && 5 >(rand()/(RAND_MAX/6000))) ||
+ ((r&0xFF) == PT_O2 && 2 >(rand()/(RAND_MAX/500))) ||
+ ((r&0xFF) == PT_LO2))&&
+ (!(parts[i].life))
+ )
+ {
+ parts[i].type=PT_BMTL;
+ parts[i].tmp=(rand()/(RAND_MAX/10))+20;
+ }
+ }
+ }
+ else if((t==PT_SPRK||parts[i].type==PT_SPRK) && parts[i].ctype==PT_IRON) {
+ for(nx=-1; nx<2; nx++)
+ for(ny=-1; ny<2; ny++)
+ if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART || !r)
+ continue;
+ if(((r&0xFF) == PT_DSTW && 30>(rand()/(RAND_MAX/1000))) ||
+ ((r&0xFF) == PT_SLTW && 30>(rand()/(RAND_MAX/1000))) ||
+ ((r&0xFF) == PT_WATR && 30>(rand()/(RAND_MAX/1000))))
+ {
+ parts[r>>8].type=PT_O2;
+ //parts[r>>8].tmp=(rand()/(RAND_MAX/10))+20;
+ }
+ }
+ }
else if(t==PT_COAL)
{
if(parts[i].life<=0) {
@@ -1420,15 +1425,15 @@ void update_particles_i(pixel *vid, int start, int inc)
//t = parts[i].life = PT_NONE;
kill_part(i);
r = create_part(-1, x, y, PT_PLSM);
- if(r!=-1)
- parts[r].life = 50;
+ if(r!=-1)
+ parts[r].life = 50;
//goto killed;
} else if (parts[i].life < 40) {
parts[i].life--;
if((rand()%100)==0) {
r = create_part(-1, (nx=x+rand()%3-1), (ny=y+rand()%3-1), PT_PLSM);
- if(r!=-1)
- parts[r].life = 50;
+ if(r!=-1)
+ parts[r].life = 50;
}
}
if((pv[y/CELL][x/CELL] > 2.7f)&&parts[i].tmp>40)
@@ -1463,15 +1468,15 @@ void update_particles_i(pixel *vid, int start, int inc)
//t = PT_NONE;
kill_part(i);
r = create_part(-1, x, y, PT_PLSM);
- if(r!=-1)
- parts[r].life = 50;
+ if(r!=-1)
+ parts[r].life = 50;
//goto killed;
} else if (parts[i].life < 40) {
parts[i].life--;
if((rand()%10)==0) {
r = create_part(-1, (nx=x+rand()%3-1), (ny=y+rand()%3-1), PT_PLSM);
- if(r!=-1)
- parts[r].life = 50;
+ if(r!=-1)
+ parts[r].life = 50;
}
}
for(nx=-2; nx<3; nx++)
@@ -1777,9 +1782,9 @@ void update_particles_i(pixel *vid, int start, int inc)
}
}
}
- else if(t==PT_MORT){
- create_part(-1, x, y-1, PT_SMKE);
- }
+ else if(t==PT_MORT) {
+ create_part(-1, x, y-1, PT_SMKE);
+ }
else if(t==PT_LCRY)
{
for(nx=-1; nx<2; nx++)
@@ -1946,7 +1951,7 @@ void update_particles_i(pixel *vid, int start, int inc)
}
}
else if(parts[i].tmp==2) {
- int col = rand()%200+4;
+ int col = rand()%200+4;
for(nx=-2; nx<3; nx++) {
for(ny=-2; ny<3; ny++) {
if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
@@ -2040,7 +2045,7 @@ void update_particles_i(pixel *vid, int start, int inc)
continue;
rt = parts[r>>8].type;
if((a || ptypes[rt].explosive) && ((rt!=PT_RBDM && rt!=PT_LRBD && rt!=PT_INSL && rt!=PT_SWCH) || t!=PT_SPRK) &&
- !(t==PT_PHOT && rt==PT_INSL) &&
+ !(t==PT_PHOT && rt==PT_INSL) &&
(t!=PT_LAVA || parts[i].life>0 || (rt!=PT_STNE && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_METL && rt!=PT_IRON && rt!=PT_ETRD && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SWCH && rt!=PT_INWR)) &&
ptypes[rt].flammable && (ptypes[rt].flammable + (int)(pv[(y+ny)/CELL][(x+nx)/CELL]*10.0f))>(rand()%1000))
{
@@ -2621,8 +2626,8 @@ killed:
parts[i].ctype = pmap[y+ny][x+nx]&0xFF;
}
else {
- create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype);
- }
+ create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype);
+ }
}
if(parts[i].type==PT_PCLN)
@@ -2641,21 +2646,21 @@ killed:
(pmap[y+ny][x+nx]&0xFF)!=PT_STKM &&
(pmap[y+ny][x+nx]&0xFF)!=0xFF)
parts[i].ctype = pmap[y+ny][x+nx]&0xFF;
- if(parts[i].ctype && parts[i].life==10){
- if(parts[i].ctype==PT_PHOT){
- for(nx=-1; nx<2; nx++){
- for(ny=-1; ny<2; ny++){
- r = create_part(-1, x+nx, y+ny, parts[i].ctype);
- if(r!=-1){
- parts[r].vx = nx*3;
- parts[r].vy = ny*3;
- }
- }
- }
- } else {
- create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype);
- }
- }
+ if(parts[i].ctype && parts[i].life==10) {
+ if(parts[i].ctype==PT_PHOT) {
+ for(nx=-1; nx<2; nx++) {
+ for(ny=-1; ny<2; ny++) {
+ r = create_part(-1, x+nx, y+ny, parts[i].ctype);
+ if(r!=-1) {
+ parts[r].vx = nx*3;
+ parts[r].vy = ny*3;
+ }
+ }
+ }
+ } else {
+ create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype);
+ }
+ }
}
if(t==PT_YEST)
{
@@ -2697,7 +2702,7 @@ killed:
lt = pmap[y][x] & 0xFF;
- r = eval_move(PT_PHOT, nx, ny, NULL);
+ r = eval_move(PT_PHOT, nx, ny, NULL);
if(((rt==PT_GLAS && lt!=PT_GLAS) || (rt!=PT_GLAS && lt==PT_GLAS)) && r) {
if(!get_normal_interp(REFRACT|parts[i].type, x, y, parts[i].vx, parts[i].vy, &nrx, &nry)) {
@@ -2705,13 +2710,13 @@ killed:
continue;
}
- r = get_wavelength_bin(&parts[i].ctype);
- if(r == -1) {
- kill_part(i);
- continue;
- }
- nn = GLASS_IOR - GLASS_DISP*(r-15)/15.0f;
- nn *= nn;
+ r = get_wavelength_bin(&parts[i].ctype);
+ if(r == -1) {
+ kill_part(i);
+ continue;
+ }
+ nn = GLASS_IOR - GLASS_DISP*(r-15)/15.0f;
+ nn *= nn;
nrx = -nrx;
nry = -nry;
@@ -2722,10 +2727,10 @@ killed:
if(ct2 < 0.0f) {
parts[i].vx -= 2.0f*ct1*nrx;
parts[i].vy -= 2.0f*ct1*nry;
- parts[i].x = lx;
- parts[i].y = ly;
- nx = (int)(lx + 0.5f);
- ny = (int)(ly + 0.5f);
+ parts[i].x = lx;
+ parts[i].y = ly;
+ nx = (int)(lx + 0.5f);
+ ny = (int)(ly + 0.5f);
} else {
ct2 = sqrtf(ct2);
ct2 = ct2 - nn*ct1;
@@ -2855,25 +2860,25 @@ killed:
}
else if(t==PT_NEUT || t==PT_PHOT)
{
- r = pmap[ny][nx];
-
- /* this should be replaced with a particle type attribute ("photwl" or something) */
- if((r & 0xFF) == PT_PSCN) parts[i].ctype = 0x00000000;
- if((r & 0xFF) == PT_NSCN) parts[i].ctype = 0x00000000;
- if((r & 0xFF) == PT_SPRK) parts[i].ctype = 0x00000000;
- if((r & 0xFF) == PT_COAL) parts[i].ctype = 0x00000000;
- if((r & 0xFF) == PT_BCOL) parts[i].ctype = 0x00000000;
- if((r & 0xFF) == PT_PLEX) parts[i].ctype &= 0x1F00003E;
- if((r & 0xFF) == PT_NITR) parts[i].ctype &= 0x0007C000;
- if((r & 0xFF) == PT_NBLE) parts[i].ctype &= 0x3FFF8000;
- if((r & 0xFF) == PT_LAVA) parts[i].ctype &= 0x3FF00000;
- if((r & 0xFF) == PT_ACID) parts[i].ctype &= 0x1FE001FE;
- if((r & 0xFF) == PT_DUST) parts[i].ctype &= 0x3FFFFFC0;
- if((r & 0xFF) == PT_SNOW) parts[i].ctype &= 0x03FFFFFF;
- if((r & 0xFF) == PT_GOO) parts[i].ctype &= 0x3FFAAA00;
- if((r & 0xFF) == PT_PLNT) parts[i].ctype &= 0x0007C000;
- if((r & 0xFF) == PT_PLUT) parts[i].ctype &= 0x001FCE00;
- if((r & 0xFF) == PT_URAN) parts[i].ctype &= 0x003FC000;
+ r = pmap[ny][nx];
+
+ /* this should be replaced with a particle type attribute ("photwl" or something) */
+ if((r & 0xFF) == PT_PSCN) parts[i].ctype = 0x00000000;
+ if((r & 0xFF) == PT_NSCN) parts[i].ctype = 0x00000000;
+ if((r & 0xFF) == PT_SPRK) parts[i].ctype = 0x00000000;
+ if((r & 0xFF) == PT_COAL) parts[i].ctype = 0x00000000;
+ if((r & 0xFF) == PT_BCOL) parts[i].ctype = 0x00000000;
+ if((r & 0xFF) == PT_PLEX) parts[i].ctype &= 0x1F00003E;
+ if((r & 0xFF) == PT_NITR) parts[i].ctype &= 0x0007C000;
+ if((r & 0xFF) == PT_NBLE) parts[i].ctype &= 0x3FFF8000;
+ if((r & 0xFF) == PT_LAVA) parts[i].ctype &= 0x3FF00000;
+ if((r & 0xFF) == PT_ACID) parts[i].ctype &= 0x1FE001FE;
+ if((r & 0xFF) == PT_DUST) parts[i].ctype &= 0x3FFFFFC0;
+ if((r & 0xFF) == PT_SNOW) parts[i].ctype &= 0x03FFFFFF;
+ if((r & 0xFF) == PT_GOO) parts[i].ctype &= 0x3FFAAA00;
+ if((r & 0xFF) == PT_PLNT) parts[i].ctype &= 0x0007C000;
+ if((r & 0xFF) == PT_PLUT) parts[i].ctype &= 0x001FCE00;
+ if((r & 0xFF) == PT_URAN) parts[i].ctype &= 0x003FC000;
if(get_normal_interp(t, lx, ly, parts[i].vx, parts[i].vy, &nrx, &nry)) {
dp = nrx*parts[i].vx + nry*parts[i].vy;
@@ -2893,10 +2898,10 @@ killed:
continue;
}
- if(!parts[i].ctype) {
- kill_part(i);
- continue;
- }
+ if(!parts[i].ctype) {
+ kill_part(i);
+ continue;
+ }
}
else
@@ -2958,9 +2963,9 @@ void update_particles(pixel *vid)
x = (int)(parts[i].x+0.5f);
y = (int)(parts[i].y+0.5f);
if(x>=0 && y>=0 && x<XRES && y<YRES && t!=PT_PHOT) {
- if(t!=PT_NEUT || (pmap[y][x]&0xFF)!=PT_GLAS)
- pmap[y][x] = t|(i<<8);
- }
+ if(t!=PT_NEUT || (pmap[y][x]&0xFF)!=PT_GLAS)
+ pmap[y][x] = t|(i<<8);
+ }
}
else
{