diff --git a/src/main.c b/src/main.c index d88b9726b..f7ffec97b 100755 --- a/src/main.c +++ b/src/main.c @@ -270,8 +270,11 @@ void *build_save(int *size, int x0, int y0, int w, int h) { x = (int)(parts[i].x+0.5f); y = (int)(parts[i].y+0.5f); - if(x>=x0 && x=y0 && y=x0 && x=y0 && y>8; parts[k].type = j; + if(j == PT_PHOT) + parts[k].ctype = 0x3fffffff; parts[k].x = (float)x; parts[k].y = (float)y; m[(x-x0)+(y-y0)*w] = k+1; @@ -519,6 +524,8 @@ int parse_save(void *save, int size, int replace, int x0, int y0) else if(i < nf) { parts[fp[i]].type = j; + if(j == PT_PHOT) + parts[fp[i]].ctype = 0x3fffffff; parts[fp[i]].x = (float)x; parts[fp[i]].y = (float)y; m[(x-x0)+(y-y0)*w] = fp[i]+1; diff --git a/src/powder.c b/src/powder.c index d8fa1fb15..40150b9ef 100644 --- a/src/powder.c +++ b/src/powder.c @@ -72,6 +72,7 @@ static int eval_move(int pt, int nx, int ny, unsigned *rr) 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_LCRY&&parts[r>>8].life > 5))) return 2; @@ -101,6 +102,7 @@ static int eval_move(int pt, int nx, int ny, unsigned *rr) } static void create_cherenkov_photon(int pp); +static void create_gain_photon(int pp); int try_move(int i, int x, int y, int nx, int ny) { @@ -110,6 +112,13 @@ int try_move(int i, int x, int y, int nx, int ny) return 1; e = eval_move(parts[i].type, nx, ny, &r); + + /* half-silvered mirror */ + if(!e && parts[i].type==PT_PHOT && + (((r&0xFF)==PT_BMTL && rand()>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); @@ -154,16 +168,22 @@ int try_move(int i, int x, int y, int nx, int ny) if(r && (r>>8)> 8; + if(r && e>8)>= 8; - parts[r].x += x-nx; - parts[r].y += y-ny; - } - return 1; } #define SURF_RANGE 10 @@ -314,14 +334,16 @@ int get_normal_interp(int pt, float x0, float y0, float dx, float dy, float *nx, 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); + + if(x>=0 && y>=0 && x=0 && y>=0 && x=XRES || ny>=YRES) + return; + + if((pmap[ny][nx] & 0xFF) != PT_GLOW) + return; + + pfree = parts[i].life; + + parts[i].type = PT_PHOT; + parts[i].life = 680; + parts[i].x = xx; + parts[i].y = yy; + parts[i].vx = parts[pp].vx; + parts[i].vy = parts[pp].vy; + parts[i].temp = parts[pmap[ny][nx] >> 8].temp; + parts[i].tmp = 0; + + temp_bin = (int)((parts[i].temp-273.0f)*0.25f); + if(temp_bin < 0) temp_bin = 0; + if(temp_bin > 25) temp_bin = 25; + parts[i].ctype = 0x1F << temp_bin; +} + static void create_cherenkov_photon(int pp) { int i, lr, nx, ny; @@ -759,7 +826,7 @@ void update_particles_i(pixel *vid, int start, int inc) { if(!(parts[i].life==10&&(parts[i].type==PT_LCRY||parts[i].type==PT_PCLN||parts[i].type==PT_HSWC))) parts[i].life--; - if(parts[i].life<=0 && t!=PT_METL && t!=PT_FIRW && t!=PT_PCLN && t!=PT_HSWC && t!=PT_WATR && t!=PT_RBDM && t!=PT_LRBD && t!=PT_SLTW && t!=PT_BRMT && t!=PT_PSCN && t!=PT_NSCN && t!=PT_NTCT && t!=PT_PTCT && t!=PT_BMTL && t!=PT_SPRK && t!=PT_LAVA && t!=PT_ETRD&&t!=PT_LCRY && t!=PT_INWR) + if(parts[i].life<=0 && t!=PT_METL && t!=PT_FIRW && t!=PT_PCLN && t!=PT_HSWC && t!=PT_WATR && t!=PT_RBDM && t!=PT_LRBD && t!=PT_SLTW && t!=PT_BRMT && t!=PT_PSCN && t!=PT_NSCN && t!=PT_NTCT && t!=PT_PTCT && t!=PT_BMTL && t!=PT_SPRK && t!=PT_LAVA && t!=PT_ETRD&&t!=PT_LCRY && t!=PT_INWR && t!=PT_GLOW) { kill_part(i); continue; @@ -2705,6 +2772,7 @@ killed: /* 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; @@ -2801,8 +2869,8 @@ void update_particles(pixel *vid) t = parts[i].type; x = (int)(parts[i].x+0.5f); y = (int)(parts[i].y+0.5f); - if(x>=0 && y>=0 && x=0 && y>=0 && x