summaryrefslogtreecommitdiff
path: root/src/powder.c
diff options
context:
space:
mode:
authorFelix Wallin <nibbler.v1@gmail.com>2010-12-20 13:34:55 (GMT)
committer Felix Wallin <nibbler.v1@gmail.com>2010-12-20 13:34:55 (GMT)
commit14b4dfef87892ad744cbb8b6fbdc0bc80044d51b (patch)
treea50bde6af1f0df4ecc8ed512ccfd5a9010b93a0b /src/powder.c
parentcb6597f9e192b13546295c030ad98bad4f041648 (diff)
downloadpowder-14b4dfef87892ad744cbb8b6fbdc0bc80044d51b.zip
powder-14b4dfef87892ad744cbb8b6fbdc0bc80044d51b.tar.gz
nice
Diffstat (limited to 'src/powder.c')
-rw-r--r--src/powder.c3163
1 files changed, 1578 insertions, 1585 deletions
diff --git a/src/powder.c b/src/powder.c
index be1c7cd..0e8e0f8 100644
--- a/src/powder.c
+++ b/src/powder.c
@@ -78,8 +78,8 @@ static int eval_move(int pt, int nx, int ny, unsigned *rr)
(r&0xFF)==PT_GLOW || (r&0xFF)==PT_WATR ||
(r&0xFF)==PT_DSTW || (r&0xFF)==PT_SLTW ||
(r&0xFF)==PT_ISOZ || (r&0xFF)==PT_ISZS ||
- (r&0xFF)==PT_FILT || (r&0xFF)==PT_INVIS ||
- ((r&0xFF)==PT_LCRY&&parts[r>>8].life > 5)))
+ (r&0xFF)==PT_FILT || (r&0xFF)==PT_INVIS ||
+ ((r&0xFF)==PT_LCRY&&parts[r>>8].life > 5)))
return 2;
if(pt==PT_STKM) //Stick man's head shouldn't collide
@@ -87,7 +87,7 @@ static int eval_move(int pt, int nx, int ny, unsigned *rr)
if(pt==PT_STKM2) //Stick man's head shouldn't collide
return 2;
if((pt==PT_BIZR||pt==PT_BIZRG)&&(r&0xFF)==PT_FILT)
- return 2;
+ return 2;
if(bmap[ny/CELL][nx/CELL]==WL_ALLOWGAS && ptypes[pt].falldown!=0 && pt!=PT_FIRE && pt!=PT_SMKE)
return 0;
if(ptypes[pt].falldown!=2 && bmap[ny/CELL][nx/CELL]==WL_ALLOWLIQUID)
@@ -101,22 +101,22 @@ static int eval_move(int pt, int nx, int ny, unsigned *rr)
if(ptypes[pt].falldown!=1 && bmap[ny/CELL][nx/CELL]==WL_ALLOWSOLID)
return 0;
- if(r && (r&0xFF) < PT_NUM){
- if(ptypes[pt].properties&TYPE_ENERGY && ptypes[(r&0xFF)].properties&TYPE_ENERGY)
- return 2;
-
- if(pt==PT_NEUT && ptypes[(r&0xFF)].properties&PROP_NEUTPASS)
- return 2;
- if(pt==PT_NEUT && ptypes[(r&0xFF)].properties&PROP_NEUTPENETRATE)
- return 1;
- if((r&0xFF)==PT_NEUT && ptypes[pt].properties&PROP_NEUTPENETRATE)
- return 0;
+ if(r && (r&0xFF) < PT_NUM) {
+ if(ptypes[pt].properties&TYPE_ENERGY && ptypes[(r&0xFF)].properties&TYPE_ENERGY)
+ return 2;
+
+ if(pt==PT_NEUT && ptypes[(r&0xFF)].properties&PROP_NEUTPASS)
+ return 2;
+ if(pt==PT_NEUT && ptypes[(r&0xFF)].properties&PROP_NEUTPENETRATE)
+ return 1;
+ if((r&0xFF)==PT_NEUT && ptypes[pt].properties&PROP_NEUTPENETRATE)
+ return 0;
}
-
+
if (r && ((r&0xFF) >= PT_NUM || (ptypes[pt].weight <= ptypes[(r&0xFF)].weight)))
return 0;
- if(pt == PT_PHOT)
+ if(pt == PT_PHOT)
return 2;
return 1;
@@ -133,8 +133,8 @@ int try_move(int i, int x, int y, int nx, int ny)
return 1;
e = eval_move(parts[i].type, nx, ny, &r);
- if((pmap[ny][nx]&0xFF)==PT_INVIS && (pv[ny/CELL][nx/CELL]>4.0f ||pv[ny/CELL][nx/CELL]<-4.0f))
- return 1;
+ if((pmap[ny][nx]&0xFF)==PT_INVIS && (pv[ny/CELL][nx/CELL]>4.0f ||pv[ny/CELL][nx/CELL]<-4.0f))
+ return 1;
/* half-silvered mirror */
if(!e && parts[i].type==PT_PHOT &&
(((r&0xFF)==PT_BMTL && rand()<RAND_MAX/2) ||
@@ -162,58 +162,58 @@ int try_move(int i, int x, int y, int nx, int ny)
parts[r>>8].life = 120;
create_gain_photon(i);
}
- if(parts[i].type == PT_PHOT && (r&0xFF)==PT_FILT)
- {
- int temp_bin = (int)((parts[r>>8].temp-273.0f)*0.025f);
- if(temp_bin < 0) temp_bin = 0;
- if(temp_bin > 25) temp_bin = 25;
- parts[i].ctype = 0x1F << temp_bin;
- }
- if(parts[i].type == PT_NEUT && (r&0xFF)==PT_GLAS) {
- if(rand() < RAND_MAX/10)
- create_cherenkov_photon(i);
- }
- if(parts[i].type == PT_PHOT && (r&0xFF)==PT_INVIS) {
- parts[i].type = PT_NEUT;
- parts[i].ctype = 0;
- }
- if((parts[i].type==PT_BIZR||parts[i].type==PT_BIZRG) && (r&0xFF)==PT_FILT)
- {
- int temp_bin = (int)((parts[r>>8].temp-273.0f)*0.025f);
- if(temp_bin < 0) temp_bin = 0;
- if(temp_bin > 25) temp_bin = 25;
- parts[i].ctype = 0x1F << temp_bin;
- }
+ if(parts[i].type == PT_PHOT && (r&0xFF)==PT_FILT)
+ {
+ int temp_bin = (int)((parts[r>>8].temp-273.0f)*0.025f);
+ if(temp_bin < 0) temp_bin = 0;
+ if(temp_bin > 25) temp_bin = 25;
+ parts[i].ctype = 0x1F << temp_bin;
+ }
+ if(parts[i].type == PT_NEUT && (r&0xFF)==PT_GLAS) {
+ if(rand() < RAND_MAX/10)
+ create_cherenkov_photon(i);
+ }
+ if(parts[i].type == PT_PHOT && (r&0xFF)==PT_INVIS) {
+ parts[i].type = PT_NEUT;
+ parts[i].ctype = 0;
+ }
+ if((parts[i].type==PT_BIZR||parts[i].type==PT_BIZRG) && (r&0xFF)==PT_FILT)
+ {
+ int temp_bin = (int)((parts[r>>8].temp-273.0f)*0.025f);
+ if(temp_bin < 0) temp_bin = 0;
+ if(temp_bin > 25) temp_bin = 25;
+ parts[i].ctype = 0x1F << temp_bin;
+ }
return 1;
}
if((r&0xFF)==PT_VOID)
{
- if(parts[i].type == PT_STKM)
- {
- death = 1;
- isplayer = 0;
- }
- if(parts[i].type == PT_STKM2)
- {
- death2 = 1;
- isplayer2 = 0;
- }
+ if(parts[i].type == PT_STKM)
+ {
+ death = 1;
+ isplayer = 0;
+ }
+ if(parts[i].type == PT_STKM2)
+ {
+ death2 = 1;
+ isplayer2 = 0;
+ }
parts[i].type=PT_NONE;
return 0;
}
if((r&0xFF)==PT_BHOL)
{
- if(parts[i].type == PT_STKM)
- {
- death = 1;
- isplayer = 0;
- }
- if(parts[i].type == PT_STKM2)
- {
- death2 = 1;
- isplayer2 = 0;
- }
+ if(parts[i].type == PT_STKM)
+ {
+ death = 1;
+ isplayer = 0;
+ }
+ if(parts[i].type == PT_STKM2)
+ {
+ death2 = 1;
+ isplayer2 = 0;
+ }
parts[i].type=PT_NONE;
if(!legacy_enable)
{
@@ -223,7 +223,7 @@ int try_move(int i, int x, int y, int nx, int ny)
return 0;
}
if((pmap[ny][nx]&0xFF)==PT_CNCT)
- return 0;
+ return 0;
if(parts[i].type==PT_CNCT && y<ny && (pmap[y+1][x]&0xFF)==PT_CNCT)
return 0;
@@ -283,7 +283,10 @@ static int is_boundary(int pt, int x, int y)
{
if(!is_blocking(pt,x,y))
return 0;
- if(is_blocking(pt,x,y-1) && is_blocking(pt,x,y+1) && is_blocking(pt,x-1,y) && is_blocking(pt,x+1,y))
+ if(is_blocking(pt,x,y-1)
+ && is_blocking(pt,x,y+1)
+ && is_blocking(pt,x-1,y)
+ && is_blocking(pt,x+1,y))
return 0;
return 1;
}
@@ -391,28 +394,29 @@ void kill_part(int i)
{
int x, y;
- if(parts[i].type != PT_PHOT) {
+ if(parts[i].type != PT_PHOT)
+ {
x = (int)(parts[i].x+0.5f);
y = (int)(parts[i].y+0.5f);
- if(parts[i].type == PT_STKM)
- {
- death = 1;
- isplayer = 0;
- }
- if(parts[i].type == PT_STKM2)
- {
- death2 = 1;
- isplayer2 = 0;
- }
- if(parts[i].type == PT_SPAWN)
- {
- ISSPAWN1 = 0;
- }
- if(parts[i].type == PT_SPAWN2)
- {
- ISSPAWN2 = 0;
- }
- if(x>=0 && y>=0 && x<XRES && y<YRES)
+ if(parts[i].type == PT_STKM)
+ {
+ death = 1;
+ isplayer = 0;
+ }
+ else if(parts[i].type == PT_STKM2)
+ {
+ death2 = 1;
+ isplayer2 = 0;
+ }
+ else if(parts[i].type == PT_SPAWN)
+ {
+ ISSPAWN1 = 0;
+ }
+ else if(parts[i].type == PT_SPAWN2)
+ {
+ ISSPAWN2 = 0;
+ }
+ else if(x>=0 && y>=0 && x<XRES && y<YRES)
pmap[y][x] = 0;
}
@@ -438,17 +442,17 @@ inline int create_part(int p, int x, int y, int t)
{
if(t==SPC_HEAT&&parts[pmap[y][x]>>8].temp<MAX_TEMP)
{
- if((pmap[y][x]&0xFF)==PT_PUMP)
- parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp + 0.1f, MIN_TEMP, MAX_TEMP);
- else
- parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp + 4.0f, MIN_TEMP, MAX_TEMP);
+ if((pmap[y][x]&0xFF)==PT_PUMP)
+ parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp + 0.1f, MIN_TEMP, MAX_TEMP);
+ else
+ parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp + 4.0f, MIN_TEMP, MAX_TEMP);
}
if(t==SPC_COOL&&parts[pmap[y][x]>>8].temp>MIN_TEMP)
{
- if((pmap[y][x]&0xFF)==PT_PUMP)
- parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp - 0.1f, MIN_TEMP, MAX_TEMP);
- else
- parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp - 4.0f, MIN_TEMP, MAX_TEMP);
+ if((pmap[y][x]&0xFF)==PT_PUMP)
+ parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp - 0.1f, MIN_TEMP, MAX_TEMP);
+ else
+ parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp - 4.0f, MIN_TEMP, MAX_TEMP);
}
return pmap[y][x]>>8;
}
@@ -459,28 +463,27 @@ inline int create_part(int p, int x, int y, int t)
}
if(t==SPC_AIR)
{
- pv[y/CELL][x/CELL] += 0.03f;
- if(y+CELL<YRES)
- pv[y/CELL+1][x/CELL] += 0.03f;
- if(x+CELL<XRES)
+ if(y + CELL < YRES && x + CELL < XRES)
+ pv[y/CELL][x/CELL] += 0.03f;
+ /* if(x+CELL<XRES)
{
pv[y/CELL][x/CELL+1] += 0.03f;
- if(y+CELL<YRES)
- pv[y/CELL+1][x/CELL+1] += 0.03f;
- }
+ pv[y/CELL+1][x/CELL+1] += 0.03f;
+ }*/
return -1;
}
if(t==SPC_VACUUM)
{
- pv[y/CELL][x/CELL] -= 0.03f;
- if(y+CELL<YRES)
- pv[y/CELL+1][x/CELL] -= 0.03f;
- if(x+CELL<XRES)
- {
- pv[y/CELL][x/CELL+1] -= 0.03f;
- if(y+CELL<YRES)
- pv[y/CELL+1][x/CELL+1] -= 0.03f;
- }
+ if (y + CELL < YRES && x + CELL < XRES)
+ pv[y/CELL][x/CELL] -= 0.03f;
+ /*if(y+CELL<YRES)
+ pv[y/CELL+1][x/CELL] -= 0.03f;
+ if(x+CELL<XRES)
+ {
+ pv[y/CELL][x/CELL+1] -= 0.03f;
+ if(y+CELL<YRES)
+ pv[y/CELL+1][x/CELL+1] -= 0.03f;
+ }*/
return -1;
}
@@ -500,11 +503,11 @@ inline int create_part(int p, int x, int y, int t)
(pmap[y][x]&0xFF)!=PT_BRMT &&
(pmap[y][x]&0xFF)!=PT_NBLE &&
(pmap[y][x]&0xFF)!=PT_IRON &&
- (pmap[y][x]&0xFF)!=PT_INST &&
+ (pmap[y][x]&0xFF)!=PT_INST &&
(pmap[y][x]&0xFF)!=PT_INWR)
return -1;
- if(parts[pmap[y][x]>>8].life!=0)
- return -1;
+ if(parts[pmap[y][x]>>8].life!=0)
+ return -1;
parts[pmap[y][x]>>8].type = PT_SPRK;
parts[pmap[y][x]>>8].life = 4;
parts[pmap[y][x]>>8].ctype = pmap[y][x]&0xFF;
@@ -512,15 +515,15 @@ inline int create_part(int p, int x, int y, int t)
return pmap[y][x]>>8;
}
if(t==PT_SPAWN&&ISSPAWN1)
- return -1;
+ return -1;
if(t==PT_SPAWN2&&ISSPAWN2)
- return -1;
+ return -1;
if(p==-1)//creating from anything but brush
{
- if(pmap[y][x])
- if((pmap[y][x]&0xFF)!=PT_SPAWN&&(pmap[y][x]&0xFF)!=PT_SPAWN2)
- if(t!=PT_STKM&&t!=PT_STKM2)
- return -1;
+ if(pmap[y][x])
+ if((pmap[y][x]&0xFF)!=PT_SPAWN&&(pmap[y][x]&0xFF)!=PT_SPAWN2)
+ if(t!=PT_STKM&&t!=PT_STKM2)
+ return -1;
if(pfree == -1)
return -1;
i = pfree;
@@ -529,13 +532,13 @@ inline int create_part(int p, int x, int y, int t)
else if(p==-2)//creating from brush
{
if(pmap[y][x])
- {
- if(((pmap[y][x]&0xFF)==PT_CLNE||(pmap[y][x]&0xFF)==PT_BCLN||(pmap[y][x]&0xFF)==PT_PCLN)&&(t!=PT_CLNE&&t!=PT_PCLN&&t!=PT_BCLN))
- {
- parts[pmap[y][x]>>8].ctype = t;
- }
+ {
+ if(((pmap[y][x]&0xFF)==PT_CLNE||(pmap[y][x]&0xFF)==PT_BCLN||(pmap[y][x]&0xFF)==PT_PCLN)&&(t!=PT_CLNE&&t!=PT_PCLN&&t!=PT_BCLN))
+ {
+ parts[pmap[y][x]>>8].ctype = t;
+ }
return -1;
- }
+ }
if(pfree == -1)
return -1;
i = pfree;
@@ -569,19 +572,19 @@ inline int create_part(int p, int x, int y, int t)
parts[i].life = 150;
}
End Testing*/
- if(t==PT_WARP) {
- parts[i].life = rand()%95+70;
- }
+ if(t==PT_WARP) {
+ parts[i].life = rand()%95+70;
+ }
if(t==PT_FUSE) {
parts[i].life = 50;
parts[i].tmp = 50;
}
if(t==PT_DEUT)
- parts[i].life = 10;
- if(t==PT_BRAY)
- parts[i].life = 30;
- if(t==PT_PUMP)
- parts[i].life= 10;
+ parts[i].life = 10;
+ if(t==PT_BRAY)
+ parts[i].life = 30;
+ if(t==PT_PUMP)
+ parts[i].life= 10;
if(t==PT_FSEP)
parts[i].life = 50;
if(t==PT_COAL) {
@@ -589,9 +592,9 @@ inline int create_part(int p, int x, int y, int t)
parts[i].tmp = 50;
}
if(t==PT_FRZW)
- parts[i].life = 100;
+ parts[i].life = 100;
if(t==PT_PIPE)
- parts[i].life = 60;
+ parts[i].life = 60;
if(t==PT_BCOL)
parts[i].life = 110;
if(t==PT_FIRE)
@@ -627,34 +630,34 @@ inline int create_part(int p, int x, int y, int t)
parts[i].vy = 3.0f*sinf(a);
}
if(t==PT_BIZR||t==PT_BIZRG)
- parts[i].ctype = 0x47FFFF;
+ parts[i].ctype = 0x47FFFF;
if(t!=PT_STKM&&t!=PT_STKM2)// && t!=PT_PHOT && t!=PT_NEUT) is this needed? it breaks floodfill
pmap[y][x] = t|(i<<8);
else if(t==PT_STKM)
{
if(isplayer==0)
{
- if(pmap[y][x]&0xFF==PT_SPAWN)
- {
- parts[pmap[y][x]>>8].type = PT_STKM;
- parts[pmap[y][x]>>8].vx = 0;
- parts[pmap[y][x]>>8].vy = 0;
- parts[pmap[y][x]>>8].life = 100;
- parts[pmap[y][x]>>8].ctype = 0;
- parts[pmap[y][x]>>8].temp = ptypes[t].heat;
-
- }
- else
- {
- parts[i].x = (float)x;
- parts[i].y = (float)y;
- parts[i].type = PT_STKM;
- parts[i].vx = 0;
- parts[i].vy = 0;
- parts[i].life = 100;
- parts[i].ctype = 0;
- parts[i].temp = ptypes[t].heat;
- }
+ if(pmap[y][x]&0xFF==PT_SPAWN)
+ {
+ parts[pmap[y][x]>>8].type = PT_STKM;
+ parts[pmap[y][x]>>8].vx = 0;
+ parts[pmap[y][x]>>8].vy = 0;
+ parts[pmap[y][x]>>8].life = 100;
+ parts[pmap[y][x]>>8].ctype = 0;
+ parts[pmap[y][x]>>8].temp = ptypes[t].heat;
+
+ }
+ else
+ {
+ parts[i].x = (float)x;
+ parts[i].y = (float)y;
+ parts[i].type = PT_STKM;
+ parts[i].vx = 0;
+ parts[i].vy = 0;
+ parts[i].life = 100;
+ parts[i].ctype = 0;
+ parts[i].temp = ptypes[t].heat;
+ }
@@ -680,35 +683,35 @@ inline int create_part(int p, int x, int y, int t)
isplayer = 1;
}
- //kill_part(playerspawn);
- create_part(-1,x,y,PT_SPAWN);
- ISSPAWN1 = 1;
+ //kill_part(playerspawn);
+ create_part(-1,x,y,PT_SPAWN);
+ ISSPAWN1 = 1;
}
else if(t==PT_STKM2)
{
if(isplayer2==0)
{
- if(pmap[y][x]&0xFF==PT_SPAWN2)
- {
- parts[pmap[y][x]>>8].type = PT_STKM2;
- parts[pmap[y][x]>>8].vx = 0;
- parts[pmap[y][x]>>8].vy = 0;
- parts[pmap[y][x]>>8].life = 100;
- parts[pmap[y][x]>>8].ctype = 0;
- parts[pmap[y][x]>>8].temp = ptypes[t].heat;
-
- }
- else
- {
- parts[i].x = (float)x;
- parts[i].y = (float)y;
- parts[i].type = PT_STKM2;
- parts[i].vx = 0;
- parts[i].vy = 0;
- parts[i].life = 100;
- parts[i].ctype = 0;
- parts[i].temp = ptypes[t].heat;
- }
+ if(pmap[y][x]&0xFF==PT_SPAWN2)
+ {
+ parts[pmap[y][x]>>8].type = PT_STKM2;
+ parts[pmap[y][x]>>8].vx = 0;
+ parts[pmap[y][x]>>8].vy = 0;
+ parts[pmap[y][x]>>8].life = 100;
+ parts[pmap[y][x]>>8].ctype = 0;
+ parts[pmap[y][x]>>8].temp = ptypes[t].heat;
+
+ }
+ else
+ {
+ parts[i].x = (float)x;
+ parts[i].y = (float)y;
+ parts[i].type = PT_STKM2;
+ parts[i].vx = 0;
+ parts[i].vy = 0;
+ parts[i].life = 100;
+ parts[i].ctype = 0;
+ parts[i].temp = ptypes[t].heat;
+ }
@@ -734,9 +737,9 @@ inline int create_part(int p, int x, int y, int t)
isplayer2 = 1;
}
- //kill_part(player2spawn);
- create_part(-1,x,y,PT_SPAWN2);
- ISSPAWN2 = 1;
+ //kill_part(player2spawn);
+ create_part(-1,x,y,PT_SPAWN2);
+ ISSPAWN2 = 1;
}
return i;
@@ -844,17 +847,17 @@ inline void delete_part(int x, int y)
if(!i || (i>>8)>=NPART)
return;
if((parts[i>>8].type==SLALT)||SLALT==0)
- {
- kill_part(i>>8);
- pmap[y][x] = 0;
- }
+ {
+ kill_part(i>>8);
+ pmap[y][x] = 0;
+ }
else if(ptypes[parts[i>>8].type].menusection==SEC)
- {
- kill_part(i>>8);
- pmap[y][x] = 0;
- }
- else
- return;
+ {
+ kill_part(i>>8);
+ pmap[y][x] = 0;
+ }
+ else
+ return;
}
#if defined(WIN32) && !defined(__GNUC__)
@@ -963,25 +966,25 @@ _inline int parts_avg(int ci, int ni,int t)//t is the particle you are looking f
inline int parts_avg(int ci, int ni,int t)
#endif
{
- if(t==PT_INSL)//to keep electronics working
- {
- int pmr = pmap[(int)((parts[ci].y + parts[ni].y)/2)][(int)((parts[ci].x + parts[ni].x)/2)];
- if((pmr>>8) < NPART && pmr)
- return parts[pmr>>8].type;
- else
- return PT_NONE;
- }
- else
- {
- int pmr2 = pmap[(int)((parts[ci].y + parts[ni].y)/2+0.5f)][(int)((parts[ci].x + parts[ni].x)/2+0.5f)];//seems to be more accurate.
- if((pmr2>>8) < NPART && pmr2)
- {
- if(parts[pmr2>>8].type==t)
- return t;
- }
- else
- return PT_NONE;
- }
+ if(t==PT_INSL)//to keep electronics working
+ {
+ int pmr = pmap[(int)((parts[ci].y + parts[ni].y)/2)][(int)((parts[ci].x + parts[ni].x)/2)];
+ if((pmr>>8) < NPART && pmr)
+ return parts[pmr>>8].type;
+ else
+ return PT_NONE;
+ }
+ else
+ {
+ int pmr2 = pmap[(int)((parts[ci].y + parts[ni].y)/2+0.5f)][(int)((parts[ci].x + parts[ni].x)/2+0.5f)];//seems to be more accurate.
+ if((pmr2>>8) < NPART && pmr2)
+ {
+ if(parts[pmr2>>8].type==t)
+ return t;
+ }
+ else
+ return PT_NONE;
+ }
}
@@ -1017,267 +1020,257 @@ void update_particles_i(pixel *vid, int start, int inc)
float c_heat = 0.0f;
int h_count = 0;
int starti = (start*-1);
- if(sys_pause&&!framerender)
- return;
+ if(sys_pause&&!framerender)
+ return;
if(ISGRAV==1)
- {
- ISGRAV = 0;
- GRAV ++;
- GRAV_R = 60;
- GRAV_G = 0;
- GRAV_B = 0;
- GRAV_R2 = 30;
- GRAV_G2 = 30;
- GRAV_B2 = 0;
- for( q = 0;q <= GRAV;q++)
- {
- if(GRAV_R >0 && GRAV_G==0)
- {
- GRAV_R--;
- GRAV_B++;
- }
- if(GRAV_B >0 && GRAV_R==0)
- {
- GRAV_B--;
- GRAV_G++;
- }
- if(GRAV_G >0 && GRAV_B==0)
- {
- GRAV_G--;
- GRAV_R++;
- }
- if(GRAV_R2 >0 && GRAV_G2==0)
- {
- GRAV_R2--;
- GRAV_B2++;
- }
- if(GRAV_B2 >0 && GRAV_R2==0)
- {
- GRAV_B2--;
- GRAV_G2++;
- }
- if(GRAV_G2 >0 && GRAV_B2==0)
- {
- GRAV_G2--;
- GRAV_R2++;
- }
- }
- if(GRAV>180) GRAV = 0;
-
- }
- if(ISLOVE==1)
- {
- ISLOVE = 0;
- for(ny=0;ny<YRES-4;ny++)
- {
- for(nx=0;nx<XRES-4;nx++)
- {
- r=pmap[ny][nx];
- if((r>>8)>=NPART || !r)
- {
- continue;
- }
- else if((ny<9||nx<9||ny>YRES-7||nx>XRES-10)&&parts[r>>8].type==PT_LOVE)
- parts[r>>8].type = PT_NONE;
- else if(parts[r>>8].type==PT_LOVE)
- {
- love[nx/9][ny/9] = 1;
- }
-
- }
- }
- for(nx=9;nx<=XRES-18;nx++)
- {
- for(ny=9;ny<=YRES-7;ny++)
- {
- if(love[nx/9][ny/9]==1)
- {
- for( nnx=0;nnx<9;nnx++)
- for( nny=0;nny<9;nny++)
- {
- if(ny+nny>0&&ny+nny<YRES&&nx+nnx>=0&&nx+nnx<XRES)
- {
- rt=pmap[ny+nny][nx+nnx];
- if((rt>>8)>=NPART)
- {
- continue;
- }
- if(!rt&&loverule[nnx][nny]==1)
- create_part(-1,nx+nnx,ny+nny,PT_LOVE);
- else if(!rt)
- continue;
- else if(parts[rt>>8].type==PT_LOVE&&loverule[nnx][nny]==0)
- parts[rt>>8].type=PT_NONE;
-
- }
- }
- }
- love[nx/9][ny/9]=0;
- }
- }
- }
- if(ISLOLZ==1)
- {
- ISLOLZ = 0;
- for(ny=0;ny<YRES-4;ny++)
- {
- for(nx=0;nx<XRES-4;nx++)
- {
- r=pmap[ny][nx];
- if((r>>8)>=NPART || !r)
- {
- continue;
- }
- else if((ny<9||nx<9||ny>YRES-7||nx>XRES-10)&&parts[r>>8].type==PT_LOLZ)
- parts[r>>8].type = PT_NONE;
- else if(parts[r>>8].type==PT_LOLZ)
- {
- lolz[nx/9][ny/9] = 1;
- }
-
- }
- }
- for(nx=9;nx<=XRES-18;nx++)
- {
- for(ny=9;ny<=YRES-7;ny++)
- {
- if(lolz[nx/9][ny/9]==1)
- {
- for( nnx=0;nnx<9;nnx++)
- for( nny=0;nny<9;nny++)
- {
- if(ny+nny>0&&ny+nny<YRES&&nx+nnx>=0&&nx+nnx<XRES)
- {
- rt=pmap[ny+nny][nx+nnx];
- if((rt>>8)>=NPART)
- {
- continue;
- }
- if(!rt&&lolzrule[nny][nnx]==1)
- create_part(-1,nx+nnx,ny+nny,PT_LOLZ);
- else if(!rt)
- continue;
- else if(parts[rt>>8].type==PT_LOLZ&&lolzrule[nny][nnx]==0)
- parts[rt>>8].type=PT_NONE;
-
- }
- }
- }
- lolz[nx/9][ny/9]=0;
- }
- }
- }
- if(ISGOL==1&&CGOL>=GSPEED)//GSPEED is frames per generation
- {
- int createdsomething = 0;
- for(nx=4;nx<XRES-4;nx++)
- for(ny=4;ny<YRES-4;ny++)
- {
- CGOL=0;
- ISGOL=0;
- r = pmap[ny][nx];
- if((r>>8)>=NPART || !r)
- {
- gol[nx][ny] = 0;
- continue;
- }
- else
- for( golnum=1;golnum<NGOL;golnum++)
- if(parts[r>>8].type==golnum+77)
- {
- gol[nx][ny] = golnum;
- for( nnx=-1;nnx<2;nnx++)
- for( nny=-1;nny<2;nny++)//it will count itself as its own neighbor, which is needed, but will have 1 extra for delete check
- {
- if(ny+nny<4&&nx+nnx<4){//any way to make wrapping code smaller?
- gol2[XRES-5][YRES-5][golnum] ++;
- gol2[XRES-5][YRES-5][0] ++;
- }
- else if(ny+nny<4&&nx+nnx>=XRES-4){
- gol2[4][YRES-5][golnum] ++;
- gol2[4][YRES-5][0] ++;
- }
- else if(ny+nny>=YRES-4&&nx+nnx<4){
- gol2[XRES-5][4][golnum] ++;
- gol2[XRES-5][4][0] ++;
- }
- else if(nx+nnx<4){
- gol2[XRES-5][ny+nny][golnum] ++;
- gol2[XRES-5][ny+nny][0] ++;
- }
- else if(ny+nny<4){
- gol2[nx+nnx][YRES-5][golnum] ++;
- gol2[nx+nnx][YRES-5][0] ++;
- }
- else if(ny+nny>=YRES-4&&nx+nnx>=XRES-4){
- gol2[4][4][golnum] ++;
- gol2[4][4][0] ++;
- }
- else if(ny+nny>=YRES-4){
- gol2[nx+nnx][4][golnum] ++;
- gol2[nx+nnx][4][0] ++;
- }
- else if(nx+nnx>=XRES-4){
- gol2[4][ny+nny][golnum] ++;
- gol2[4][ny+nny][0] ++;
- }
- else{
- gol2[nx+nnx][ny+nny][golnum] ++;
- gol2[nx+nnx][ny+nny][0] ++;
- }
- }
- }
- }
- for(nx=4;nx<XRES-4;nx++)
- for(ny=4;ny<YRES-4;ny++)
- {
- int neighbors = gol2[nx][ny][0];
- if(neighbors==0)
- continue;
- for( golnum = 1;golnum<NGOL;golnum++)
- for( goldelete = 0;goldelete<9;goldelete++)
- {
- if(neighbors==goldelete&&gol[nx][ny]==0&&grule[golnum][goldelete]>=2&&gol2[nx][ny][golnum]>=(goldelete%2)+goldelete/2)
- {
- if(create_part(-1,nx,ny,golnum+77))
- createdsomething = 1;
- }
- else if(neighbors-1==goldelete&&gol[nx][ny]==golnum&&(grule[golnum][goldelete]==0||grule[golnum][goldelete]==2))//subtract 1 because it counted itself
- parts[pmap[ny][nx]>>8].type = PT_NONE;
- }
- gol2[nx][ny][0] = 0;
- for( z = 1;z<NGOL;z++)
- gol2[nx][ny][z] = 0;
- }
- if(createdsomething)
- GENERATION ++;
- }
- //if(ISWIRE==1)
- //{
- // CGOL = 0;
- // ISWIRE = 0;
- //}
- if(ISWIRE==1)
- {
- for( q = 0;q<99;q++)
- if(!wireless[q][1])
- {
- wireless[q][0] = 0;
- }
- else
- wireless[q][1] = 0;
- }
+ {
+ ISGRAV = 0;
+ GRAV ++;
+ GRAV_R = 60;
+ GRAV_G = 0;
+ GRAV_B = 0;
+ GRAV_R2 = 30;
+ GRAV_G2 = 30;
+ GRAV_B2 = 0;
+ for( q = 0; q <= GRAV; q++)
+ {
+ if(GRAV_R >0 && GRAV_G==0)
+ {
+ GRAV_R--;
+ GRAV_B++;
+ }
+ if(GRAV_B >0 && GRAV_R==0)
+ {
+ GRAV_B--;
+ GRAV_G++;
+ }
+ if(GRAV_G >0 && GRAV_B==0)
+ {
+ GRAV_G--;
+ GRAV_R++;
+ }
+ if(GRAV_R2 >0 && GRAV_G2==0)
+ {
+ GRAV_R2--;
+ GRAV_B2++;
+ }
+ if(GRAV_B2 >0 && GRAV_R2==0)
+ {
+ GRAV_B2--;
+ GRAV_G2++;
+ }
+ if(GRAV_G2 >0 && GRAV_B2==0)
+ {
+ GRAV_G2--;
+ GRAV_R2++;
+ }
+ }
+ if(GRAV>180) GRAV = 0;
+
+ }
+ if(ISLOVE==1)
+ {
+ ISLOVE = 0;
+ for(ny=0; ny<YRES-4; ny++)
+ {
+ for(nx=0; nx<XRES-4; nx++)
+ {
+ r=pmap[ny][nx];
+ if((r>>8)>=NPART || !r)
+ {
+ continue;
+ }
+ else if((ny<9||nx<9||ny>YRES-7||nx>XRES-10)&&parts[r>>8].type==PT_LOVE)
+ parts[r>>8].type = PT_NONE;
+ else if(parts[r>>8].type==PT_LOVE)
+ {
+ love[nx/9][ny/9] = 1;
+ }
+
+ }
+ }
+ for(nx=9; nx<=XRES-18; nx++)
+ {
+ for(ny=9; ny<=YRES-7; ny++)
+ {
+ if(love[nx/9][ny/9]==1)
+ {
+ for( nnx=0; nnx<9; nnx++)
+ for( nny=0; nny<9; nny++)
+ {
+ if(ny+nny>0&&ny+nny<YRES&&nx+nnx>=0&&nx+nnx<XRES)
+ {
+ rt=pmap[ny+nny][nx+nnx];
+ if((rt>>8)>=NPART)
+ {
+ continue;
+ }
+ if(!rt&&loverule[nnx][nny]==1)
+ create_part(-1,nx+nnx,ny+nny,PT_LOVE);
+ else if(!rt)
+ continue;
+ else if(parts[rt>>8].type==PT_LOVE&&loverule[nnx][nny]==0)
+ parts[rt>>8].type=PT_NONE;
+
+ }
+ }
+ }
+ love[nx/9][ny/9]=0;
+ }
+ }
+ }
+ if(ISLOLZ==1)
+ {
+ ISLOLZ = 0;
+ for(ny=0; ny<YRES-4; ny++)
+ for(nx=0; nx<XRES-4; nx++)
+ {
+ r=pmap[ny][nx];
+ if((r>>8)>=NPART || !r)
+ continue;
+ else if((ny<9||nx<9||ny>YRES-7||nx>XRES-10)&&parts[r>>8].type==PT_LOLZ)
+ parts[r>>8].type = PT_NONE;
+ else if(parts[r>>8].type==PT_LOLZ)
+ lolz[nx/9][ny/9] = 1;
+
+ }
+ for(nx=9; nx<=XRES-18; nx++)
+ {
+ for(ny=9; ny<=YRES-7; ny++)
+ {
+ if(lolz[nx/9][ny/9]==1)
+ {
+ for( nnx=0; nnx<9; nnx++)
+ for( nny=0; nny<9; nny++)
+ if(ny+nny>0&&ny+nny<YRES&&nx+nnx>=0&&nx+nnx<XRES)
+ {
+ rt=pmap[ny+nny][nx+nnx];
+ if((rt>>8)>=NPART)
+ continue;
+ if(!rt&&lolzrule[nny][nnx]==1)
+ create_part(-1,nx+nnx,ny+nny,PT_LOLZ);
+ else if(!rt)
+ continue;
+ else if(parts[rt>>8].type==PT_LOLZ&&lolzrule[nny][nnx]==0)
+ parts[rt>>8].type=PT_NONE;
+
+ }
+ }
+ lolz[nx/9][ny/9]=0;
+ }
+ }
+ }
+ if(ISGOL==1&&CGOL>=GSPEED)//GSPEED is frames per generation
+ {
+ int createdsomething = 0;
+ for(nx=4; nx<XRES-4; nx++)
+ for(ny=4; ny<YRES-4; ny++)
+ {
+ CGOL=0;
+ ISGOL=0;
+ r = pmap[ny][nx];
+ if((r>>8)>=NPART || !r)
+ {
+ gol[nx][ny] = 0;
+ continue;
+ }
+ else
+ for( golnum=1; golnum<NGOL; golnum++)
+ if(parts[r>>8].type==golnum+77)
+ {
+ gol[nx][ny] = golnum;
+ for( nnx=-1; nnx<2; nnx++)
+ for( nny=-1; nny<2; nny++) //it will count itself as its own neighbor, which is needed, but will have 1 extra for delete check
+ {
+ if(ny+nny<4&&nx+nnx<4) { //any way to make wrapping code smaller?
+ gol2[XRES-5][YRES-5][golnum] ++;
+ gol2[XRES-5][YRES-5][0] ++;
+ }
+ else if(ny+nny<4&&nx+nnx>=XRES-4) {
+ gol2[4][YRES-5][golnum] ++;
+ gol2[4][YRES-5][0] ++;
+ }
+ else if(ny+nny>=YRES-4&&nx+nnx<4) {
+ gol2[XRES-5][4][golnum] ++;
+ gol2[XRES-5][4][0] ++;
+ }
+ else if(nx+nnx<4) {
+ gol2[XRES-5][ny+nny][golnum] ++;
+ gol2[XRES-5][ny+nny][0] ++;
+ }
+ else if(ny+nny<4) {
+ gol2[nx+nnx][YRES-5][golnum] ++;
+ gol2[nx+nnx][YRES-5][0] ++;
+ }
+ else if(ny+nny>=YRES-4&&nx+nnx>=XRES-4) {
+ gol2[4][4][golnum] ++;
+ gol2[4][4][0] ++;
+ }
+ else if(ny+nny>=YRES-4) {
+ gol2[nx+nnx][4][golnum] ++;
+ gol2[nx+nnx][4][0] ++;
+ }
+ else if(nx+nnx>=XRES-4) {
+ gol2[4][ny+nny][golnum] ++;
+ gol2[4][ny+nny][0] ++;
+ }
+ else {
+ gol2[nx+nnx][ny+nny][golnum] ++;
+ gol2[nx+nnx][ny+nny][0] ++;
+ }
+ }
+ }
+ }
+ for(nx=4; nx<XRES-4; nx++)
+ for(ny=4; ny<YRES-4; ny++)
+ {
+ int neighbors = gol2[nx][ny][0];
+ if(neighbors==0)
+ continue;
+ for( golnum = 1; golnum<NGOL; golnum++)
+ for( goldelete = 0; goldelete<9; goldelete++)
+ {
+ if(neighbors==goldelete&&gol[nx][ny]==0&&grule[golnum][goldelete]>=2&&gol2[nx][ny][golnum]>=(goldelete%2)+goldelete/2)
+ {
+ if(create_part(-1,nx,ny,golnum+77))
+ createdsomething = 1;
+ }
+ else if(neighbors-1==goldelete&&gol[nx][ny]==golnum&&(grule[golnum][goldelete]==0||grule[golnum][goldelete]==2))//subtract 1 because it counted itself
+ parts[pmap[ny][nx]>>8].type = PT_NONE;
+ }
+ gol2[nx][ny][0] = 0;
+ for( z = 1; z<NGOL; z++)
+ gol2[nx][ny][z] = 0;
+ }
+ if(createdsomething)
+ GENERATION ++;
+ }
+ //if(ISWIRE==1)
+ //{
+ // CGOL = 0;
+ // ISWIRE = 0;
+ //}
+ if(ISWIRE==1)
+ {
+ for( q = 0; q<99; q++)
+ if(!wireless[q][1])
+ {
+ wireless[q][0] = 0;
+ }
+ else
+ wireless[q][1] = 0;
+ }
for(i=start; i<(NPART-starti); i+=inc)
if(parts[i].type)
{
- lx = parts[i].x;
+ lx = parts[i].x;
ly = parts[i].y;
t = parts[i].type;
- if (ptypes[t].update_func)
- {
- if (ptypes[t].update_func (i))
- goto killed;
- }
+ if (ptypes[t].update_func)
+ {
+ if (ptypes[t].update_func (i))
+ goto killed;
+ }
//printf("parts[%d].type: %d\n", i, parts[i].type);
@@ -1303,8 +1296,8 @@ void update_particles_i(pixel *vid, int start, int inc)
parts[i].life = 64;
if(t == PT_SLTW)
parts[i].life = 54;
- if(t == PT_SWCH)
- parts[i].life = 15;
+ if(t == PT_SWCH)
+ parts[i].life = 15;
}
}
@@ -1335,49 +1328,49 @@ void update_particles_i(pixel *vid, int start, int inc)
vx[y/CELL][x/CELL] *= ptypes[t].airloss;
vy[y/CELL][x/CELL] *= ptypes[t].airloss;
- if(t==PT_ANAR)
- {
- vx[y/CELL][x/CELL] -= ptypes[t].airdrag*parts[i].vx;
- vy[y/CELL][x/CELL] -= ptypes[t].airdrag*parts[i].vy;
- }
- else
- {
- vx[y/CELL][x/CELL] += ptypes[t].airdrag*parts[i].vx;
- vy[y/CELL][x/CELL] += ptypes[t].airdrag*parts[i].vy;
- }
+ if(t==PT_ANAR)
+ {
+ vx[y/CELL][x/CELL] -= ptypes[t].airdrag*parts[i].vx;
+ vy[y/CELL][x/CELL] -= ptypes[t].airdrag*parts[i].vy;
+ }
+ else
+ {
+ vx[y/CELL][x/CELL] += ptypes[t].airdrag*parts[i].vx;
+ vy[y/CELL][x/CELL] += ptypes[t].airdrag*parts[i].vy;
+ }
if(t==PT_GAS||t==PT_NBLE||t==PT_PUMP)
{
- if(t==PT_PUMP && parts[i].life==10)
- {
- if(parts[i].temp>=256.0+273.15)
- parts[i].temp=256.0+273.15;
- if(parts[i].temp<= -256.0+273.15)
- parts[i].temp = -256.0+273.15;
-
- if(pv[y/CELL][x/CELL]<(parts[i].temp-273.15))
- pv[y/CELL][x/CELL] += 0.1f*((parts[i].temp-273.15)-pv[y/CELL][x/CELL]);
- if(y+CELL<YRES && pv[y/CELL+1][x/CELL]<(parts[i].temp-273.15))
- pv[y/CELL+1][x/CELL] += 0.1f*((parts[i].temp-273.15)-pv[y/CELL+1][x/CELL]);
- if(x+CELL<XRES)
- {
- pv[y/CELL][x/CELL+1] += 0.1f*((parts[i].temp-273.15)-pv[y/CELL][x/CELL+1]);
- if(y+CELL<YRES)
- pv[y/CELL+1][x/CELL+1] += 0.1f*((parts[i].temp-273.15)-pv[y/CELL+1][x/CELL+1]);
- }
- }
- else
- {
- if(pv[y/CELL][x/CELL]<3.5f)
- pv[y/CELL][x/CELL] += ptypes[t].hotair*(3.5f-pv[y/CELL][x/CELL]);
- if(y+CELL<YRES && pv[y/CELL+1][x/CELL]<3.5f)
- pv[y/CELL+1][x/CELL] += ptypes[t].hotair*(3.5f-pv[y/CELL+1][x/CELL]);
- if(x+CELL<XRES)
- {
- pv[y/CELL][x/CELL+1] += ptypes[t].hotair*(3.5f-pv[y/CELL][x/CELL+1]);
- if(y+CELL<YRES)
- pv[y/CELL+1][x/CELL+1] += ptypes[t].hotair*(3.5f-pv[y/CELL+1][x/CELL+1]);
- }
- }
+ if(t==PT_PUMP && parts[i].life==10)
+ {
+ if(parts[i].temp>=256.0+273.15)
+ parts[i].temp=256.0+273.15;
+ if(parts[i].temp<= -256.0+273.15)
+ parts[i].temp = -256.0+273.15;
+
+ if(pv[y/CELL][x/CELL]<(parts[i].temp-273.15))
+ pv[y/CELL][x/CELL] += 0.1f*((parts[i].temp-273.15)-pv[y/CELL][x/CELL]);
+ if(y+CELL<YRES && pv[y/CELL+1][x/CELL]<(parts[i].temp-273.15))
+ pv[y/CELL+1][x/CELL] += 0.1f*((parts[i].temp-273.15)-pv[y/CELL+1][x/CELL]);
+ if(x+CELL<XRES)
+ {
+ pv[y/CELL][x/CELL+1] += 0.1f*((parts[i].temp-273.15)-pv[y/CELL][x/CELL+1]);
+ if(y+CELL<YRES)
+ pv[y/CELL+1][x/CELL+1] += 0.1f*((parts[i].temp-273.15)-pv[y/CELL+1][x/CELL+1]);
+ }
+ }
+ else
+ {
+ if(pv[y/CELL][x/CELL]<3.5f)
+ pv[y/CELL][x/CELL] += ptypes[t].hotair*(3.5f-pv[y/CELL][x/CELL]);
+ if(y+CELL<YRES && pv[y/CELL+1][x/CELL]<3.5f)
+ pv[y/CELL+1][x/CELL] += ptypes[t].hotair*(3.5f-pv[y/CELL+1][x/CELL]);
+ if(x+CELL<XRES)
+ {
+ pv[y/CELL][x/CELL+1] += ptypes[t].hotair*(3.5f-pv[y/CELL][x/CELL+1]);
+ if(y+CELL<YRES)
+ pv[y/CELL+1][x/CELL+1] += ptypes[t].hotair*(3.5f-pv[y/CELL+1][x/CELL+1]);
+ }
+ }
}
else
@@ -1414,7 +1407,7 @@ void update_particles_i(pixel *vid, int start, int inc)
parts[i].life = rand()%80+300;
}
}
- else if((t==PT_BCLN) && !parts[i].life)
+ else if((t==PT_BCLN) && !parts[i].life)
{
if(pv[y/CELL][x/CELL]>4.0f)
{
@@ -1425,16 +1418,16 @@ void update_particles_i(pixel *vid, int start, int inc)
}
else
{
- if(t==PT_ANAR)
- {
- parts[i].vx -= ptypes[t].advection*vx[y/CELL][x/CELL];
- parts[i].vy -= ptypes[t].advection*vy[y/CELL][x/CELL] + ptypes[t].gravity;
- }
- else{
- parts[i].vx += ptypes[t].advection*vx[y/CELL][x/CELL];
- parts[i].vy += ptypes[t].advection*vy[y/CELL][x/CELL] + ptypes[t].gravity;
-
- }
+ if(t==PT_ANAR)
+ {
+ parts[i].vx -= ptypes[t].advection*vx[y/CELL][x/CELL];
+ parts[i].vy -= ptypes[t].advection*vy[y/CELL][x/CELL] + ptypes[t].gravity;
+ }
+ else {
+ parts[i].vx += ptypes[t].advection*vx[y/CELL][x/CELL];
+ parts[i].vy += ptypes[t].advection*vy[y/CELL][x/CELL] + ptypes[t].gravity;
+
+ }
}
if(ptypes[t].diffusion)
@@ -1508,18 +1501,18 @@ void update_particles_i(pixel *vid, int start, int inc)
if(t==PT_GAS && pv[y/CELL][x/CELL]>6.0f)
t = parts[i].type = PT_OIL;
if(t==PT_DESL && pv[y/CELL][x/CELL]>12.0f)
- {
+ {
t = parts[i].type = PT_FIRE;
- parts[i].life = rand()%50+120;
- }
+ parts[i].life = rand()%50+120;
+ }
}
if(t==PT_GAS && pv[y/CELL][x/CELL]<-6.0f)
t = parts[i].type = PT_OIL;
if(t==PT_DESL && pv[y/CELL][x/CELL]>5.0f)
- { // Only way I know to make it
- t = parts[i].type = PT_FIRE; // combust under pressure.
- parts[i].life = rand()%50+120;
- }
+ { // Only way I know to make it
+ t = parts[i].type = PT_FIRE; // combust under pressure.
+ parts[i].life = rand()%50+120;
+ }
if(t==PT_GAS && pv[y/CELL][x/CELL]>6.0f)
t = parts[i].type = PT_OIL;
if(t==PT_BMTL && pv[y/CELL][x/CELL]>2.5f)
@@ -1528,21 +1521,21 @@ void update_particles_i(pixel *vid, int start, int inc)
t = parts[i].type = PT_BRMT;
if(t==PT_BRCK && pv[y/CELL][x/CELL]>8.8f)
t = parts[i].type = PT_STNE;
- if(t==PT_PIPE && pv[y/CELL][x/CELL]>10.0f)
+ if(t==PT_PIPE && pv[y/CELL][x/CELL]>10.0f)
t = parts[i].type = PT_BRMT;
- if(t==PT_PSTE && pv[y/CELL][x/CELL]>0.5f)
+ if(t==PT_PSTE && pv[y/CELL][x/CELL]>0.5f)
t = parts[i].type = PT_PSTS;
- if(t==PT_PSTS && pv[y/CELL][x/CELL]<0.5f)
+ if(t==PT_PSTS && pv[y/CELL][x/CELL]<0.5f)
t = parts[i].type = PT_PSTE;
- if(t==PT_SHLD1 && pv[y/CELL][x/CELL]>7.0f)
+ if(t==PT_SHLD1 && pv[y/CELL][x/CELL]>7.0f)
t = parts[i].type = PT_NONE;
- if(t==PT_SHLD2 && pv[y/CELL][x/CELL]>15.0f)
+ if(t==PT_SHLD2 && pv[y/CELL][x/CELL]>15.0f)
t = parts[i].type = PT_NONE;
- if(t==PT_SHLD3 && pv[y/CELL][x/CELL]>25.0f)
+ if(t==PT_SHLD3 && pv[y/CELL][x/CELL]>25.0f)
t = parts[i].type = PT_NONE;
- if(t==PT_SHLD4 && pv[y/CELL][x/CELL]>40.0f)
+ if(t==PT_SHLD4 && pv[y/CELL][x/CELL]>40.0f)
t = parts[i].type = PT_NONE;
- if(t==PT_WIFI && pv[y/CELL][x/CELL]>15.0f)
+ if(t==PT_WIFI && pv[y/CELL][x/CELL]>15.0f)
t = parts[i].type = PT_BRMT;
//if(t==PT_GLAS && pv[y/CELL][x/CELL]>4.0f)
// t = parts[i].type = PT_BGLA;
@@ -1562,20 +1555,20 @@ void update_particles_i(pixel *vid, int start, int inc)
t = PT_NEUT;
create_part(i, x, y, t);
}
- if((t==PT_ISOZ||t==PT_ISZS) && 1>rand()%200 && ((int)(-4.0f*(pv[y/CELL][x/CELL])))>(rand()%1000))
+ if((t==PT_ISOZ||t==PT_ISZS) && 1>rand()%200 && ((int)(-4.0f*(pv[y/CELL][x/CELL])))>(rand()%1000))
{
t = PT_PHOT;
- rr = (rand()%228+128)/127.0f;
- rrr = (rand()%360)*3.14159f/180.0f;
- parts[i].life = 680;
- parts[i].ctype = 0x3FFFFFFF;
- parts[i].vx = rr*cosf(rrr);
- parts[i].vy = rr*sinf(rrr);
+ rr = (rand()%228+128)/127.0f;
+ rrr = (rand()%360)*3.14159f/180.0f;
+ parts[i].life = 680;
+ parts[i].ctype = 0x3FFFFFFF;
+ parts[i].vx = rr*cosf(rrr);
+ parts[i].vy = rr*sinf(rrr);
create_part(i, x, y, t);
}
- if(t==PT_PSTE)
- if(parts[i].temp>747.0f)
- t = parts[i].type = PT_BRCK;
+ if(t==PT_PSTE)
+ if(parts[i].temp>747.0f)
+ t = parts[i].type = PT_BRCK;
if(t==PT_SPRK&&parts[i].ctype==PT_ETRD&&parts[i].life==1)
{
nearp = nearest_part(i, PT_ETRD);
@@ -1701,15 +1694,15 @@ void update_particles_i(pixel *vid, int start, int inc)
}
else
{
- if((t==PT_BIZR||t==PT_BIZRG||t==PT_BIZRS)&&pt>=pstates[t].gtemp)
- {
- t = parts[i].type = pstates[t].gas;
- }
- else{
- t = parts[i].type = pstates[t].gas;
- pv[y/CELL][x/CELL] += 0.50f;
- }
-
+ if((t==PT_BIZR||t==PT_BIZRG||t==PT_BIZRS)&&pt>=pstates[t].gtemp)
+ {
+ t = parts[i].type = pstates[t].gas;
+ }
+ else {
+ t = parts[i].type = pstates[t].gas;
+ pv[y/CELL][x/CELL] += 0.50f;
+ }
+
if(t==PT_FIRE)
parts[i].life = rand()%50+120;
if(t==PT_HFLM)
@@ -1820,13 +1813,13 @@ void update_particles_i(pixel *vid, int start, int inc)
}
else if(t==PT_ICEI || t==PT_SNOW)
{
- if(parts[i].ctype==PT_FRZW)
- {
- parts[i].temp -= 1.0f;
- if(parts[i].temp<0)
- parts[i].temp = 0;
-
- }
+ if(parts[i].ctype==PT_FRZW)
+ {
+ parts[i].temp -= 1.0f;
+ if(parts[i].temp<0)
+ parts[i].temp = 0;
+
+ }
for(nx=-2; nx<3; nx++)
for(ny=-2; ny<3; ny++)
if(x+nx>=0 && y+ny>0 &&
@@ -1978,60 +1971,60 @@ void update_particles_i(pixel *vid, int start, int inc)
}
}
}
- else if(t==PT_ARAY && parts[i].life==0){
- 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];
+ else if(t==PT_ARAY && parts[i].life==0) {
+ 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_SPRK){
- int destroy = (parts[r>>8].ctype==PT_PSCN)?1:0;
- for (docontinue = 1, nxx = 0, nyy = 0, nxi = nx*-1, nyi = ny*-1; docontinue; nyy+=nyi, nxx+=nxi) {
- if(!(x+nxi+nxx<XRES && y+nyi+nyy<YRES && x+nxi+nxx >= 0 && y+nyi+nyy >= 0)){
- break;
- }
- r = pmap[y+nyi+nyy][x+nxi+nxx];
- if(!((r>>8)>=NPART)) {
- if(!r){
- int nr = create_part(-1, x+nxi+nxx, y+nyi+nyy, PT_BRAY);
- if(nr!=-1&&destroy){
- parts[nr].tmp = 2;
- parts[nr].life = 2;
- }
- } else if(!destroy) {
- if(parts[r>>8].type==PT_BRAY&&parts[r>>8].tmp==0){
- if(nyy!=0 || nxx!=0){
- parts[r>>8].type = PT_BRAY;
- parts[r>>8].life = 1020;
- parts[r>>8].tmp = 1;
- }
- docontinue = 0;
- } else if(parts[r>>8].type==PT_BRAY&&parts[r>>8].tmp==1){
- parts[r>>8].life = 1020;
- //docontinue = 1;
- } else if(parts[r>>8].type!=PT_INWR && parts[r>>8].type!=PT_ARAY) {
- if(nyy!=0 || nxx!=0){
- create_part(-1, x+nxi+nxx, y+nyi+nyy, PT_SPRK);
- }
- docontinue = 0;
- }
- } else if(destroy) {
- if(parts[r>>8].type==PT_BRAY){
- parts[r>>8].life = 1;
- docontinue = 1;
- } else {
- docontinue = 0;
- }
- }
- }
- }
- }
- //parts[i].life = 4;
- }
- }
- }
- }
+ if((r&0xFF)==PT_SPRK) {
+ int destroy = (parts[r>>8].ctype==PT_PSCN)?1:0;
+ for (docontinue = 1, nxx = 0, nyy = 0, nxi = nx*-1, nyi = ny*-1; docontinue; nyy+=nyi, nxx+=nxi) {
+ if(!(x+nxi+nxx<XRES && y+nyi+nyy<YRES && x+nxi+nxx >= 0 && y+nyi+nyy >= 0)) {
+ break;
+ }
+ r = pmap[y+nyi+nyy][x+nxi+nxx];
+ if(!((r>>8)>=NPART)) {
+ if(!r) {
+ int nr = create_part(-1, x+nxi+nxx, y+nyi+nyy, PT_BRAY);
+ if(nr!=-1&&destroy) {
+ parts[nr].tmp = 2;
+ parts[nr].life = 2;
+ }
+ } else if(!destroy) {
+ if(parts[r>>8].type==PT_BRAY&&parts[r>>8].tmp==0) {
+ if(nyy!=0 || nxx!=0) {
+ parts[r>>8].type = PT_BRAY;
+ parts[r>>8].life = 1020;
+ parts[r>>8].tmp = 1;
+ }
+ docontinue = 0;
+ } else if(parts[r>>8].type==PT_BRAY&&parts[r>>8].tmp==1) {
+ parts[r>>8].life = 1020;
+ //docontinue = 1;
+ } else if(parts[r>>8].type!=PT_INWR && parts[r>>8].type!=PT_ARAY) {
+ if(nyy!=0 || nxx!=0) {
+ create_part(-1, x+nxi+nxx, y+nyi+nyy, PT_SPRK);
+ }
+ docontinue = 0;
+ }
+ } else if(destroy) {
+ if(parts[r>>8].type==PT_BRAY) {
+ parts[r>>8].life = 1;
+ docontinue = 1;
+ } else {
+ docontinue = 0;
+ }
+ }
+ }
+ }
+ }
+ //parts[i].life = 4;
+ }
+ }
+ }
+ }
else if(t==PT_FUSE)
{
if(parts[i].life<=0) {
@@ -2138,70 +2131,70 @@ void update_particles_i(pixel *vid, int start, int inc)
{
t = parts[i].type = PT_PLNT;
parts[r>>8].type = PT_PLNT;
- parts[r>>8].life = 0;
+ parts[r>>8].life = 0;
}
else if((r&0xFF)==PT_LAVA && 1>(rand()%250))
{
parts[i].life = 4;
t = parts[i].type = PT_FIRE;
}
- else if((r&0xFF)==PT_SMKE && (1>rand()%250))
- {
- parts[r>>8].type = PT_NONE;
- parts[i].life = rand()%60 + 60;
- }
- else if((r&0xFF)==PT_WOOD && (1>rand()%20) && abs(nx+ny)<=2 && VINE_MODE)
- {
- int nnx = rand()%3 -1;
- int nny = rand()%3 -1;
- if(x+nx+nnx>=0 && y+ny+nny>0 &&
- x+nx+nnx<XRES && y+ny+nny<YRES && (nnx || nny))
- {
- if((pmap[y+ny+nny][x+nx+nnx]>>8)>=NPART||pmap[y+ny+nny][x+nx+nnx])
- continue;
- if(create_part(-1,x+nx+nnx,y+ny+nny,PT_VINE))
- parts[pmap[y+ny+nny][x+nx+nnx]>>8].temp = parts[i].temp;
- }
- }
+ else if((r&0xFF)==PT_SMKE && (1>rand()%250))
+ {
+ parts[r>>8].type = PT_NONE;
+ parts[i].life = rand()%60 + 60;
+ }
+ else if((r&0xFF)==PT_WOOD && (1>rand()%20) && abs(nx+ny)<=2 && VINE_MODE)
+ {
+ int nnx = rand()%3 -1;
+ int nny = rand()%3 -1;
+ if(x+nx+nnx>=0 && y+ny+nny>0 &&
+ x+nx+nnx<XRES && y+ny+nny<YRES && (nnx || nny))
+ {
+ if((pmap[y+ny+nny][x+nx+nnx]>>8)>=NPART||pmap[y+ny+nny][x+nx+nnx])
+ continue;
+ if(create_part(-1,x+nx+nnx,y+ny+nny,PT_VINE))
+ parts[pmap[y+ny+nny][x+nx+nnx]>>8].temp = parts[i].temp;
+ }
+ }
//if(t==PT_SNOW && (r&0xFF)==PT_WATR && 15>(rand()%1000))
//t = parts[i].type = PT_WATR;
}
- if(parts[i].life==2)
- {
- 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)
- continue;
- if(!r)
- create_part(-1,x+nx,y+ny,PT_O2);
- }
- parts[i].life = 0;
- }
+ if(parts[i].life==2)
+ {
+ 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)
+ continue;
+ if(!r)
+ create_part(-1,x+nx,y+ny,PT_O2);
+ }
+ parts[i].life = 0;
+ }
+ }
+ else if(t==PT_VINE)
+ {
+ nx=(rand()%3)-1;
+ ny=(rand()%3)-1;
+ 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)
+ continue;
+ if(1>rand()%15)
+ parts[i].type=PT_PLNT;
+ else if(!r)
+ {
+ create_part(-1,x+nx,y+ny,PT_VINE);
+ parts[pmap[y+ny][x+nx]>>8].temp = parts[i].temp;
+ parts[i].type=PT_PLNT;
+ }
+ }
}
- else if(t==PT_VINE)
- {
- nx=(rand()%3)-1;
- ny=(rand()%3)-1;
- 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)
- continue;
- if(1>rand()%15)
- parts[i].type=PT_PLNT;
- else if(!r)
- {
- create_part(-1,x+nx,y+ny,PT_VINE);
- parts[pmap[y+ny][x+nx]>>8].temp = parts[i].temp;
- parts[i].type=PT_PLNT;
- }
- }
- }
else if(t==PT_THRM)
{
for(nx=-2; nx<3; nx++)
@@ -2262,10 +2255,10 @@ void update_particles_i(pixel *vid, int start, int inc)
parts[i].life = 4;
t = parts[i].type = PT_FIRE;
}
- if(((r&0xFF)==PT_CNCT&&t==PT_WATR) && 1>(rand()%500))
+ if(((r&0xFF)==PT_CNCT&&t==PT_WATR) && 1>(rand()%500))
{
t = parts[i].type = PT_PSTE;
- parts[r>>8].type = PT_NONE;
+ parts[r>>8].type = PT_NONE;
}
}
}
@@ -2288,8 +2281,8 @@ void update_particles_i(pixel *vid, int start, int inc)
{
parts[r>>8].type = PT_NONE;
}
- if((r&0xFF)==PT_PLNT&&5>(rand()%1000))
- parts[r>>8].type = PT_NONE;
+ if((r&0xFF)==PT_PLNT&&5>(rand()%1000))
+ parts[r>>8].type = PT_NONE;
if(((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && pt>12.0f && 1>(rand()%500))
{
parts[i].life = 4;
@@ -2364,11 +2357,11 @@ void update_particles_i(pixel *vid, int start, int inc)
}
else if(((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && ptypes[parts[r>>8].type].hardness>(rand()%1000))&&parts[i].life>=50)
{
- if(parts_avg(i, r>>8,PT_GLAS)!= PT_GLAS)
- {
- parts[i].life--;
- parts[r>>8].type = PT_NONE;
- }
+ if(parts_avg(i, r>>8,PT_GLAS)!= PT_GLAS)
+ {
+ parts[i].life--;
+ parts[r>>8].type = PT_NONE;
+ }
}
else if (parts[i].life==50)
{
@@ -2399,11 +2392,11 @@ void update_particles_i(pixel *vid, int start, int inc)
if(33>rand()%100)
{
create_part(r>>8, x+nx, y+ny, rand()%3 ? PT_LAVA : PT_URAN);
- parts[r>>8].temp = MAX_TEMP;
- if(parts[r>>8].type==PT_LAVA){
- parts[r>>8].tmp = 100;
- parts[r>>8].ctype = PT_PLUT;
- }
+ parts[r>>8].temp = MAX_TEMP;
+ if(parts[r>>8].type==PT_LAVA) {
+ parts[r>>8].tmp = 100;
+ parts[r>>8].ctype = PT_PLUT;
+ }
}
else
{
@@ -2414,22 +2407,22 @@ void update_particles_i(pixel *vid, int start, int inc)
pv[y/CELL][x/CELL] += 10.0f * CFDS; //Used to be 2, some people said nukes weren't powerful enough
fe ++;
}
- if((r&0xFF)==PT_DEUT && (rt+1)>(rand()%1000))
- {
-
- create_part(r>>8, x+nx, y+ny, PT_NEUT);
- parts[r>>8].vx = 0.25f*parts[r>>8].vx + parts[i].vx;
- parts[r>>8].vy = 0.25f*parts[r>>8].vy + parts[i].vy;
- if(parts[r>>8].life>0)
- {
- parts[r>>8].life --;
- parts[r>>8].temp += (parts[r>>8].life*17);
- pv[y/CELL][x/CELL] += 6.0f * CFDS;
-
- }
- else
- parts[r>>8].type = PT_NONE;
- }
+ if((r&0xFF)==PT_DEUT && (rt+1)>(rand()%1000))
+ {
+
+ create_part(r>>8, x+nx, y+ny, PT_NEUT);
+ parts[r>>8].vx = 0.25f*parts[r>>8].vx + parts[i].vx;
+ parts[r>>8].vy = 0.25f*parts[r>>8].vy + parts[i].vy;
+ if(parts[r>>8].life>0)
+ {
+ parts[r>>8].life --;
+ parts[r>>8].temp += (parts[r>>8].life*17);
+ pv[y/CELL][x/CELL] += 6.0f * CFDS;
+
+ }
+ else
+ parts[r>>8].type = PT_NONE;
+ }
if((r&0xFF)==PT_GUNP && 15>(rand()%1000))
parts[r>>8].type = PT_DUST;
if((r&0xFF)==PT_DYST && 15>(rand()%1000))
@@ -2453,15 +2446,15 @@ void update_particles_i(pixel *vid, int start, int inc)
parts[r>>8].type = PT_GAS;
if((r&0xFF)==PT_COAL && 5>(rand()%100))
parts[r>>8].type = PT_WOOD;
- if((r&0xFF)==PT_DUST && 5>(rand()%100))
+ if((r&0xFF)==PT_DUST && 5>(rand()%100))
parts[r>>8].type = PT_FWRK;
- if((r&0xFF)==PT_FWRK && 5>(rand()%100))
+ if((r&0xFF)==PT_FWRK && 5>(rand()%100))
parts[r>>8].ctype = PT_DUST;
- if((r&0xFF)==PT_ACID && 5>(rand()%100))
- {
+ if((r&0xFF)==PT_ACID && 5>(rand()%100))
+ {
parts[r>>8].type = PT_ISOZ;
- parts[r>>8].life = 0;
- }
+ parts[r>>8].life = 0;
+ }
/*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||
@@ -2487,7 +2480,7 @@ void update_particles_i(pixel *vid, int start, int inc)
parts[i].vy *= 0.995;
}
}
- for(nx=-1; nx<2; nx++)
+ 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))
@@ -2495,165 +2488,165 @@ 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_ISOZ && 5>(rand()%2000))
- {
- parts[i].vx *= 0.90;
+ if((r&0xFF)==PT_ISOZ && 5>(rand()%2000))
+ {
+ parts[i].vx *= 0.90;
parts[i].vy *= 0.90;
parts[r>>8].type = PT_PHOT;
- rrr = (rand()%360)*3.14159f/180.0f;
- rr = (rand()%128+128)/127.0f;
- parts[r>>8].life = 680;
- parts[r>>8].ctype = 0x3FFFFFFF;
- parts[r>>8].vx = rr*cosf(rrr);
- parts[r>>8].vy = rr*sinf(rrr);
- pv[y/CELL][x/CELL] -= 15.0f * CFDS;
- }
- if((r&0xFF)==PT_ISZS && 5>(rand()%2000))
- {
- parts[i].vx *= 0.90;
+ rrr = (rand()%360)*3.14159f/180.0f;
+ rr = (rand()%128+128)/127.0f;
+ parts[r>>8].life = 680;
+ parts[r>>8].ctype = 0x3FFFFFFF;
+ parts[r>>8].vx = rr*cosf(rrr);
+ parts[r>>8].vy = rr*sinf(rrr);
+ pv[y/CELL][x/CELL] -= 15.0f * CFDS;
+ }
+ if((r&0xFF)==PT_ISZS && 5>(rand()%2000))
+ {
+ parts[i].vx *= 0.90;
parts[i].vy *= 0.90;
parts[r>>8].type = PT_PHOT;
- rr = (rand()%228+128)/127.0f;
- rrr = (rand()%360)*3.14159f/180.0f;
- parts[r>>8].life = 680;
- parts[r>>8].ctype = 0x3FFFFFFF;
- parts[r>>8].vx = rr*cosf(rrr);
- parts[r>>8].vy = rr*sinf(rrr);
- pv[y/CELL][x/CELL] -= 15.0f * CFDS;
- }
- }
+ rr = (rand()%228+128)/127.0f;
+ rrr = (rand()%360)*3.14159f/180.0f;
+ parts[r>>8].life = 680;
+ parts[r>>8].ctype = 0x3FFFFFFF;
+ parts[r>>8].vx = rr*cosf(rrr);
+ parts[r>>8].vy = rr*sinf(rrr);
+ pv[y/CELL][x/CELL] -= 15.0f * CFDS;
+ }
+ }
+ }
+ else if(t==PT_GLOW)
+ {
+ 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(parts[r>>8].type==PT_WATR&&5>(rand()%2000))
+ {
+ t = parts[i].type = PT_NONE;
+ parts[r>>8].type = PT_DEUT;
+ parts[r>>8].life = 10;
+ }
+ }
}
- else if(t==PT_GLOW)
- {
- 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(parts[r>>8].type==PT_WATR&&5>(rand()%2000))
- {
- t = parts[i].type = PT_NONE;
- parts[r>>8].type = PT_DEUT;
- parts[r>>8].life = 10;
- }
- }
- }
else if(t==PT_MORT) {
create_part(-1, x, y-1, PT_SMKE);
}
- else if(t>77&&t<77+NGOL)
- {
- if(parts[i].temp>0)
- parts[i].temp -= 50.0f;
- ISGOL=1;
- }
- else if(t==PT_LOVE)
- ISLOVE=1;
- else if(t==PT_LOLZ)
- ISLOLZ=1;
- else if(t==PT_GRAV)
- ISGRAV=1;
- else if(t==PT_SPNG)
- {
- if(pv[y/CELL][x/CELL]<=3&&pv[y/CELL][x/CELL]>=-3)
- {
- 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 || parts[i].temp>374.0f)
- continue;
- if(parts[r>>8].type==PT_WATR&&33>=rand()/(RAND_MAX/100)+1)
- {
- parts[i].life++;
- parts[r>>8].type=PT_NONE;
- }
- }
- }
- else
- 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)
- continue;
- if((bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALLELEC||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_EWALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_DESTROYALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALL||
- bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWAIR||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWSOLID||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWGAS))
- continue;
- if((!r)&&parts[i].life>=1)//if nothing then create water
- {
- create_part(-1,x+nx,y+ny,PT_WATR);
- parts[i].life--;
- }
- }
- for( trade = 0; trade<9;trade ++)
- {
- nx = rand()%5-2;
- ny = rand()%5-2;
- 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(parts[r>>8].type==t&&(parts[i].life>parts[r>>8].life)&&parts[i].life>0)//diffusion
- {
- int temp = parts[i].life - parts[r>>8].life;
- if(temp ==1)
- {
- parts[r>>8].life ++;
- parts[i].life --;
- trade = 9;
- }
- else if(temp>0)
- {
- parts[r>>8].life += temp/2;
- parts[i].life -= temp/2;
- trade = 9;
- }
- }
- }
- }
- 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(parts[r>>8].type==PT_FIRE&&parts[i].life>0)
- {
- if(parts[i].life<=2)
- parts[i].life --;
- parts[i].life -= parts[i].life/3;
- }
- }
- if(parts[i].temp>=374)
- 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)
- continue;
- if((bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALLELEC||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWLIQUID||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_DESTROYALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWSOLID))
- continue;
- if((!r)&&parts[i].life>=1)//if nothing then create steam
- {
- create_part(-1,x+nx,y+ny,PT_WTRV);
- parts[i].life--;
- parts[i].temp -= 40.0f;
- }
- }
- }
- else if(t==PT_FOG)
- {
- if(parts[i].temp>=373.15)
- t = parts[i].type = PT_WTRV;
- for(nx=-1; nx<2; nx++)
+ else if(t>77&&t<77+NGOL)
+ {
+ if(parts[i].temp>0)
+ parts[i].temp -= 50.0f;
+ ISGOL=1;
+ }
+ else if(t==PT_LOVE)
+ ISLOVE=1;
+ else if(t==PT_LOLZ)
+ ISLOLZ=1;
+ else if(t==PT_GRAV)
+ ISGRAV=1;
+ else if(t==PT_SPNG)
+ {
+ if(pv[y/CELL][x/CELL]<=3&&pv[y/CELL][x/CELL]>=-3)
+ {
+ 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 || parts[i].temp>374.0f)
+ continue;
+ if(parts[r>>8].type==PT_WATR&&33>=rand()/(RAND_MAX/100)+1)
+ {
+ parts[i].life++;
+ parts[r>>8].type=PT_NONE;
+ }
+ }
+ }
+ else
+ 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)
+ continue;
+ if((bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALLELEC||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_EWALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_DESTROYALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALL||
+ bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWAIR||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWSOLID||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWGAS))
+ continue;
+ if((!r)&&parts[i].life>=1)//if nothing then create water
+ {
+ create_part(-1,x+nx,y+ny,PT_WATR);
+ parts[i].life--;
+ }
+ }
+ for( trade = 0; trade<9; trade ++)
+ {
+ nx = rand()%5-2;
+ ny = rand()%5-2;
+ 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(parts[r>>8].type==t&&(parts[i].life>parts[r>>8].life)&&parts[i].life>0)//diffusion
+ {
+ int temp = parts[i].life - parts[r>>8].life;
+ if(temp ==1)
+ {
+ parts[r>>8].life ++;
+ parts[i].life --;
+ trade = 9;
+ }
+ else if(temp>0)
+ {
+ parts[r>>8].life += temp/2;
+ parts[i].life -= temp/2;
+ trade = 9;
+ }
+ }
+ }
+ }
+ 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(parts[r>>8].type==PT_FIRE&&parts[i].life>0)
+ {
+ if(parts[i].life<=2)
+ parts[i].life --;
+ parts[i].life -= parts[i].life/3;
+ }
+ }
+ if(parts[i].temp>=374)
+ 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)
+ continue;
+ if((bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALLELEC||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWLIQUID||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_DESTROYALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWSOLID))
+ continue;
+ if((!r)&&parts[i].life>=1)//if nothing then create steam
+ {
+ create_part(-1,x+nx,y+ny,PT_WTRV);
+ parts[i].life--;
+ parts[i].temp -= 40.0f;
+ }
+ }
+ }
+ else if(t==PT_FOG)
+ {
+ if(parts[i].temp>=373.15)
+ t = parts[i].type = PT_WTRV;
+ 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))
@@ -2661,21 +2654,21 @@ void update_particles_i(pixel *vid, int start, int inc)
r = pmap[y+ny][x+nx];
if((r>>8)>=NPART || !r)
continue;
- if(pstates[parts[r>>8].type].state==ST_SOLID&&5>=rand()%50&&parts[i].life==0&&!(parts[r>>8].type==PT_CLNE||parts[r>>8].type==PT_PCLN))
- {
- t = parts[i].type = PT_RIME;
- }
- if(parts[r>>8].type==PT_SPRK)
+ if(pstates[parts[r>>8].type].state==ST_SOLID&&5>=rand()%50&&parts[i].life==0&&!(parts[r>>8].type==PT_CLNE||parts[r>>8].type==PT_PCLN))
+ {
+ t = parts[i].type = PT_RIME;
+ }
+ if(parts[r>>8].type==PT_SPRK)
{
- parts[i].life += rand()%20;
- }
- }
- }
- else if(t==PT_RIME)
- {
- parts[i].vx = 0;
- parts[i].vy = 0;
- for(nx=-1; nx<2; nx++)
+ parts[i].life += rand()%20;
+ }
+ }
+ }
+ else if(t==PT_RIME)
+ {
+ parts[i].vx = 0;
+ parts[i].vy = 0;
+ 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))
@@ -2686,160 +2679,160 @@ void update_particles_i(pixel *vid, int start, int inc)
rt = parts[r>>8].type;
if(rt==PT_SPRK)
{
- t = parts[i].type = PT_FOG;
- parts[i].life = rand()%50 + 60;
- }
- else if(rt==PT_FOG&&parts[r>>8].life>0)
- {
- t = parts[i].type = PT_FOG;
- parts[i].life = parts[r>>8].life;
- }
- }
- }
- else if(t==PT_DEUT)
- {
- int maxlife = ((10000/(parts[i].temp + 1))-1);
- if((10000%((int)parts[i].temp+1))>rand()%((int)parts[i].temp+1))
- maxlife ++;
- if(parts[i].life < maxlife)
- {
- 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 || (parts[i].life >=maxlife))
- continue;
- if(parts[r>>8].type==PT_DEUT&&33>=rand()/(RAND_MAX/100)+1)
- {
- if((parts[i].life + parts[r>>8].life + 1) <= maxlife)
- {
- parts[i].life += parts[r>>8].life + 1;
- parts[r>>8].type=PT_NONE;
- }
- }
- }
- }
- else
- 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 || (parts[i].life<=maxlife))
- continue;
- if((bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALLELEC||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_EWALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_DESTROYALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALL||
- bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWAIR||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWSOLID||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWGAS))
- continue;
- if((!r)&&parts[i].life>=1)//if nothing then create deut
- {
- create_part(-1,x+nx,y+ny,PT_DEUT);
- parts[i].life--;
- parts[pmap[y+ny][x+nx]>>8].temp = parts[i].temp;
- parts[pmap[y+ny][x+nx]>>8].life = 0;
- }
- }
- for( trade = 0; trade<4;trade ++)
- {
- nx = rand()%5-2;
- ny = rand()%5-2;
- 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(parts[r>>8].type==t&&(parts[i].life>parts[r>>8].life)&&parts[i].life>0)//diffusion
- {
- int temp = parts[i].life - parts[r>>8].life;
- if(temp ==1)
- {
- parts[r>>8].life ++;
- parts[i].life --;
- }
- else if(temp>0)
- {
- parts[r>>8].life += temp/2;
- parts[i].life -= temp/2;
- }
- }
- }
- }
- }
- else if(t==PT_WARP)
- {
- for( trade = 0; trade<5;trade ++)
- {
- nx = rand()%3-1;
- ny = rand()%3-1;
- 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(parts[r>>8].type!=PT_WARP&&parts[r>>8].type!=PT_STKM&&parts[r>>8].type!=PT_DMND&&parts[r>>8].type!=PT_CLNE&&parts[r>>8].type!=PT_BCLN&&parts[r>>8].type!=PT_PCLN&&(10>=rand()%200))
- {
- parts[i].x = parts[r>>8].x;
- parts[i].y = parts[r>>8].y;
- parts[r>>8].x = x;
- parts[r>>8].y = y;
- parts[i].life += 4;
- trade = 5;
- }
- }
- }
- }
- else if(t==PT_FWRK)
- {
- if((parts[i].temp>400&&(9+parts[i].temp/40)>rand()%100000&&parts[i].life==0&&!pmap[y-1][x])||parts[i].ctype==PT_DUST)
- {
- create_part(-1, x , y-1 , PT_FWRK);
- r = pmap[y-1][x];
- if(parts[r>>8].type==PT_FWRK)
- {
- parts[r>>8].vy = rand()%8-22;
- parts[r>>8].vx = rand()%20-rand()%20;
- parts[r>>8].life=rand()%15+25;
- t=parts[i].type=PT_NONE;
- }
- }
- if(parts[i].life>1)
- {
- if(parts[i].life>=45&&parts[i].type==PT_FWRK)
- parts[i].life=0;
- }
- if((parts[i].life<3&&parts[i].life>0)||parts[i].vy>6&&parts[i].life>0)
- {
- int q = (rand()%255+1);
- int w = (rand()%255+1);
- int e = (rand()%255+1);
- for(nx=-1; nx<2; nx++)
- for(ny=-2; ny<3; ny++)
- if(x+nx>=0 && y+ny>0 &&
- x+nx<XRES && y+ny<YRES)
- {
- if(5>=rand()%8)
- {
- if(!pmap[y+ny][x+nx])
- {
- create_part(-1, x+nx, y+ny , PT_DUST);
- pv[y/CELL][x/CELL] += 2.00f*CFDS;
- a= pmap[y+ny][x+nx];
- if(parts[a>>8].type==PT_DUST)
- {
- parts[a>>8].vy = -(rand()%10-1);
- parts[a>>8].vx = ((rand()%2)*2-1)*rand()%(5+5)+(parts[i].vx)*2 ;
- parts[a>>8].life= rand()%37+18;
- parts[a>>8].tmp=q;
- parts[a>>8].flags=w;
- parts[a>>8].ctype=e;
- parts[a>>8].temp= rand()%20+6000;
- }
- }
- }
- }
- t=parts[i].type=PT_NONE;
- }
- }
+ t = parts[i].type = PT_FOG;
+ parts[i].life = rand()%50 + 60;
+ }
+ else if(rt==PT_FOG&&parts[r>>8].life>0)
+ {
+ t = parts[i].type = PT_FOG;
+ parts[i].life = parts[r>>8].life;
+ }
+ }
+ }
+ else if(t==PT_DEUT)
+ {
+ int maxlife = ((10000/(parts[i].temp + 1))-1);
+ if((10000%((int)parts[i].temp+1))>rand()%((int)parts[i].temp+1))
+ maxlife ++;
+ if(parts[i].life < maxlife)
+ {
+ 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 || (parts[i].life >=maxlife))
+ continue;
+ if(parts[r>>8].type==PT_DEUT&&33>=rand()/(RAND_MAX/100)+1)
+ {
+ if((parts[i].life + parts[r>>8].life + 1) <= maxlife)
+ {
+ parts[i].life += parts[r>>8].life + 1;
+ parts[r>>8].type=PT_NONE;
+ }
+ }
+ }
+ }
+ else
+ 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 || (parts[i].life<=maxlife))
+ continue;
+ if((bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALLELEC||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_EWALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_DESTROYALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALL||
+ bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWAIR||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWSOLID||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWGAS))
+ continue;
+ if((!r)&&parts[i].life>=1)//if nothing then create deut
+ {
+ create_part(-1,x+nx,y+ny,PT_DEUT);
+ parts[i].life--;
+ parts[pmap[y+ny][x+nx]>>8].temp = parts[i].temp;
+ parts[pmap[y+ny][x+nx]>>8].life = 0;
+ }
+ }
+ for( trade = 0; trade<4; trade ++)
+ {
+ nx = rand()%5-2;
+ ny = rand()%5-2;
+ 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(parts[r>>8].type==t&&(parts[i].life>parts[r>>8].life)&&parts[i].life>0)//diffusion
+ {
+ int temp = parts[i].life - parts[r>>8].life;
+ if(temp ==1)
+ {
+ parts[r>>8].life ++;
+ parts[i].life --;
+ }
+ else if(temp>0)
+ {
+ parts[r>>8].life += temp/2;
+ parts[i].life -= temp/2;
+ }
+ }
+ }
+ }
+ }
+ else if(t==PT_WARP)
+ {
+ for( trade = 0; trade<5; trade ++)
+ {
+ nx = rand()%3-1;
+ ny = rand()%3-1;
+ 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(parts[r>>8].type!=PT_WARP&&parts[r>>8].type!=PT_STKM&&parts[r>>8].type!=PT_DMND&&parts[r>>8].type!=PT_CLNE&&parts[r>>8].type!=PT_BCLN&&parts[r>>8].type!=PT_PCLN&&(10>=rand()%200))
+ {
+ parts[i].x = parts[r>>8].x;
+ parts[i].y = parts[r>>8].y;
+ parts[r>>8].x = x;
+ parts[r>>8].y = y;
+ parts[i].life += 4;
+ trade = 5;
+ }
+ }
+ }
+ }
+ else if(t==PT_FWRK)
+ {
+ if((parts[i].temp>400&&(9+parts[i].temp/40)>rand()%100000&&parts[i].life==0&&!pmap[y-1][x])||parts[i].ctype==PT_DUST)
+ {
+ create_part(-1, x , y-1 , PT_FWRK);
+ r = pmap[y-1][x];
+ if(parts[r>>8].type==PT_FWRK)
+ {
+ parts[r>>8].vy = rand()%8-22;
+ parts[r>>8].vx = rand()%20-rand()%20;
+ parts[r>>8].life=rand()%15+25;
+ t=parts[i].type=PT_NONE;
+ }
+ }
+ if(parts[i].life>1)
+ {
+ if(parts[i].life>=45&&parts[i].type==PT_FWRK)
+ parts[i].life=0;
+ }
+ if((parts[i].life<3&&parts[i].life>0)||parts[i].vy>6&&parts[i].life>0)
+ {
+ int q = (rand()%255+1);
+ int w = (rand()%255+1);
+ int e = (rand()%255+1);
+ for(nx=-1; nx<2; nx++)
+ for(ny=-2; ny<3; ny++)
+ if(x+nx>=0 && y+ny>0 &&
+ x+nx<XRES && y+ny<YRES)
+ {
+ if(5>=rand()%8)
+ {
+ if(!pmap[y+ny][x+nx])
+ {
+ create_part(-1, x+nx, y+ny , PT_DUST);
+ pv[y/CELL][x/CELL] += 2.00f*CFDS;
+ a= pmap[y+ny][x+nx];
+ if(parts[a>>8].type==PT_DUST)
+ {
+ parts[a>>8].vy = -(rand()%10-1);
+ parts[a>>8].vx = ((rand()%2)*2-1)*rand()%(5+5)+(parts[i].vx)*2 ;
+ parts[a>>8].life= rand()%37+18;
+ parts[a>>8].tmp=q;
+ parts[a>>8].flags=w;
+ parts[a>>8].ctype=e;
+ parts[a>>8].temp= rand()%20+6000;
+ }
+ }
+ }
+ }
+ t=parts[i].type=PT_NONE;
+ }
+ }
else if(t==PT_LCRY)
{
for(nx=-1; nx<2; nx++)
@@ -2875,127 +2868,127 @@ void update_particles_i(pixel *vid, int start, int inc)
}
}
}
- else if(t==PT_PIPE)
- {
- if(!parts[i].ctype && parts[i].life<=10)
- {
- if(parts[i].temp<272.15)
- {
- if(parts[i].temp>173.25&&parts[i].temp<273.15)
- {
- parts[i].ctype = 2;
- parts[i].life = 0;
- }
- if(parts[i].temp>73.25&&parts[i].temp<=173.15)
- {
- parts[i].ctype = 3;
- parts[i].life = 0;
- }
- if(parts[i].temp>=0&&parts[i].temp<=73.15)
- {
- parts[i].ctype = 4;
- parts[i].life = 0;
- }
- }
- else
- {
- 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 )
- continue;
- if(!r)
- create_part(-1,x+nx,y+ny,PT_BRCK);
- }
- if(parts[i].life==1)
- parts[i].ctype = 1;
- }
- }
- if(parts[i].ctype==1)
- {
- 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)
- continue;
- if(!r&&!parts[i].life)
- parts[i].life=50;
- }
- if(parts[i].life==2)
- {
- parts[i].ctype = 2;
- parts[i].life = 6;
- }
- }
- if(parts[i].ctype>1)
- for( q = 0;q<3;q++)
- for( ctype = 2;ctype<5;ctype++)
- {
- if(parts[i].ctype==ctype)
- {
- if(parts[i].life==3)
- {
- 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(parts[r>>8].type==PT_PIPE&&parts[r>>8].ctype==1)
- {
- parts[r>>8].ctype = (((ctype)%3)+2);//reverse
- parts[r>>8].life = 6;
- }
- }
- }
- else
- {
- nx = rand()%3-1;
- ny = rand()%3-1;
- 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)
- continue;
- else if(!r&&parts[i].tmp!=0)
- {
- if(create_part(-1,x+nx,y+ny,parts[i].tmp))
- {
- parts[pmap[y+ny][x+nx]>>8].temp = parts[i].temp;//pipe saves temp and life now
- parts[pmap[y+ny][x+nx]>>8].life = parts[i].flags;
- }
- parts[i].tmp = 0;
- continue;
- }
- else if(!r)
- continue;
- else if(parts[i].tmp == 0 && (ptypes[parts[r>>8].type].falldown!= 0 || pstates[parts[r>>8].type].state == ST_GAS))
- {
- parts[i].tmp = parts[r>>8].type;
- parts[i].temp = parts[r>>8].temp;
- parts[i].flags = parts[r>>8].life;
- parts[r>>8].type = PT_NONE;
- }
- else if(parts[r>>8].type==PT_PIPE && parts[r>>8].ctype!=(((ctype)%3)+2) && parts[r>>8].tmp==0&&parts[i].tmp>0)
- {
- parts[r>>8].tmp = parts[i].tmp;
- parts[r>>8].temp = parts[i].temp;
- parts[r>>8].flags = parts[i].flags;
- parts[i].tmp = 0;
- }
- }
- }
- }
- }
- }
- else if(t==PT_FRZZ)
- {
- for(nx=-1; nx<2; nx++)
+ else if(t==PT_PIPE)
+ {
+ if(!parts[i].ctype && parts[i].life<=10)
+ {
+ if(parts[i].temp<272.15)
+ {
+ if(parts[i].temp>173.25&&parts[i].temp<273.15)
+ {
+ parts[i].ctype = 2;
+ parts[i].life = 0;
+ }
+ if(parts[i].temp>73.25&&parts[i].temp<=173.15)
+ {
+ parts[i].ctype = 3;
+ parts[i].life = 0;
+ }
+ if(parts[i].temp>=0&&parts[i].temp<=73.15)
+ {
+ parts[i].ctype = 4;
+ parts[i].life = 0;
+ }
+ }
+ else
+ {
+ 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 )
+ continue;
+ if(!r)
+ create_part(-1,x+nx,y+ny,PT_BRCK);
+ }
+ if(parts[i].life==1)
+ parts[i].ctype = 1;
+ }
+ }
+ if(parts[i].ctype==1)
+ {
+ 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)
+ continue;
+ if(!r&&!parts[i].life)
+ parts[i].life=50;
+ }
+ if(parts[i].life==2)
+ {
+ parts[i].ctype = 2;
+ parts[i].life = 6;
+ }
+ }
+ if(parts[i].ctype>1)
+ for( q = 0; q<3; q++)
+ for( ctype = 2; ctype<5; ctype++)
+ {
+ if(parts[i].ctype==ctype)
+ {
+ if(parts[i].life==3)
+ {
+ 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(parts[r>>8].type==PT_PIPE&&parts[r>>8].ctype==1)
+ {
+ parts[r>>8].ctype = (((ctype)%3)+2);//reverse
+ parts[r>>8].life = 6;
+ }
+ }
+ }
+ else
+ {
+ nx = rand()%3-1;
+ ny = rand()%3-1;
+ 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)
+ continue;
+ else if(!r&&parts[i].tmp!=0)
+ {
+ if(create_part(-1,x+nx,y+ny,parts[i].tmp))
+ {
+ parts[pmap[y+ny][x+nx]>>8].temp = parts[i].temp;//pipe saves temp and life now
+ parts[pmap[y+ny][x+nx]>>8].life = parts[i].flags;
+ }
+ parts[i].tmp = 0;
+ continue;
+ }
+ else if(!r)
+ continue;
+ else if(parts[i].tmp == 0 && (ptypes[parts[r>>8].type].falldown!= 0 || pstates[parts[r>>8].type].state == ST_GAS))
+ {
+ parts[i].tmp = parts[r>>8].type;
+ parts[i].temp = parts[r>>8].temp;
+ parts[i].flags = parts[r>>8].life;
+ parts[r>>8].type = PT_NONE;
+ }
+ else if(parts[r>>8].type==PT_PIPE && parts[r>>8].ctype!=(((ctype)%3)+2) && parts[r>>8].tmp==0&&parts[i].tmp>0)
+ {
+ parts[r>>8].tmp = parts[i].tmp;
+ parts[r>>8].temp = parts[i].temp;
+ parts[r>>8].flags = parts[i].flags;
+ parts[i].tmp = 0;
+ }
+ }
+ }
+ }
+ }
+ }
+ else if(t==PT_FRZZ)
+ {
+ 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))
@@ -3003,18 +2996,18 @@ void update_particles_i(pixel *vid, int start, int inc)
r = pmap[y+ny][x+nx];
if((r>>8)>=NPART || !r)
continue;
- if(parts[r>>8].type==PT_WATR&&5>rand()%100)
- {
- parts[r>>8].type=PT_FRZW;
- parts[r>>8].life = 100;
- t = parts[i].type = PT_NONE;
- }
-
- }
- }
- else if(t==PT_FRZW)
- {
- for(nx=-1; nx<2; nx++)
+ if(parts[r>>8].type==PT_WATR&&5>rand()%100)
+ {
+ parts[r>>8].type=PT_FRZW;
+ parts[r>>8].life = 100;
+ t = parts[i].type = PT_NONE;
+ }
+
+ }
+ }
+ else if(t==PT_FRZW)
+ {
+ 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))
@@ -3022,31 +3015,31 @@ void update_particles_i(pixel *vid, int start, int inc)
r = pmap[y+ny][x+nx];
if((r>>8)>=NPART || !r)
continue;
- if(parts[r>>8].type==PT_WATR&&5>rand()%70)
- {
- parts[r>>8].type=PT_FRZW;
- }
- }
- if(parts[i].life==0&&13>rand()%2500)
- {
- t = parts[i].type=PT_ICEI;
- parts[i].ctype=PT_FRZW;
- parts[i].temp -= 200.0f;
- if(parts[i].temp<0)
- parts[i].temp = 0;
- }
- else if((100-(parts[i].life))>rand()%50000)
- {
- t = parts[i].type=PT_ICEI;
- parts[i].ctype=PT_FRZW;
- parts[i].temp -= 200.0f;
- if(parts[i].temp<0)
- parts[i].temp = 0;
- }
- }
- else if(t==PT_INST)
- {
- for(nx=-2; nx<3; nx++)
+ if(parts[r>>8].type==PT_WATR&&5>rand()%70)
+ {
+ parts[r>>8].type=PT_FRZW;
+ }
+ }
+ if(parts[i].life==0&&13>rand()%2500)
+ {
+ t = parts[i].type=PT_ICEI;
+ parts[i].ctype=PT_FRZW;
+ parts[i].temp -= 200.0f;
+ if(parts[i].temp<0)
+ parts[i].temp = 0;
+ }
+ else if((100-(parts[i].life))>rand()%50000)
+ {
+ t = parts[i].type=PT_ICEI;
+ parts[i].ctype=PT_FRZW;
+ parts[i].temp -= 200.0f;
+ if(parts[i].temp<0)
+ parts[i].temp = 0;
+ }
+ }
+ else if(t==PT_INST)
+ {
+ 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) && abs(nx)+abs(ny)<4)
@@ -3054,101 +3047,101 @@ void update_particles_i(pixel *vid, int start, int inc)
r = pmap[y+ny][x+nx];
if((r>>8)>=NPART || !r)
continue;
- else if(parts[r>>8].type==PT_SPRK&&(parts[r>>8].ctype==PT_PSCN)&&(parts[r>>8].life>=3)&&parts[i].life%4==0)
- {
- flood_parts(x,y,PT_SPRK,PT_INST,-1);//add life
- parts[r>>8].type==parts[r>>8].ctype;
- }
- }
- }
- else if(t==PT_PRTI)
- {
- int temprange = 100;
- int count =0;
- for( temp = 0; temp < MAX_TEMP; temp += temprange)
- if(parts[i].temp-73.15>temp&&parts[i].temp-73.15 <temp+temprange)
- parts[i].tmp = temp/100;
- for(ny=-1; ny<2; ny++)
+ else if(parts[r>>8].type==PT_SPRK&&(parts[r>>8].ctype==PT_PSCN)&&(parts[r>>8].life>=3)&&parts[i].life%4==0)
+ {
+ flood_parts(x,y,PT_SPRK,PT_INST,-1);//add life
+ parts[r>>8].type==parts[r>>8].ctype;
+ }
+ }
+ }
+ else if(t==PT_PRTI)
+ {
+ int temprange = 100;
+ int count =0;
+ for( temp = 0; temp < MAX_TEMP; temp += temprange)
+ if(parts[i].temp-73.15>temp&&parts[i].temp-73.15 <temp+temprange)
+ parts[i].tmp = temp/100;
+ for(ny=-1; ny<2; ny++)
for(nx=-1; nx<2; nx++)
if(x+nx>=0 && y+ny>0 &&
x+nx<XRES && y+ny<YRES && (nx || ny))
{
- count ++;
+ count ++;
r = pmap[y+ny][x+nx];
if((r>>8)>=NPART || !r)
continue;
- if(parts[r>>8].type==PT_SPRK || (parts[r>>8].type!=PT_PRTI && parts[r>>8].type!=PT_PRTO && (ptypes[parts[r>>8].type].falldown!= 0 || pstates[parts[r>>8].type].state == ST_GAS)))
- for( nnx=0;nnx<8;nnx++)
- if(!portal[parts[i].tmp][count-1][nnx])
- {
- portal[parts[i].tmp][count-1][nnx] = parts[r>>8].type;
- portaltemp[parts[i].tmp][count-1][nnx] = parts[r>>8].temp;
- if(parts[r>>8].type==PT_SPRK)
- parts[r>>8].type = parts[r>>8].ctype;
- else
- parts[r>>8].type = PT_NONE;
- break;
- }
- }
- }
- else if(t==PT_PRTO)
- {
- int temprange = 100;
- int count = 0;
- for( temp = 0; temp < MAX_TEMP; temp += temprange)
- if(parts[i].temp-73.15>temp&&parts[i].temp-73.15 <temp+temprange)
- parts[i].tmp = temp/100;
- for(ny=1; ny>-2; ny--)
+ if(parts[r>>8].type==PT_SPRK || (parts[r>>8].type!=PT_PRTI && parts[r>>8].type!=PT_PRTO && (ptypes[parts[r>>8].type].falldown!= 0 || pstates[parts[r>>8].type].state == ST_GAS)))
+ for( nnx=0; nnx<8; nnx++)
+ if(!portal[parts[i].tmp][count-1][nnx])
+ {
+ portal[parts[i].tmp][count-1][nnx] = parts[r>>8].type;
+ portaltemp[parts[i].tmp][count-1][nnx] = parts[r>>8].temp;
+ if(parts[r>>8].type==PT_SPRK)
+ parts[r>>8].type = parts[r>>8].ctype;
+ else
+ parts[r>>8].type = PT_NONE;
+ break;
+ }
+ }
+ }
+ else if(t==PT_PRTO)
+ {
+ int temprange = 100;
+ int count = 0;
+ for( temp = 0; temp < MAX_TEMP; temp += temprange)
+ if(parts[i].temp-73.15>temp&&parts[i].temp-73.15 <temp+temprange)
+ parts[i].tmp = temp/100;
+ for(ny=1; ny>-2; ny--)
for(nx=1; nx>-2; nx--)
if(x+nx>=0 && y+ny>0 &&
x+nx<XRES && y+ny<YRES && (nx || ny))
{
- count ++;
+ count ++;
r = pmap[y+ny][x+nx];
if((r>>8)>=NPART || r)
continue;
- if(!r)
- {
- for( nnx =0 ;nnx<8;nnx++)
- {
- int randomness = count + rand()%3-1;
- if(randomness<1)
- randomness=1;
- if(randomness>8)
- randomness=8;
- if(portal[parts[i].tmp][randomness-1][nnx]==PT_SPRK)//todo. make it look better
- {
- create_part(-1,x+1,y,portal[parts[i].tmp][randomness-1][nnx]);
- create_part(-1,x+1,y+1,portal[parts[i].tmp][randomness-1][nnx]);
- create_part(-1,x+1,y-1,portal[parts[i].tmp][randomness-1][nnx]);
- create_part(-1,x,y-1,portal[parts[i].tmp][randomness-1][nnx]);
- create_part(-1,x,y+1,portal[parts[i].tmp][randomness-1][nnx]);
- create_part(-1,x-1,y+1,portal[parts[i].tmp][randomness-1][nnx]);
- create_part(-1,x-1,y,portal[parts[i].tmp][randomness-1][nnx]);
- create_part(-1,x-1,y-1,portal[parts[i].tmp][randomness-1][nnx]);
- portal[parts[i].tmp][randomness-1][nnx] = 0;
- portaltemp[parts[i].tmp][randomness-1][nnx] = 0;
- break;
- }
- else if(portal[parts[i].tmp][randomness-1][nnx])
- {
- create_part(-1,x+nx,y+ny,portal[parts[i].tmp][randomness-1][nnx]);
- parts[pmap[y+ny][x+nx]>>8].temp = portaltemp[parts[i].tmp][randomness-1][nnx];
- portal[parts[i].tmp][randomness-1][nnx] = 0;
- portaltemp[parts[i].tmp][randomness-1][nnx] = 0;
- break;
- }
- }
- }
- }
- }
- else if(t==PT_WIFI)
- {
- int temprange = 100;
- for( temp = 0; temp < MAX_TEMP; temp += temprange)
- if(parts[i].temp-73.15>temp&&parts[i].temp-73.15 <temp+temprange)
- parts[i].tmp = temp/100;
- for(ny=-1; ny<2; ny++)
+ if(!r)
+ {
+ for( nnx =0 ; nnx<8; nnx++)
+ {
+ int randomness = count + rand()%3-1;
+ if(randomness<1)
+ randomness=1;
+ if(randomness>8)
+ randomness=8;
+ if(portal[parts[i].tmp][randomness-1][nnx]==PT_SPRK)//todo. make it look better
+ {
+ create_part(-1,x+1,y,portal[parts[i].tmp][randomness-1][nnx]);
+ create_part(-1,x+1,y+1,portal[parts[i].tmp][randomness-1][nnx]);
+ create_part(-1,x+1,y-1,portal[parts[i].tmp][randomness-1][nnx]);
+ create_part(-1,x,y-1,portal[parts[i].tmp][randomness-1][nnx]);
+ create_part(-1,x,y+1,portal[parts[i].tmp][randomness-1][nnx]);
+ create_part(-1,x-1,y+1,portal[parts[i].tmp][randomness-1][nnx]);
+ create_part(-1,x-1,y,portal[parts[i].tmp][randomness-1][nnx]);
+ create_part(-1,x-1,y-1,portal[parts[i].tmp][randomness-1][nnx]);
+ portal[parts[i].tmp][randomness-1][nnx] = 0;
+ portaltemp[parts[i].tmp][randomness-1][nnx] = 0;
+ break;
+ }
+ else if(portal[parts[i].tmp][randomness-1][nnx])
+ {
+ create_part(-1,x+nx,y+ny,portal[parts[i].tmp][randomness-1][nnx]);
+ parts[pmap[y+ny][x+nx]>>8].temp = portaltemp[parts[i].tmp][randomness-1][nnx];
+ portal[parts[i].tmp][randomness-1][nnx] = 0;
+ portaltemp[parts[i].tmp][randomness-1][nnx] = 0;
+ break;
+ }
+ }
+ }
+ }
+ }
+ else if(t==PT_WIFI)
+ {
+ int temprange = 100;
+ for( temp = 0; temp < MAX_TEMP; temp += temprange)
+ if(parts[i].temp-73.15>temp&&parts[i].temp-73.15 <temp+temprange)
+ parts[i].tmp = temp/100;
+ for(ny=-1; ny<2; ny++)
for(nx=-1; nx<2; nx++)
if(x+nx>=0 && y+ny>0 &&
x+nx<XRES && y+ny<YRES && (nx || ny))
@@ -3156,27 +3149,27 @@ void update_particles_i(pixel *vid, int start, int inc)
r = pmap[y+ny][x+nx];
if((r>>8)>=NPART || !r)
continue;
- if(parts[r>>8].type==PT_NSCN&&parts[r>>8].life==0 && wireless[parts[i].tmp][0])
- {
- parts[r>>8].type = PT_SPRK;
- parts[r>>8].ctype = PT_NSCN;
- parts[r>>8].life = 4;
- }
- else if(parts[r>>8].type==PT_PSCN&&parts[r>>8].life==0 && wireless[parts[i].tmp][0])
- {
- parts[r>>8].type = PT_SPRK;
- parts[r>>8].ctype = PT_PSCN;
- parts[r>>8].life = 4;
- }
- else if(parts[r>>8].type==PT_SPRK && parts[r>>8].ctype!=PT_NSCN && parts[r>>8].life>=3 && !wireless[parts[i].tmp][0])
- {
- //parts[r>>8].type = parts[r>>8].ctype;
- wireless[parts[i].tmp][0] = 1;
- wireless[parts[i].tmp][1] = 1;
- ISWIRE = 1;
- }
- }
- }
+ if(parts[r>>8].type==PT_NSCN&&parts[r>>8].life==0 && wireless[parts[i].tmp][0])
+ {
+ parts[r>>8].type = PT_SPRK;
+ parts[r>>8].ctype = PT_NSCN;
+ parts[r>>8].life = 4;
+ }
+ else if(parts[r>>8].type==PT_PSCN&&parts[r>>8].life==0 && wireless[parts[i].tmp][0])
+ {
+ parts[r>>8].type = PT_SPRK;
+ parts[r>>8].ctype = PT_PSCN;
+ parts[r>>8].life = 4;
+ }
+ else if(parts[r>>8].type==PT_SPRK && parts[r>>8].ctype!=PT_NSCN && parts[r>>8].life>=3 && !wireless[parts[i].tmp][0])
+ {
+ //parts[r>>8].type = parts[r>>8].ctype;
+ wireless[parts[i].tmp][0] = 1;
+ wireless[parts[i].tmp][1] = 1;
+ ISWIRE = 1;
+ }
+ }
+ }
else if(t==PT_PCLN)
{
for(nx=-2; nx<3; nx++)
@@ -3247,7 +3240,7 @@ void update_particles_i(pixel *vid, int start, int inc)
}
}
}
- else if(t==PT_PUMP)
+ else if(t==PT_PUMP)
{
for(nx=-2; nx<3; nx++)
for(ny=-2; ny<3; ny++)
@@ -3282,9 +3275,9 @@ void update_particles_i(pixel *vid, int start, int inc)
}
}
}
- else if(t==PT_SHLD1)
- {
- for(nx=-1; nx<2; nx++)
+ else if(t==PT_SHLD1)
+ {
+ 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))
@@ -3292,31 +3285,31 @@ void update_particles_i(pixel *vid, int start, int inc)
r = pmap[y+ny][x+nx];
if((r>>8)>=NPART || !r)
continue;
- else if(parts[r>>8].type==PT_SPRK&&parts[i].life==0)
- for( nnx=-1;nnx<2;nnx++)
- for( nny=-1;nny<2;nny++)
- {
- if(7>rand()%200&&parts[i].life==0)
- {
- t = parts[i].type = PT_SHLD2;
- parts[i].life = 7;
- }
- else if(!pmap[y+ny+nny][x+nx+nnx])
- {
- create_part(-1,x+nx+nnx,y+ny+nny,PT_SHLD1);
- //parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7;
- }
- }
- else if(parts[r>>8].type==PT_SHLD3&&4>rand()%10)
- {
- t = parts[i].type=PT_SHLD2;
- parts[i].life = 7;
- }
- }
- }
- else if(t==PT_SHLD2)
- {
- for(nx=-1; nx<2; nx++)
+ else if(parts[r>>8].type==PT_SPRK&&parts[i].life==0)
+ for( nnx=-1; nnx<2; nnx++)
+ for( nny=-1; nny<2; nny++)
+ {
+ if(7>rand()%200&&parts[i].life==0)
+ {
+ t = parts[i].type = PT_SHLD2;
+ parts[i].life = 7;
+ }
+ else if(!pmap[y+ny+nny][x+nx+nnx])
+ {
+ create_part(-1,x+nx+nnx,y+ny+nny,PT_SHLD1);
+ //parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7;
+ }
+ }
+ else if(parts[r>>8].type==PT_SHLD3&&4>rand()%10)
+ {
+ t = parts[i].type=PT_SHLD2;
+ parts[i].life = 7;
+ }
+ }
+ }
+ else if(t==PT_SHLD2)
+ {
+ 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))
@@ -3324,35 +3317,35 @@ void update_particles_i(pixel *vid, int start, int inc)
r = pmap[y+ny][x+nx];
if((r>>8)>=NPART)
continue;
- if(!r && parts[i].life>0)
- create_part(-1,x+nx,y+ny,PT_SHLD1);
- if(!r)
- continue;
- else if(parts[r>>8].type==PT_SPRK&&parts[i].life==0)
- for( nnx=-1;nnx<2;nnx++)
- for( nny=-1;nny<2;nny++)
- {
- if(3>rand()%200&&parts[i].life==0)
- {
- t = parts[i].type = PT_SHLD3;
- parts[i].life = 7;
- }
- else if(!pmap[y+ny+nny][x+nx+nnx])
- {
- create_part(-1,x+nx+nnx,y+ny+nny,PT_SHLD1);
- parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7;
- }
- }
- else if(parts[r>>8].type==PT_SHLD4&&4>rand()%10)
- {
- t = parts[i].type=PT_SHLD3;
- parts[i].life = 7;
- }
- }
- }
- else if(t==PT_SHLD3)
- {
- for(nx=-1; nx<2; nx++)
+ if(!r && parts[i].life>0)
+ create_part(-1,x+nx,y+ny,PT_SHLD1);
+ if(!r)
+ continue;
+ else if(parts[r>>8].type==PT_SPRK&&parts[i].life==0)
+ for( nnx=-1; nnx<2; nnx++)
+ for( nny=-1; nny<2; nny++)
+ {
+ if(3>rand()%200&&parts[i].life==0)
+ {
+ t = parts[i].type = PT_SHLD3;
+ parts[i].life = 7;
+ }
+ else if(!pmap[y+ny+nny][x+nx+nnx])
+ {
+ create_part(-1,x+nx+nnx,y+ny+nny,PT_SHLD1);
+ parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7;
+ }
+ }
+ else if(parts[r>>8].type==PT_SHLD4&&4>rand()%10)
+ {
+ t = parts[i].type=PT_SHLD3;
+ parts[i].life = 7;
+ }
+ }
+ }
+ else if(t==PT_SHLD3)
+ {
+ 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))
@@ -3360,43 +3353,43 @@ void update_particles_i(pixel *vid, int start, int inc)
r = pmap[y+ny][x+nx];
if((r>>8)>=NPART)
continue;
- if(!r)
- {
- if(1>rand()%2500)
- {
- create_part(-1,x+nx,y+ny,PT_SHLD1);
- parts[pmap[y+ny][x+nx]>>8].life=7;
- t = parts[i].type = PT_SHLD2;
- }
- else
- continue;
-
- }
- if(parts[r>>8].type==PT_SHLD1 && parts[i].life>3)
- {
- parts[r>>8].type = PT_SHLD2;
- parts[r>>8].life=7;
- }
- else if(parts[r>>8].type==PT_SPRK&&parts[i].life==0)
- for( nnx=-1;nnx<2;nnx++)
- for( nny=-1;nny<2;nny++)
- {
- if(2>rand()%3000&&parts[i].life==0)
- {
- t = parts[i].type = PT_SHLD4;
- parts[i].life = 7;
- }
- else if(!pmap[y+ny+nny][x+nx+nnx])
- {
- create_part(-1,x+nx+nnx,y+ny+nny,PT_SHLD1);
- parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7;
- }
- }
- }
- }
- else if(t==PT_SHLD4)
- {
- for(nx=-1; nx<2; nx++)
+ if(!r)
+ {
+ if(1>rand()%2500)
+ {
+ create_part(-1,x+nx,y+ny,PT_SHLD1);
+ parts[pmap[y+ny][x+nx]>>8].life=7;
+ t = parts[i].type = PT_SHLD2;
+ }
+ else
+ continue;
+
+ }
+ if(parts[r>>8].type==PT_SHLD1 && parts[i].life>3)
+ {
+ parts[r>>8].type = PT_SHLD2;
+ parts[r>>8].life=7;
+ }
+ else if(parts[r>>8].type==PT_SPRK&&parts[i].life==0)
+ for( nnx=-1; nnx<2; nnx++)
+ for( nny=-1; nny<2; nny++)
+ {
+ if(2>rand()%3000&&parts[i].life==0)
+ {
+ t = parts[i].type = PT_SHLD4;
+ parts[i].life = 7;
+ }
+ else if(!pmap[y+ny+nny][x+nx+nnx])
+ {
+ create_part(-1,x+nx+nnx,y+ny+nny,PT_SHLD1);
+ parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7;
+ }
+ }
+ }
+ }
+ else if(t==PT_SHLD4)
+ {
+ 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))
@@ -3404,35 +3397,35 @@ void update_particles_i(pixel *vid, int start, int inc)
r = pmap[y+ny][x+nx];
if((r>>8)>=NPART)
continue;
- if(!r)
- {
- if(1>rand()%5500)
- {
- create_part(-1,x+nx,y+ny,PT_SHLD1);
- parts[pmap[y+ny][x+nx]>>8].life=7;
- t = parts[i].type = PT_SHLD2;
- }
- else
- continue;
-
- }
- if(parts[r>>8].type==PT_SHLD2 && parts[i].life>3)
- {
- parts[r>>8].type = PT_SHLD3;
- parts[r>>8].life = 7;
- }
- else if(parts[r>>8].type==PT_SPRK&&parts[i].life==0)
- for( nnx=-1;nnx<2;nnx++)
- for( nny=-1;nny<2;nny++)
- {
- if(!pmap[y+ny+nny][x+nx+nnx])
- {
- create_part(-1,x+nx+nnx,y+ny+nny,PT_SHLD1);
- parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7;
- }
- }
- }
- }
+ if(!r)
+ {
+ if(1>rand()%5500)
+ {
+ create_part(-1,x+nx,y+ny,PT_SHLD1);
+ parts[pmap[y+ny][x+nx]>>8].life=7;
+ t = parts[i].type = PT_SHLD2;
+ }
+ else
+ continue;
+
+ }
+ if(parts[r>>8].type==PT_SHLD2 && parts[i].life>3)
+ {
+ parts[r>>8].type = PT_SHLD3;
+ parts[r>>8].life = 7;
+ }
+ else if(parts[r>>8].type==PT_SPRK&&parts[i].life==0)
+ for( nnx=-1; nnx<2; nnx++)
+ for( nny=-1; nny<2; nny++)
+ {
+ if(!pmap[y+ny+nny][x+nx+nnx])
+ {
+ create_part(-1,x+nx+nnx,y+ny+nny,PT_SHLD1);
+ parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7;
+ }
+ }
+ }
+ }
else if(t==PT_AMTR)
{
for(nx=-1; nx<2; nx++)
@@ -3451,7 +3444,7 @@ void update_particles_i(pixel *vid, int start, int inc)
{
parts[i].type = PT_NONE;
kill_part(i);
- goto killed;
+ goto killed;
}
parts[r>>8].life = 0;
parts[r>>8].type = PT_NONE;
@@ -3517,11 +3510,11 @@ void update_particles_i(pixel *vid, int start, int inc)
}
pv[y/CELL][x/CELL] += 20;
kill_part(i);
- goto killed;
+ goto killed;
} else if(parts[i].tmp>=3) {
if(parts[i].life<=0) {
kill_part(i);
- goto killed;
+ goto killed;
}
}
}
@@ -3570,11 +3563,11 @@ void update_particles_i(pixel *vid, int start, int inc)
parts[i].life = 10;
}
}
- else if(parts[r>>8].type == PT_SPRK && parts[r>>8].ctype==PT_SWCH && parts[i].life<10&&parts_avg(i,r>>8,PT_INSL)!=PT_INSL)
- {
- parts[r>>8].type = parts[r>>8].ctype;
- parts[r>>8].life = 9;
- }
+ else if(parts[r>>8].type == PT_SPRK && parts[r>>8].ctype==PT_SWCH && parts[i].life<10&&parts_avg(i,r>>8,PT_INSL)!=PT_INSL)
+ {
+ parts[r>>8].type = parts[r>>8].ctype;
+ parts[r>>8].life = 9;
+ }
}
}
if(t==PT_SWCH)
@@ -4174,7 +4167,7 @@ killed:
isplayer = 1;
}
- if(t==PT_STKM2)
+ if(t==PT_STKM2)
{
float dt = 0.9;///(FPSB*FPSB); //Delta time in square
//Tempirature handling
@@ -4564,24 +4557,24 @@ killed:
isplayer2 = 1;
}
- if(t==PT_SPAWN)
- {
- if(death==1)
- {
- playerspawn = create_part(-1,x,y,PT_STKM);
- isplayer = 1;
- }
- death = 0;
- }
- if(t==PT_SPAWN2)
- {
- if(death2==1)
- {
- player2spawn = create_part(-1,x,y,PT_STKM2);
- isplayer2 = 1;
- }
- death2 = 0;
- }
+ if(t==PT_SPAWN)
+ {
+ if(death==1)
+ {
+ playerspawn = create_part(-1,x,y,PT_STKM);
+ isplayer = 1;
+ }
+ death = 0;
+ }
+ if(t==PT_SPAWN2)
+ {
+ if(death2==1)
+ {
+ player2spawn = create_part(-1,x,y,PT_STKM2);
+ isplayer2 = 1;
+ }
+ death2 = 0;
+ }
if(t==PT_CLNE)
{
if(!parts[i].ctype)
@@ -4592,10 +4585,10 @@ killed:
x+nx<XRES && y+ny<YRES &&
pmap[y+ny][x+nx] &&
(pmap[y+ny][x+nx]&0xFF)!=PT_CLNE &&
- (pmap[y+ny][x+nx]&0xFF)!=PT_BCLN &&
- (pmap[y+ny][x+nx]&0xFF)!=PT_PCLN &&
+ (pmap[y+ny][x+nx]&0xFF)!=PT_BCLN &&
+ (pmap[y+ny][x+nx]&0xFF)!=PT_PCLN &&
(pmap[y+ny][x+nx]&0xFF)!=PT_STKM &&
- (pmap[y+ny][x+nx]&0xFF)!=PT_STKM2 &&
+ (pmap[y+ny][x+nx]&0xFF)!=PT_STKM2 &&
(pmap[y+ny][x+nx]&0xFF)!=0xFF)
parts[i].ctype = pmap[y+ny][x+nx]&0xFF;
}
@@ -4604,7 +4597,7 @@ killed:
}
}
- if(t==PT_BCLN)
+ if(t==PT_BCLN)
{
if(!parts[i].ctype)
{
@@ -4614,10 +4607,10 @@ killed:
x+nx<XRES && y+ny<YRES &&
pmap[y+ny][x+nx] &&
(pmap[y+ny][x+nx]&0xFF)!=PT_CLNE &&
- (pmap[y+ny][x+nx]&0xFF)!=PT_BCLN &&
- (pmap[y+ny][x+nx]&0xFF)!=PT_PCLN &&
+ (pmap[y+ny][x+nx]&0xFF)!=PT_BCLN &&
+ (pmap[y+ny][x+nx]&0xFF)!=PT_PCLN &&
(pmap[y+ny][x+nx]&0xFF)!=PT_STKM &&
- (pmap[y+ny][x+nx]&0xFF)!=PT_STKM2 &&
+ (pmap[y+ny][x+nx]&0xFF)!=PT_STKM2 &&
(pmap[y+ny][x+nx]&0xFF)!=0xFF)
parts[i].ctype = pmap[y+ny][x+nx]&0xFF;
}
@@ -4636,12 +4629,12 @@ killed:
pmap[y+ny][x+nx] &&
(pmap[y+ny][x+nx]&0xFF)!=PT_CLNE &&
(pmap[y+ny][x+nx]&0xFF)!=PT_PCLN &&
- (pmap[y+ny][x+nx]&0xFF)!=PT_BCLN &&
+ (pmap[y+ny][x+nx]&0xFF)!=PT_BCLN &&
(pmap[y+ny][x+nx]&0xFF)!=PT_SPRK &&
(pmap[y+ny][x+nx]&0xFF)!=PT_NSCN &&
(pmap[y+ny][x+nx]&0xFF)!=PT_PSCN &&
(pmap[y+ny][x+nx]&0xFF)!=PT_STKM &&
- (pmap[y+ny][x+nx]&0xFF)!=PT_STKM2 &&
+ (pmap[y+ny][x+nx]&0xFF)!=PT_STKM2 &&
(pmap[y+ny][x+nx]&0xFF)!=0xFF)
parts[i].ctype = pmap[y+ny][x+nx]&0xFF;
if(parts[i].ctype && parts[i].life==10) {
@@ -4656,13 +4649,13 @@ killed:
}
}
}
- else if(parts[i].ctype>77&&parts[i].ctype<77+NGOL) {
+ else if(parts[i].ctype>77&&parts[i].ctype<77+NGOL) {
for(nx=-1; nx<2; nx++) {
for(ny=-1; ny<2; ny++) {
create_part(-1, x+nx, y+ny, parts[i].ctype);
}
}
- }else {
+ } else {
create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype);
}
}
@@ -4899,14 +4892,14 @@ killed:
continue;
}
} else {
- if(t!=PT_NEUT)
- kill_part(i);
+ if(t!=PT_NEUT)
+ kill_part(i);
continue;
}
if(!parts[i].ctype) {
- if(t!=PT_NEUT)
- kill_part(i);
+ if(t!=PT_NEUT)
+ kill_part(i);
continue;
}
}
@@ -4975,7 +4968,7 @@ void update_particles(pixel *vid)
if(t!=PT_NEUT || (pmap[y][x]&0xFF)!=PT_GLAS)
pmap[y][x] = t|(i<<8);
}
- NUM_PARTS ++;
+ NUM_PARTS ++;
}
else
{
@@ -5486,8 +5479,8 @@ void update_particles(pixel *vid)
void rotate_area(int area_x, int area_y, int area_w, int area_h, int invert)
{
- //TODO: MSCC doesn't like arrays who's size is determined at runtime.
- #if !(defined(WIN32) && !defined(__GNUC__))
+ //TODO: MSCC doesn't like arrays who's size is determined at runtime.
+#if !(defined(WIN32) && !defined(__GNUC__))
int cx = 0;
int cy = 0;
unsigned tpmap[area_h][area_w];
@@ -5498,57 +5491,57 @@ void rotate_area(int area_x, int area_y, int area_w, int area_h, int invert)
{
for(cx=0; cx<area_w; cx++)//save walls to temp
{
- if(area_x + cx<XRES&&area_y + cy<YRES)
- {
- if(bmap[(cy+area_y)/CELL][(cx+area_x)/CELL])
- tbmap[cy/CELL][cx/CELL] = bmap[(cy+area_y)/CELL][(cx+area_x)/CELL];
- else
- tbmap[cy/CELL][cx/CELL] = 0;
- }
+ if(area_x + cx<XRES&&area_y + cy<YRES)
+ {
+ if(bmap[(cy+area_y)/CELL][(cx+area_x)/CELL])
+ tbmap[cy/CELL][cx/CELL] = bmap[(cy+area_y)/CELL][(cx+area_x)/CELL];
+ else
+ tbmap[cy/CELL][cx/CELL] = 0;
+ }
}
}
for(cy=0; cy<area_h; cy++)
{
for(cx=0; cx<area_w; cx++)//save particles to temp
{
- if((area_x + cx<XRES&&area_y + cy<YRES))
- {
- tpmap[cy][cx] = pmap[(int)(cy+area_y+0.5f)][(int)(cx+area_x+0.5f)];
- }
- else
- tpmap[(int)(cy+0.5f)][(int)(cx+0.5f)] = 0;
+ if((area_x + cx<XRES&&area_y + cy<YRES))
+ {
+ tpmap[cy][cx] = pmap[(int)(cy+area_y+0.5f)][(int)(cx+area_x+0.5f)];
+ }
+ else
+ tpmap[(int)(cy+0.5f)][(int)(cx+0.5f)] = 0;
}
}
for(cy=0; cy<area_w; cy++)
{
for(cx=0; cx<area_h; cx++)//rotate temp arrays
{
- if(invert)
- {
- rtbmap[cy/CELL][((area_h-1)-cx)/CELL] = tbmap[cy/CELL][cx/CELL];
- rtpmap[cy][(area_h-1)-cx] = tpmap[(int)(cy+0.5f)][(int)(cx+0.5f)];
- }
- else
- {
- rtbmap[((area_h-1)-cx)/CELL][cy/CELL] = tbmap[cy/CELL][cx/CELL];
- rtpmap[(area_h-1)-cx][cy] = tpmap[(int)(cy+0.5f)][(int)(cx+0.5f)];
- }
- }
+ if(invert)
+ {
+ rtbmap[cy/CELL][((area_h-1)-cx)/CELL] = tbmap[cy/CELL][cx/CELL];
+ rtpmap[cy][(area_h-1)-cx] = tpmap[(int)(cy+0.5f)][(int)(cx+0.5f)];
+ }
+ else
+ {
+ rtbmap[((area_h-1)-cx)/CELL][cy/CELL] = tbmap[cy/CELL][cx/CELL];
+ rtpmap[(area_h-1)-cx][cy] = tpmap[(int)(cy+0.5f)][(int)(cx+0.5f)];
+ }
+ }
}
for(cy=0; cy<area_w; cy++)
{
for(cx=0; cx<area_h; cx++)//move particles and walls
{
- if(area_x + cx<XRES&&area_y + cy<YRES)
- {
- if((rtpmap[cy][cx]>>8)<=NPART&&rtpmap[cy][cx])
- {
- parts[rtpmap[(int)(cy+0.5f)][(int)(cx+0.5f)]>>8].x = area_x +cx;
- parts[rtpmap[(int)(cy+0.5f)][(int)(cx+0.5f)]>>8].y = area_y +cy;
- }
- bmap[(area_y+cy)/CELL][(area_x+cx)/CELL] = rtbmap[cy/CELL][cx/CELL];
- }
- }
+ if(area_x + cx<XRES&&area_y + cy<YRES)
+ {
+ if((rtpmap[cy][cx]>>8)<=NPART&&rtpmap[cy][cx])
+ {
+ parts[rtpmap[(int)(cy+0.5f)][(int)(cx+0.5f)]>>8].x = area_x +cx;
+ parts[rtpmap[(int)(cy+0.5f)][(int)(cx+0.5f)]>>8].y = area_y +cy;
+ }
+ bmap[(area_y+cy)/CELL][(area_x+cx)/CELL] = rtbmap[cy/CELL][cx/CELL];
+ }
+ }
}
#endif
}
@@ -5592,21 +5585,21 @@ int flood_parts(int x, int y, int c, int cm, int bm)
int x1, x2, dy = (c<PT_NUM)?1:CELL;
int co = c;
if(cm==PT_INST&&co==PT_SPRK)
- if((pmap[y][x]&0xFF)==PT_SPRK)
- return 0;
+ if((pmap[y][x]&0xFF)==PT_SPRK)
+ return 0;
if(c>=UI_WALLSTART&&c<=UI_WALLSTART+UI_WALLCOUNT)
{
c = c-100;
}
if(cm==-1)
{
- if(c==0)
+ if(c==0)
{
cm = pmap[y][x]&0xFF;
if(!cm)
return 0;
- if(REPLACE_MODE && cm!=SLALT)
- return 0;
+ if(REPLACE_MODE && cm!=SLALT)
+ return 0;
}
else
cm = 0;
@@ -5633,17 +5626,17 @@ int flood_parts(int x, int y, int c, int cm, int bm)
while(x1>=CELL)
{
if((pmap[y][x1-1]&0xFF)!=cm || bmap[y/CELL][(x1-1)/CELL]!=bm)
- {
- break;
- }
+ {
+ break;
+ }
x1--;
}
while(x2<XRES-CELL)
{
if((pmap[y][x2+1]&0xFF)!=cm || bmap[y/CELL][(x2+1)/CELL]!=bm)
- {
- break;
- }
+ {
+ break;
+ }
x2++;
}
@@ -5656,70 +5649,70 @@ int flood_parts(int x, int y, int c, int cm, int bm)
// fill children
if(cm==PT_INST&&co==PT_SPRK)//wire crossing for INST
{
- if(y>=CELL+dy && x1==x2 &&
- ((pmap[y-1][x1-1]&0xFF)==PT_INST||(pmap[y-1][x1-1]&0xFF)==PT_SPRK) && ((pmap[y-1][x1]&0xFF)==PT_INST||(pmap[y-1][x1]&0xFF)==PT_SPRK) && ((pmap[y-1][x1+1]&0xFF)==PT_INST || (pmap[y-1][x1+1]&0xFF)==PT_SPRK) &&
- (pmap[y-2][x1-1]&0xFF)!=PT_INST && ((pmap[y-2][x1]&0xFF)==PT_INST ||(pmap[y-2][x1]&0xFF)==PT_SPRK) && (pmap[y-2][x1+1]&0xFF)!=PT_INST)
- flood_parts(x1, y-2, co, cm, bm);
- else if(y>=CELL+dy)
- for(x=x1; x<=x2; x++)
- if((pmap[y-1][x]&0xFF)!=PT_SPRK)
- {
- if(x==x1 || x==x2 || y>=YRES-CELL-1 ||
- (pmap[y-1][x-1]&0xFF)==PT_INST || (pmap[y-1][x+1]&0xFF)==PT_INST ||
- (pmap[y+1][x-1]&0xFF)==PT_INST || ((pmap[y+1][x]&0xFF)!=PT_INST&&(pmap[y+1][x]&0xFF)!=PT_SPRK) || (pmap[y+1][x+1]&0xFF)==PT_INST)
- flood_parts(x, y-dy, co, cm, bm);
+ if(y>=CELL+dy && x1==x2 &&
+ ((pmap[y-1][x1-1]&0xFF)==PT_INST||(pmap[y-1][x1-1]&0xFF)==PT_SPRK) && ((pmap[y-1][x1]&0xFF)==PT_INST||(pmap[y-1][x1]&0xFF)==PT_SPRK) && ((pmap[y-1][x1+1]&0xFF)==PT_INST || (pmap[y-1][x1+1]&0xFF)==PT_SPRK) &&
+ (pmap[y-2][x1-1]&0xFF)!=PT_INST && ((pmap[y-2][x1]&0xFF)==PT_INST ||(pmap[y-2][x1]&0xFF)==PT_SPRK) && (pmap[y-2][x1+1]&0xFF)!=PT_INST)
+ flood_parts(x1, y-2, co, cm, bm);
+ else if(y>=CELL+dy)
+ for(x=x1; x<=x2; x++)
+ if((pmap[y-1][x]&0xFF)!=PT_SPRK)
+ {
+ if(x==x1 || x==x2 || y>=YRES-CELL-1 ||
+ (pmap[y-1][x-1]&0xFF)==PT_INST || (pmap[y-1][x+1]&0xFF)==PT_INST ||
+ (pmap[y+1][x-1]&0xFF)==PT_INST || ((pmap[y+1][x]&0xFF)!=PT_INST&&(pmap[y+1][x]&0xFF)!=PT_SPRK) || (pmap[y+1][x+1]&0xFF)==PT_INST)
+ flood_parts(x, y-dy, co, cm, bm);
- }
+ }
- if(y<YRES-CELL-dy && x1==x2 &&
- ((pmap[y+1][x1-1]&0xFF)==PT_INST||(pmap[y+1][x1-1]&0xFF)==PT_SPRK) && ((pmap[y+1][x1]&0xFF)==PT_INST||(pmap[y+1][x1]&0xFF)==PT_SPRK) && ((pmap[y+1][x1+1]&0xFF)==PT_INST || (pmap[y+1][x1+1]&0xFF)==PT_SPRK) &&
- (pmap[y+2][x1-1]&0xFF)!=PT_INST && ((pmap[y+2][x1]&0xFF)==PT_INST ||(pmap[y+2][x1]&0xFF)==PT_SPRK) && (pmap[y+2][x1+1]&0xFF)!=PT_INST)
- flood_parts(x1, y+2, co, cm, bm);
- else if(y<YRES-CELL-dy)
+ if(y<YRES-CELL-dy && x1==x2 &&
+ ((pmap[y+1][x1-1]&0xFF)==PT_INST||(pmap[y+1][x1-1]&0xFF)==PT_SPRK) && ((pmap[y+1][x1]&0xFF)==PT_INST||(pmap[y+1][x1]&0xFF)==PT_SPRK) && ((pmap[y+1][x1+1]&0xFF)==PT_INST || (pmap[y+1][x1+1]&0xFF)==PT_SPRK) &&
+ (pmap[y+2][x1-1]&0xFF)!=PT_INST && ((pmap[y+2][x1]&0xFF)==PT_INST ||(pmap[y+2][x1]&0xFF)==PT_SPRK) && (pmap[y+2][x1+1]&0xFF)!=PT_INST)
+ flood_parts(x1, y+2, co, cm, bm);
+ else if(y<YRES-CELL-dy)
for(x=x1; x<=x2; x++)
- if((pmap[y+1][x]&0xFF)!=PT_SPRK)
- {
- if(x==x1 || x==x2 || y<0 ||
- (pmap[y+1][x-1]&0xFF)==PT_INST || (pmap[y+1][x+1]&0xFF)==PT_INST ||
- (pmap[y-1][x-1]&0xFF)==PT_INST || ((pmap[y-1][x]&0xFF)!=PT_INST&&(pmap[y-1][x]&0xFF)!=PT_SPRK) || (pmap[y-1][x+1]&0xFF)==PT_INST)
- flood_parts(x, y+dy, co, cm, bm);
-
- }
+ if((pmap[y+1][x]&0xFF)!=PT_SPRK)
+ {
+ if(x==x1 || x==x2 || y<0 ||
+ (pmap[y+1][x-1]&0xFF)==PT_INST || (pmap[y+1][x+1]&0xFF)==PT_INST ||
+ (pmap[y-1][x-1]&0xFF)==PT_INST || ((pmap[y-1][x]&0xFF)!=PT_INST&&(pmap[y-1][x]&0xFF)!=PT_SPRK) || (pmap[y-1][x+1]&0xFF)==PT_INST)
+ flood_parts(x, y+dy, co, cm, bm);
+
+ }
}
else
{
- if(y>=CELL+dy)
- for(x=x1; x<=x2; x++)
- if((pmap[y-dy][x]&0xFF)==cm && bmap[(y-dy)/CELL][x/CELL]==bm)
- if(!flood_parts(x, y-dy, co, cm, bm))
- return 0;
- if(y<YRES-CELL-dy)
- for(x=x1; x<=x2; x++)
- if((pmap[y+dy][x]&0xFF)==cm && bmap[(y+dy)/CELL][x/CELL]==bm)
- if(!flood_parts(x, y+dy, co, cm, bm))
- return 0;
+ if(y>=CELL+dy)
+ for(x=x1; x<=x2; x++)
+ if((pmap[y-dy][x]&0xFF)==cm && bmap[(y-dy)/CELL][x/CELL]==bm)
+ if(!flood_parts(x, y-dy, co, cm, bm))
+ return 0;
+ if(y<YRES-CELL-dy)
+ for(x=x1; x<=x2; x++)
+ if((pmap[y+dy][x]&0xFF)==cm && bmap[(y+dy)/CELL][x/CELL]==bm)
+ if(!flood_parts(x, y+dy, co, cm, bm))
+ return 0;
}
if(!(cm==PT_INST&&co==PT_SPRK))
- return 1;
+ return 1;
}
int create_parts(int x, int y, int rx, int ry, int c)
{
int i, j, r, f = 0, u, v, oy, ox, b = 0, dw = 0, stemp = 0;//n;
-
+
int wall = c - 100;
- for(r=UI_ACTUALSTART;r<=UI_ACTUALSTART+UI_WALLCOUNT;r++)
+ for(r=UI_ACTUALSTART; r<=UI_ACTUALSTART+UI_WALLCOUNT; r++)
{
- if(wall==r)
- {
- if(c == SPC_AIR || c == SPC_HEAT || c == SPC_COOL || c == SPC_VACUUM)
- break;
- if(wall == WL_ERASE)
- b = 0;
- else
- b = wall;
- dw = 1;
- }
+ if(wall==r)
+ {
+ if(c == SPC_AIR || c == SPC_HEAT || c == SPC_COOL || c == SPC_VACUUM)
+ break;
+ if(wall == WL_ERASE)
+ b = 0;
+ else
+ b = wall;
+ dw = 1;
+ }
}
if(c == WL_FANHELPER)
{
@@ -5741,68 +5734,68 @@ int create_parts(int x, int y, int rx, int ry, int c)
{
i = ox;
j = oy;
- if(((sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))|| sdl_mod & (KMOD_CAPS) ))
- {
- if(bmap[j][i]==SLALT-100)
- b = 0;
- else
- continue;
- }
+ if(((sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))|| sdl_mod & (KMOD_CAPS) ))
+ {
+ if(bmap[j][i]==SLALT-100)
+ b = 0;
+ else
+ continue;
+ }
if(b==WL_FAN)
{
fvx[j][i] = 0.0f;
fvy[j][i] = 0.0f;
}
- if(b==WL_STREAM)
- {
- i = x + rx/2;
- j = y + rx/2;
- for(v=-1; v<2; v++)
- for(u=-1; u<2; u++)
- if(i+u>=0 && i+u<XRES/CELL &&
- j+v>=0 && j+v<YRES/CELL &&
- bmap[j+v][i+u] == WL_STREAM)
- return 1;
- bmap[j][i] = WL_STREAM;
- continue;
- }
+ if(b==WL_STREAM)
+ {
+ i = x + rx/2;
+ j = y + rx/2;
+ for(v=-1; v<2; v++)
+ for(u=-1; u<2; u++)
+ if(i+u>=0 && i+u<XRES/CELL &&
+ j+v>=0 && j+v<YRES/CELL &&
+ bmap[j+v][i+u] == WL_STREAM)
+ return 1;
+ bmap[j][i] = WL_STREAM;
+ continue;
+ }
bmap[j][i] = b;
}
}
}
return 1;
}
-
+
if(((sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))|| sdl_mod & (KMOD_CAPS) )&& !REPLACE_MODE)
- {
+ {
for(j=-ry; j<=ry; j++)
for(i=-rx; i<=rx; i++)
if((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx))
delete_part(x+i, y+j);
return 1;
- }
+ }
if(c == SPC_AIR || c == SPC_HEAT || c == SPC_COOL || c == SPC_VACUUM)
{
for(j=-ry; j<=ry; j++)
for(i=-rx; i<=rx; i++)
if((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx))
- if(!REPLACE_MODE)
- create_part(-2, x+i, y+j, c);
- else if((pmap[y+j][x+i]&0xFF)==SLALT&&SLALT!=0)
- create_part(-2, x+i, y+j, c);
+ if(!REPLACE_MODE)
+ create_part(-2, x+i, y+j, c);
+ else if((pmap[y+j][x+i]&0xFF)==SLALT&&SLALT!=0)
+ create_part(-2, x+i, y+j, c);
return 1;
}
if(c == 0 && !REPLACE_MODE)
{
- stemp = SLALT;
- SLALT = 0;
+ stemp = SLALT;
+ SLALT = 0;
for(j=-ry; j<=ry; j++)
for(i=-rx; i<=rx; i++)
if((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx))
delete_part(x+i, y+j);
- SLALT = stemp;
+ SLALT = stemp;
return 1;
}
if(REPLACE_MODE)
@@ -5810,18 +5803,18 @@ int create_parts(int x, int y, int rx, int ry, int c)
for(j=-ry; j<=ry; j++)
for(i=-rx; i<=rx; i++)
if((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx))
- {
- if((pmap[y+j][x+i]&0xFF)!=SLALT&&SLALT!=0)
- continue;
- if((pmap[y+j][x+i]))
- {
- delete_part(x+i, y+j);
- if(c!=0)
- create_part(-2, x+i, y+j, c);
- }
- }
- return 1;
-
+ {
+ if((pmap[y+j][x+i]&0xFF)!=SLALT&&SLALT!=0)
+ continue;
+ if((pmap[y+j][x+i]))
+ {
+ delete_part(x+i, y+j);
+ if(c!=0)
+ create_part(-2, x+i, y+j, c);
+ }
+ }
+ return 1;
+
}
for(j=-ry; j<=ry; j++)
for(i=-rx; i<=rx; i++)