This commit is contained in:
Simon 2010-09-26 12:57:02 +01:00
parent 7341fd9468
commit 26c67a303e

View File

@ -239,10 +239,12 @@ inline int create_part(int p, int x, int y, int t)
parts[i].life = 150; parts[i].life = 150;
} }
End Testing*/ End Testing*/
if(t==PT_FUSE) if(t==PT_FUSE){
parts[i].life = ((uint32_t)(50 << 24) | (uint32_t)50); parts[i].life = 50;
parts[i].tmp = 50;
}
if(t==PT_FSEP) if(t==PT_FSEP)
parts[i].life = 50; parts[i].life = 50;
if(t==PT_COAL) if(t==PT_COAL)
parts[i].life = 110; parts[i].life = 110;
if(t==PT_FIRE) if(t==PT_FIRE)
@ -467,9 +469,6 @@ int nearest_part(int ci, int t)
void update_particles_i(pixel *vid, int start, int inc) void update_particles_i(pixel *vid, int start, int inc)
{ {
int i, j, x, y, t, nx, ny, r, a, s, rt, fe, nt, lpv, nearp, pavg; int i, j, x, y, t, nx, ny, r, a, s, rt, fe, nt, lpv, nearp, pavg;
uint16_t tempu1, tempu2;
int16_t temps1, temps2;
float tempf1, tempf2;
float mv, dx, dy, ix, iy, lx, ly, d, pp; float mv, dx, dy, ix, iy, lx, ly, d, pp;
float pt = R_TEMP; float pt = R_TEMP;
float c_heat = 0.0f; float c_heat = 0.0f;
@ -978,46 +977,41 @@ void update_particles_i(pixel *vid, int start, int inc)
} }
else if(t==PT_FUSE) else if(t==PT_FUSE)
{ {
// I do a parts[i].life hack here, the first half bits is for the burn life, the last half bits is for the pressure life if(parts[i].life<=0) {
tempu1 = (uint16_t)(((unsigned int)parts[i].life) >> 24);
tempu2 = (uint16_t)(((unsigned int)parts[i].life) & 0x0000FFFF);
if(tempu1<=0) {
t = PT_NONE; t = PT_NONE;
kill_part(i); kill_part(i);
r = create_part(-1, x, y, PT_PLSM); r = create_part(-1, x, y, PT_PLSM);
parts[r].life = 50; parts[r].life = 50;
goto killed; goto killed;
} else if (tempu1 < 40) { } else if (parts[i].life < 40) {
tempu1--; parts[i].life--;
if((rand()%100)==0) { if((rand()%100)==0) {
r = create_part(-1, (nx=x+rand()%3-1), (ny=y+rand()%3-1), PT_PLSM); r = create_part(-1, (nx=x+rand()%3-1), (ny=y+rand()%3-1), PT_PLSM);
parts[r].life = 50; parts[r].life = 50;
} }
} }
if(pv[y/CELL][x/CELL] > 0.8f) if(pv[y/CELL][x/CELL] > 0.8f)
tempu2--; parts[i].tmp--;
else if(tempu2<=0) { else if(parts[i].tmp<=0) {
t = PT_NONE; t = PT_NONE;
kill_part(i); kill_part(i);
r = create_part(-1, x, y, PT_FSEP); r = create_part(-1, x, y, PT_FSEP);
goto killed; goto killed;
} }
for(nx=-2; nx<3; nx++) for(nx=-2; nx<3; nx++)
for(ny=-2; ny<3; ny++) for(ny=-2; ny<3; ny++)
if(x+nx>=0 && y+ny>0 && if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
x+nx<XRES && y+ny<YRES && (nx || ny))
{ {
r = pmap[y+ny][x+nx]; r = pmap[y+ny][x+nx];
if((r>>8)>=NPART || !r) if((r>>8)>=NPART || !r)
continue; continue;
if((r&0xFF)==PT_SPRK || (parts[i].temp>=(273.15+700.0f)) && 1>(rand()%20)) if((r&0xFF)==PT_SPRK || (parts[i].temp>=(273.15+700.0f)) && 1>(rand()%20))
{ {
if(tempu1>40) { if(parts[i].life>40) {
tempu1 = 39; parts[i].life = 39;
} }
} }
} }
parts[i].life = ((uint32_t)(((uint32_t)tempu1 << 24) | (uint32_t)tempu2));
} }
else if(t==PT_FSEP) else if(t==PT_FSEP)
{ {
@ -1025,30 +1019,28 @@ void update_particles_i(pixel *vid, int start, int inc)
t = PT_NONE; t = PT_NONE;
kill_part(i); kill_part(i);
r = create_part(-1, x, y, PT_PLSM); r = create_part(-1, x, y, PT_PLSM);
parts[r].life = 50; parts[r].life = 50;
goto killed; goto killed;
} else if (parts[i].life < 40) { } else if (parts[i].life < 40) {
parts[i].life--; parts[i].life--;
if((rand()%10)==0) { if((rand()%10)==0) {
r = create_part(-1, (nx=x+rand()%3-1), (ny=y+rand()%3-1), PT_PLSM); r = create_part(-1, (nx=x+rand()%3-1), (ny=y+rand()%3-1), PT_PLSM);
parts[r].life = 50; parts[r].life = 50;
} }
} }
for(nx=-2; nx<3; nx++) for(nx=-2; nx<3; nx++)
for(ny=-2; ny<3; ny++) for(ny=-2; ny<3; ny++)
if(x+nx>=0 && y+ny>0 && if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny)){
x+nx<XRES && y+ny<YRES && (nx || ny)) r = pmap[y+ny][x+nx];
{ if((r>>8)>=NPART || !r)
r = pmap[y+ny][x+nx]; continue;
if((r>>8)>=NPART || !r) if((r&0xFF)==PT_SPRK || (parts[i].temp>=(273.15+400.0f)) && 1>(rand()%15))
continue; {
if((r&0xFF)==PT_SPRK || (parts[i].temp>=(273.15+400.0f)) && 1>(rand()%15)) if(parts[i].life>40) {
{ parts[i].life = 39;
if(parts[i].life>40) {
parts[i].life = 39;
}
}
} }
}
}
} }
else if(t==PT_NTCT||t==PT_PTCT||t==PT_INWR) else if(t==PT_NTCT||t==PT_PTCT||t==PT_INWR)
{ {