From bf534e1514d37a6b1fef6163fbed32766cbc8711 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 26 Sep 2010 17:14:51 -0400 Subject: [PATCH 1/4] Added BCOL, changed FUSE->FSEP --- powder.c | 389 ++++++++++++++++++++++++++++++------------------------- powder.h | 176 +++++++++++++------------ 2 files changed, 306 insertions(+), 259 deletions(-) diff --git a/powder.c b/powder.c index ffe604b2f..cb93d7d65 100644 --- a/powder.c +++ b/powder.c @@ -124,7 +124,7 @@ void kill_part(int i) #ifdef WIN32 _inline int create_part(int p, int x, int y, int t) #else -inline int create_part(int p, int x, int y, int t) + inline int create_part(int p, int x, int y, int t) #endif { int i; @@ -181,19 +181,19 @@ inline int create_part(int p, int x, int y, int t) if(t==PT_SPRK) { if((pmap[y][x]&0xFF)!=PT_METL && - (pmap[y][x]&0xFF)!=PT_PSCN && - (pmap[y][x]&0xFF)!=PT_NSCN && - (pmap[y][x]&0xFF)!=PT_NTCT && - (pmap[y][x]&0xFF)!=PT_PTCT && - (pmap[y][x]&0xFF)!=PT_WATR && - (pmap[y][x]&0xFF)!=PT_SLTW && - (pmap[y][x]&0xFF)!=PT_BMTL && - (pmap[y][x]&0xFF)!=PT_RBDM && - (pmap[y][x]&0xFF)!=PT_LRBD && - (pmap[y][x]&0xFF)!=PT_ETRD && - (pmap[y][x]&0xFF)!=PT_BRMT && - (pmap[y][x]&0xFF)!=PT_NBLE && - (pmap[y][x]&0xFF)!=PT_INWR) + (pmap[y][x]&0xFF)!=PT_PSCN && + (pmap[y][x]&0xFF)!=PT_NSCN && + (pmap[y][x]&0xFF)!=PT_NTCT && + (pmap[y][x]&0xFF)!=PT_PTCT && + (pmap[y][x]&0xFF)!=PT_WATR && + (pmap[y][x]&0xFF)!=PT_SLTW && + (pmap[y][x]&0xFF)!=PT_BMTL && + (pmap[y][x]&0xFF)!=PT_RBDM && + (pmap[y][x]&0xFF)!=PT_LRBD && + (pmap[y][x]&0xFF)!=PT_ETRD && + (pmap[y][x]&0xFF)!=PT_BRMT && + (pmap[y][x]&0xFF)!=PT_NBLE && + (pmap[y][x]&0xFF)!=PT_INWR) return -1; parts[pmap[y][x]>>8].type = PT_SPRK; parts[pmap[y][x]>>8].life = 4; @@ -235,16 +235,18 @@ inline int create_part(int p, int x, int y, int t) parts[i].life = 75; } /*Testing - if(t==PT_WOOD){ - parts[i].life = 150; - } - End Testing*/ + if(t==PT_WOOD){ + parts[i].life = 150; + } + End Testing*/ if(t==PT_FUSE) - parts[i].life = ((uint32_t)(50 << 24) | (uint32_t)50); + parts[i].life = ((uint32_t)(50 << 24) | (uint32_t)50); if(t==PT_FSEP) - parts[i].life = 50; + parts[i].life = 50; if(t==PT_COAL) - parts[i].life = 110; + parts[i].life = ((uint32_t)(110 << 24) | (uint32_t)50); + if(t==PT_BCOL) + parts[i].life = 110; if(t==PT_FIRE) parts[i].life = rand()%50+120; if(t==PT_PLSM) @@ -334,7 +336,7 @@ inline int create_part(int p, int x, int y, int t) #ifdef WIN32 _inline void delete_part(int x, int y) #else -inline void delete_part(int x, int y) + inline void delete_part(int x, int y) #endif { unsigned i; @@ -352,7 +354,7 @@ inline void delete_part(int x, int y) #ifdef WIN32 _inline int is_wire(int x, int y) #else -inline int is_wire(int x, int y) + inline int is_wire(int x, int y) #endif { return bmap[y][x]==6 || bmap[y][x]==7 || bmap[y][x]==3 || bmap[y][x]==8 || bmap[y][x]==11 || bmap[y][x]==12; @@ -361,7 +363,7 @@ inline int is_wire(int x, int y) #ifdef WIN32 _inline int is_wire_off(int x, int y) #else -inline int is_wire_off(int x, int y) + inline int is_wire_off(int x, int y) #endif { return (bmap[y][x]==6 || bmap[y][x]==7 || bmap[y][x]==3 || bmap[y][x]==8 || bmap[y][x]==11 || bmap[y][x]==12) && emap[y][x]<8; @@ -396,30 +398,30 @@ void set_emap(int x, int y) // fill children if(y>1 && x1==x2 && - is_wire(x1-1, y-1) && is_wire(x1, y-1) && is_wire(x1+1, y-1) && - !is_wire(x1-1, y-2) && is_wire(x1, y-2) && !is_wire(x1+1, y-2)) + is_wire(x1-1, y-1) && is_wire(x1, y-1) && is_wire(x1+1, y-1) && + !is_wire(x1-1, y-2) && is_wire(x1, y-2) && !is_wire(x1+1, y-2)) set_emap(x1, y-2); else if(y>0) for(x=x1; x<=x2; x++) if(is_wire_off(x, y-1)) { if(x==x1 || x==x2 || y>=YRES/CELL-1 || - is_wire(x-1, y-1) || is_wire(x+1, y-1) || - is_wire(x-1, y+1) || !is_wire(x, y+1) || is_wire(x+1, y+1)) + is_wire(x-1, y-1) || is_wire(x+1, y-1) || + is_wire(x-1, y+1) || !is_wire(x, y+1) || is_wire(x+1, y+1)) set_emap(x, y-1); } if(y=XRES || y>=YRES || - ((bmap[y/CELL][x/CELL]==1 || - bmap[y/CELL][x/CELL]==8 || - bmap[y/CELL][x/CELL]==9 || - (bmap[y/CELL][x/CELL]==2) || - (bmap[y/CELL][x/CELL]==3 && ptypes[t].falldown!=2) || - (bmap[y/CELL][x/CELL]==10 && ptypes[t].falldown!=1) || - (bmap[y/CELL][x/CELL]==13 && ptypes[t].falldown!=0 && parts[i].type!=PT_FIRE && parts[i].type!=PT_SMKE) || - (bmap[y/CELL][x/CELL]==6 && (t==PT_METL || t==PT_SPRK)) || - (bmap[y/CELL][x/CELL]==7 && !emap[y/CELL][x/CELL])) && (t!=PT_STKM))) + ((bmap[y/CELL][x/CELL]==1 || + bmap[y/CELL][x/CELL]==8 || + bmap[y/CELL][x/CELL]==9 || + (bmap[y/CELL][x/CELL]==2) || + (bmap[y/CELL][x/CELL]==3 && ptypes[t].falldown!=2) || + (bmap[y/CELL][x/CELL]==10 && ptypes[t].falldown!=1) || + (bmap[y/CELL][x/CELL]==13 && ptypes[t].falldown!=0 && parts[i].type!=PT_FIRE && parts[i].type!=PT_SMKE) || + (bmap[y/CELL][x/CELL]==6 && (t==PT_METL || t==PT_SPRK)) || + (bmap[y/CELL][x/CELL]==7 && !emap[y/CELL][x/CELL])) && (t!=PT_STKM))) { kill_part(i); continue; @@ -648,8 +650,8 @@ void update_particles_i(pixel *vid, int start, int inc) for(nx=-1; nx<2; nx++) for(ny=-1; ny<2; ny++) if(x+nx>=0 && y+ny>0 && - x+nx=0 && y+ny>0 && - x+nx>8)>=NPART || !r) @@ -926,7 +928,7 @@ void update_particles_i(pixel *vid, int start, int inc) for(nx=-2; nx<3; nx++) for(ny=-2; ny<3; ny++) if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) @@ -949,6 +951,45 @@ void update_particles_i(pixel *vid, int start, int inc) } } else if(t==PT_COAL) + { + tempu1 = (uint16_t)(((unsigned int)parts[i].life) >> 24); + tempu2 = (uint16_t)(((unsigned int)parts[i].life) & 0x0000FFFF); + if(tempu1<=0) { + t = PT_NONE; + kill_part(i); + create_part(-1, x, y, PT_FIRE); + goto killed; + } else if(tempu1 < 100) { + tempu1--; + create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE); + } + if((pv[y/CELL][x/CELL] > 4.3f)&&tempu2>40) + tempu2=39; + else if(tempu2<40&&tempu2>0) + tempu2--; + else if(tempu2<=0) { + t = PT_NONE; + kill_part(i); + r = create_part(-1, x, y, PT_BCOL); + goto killed; + } + for(nx=-2; nx<3; nx++) + for(ny=-2; ny<3; ny++) + if(x+nx>=0 && y+ny>0 && + x+nx>8)>=NPART || !r) + continue; + if(((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM) && 1>(rand()%500)) + { + if(tempu1>100) { + tempu1 = 99; + } + } + } + parts[i].life = ((uint32_t)(((uint32_t)tempu1 << 24) | (uint32_t)tempu2)); + } else if(t==PT_BCOL) { if(parts[i].life<=0) { t = PT_NONE; @@ -956,14 +997,14 @@ void update_particles_i(pixel *vid, int start, int inc) create_part(-1, x, y, PT_FIRE); goto killed; } else if(parts[i].life < 100) { - parts[i].life--; + parts[i].life; create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE); } for(nx=-2; nx<3; nx++) for(ny=-2; ny<3; ny++) if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) @@ -971,92 +1012,94 @@ void update_particles_i(pixel *vid, int start, int inc) if(((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM) && 1>(rand()%500)) { if(parts[i].life>100) { - parts[i].life = 99; + parts[i].life = 99; } } } } - 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) { - 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; - } - } - 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; - } - for(nx=-2; nx<3; nx++) - for(ny=-2; ny<3; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) - continue; - if((r&0xFF)==PT_SPRK || (parts[i].temp>=(273.15+700.0f)) && 1>(rand()%20)) - { - if(tempu1>40) { - tempu1 = 39; - } - } - } - parts[i].life = ((uint32_t)(((uint32_t)tempu1 << 24) | (uint32_t)tempu2)); - } - else if(t==PT_FSEP) - { - 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 (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; - } - } - for(nx=-2; nx<3; nx++) - for(ny=-2; ny<3; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>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) - { - for(nx=-2; nx<3; nx++) - for(ny=-2; ny<3; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx> 24); + tempu2 = (uint16_t)(((uint32_t)parts[i].life) & 0xFFFF); + if(tempu1<=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; + } + } + if((pv[y/CELL][x/CELL] > 2.7f)&&tempu2>40) + tempu2=39; + else if(tempu2<40&&tempu2>0) + tempu2--; + else if(tempu2<=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>8)>=NPART || !r) + continue; + if((r&0xFF)==PT_SPRK || (parts[i].temp>=(273.15+700.0f)) && 1>(rand()%20)) + { + if(tempu1>40) { + tempu1 = 39; + } + } + } + parts[i].life = ((uint32_t)(((uint32_t)tempu1 << 24) | (uint32_t)tempu2)); + } + else if(t==PT_FSEP) + { + 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 (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; + } + } + for(nx=-2; nx<3; nx++) + for(ny=-2; ny<3; ny++) + if(x+nx>=0 && y+ny>0 && + x+nx>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) + { + for(nx=-2; nx<3; nx++) + for(ny=-2; ny<3; ny++) + if(x+nx>=0 && y+ny>0 && + x+nx>8)>=NPART || !r) continue; @@ -1064,14 +1107,14 @@ void update_particles_i(pixel *vid, int start, int inc) { parts[i].temp = 473.0f; } - } - } - else if(t==PT_PLNT) - { + } + } + else if(t==PT_PLNT) + { for(nx=-2; nx<3; nx++) for(ny=-2; ny<3; ny++) if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) @@ -1123,7 +1166,7 @@ void update_particles_i(pixel *vid, int start, int inc) for(nx=-2; nx<3; nx++) for(ny=-2; ny<3; ny++) if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) @@ -1158,7 +1201,7 @@ void update_particles_i(pixel *vid, int start, int inc) for(nx=-2; nx<3; nx++) for(ny=-2; ny<3; ny++) if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) @@ -1185,7 +1228,7 @@ void update_particles_i(pixel *vid, int start, int inc) for(nx=-2; nx<3; nx++) for(ny=-2; ny<3; ny++) if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) @@ -1215,7 +1258,7 @@ void update_particles_i(pixel *vid, int start, int inc) for(nx=-2; nx<3; nx++) for(ny=-2; ny<3; ny++) if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) @@ -1263,7 +1306,7 @@ void update_particles_i(pixel *vid, int start, int inc) for(nx=-1; nx<2; nx++) for(ny=-1; ny<2; ny++) if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) @@ -1312,11 +1355,11 @@ void update_particles_i(pixel *vid, int start, int inc) if((r&0xFF)==PT_COAL && 5>(rand()%100)) parts[r>>8].type = PT_WOOD; /*if(parts[r>>8].type>1 && parts[r>>8].type!=PT_NEUT && parts[r>>8].type-1!=PT_NEUT && parts[r>>8].type-1!=PT_STKM && - (ptypes[parts[r>>8].type-1].menusection==SC_LIQUID|| - ptypes[parts[r>>8].type-1].menusection==SC_EXPLOSIVE|| - ptypes[parts[r>>8].type-1].menusection==SC_GAS|| - ptypes[parts[r>>8].type-1].menusection==SC_POWDERS) && 15>(rand()%1000)) - parts[r>>8].type--;*/ + (ptypes[parts[r>>8].type-1].menusection==SC_LIQUID|| + ptypes[parts[r>>8].type-1].menusection==SC_EXPLOSIVE|| + ptypes[parts[r>>8].type-1].menusection==SC_GAS|| + ptypes[parts[r>>8].type-1].menusection==SC_POWDERS) && 15>(rand()%1000)) + parts[r>>8].type--;*/ } } else if(t==PT_PHOT) @@ -1325,7 +1368,7 @@ void update_particles_i(pixel *vid, int start, int inc) for(nx=0; nx<1; nx++) for(ny=0; ny<1; ny++) if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) @@ -1466,7 +1509,7 @@ void update_particles_i(pixel *vid, int start, int inc) for(nx=-2; nx<3; nx++) for(ny=-2; ny<3; ny++) if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) @@ -1488,7 +1531,7 @@ void update_particles_i(pixel *vid, int start, int inc) for(nx=-2; nx<3; nx++) for(ny=-2; ny<3; ny++) if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) @@ -1517,7 +1560,7 @@ void update_particles_i(pixel *vid, int start, int inc) for(nx=-2; nx<3; nx++) for(ny=-2; ny<3; ny++) if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) @@ -1526,8 +1569,8 @@ 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_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_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)) + (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_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)) { parts[r>>8].type = PT_FIRE; parts[r>>8].temp = ptypes[PT_FIRE].heat + (ptypes[rt].flammable/2); @@ -1541,7 +1584,7 @@ void update_particles_i(pixel *vid, int start, int inc) if(legacy_enable) { if(t!=PT_SPRK && ptypes[rt].meltable && ((rt!=PT_RBDM && rt!=PT_LRBD) || t!=PT_SPRK) && ((t!=PT_FIRE&&t!=PT_PLSM) || (rt!=PT_METL && rt!=PT_ETRD && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SALT && rt!=PT_INWR)) && - ptypes[rt].meltable*lpv>(rand()%1000)) + ptypes[rt].meltable*lpv>(rand()%1000)) { if(t!=PT_LAVA || parts[i].life>0) { @@ -1613,7 +1656,7 @@ void update_particles_i(pixel *vid, int start, int inc) if(pavg != PT_INSL) { if(t==PT_SPRK && (rt==PT_METL||rt==PT_ETRD||rt==PT_BMTL||rt==PT_BRMT||rt==PT_LRBD||rt==PT_RBDM||rt==PT_PSCN||rt==PT_NSCN||rt==PT_NBLE) && parts[r>>8].life==0 && - (parts[i].life<3 || ((r>>8)>8)=373.0f)&&parts[i].ctype==PT_NTCT)&&!(rt!=PT_PSCN&&!(rt==PT_NSCN&&parts[i].temp<=373.0f)&&parts[i].ctype==PT_PTCT)&&!(rt!=PT_PSCN&&!(rt==PT_NSCN)&&parts[i].ctype==PT_INWR) && pavg != PT_INSL &&!(parts[i].ctype==PT_SWCH&&(rt==PT_PSCN||rt==PT_NSCN)) ) { @@ -1625,7 +1668,7 @@ void update_particles_i(pixel *vid, int start, int inc) } } if(t==PT_SPRK && rt==PT_NTCT && parts[r>>8].life==0 && - (parts[i].life<3 || ((r>>8)>8)>8].temp>373.0f))&&pavg != PT_INSL) { @@ -1635,7 +1678,7 @@ void update_particles_i(pixel *vid, int start, int inc) } } if(t==PT_SPRK && rt==PT_PTCT && parts[r>>8].life==0 && - (parts[i].life<3 || ((r>>8)>8)>8].temp<373.0f))&&pavg != PT_INSL) { @@ -1645,7 +1688,7 @@ void update_particles_i(pixel *vid, int start, int inc) } } if(t==PT_SPRK && rt==PT_INWR && parts[r>>8].life==0 && - (parts[i].life<3 || ((r>>8)>8)>8].life==0 && - (parts[i].life<2 || ((r>>8)>8)>8].type = PT_SPRK; parts[r>>8].life = 6; parts[r>>8].ctype = rt; } if(t==PT_SPRK && rt==PT_SLTW && parts[r>>8].life==0 && - (parts[i].life<2 || ((r>>8)>8)>8].type = PT_SPRK; parts[r>>8].life = 5; @@ -1696,7 +1739,7 @@ void update_particles_i(pixel *vid, int start, int inc) } } } -killed: + killed: if(parts[i].type == PT_NONE) continue; } @@ -1772,7 +1815,7 @@ killed: if (((int)(player[0])&0x01) == 0x01 && pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_GAS) { if (pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_LIQUID - && (pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF) != PT_LNTG) + && (pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF) != PT_LNTG) { if (pmap[(int)(player[8]-1)][(int)(player[7])]) { @@ -1810,7 +1853,7 @@ killed: if (((int)(player[0])&0x02) == 0x02 && pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_GAS) { if (pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_LIQUID - && (pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF) != PT_LNTG) + && (pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF) != PT_LNTG) { if (pmap[(int)(player[8]-1)][(int)(player[7])]) { @@ -2098,11 +2141,11 @@ killed: for(nx=-1; nx<2; nx++) for(ny=-1; ny<2; ny++) if(x+nx>=0 && y+ny>0 && - x+nx=XRES-CELL || - ny=YRES-CELL) + ny=YRES-CELL) { parts[i].x = lx; parts[i].y = ly; @@ -2935,8 +2978,8 @@ int create_parts(int x, int y, int r, int c) for(v=-1; v<2; v++) for(u=-1; u<2; u++) if(i+u>=0 && i+u=0 && j+v=0 && j+v Date: Sun, 26 Sep 2010 17:28:27 -0400 Subject: [PATCH 2/4] use parts[i].tmp instead of bit hacks --- powder.c | 55 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/powder.c b/powder.c index cb93d7d65..a60d4443f 100644 --- a/powder.c +++ b/powder.c @@ -239,12 +239,16 @@ _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; - if(t==PT_COAL) - parts[i].life = ((uint32_t)(110 << 24) | (uint32_t)50); + if(t==PT_COAL) { + parts[i].life = 110; + parts[i].tmp = 50; + } if(t==PT_BCOL) parts[i].life = 110; if(t==PT_FIRE) @@ -952,22 +956,20 @@ void update_particles_i(pixel *vid, int start, int inc) } else if(t==PT_COAL) { - 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); create_part(-1, x, y, PT_FIRE); goto killed; - } else if(tempu1 < 100) { - tempu1--; + } else if(parts[i].life < 100) { + parts[i].life; create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE); } - if((pv[y/CELL][x/CELL] > 4.3f)&&tempu2>40) - tempu2=39; - else if(tempu2<40&&tempu2>0) - tempu2--; - else if(tempu2<=0) { + if((pv[y/CELL][x/CELL] > 4.3f)&&parts[i].tmp>40) + parts[i].tmp=39; + else if(parts[i].tmp<40&&parts[i].tmp>0) + parts[i].tmp--; + else if(parts[i].tmp<=0) { t = PT_NONE; kill_part(i); r = create_part(-1, x, y, PT_BCOL); @@ -983,12 +985,11 @@ void update_particles_i(pixel *vid, int start, int inc) continue; if(((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM) && 1>(rand()%500)) { - if(tempu1>100) { - tempu1 = 99; + if(parts[i].life>100) { + parts[i].life = 99; } } } - parts[i].life = ((uint32_t)(((uint32_t)tempu1 << 24) | (uint32_t)tempu2)); } else if(t==PT_BCOL) { if(parts[i].life<=0) { @@ -1022,24 +1023,24 @@ void update_particles_i(pixel *vid, int start, int inc) // 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)(((uint32_t)parts[i].life) >> 24); tempu2 = (uint16_t)(((uint32_t)parts[i].life) & 0xFFFF); - 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--; + } 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] > 2.7f)&&tempu2>40) - tempu2=39; - else if(tempu2<40&&tempu2>0) - tempu2--; - else if(tempu2<=0) { + if((pv[y/CELL][x/CELL] > 2.7f)&&parts[i].tmp>40) + parts[i].tmp=39; + else if(parts[i].tmp<40&&parts[i].tmp>0) + parts[i].tmp--; + else if(parts[i].tmp<=0) { t = PT_NONE; kill_part(i); r = create_part(-1, x, y, PT_FSEP); @@ -1055,8 +1056,8 @@ void update_particles_i(pixel *vid, int start, int inc) 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; } } } From 5b9e55436092711d862ecfc4b7fcdd69d93b75f4 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 26 Sep 2010 19:22:27 -0400 Subject: [PATCH 3/4] fixed BCOL and COAL bug --- powder.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/powder.c b/powder.c index 389c80740..cedf3bae1 100644 --- a/powder.c +++ b/powder.c @@ -962,7 +962,7 @@ void update_particles_i(pixel *vid, int start, int inc) create_part(-1, x, y, PT_FIRE); goto killed; } else if(parts[i].life < 100) { - parts[i].life; + parts[i].life--; create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE); } if((pv[y/CELL][x/CELL] > 4.3f)&&parts[i].tmp>40) @@ -999,7 +999,7 @@ void update_particles_i(pixel *vid, int start, int inc) create_part(-1, x, y, PT_FIRE); goto killed; } else if(parts[i].life < 100) { - parts[i].life; + parts[i].life--; create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE); } From 1401817f212e1c4759f38bcb47e9ec8aecfe8444 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 26 Sep 2010 19:28:18 -0400 Subject: [PATCH 4/4] fixed fuse bug --- powder.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/powder.c b/powder.c index cedf3bae1..16941fd9a 100644 --- a/powder.c +++ b/powder.c @@ -1021,9 +1021,6 @@ 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)(((uint32_t)parts[i].life) >> 24); - tempu2 = (uint16_t)(((uint32_t)parts[i].life) & 0xFFFF); if(parts[i].life<=0) { t = PT_NONE; kill_part(i); @@ -1055,14 +1052,13 @@ void update_particles_i(pixel *vid, int start, int inc) 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((r&0xFF)==PT_SPRK || ((parts[i].temp>=(273.15+700.0f)) && 1>(rand()%20))) { 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) {