summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon <simon@hardwired.org.uk>2010-09-26 11:57:02 (GMT)
committer Simon <simon@hardwired.org.uk>2010-09-26 11:57:02 (GMT)
commit26c67a303ee159006fa63f04aef7132d95069b64 (patch)
tree2bb373b805121ff2eed07a238b4d318ce945ae99
parent7341fd94685f83956374d34323c11de5c27a9e06 (diff)
downloadpowder-26c67a303ee159006fa63f04aef7132d95069b64.zip
powder-26c67a303ee159006fa63f04aef7132d95069b64.tar.gz
Gah\!
-rw-r--r--powder.c88
1 files changed, 40 insertions, 48 deletions
diff --git a/powder.c b/powder.c
index ffe604b..c474009 100644
--- a/powder.c
+++ b/powder.c
@@ -239,10 +239,12 @@ inline int create_part(int p, int x, int y, int t)
parts[i].life = 150;
}
End Testing*/
- if(t==PT_FUSE)
- parts[i].life = ((uint32_t)(50 << 24) | (uint32_t)50);
+ if(t==PT_FUSE){
+ parts[i].life = 50;
+ parts[i].tmp = 50;
+ }
if(t==PT_FSEP)
- parts[i].life = 50;
+ parts[i].life = 50;
if(t==PT_COAL)
parts[i].life = 110;
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)
{
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 pt = R_TEMP;
float c_heat = 0.0f;
@@ -978,46 +977,41 @@ void update_particles_i(pixel *vid, int start, int inc)
}
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
- tempu1 = (uint16_t)(((unsigned int)parts[i].life) >> 24);
- tempu2 = (uint16_t)(((unsigned int)parts[i].life) & 0x0000FFFF);
- if(tempu1<=0) {
+ if(parts[i].life<=0) {
t = PT_NONE;
kill_part(i);
r = create_part(-1, x, y, PT_PLSM);
parts[r].life = 50;
goto killed;
- } else if (tempu1 < 40) {
- tempu1--;
- if((rand()%100)==0) {
- r = create_part(-1, (nx=x+rand()%3-1), (ny=y+rand()%3-1), PT_PLSM);
- parts[r].life = 50;
- }
+ } 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);
+ parts[r].life = 50;
+ }
}
- if(pv[y/CELL][x/CELL] > 0.8f)
- tempu2--;
- else if(tempu2<=0) {
- t = PT_NONE;
- kill_part(i);
- r = create_part(-1, x, y, PT_FSEP);
- goto killed;
- }
+ if(pv[y/CELL][x/CELL] > 0.8f)
+ parts[i].tmp--;
+ else if(parts[i].tmp<=0) {
+ t = PT_NONE;
+ kill_part(i);
+ r = create_part(-1, x, y, PT_FSEP);
+ goto killed;
+ }
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))
+ 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_SPRK || (parts[i].temp>=(273.15+700.0f)) && 1>(rand()%20))
{
- if(tempu1>40) {
- tempu1 = 39;
+ if(parts[i].life>40) {
+ parts[i].life = 39;
}
}
}
- parts[i].life = ((uint32_t)(((uint32_t)tempu1 << 24) | (uint32_t)tempu2));
}
else if(t==PT_FSEP)
{
@@ -1025,30 +1019,28 @@ void update_particles_i(pixel *vid, int start, int inc)
t = PT_NONE;
kill_part(i);
r = create_part(-1, x, y, PT_PLSM);
- parts[r].life = 50;
+ 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);
- parts[r].life = 50;
- }
+ parts[i].life--;
+ if((rand()%10)==0) {
+ r = create_part(-1, (nx=x+rand()%3-1), (ny=y+rand()%3-1), PT_PLSM);
+ parts[r].life = 50;
+ }
}
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))
- {
- r = pmap[y+ny][x+nx];
- if((r>>8)>=NPART || !r)
- 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;
- }
- }
+ for(ny=-2; ny<3; 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_SPRK || (parts[i].temp>=(273.15+400.0f)) && 1>(rand()%15))
+ {
+ if(parts[i].life>40) {
+ parts[i].life = 39;
}
+ }
+ }
}
else if(t==PT_NTCT||t==PT_PTCT||t==PT_INWR)
{