summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon <simon@hardwired.org.uk>2010-12-05 15:49:48 (GMT)
committer Simon <simon@hardwired.org.uk>2010-12-05 15:49:48 (GMT)
commit40ab51d79f68eaef88defee0e3cf1de5cfb0b0b0 (patch)
treefffbf3f7b503d36829dd91cde10cb39abb7ca5e8 /src
parent6ecc177c8ff8a90b5c4fc996090bd1de915237ab (diff)
downloadpowder-40ab51d79f68eaef88defee0e3cf1de5cfb0b0b0.zip
powder-40ab51d79f68eaef88defee0e3cf1de5cfb0b0b0.tar.gz
Cracker64 merge
Diffstat (limited to 'src')
-rw-r--r--src/air.c25
-rw-r--r--src/graphics.c456
-rw-r--r--src/interface.c169
-rw-r--r--src/main.c259
-rw-r--r--src/misc.c2
-rw-r--r--src/powder.c1834
6 files changed, 2318 insertions, 427 deletions
diff --git a/src/air.c b/src/air.c
index 385abef..04141e2 100644
--- a/src/air.c
+++ b/src/air.c
@@ -54,15 +54,15 @@ void update_air(void)
vy[y][x] *= VLOSS;
vx[y][x] += dx*TSTEPV;
vy[y][x] += dy*TSTEPV;
- if(bmap[y][x]==1 || bmap[y][x+1]==1 ||
- bmap[y][x]==8 || bmap[y][x+1]==8 ||
- (bmap[y][x]==7 && !emap[y][x]) ||
- (bmap[y][x+1]==7 && !emap[y][x+1]))
+ if(bmap[y][x]==WL_WALL || bmap[y][x+1]==WL_WALL ||
+ bmap[y][x]==WL_WALLELEC || bmap[y][x+1]==WL_WALLELEC ||
+ (bmap[y][x]==WL_EWALL && !emap[y][x]) ||
+ (bmap[y][x+1]==WL_EWALL && !emap[y][x+1]))
vx[y][x] = 0;
- if(bmap[y][x]==1 || bmap[y+1][x]==1 ||
- bmap[y][x]==8 || bmap[y+1][x]==8 ||
- (bmap[y][x]==7 && !emap[y][x]) ||
- (bmap[y+1][x]==7 && !emap[y+1][x]))
+ if(bmap[y][x]==WL_WALL || bmap[y+1][x]==WL_WALL ||
+ bmap[y][x]==WL_WALLELEC || bmap[y+1][x]==WL_WALLELEC ||
+ (bmap[y][x]==WL_EWALL && !emap[y][x]) ||
+ (bmap[y+1][x]==WL_EWALL && !emap[y+1][x]))
vy[y][x] = 0;
}
@@ -76,9 +76,9 @@ void update_air(void)
for(i=-1; i<2; i++)
if(y+j>0 && y+j<YRES/CELL-1 &&
x+i>0 && x+i<XRES/CELL-1 &&
- bmap[y+j][x+i]!=1 &&
- bmap[y+j][x+i]!=8 &&
- (bmap[y+j][x+i]!=7 || emap[y+j][x+i]))
+ bmap[y+j][x+i]!=WL_WALL &&
+ bmap[y+j][x+i]!=WL_WALLELEC &&
+ (bmap[y+j][x+i]!=WL_EWALL || emap[y+j][x+i]))
{
f = kernel[i+1+(j+1)*3];
dx += vx[y+j][x+i]*f;
@@ -118,13 +118,12 @@ void update_air(void)
dy += VADV*tx*ty*vy[j+1][i+1];
}
- if(bmap[y][x] == 4)
+ if(bmap[y][x] == WL_FAN)
{
dx += fvx[y][x];
dy += fvy[y][x];
}
- //Pressure Caps, remove for lulz
if(dp > 256.0f) dp = 256.0f;
if(dp < -256.0f) dp = -256.0f;
if(dx > 256.0f) dx = 256.0f;
diff --git a/src/graphics.c b/src/graphics.c
index 67a1324..5476bf7 100644
--- a/src/graphics.c
+++ b/src/graphics.c
@@ -21,7 +21,7 @@
#include <misc.h>
-unsigned cmode = 3;
+unsigned cmode = CM_FIRE;
SDL_Surface *sdl_scrn;
int sdl_scale = 1;
@@ -447,7 +447,7 @@ void draw_tool(pixel *vid_buf, int b, int sl, int sr, unsigned pc, unsigned iswa
int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc)
{
int i, j, c;
- if(b>=121)
+ if(b>=UI_WALLSTART)
{
b = b-100;
//x = (2+32*((b-22)/1));
@@ -470,7 +470,7 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc)
}
}
break;
- case 23:
+ case WL_EWALL:
for(j=1; j<15; j++)
{
for(i=1; i<6+j; i++)
@@ -489,7 +489,7 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc)
}
}
break;
- case 24:
+ case WL_DETECT:
for(j=1; j<15; j+=2)
{
for(i=1+(1&(j>>1)); i<27; i+=2)
@@ -498,7 +498,7 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc)
}
}
break;
- case 25:
+ case WL_STREAM:
for(j=1; j<15; j++)
{
for(i=1; i<27; i++)
@@ -512,7 +512,7 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc)
drawpixel(vid_buf, x+i, y+8+(int)(3.9f*cos(i*0.3f)), 255, 255, 255, 255);
}
break;
- case 26:
+ case WL_SIGN:
for(j=1; j<15; j++)
{
for(i=1; i<27; i++)
@@ -523,7 +523,7 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc)
drawtext(vid_buf, x+9, y+3, "\xA1", 32, 64, 128, 255);
drawtext(vid_buf, x+9, y+3, "\xA0", 255, 255, 255, 255);
break;
- case 27:
+ case WL_FAN:
for(j=1; j<15; j+=2)
{
for(i=1+(1&(j>>1)); i<27; i+=2)
@@ -532,7 +532,7 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc)
}
}
break;
- case 28:
+ case WL_ALLOWLIQUID:
for(j=1; j<15; j++)
{
for(i=1; i<27; i++)
@@ -544,7 +544,7 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc)
}
}
break;
- case 29:
+ case WL_DESTROYALL:
for(j=1; j<15; j+=2)
{
for(i=1+(1&(j>>1)); i<27; i+=2)
@@ -553,7 +553,7 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc)
}
}
break;
- case 30:
+ case WL_ERASE:
for(j=1; j<15; j+=2)
{
for(i=1+(1&(j>>1)); i<13; i+=2)
@@ -569,7 +569,7 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc)
}
}
break;
- case 32:
+ case WL_ALLOWAIR:
for(j=1; j<15; j+=2)
{
for(i=1+(1&(j>>1)); i<27; i+=2)
@@ -578,7 +578,7 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc)
}
}
break;
- case 33:
+ case WL_ALLOWSOLID:
for(j=1; j<15; j+=2)
{
for(i=1+(1&(j>>1)); i<27; i+=2)
@@ -587,7 +587,7 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc)
}
}
break;
- case 34:
+ case WL_ALLOWALLELEC:
for(j=1; j<15; j++)
{
for(i=1; i<27; i++)
@@ -599,7 +599,7 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc)
}
}
break;
- case 36:
+ case SPC_AIR-100:
for(j=1; j<15; j++)
{
for(i=1; i<27; i++)
@@ -618,7 +618,7 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc)
}
drawtext(vid_buf, x+14-textwidth("AIR")/2, y+4, "AIR", c, c, c, 255);
break;
- case 37:
+ case SPC_HEAT-100:
for(j=1; j<15; j++)
{
for(i=1; i<27; i++)
@@ -637,7 +637,7 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc)
}
drawtext(vid_buf, x+14-textwidth("HEAT")/2, y+4, "HEAT", c, c, c, 255);
break;
- case 38:
+ case SPC_COOL-100:
for(j=1; j<15; j++)
{
for(i=1; i<27; i++)
@@ -656,7 +656,7 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc)
}
drawtext(vid_buf, x+14-textwidth("COOL")/2, y+4, "COOL", c, c, c, 255);
break;
- case 39:
+ case SPC_VACUUM-100:
for(j=1; j<15; j++)
{
for(i=1; i<27; i++)
@@ -675,7 +675,7 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc)
}
drawtext(vid_buf, x+14-textwidth("VAC")/2, y+4, "VAC", c, c, c, 255);
break;
- case 40:
+ case WL_ALLOWGAS:
for(j=1; j<15; j+=2)
{
for(i=1+(1&(j>>1)); i<27; i+=2)
@@ -693,7 +693,7 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc)
}
}
}
- if(b==30)
+ if(b==WL_ERASE)
{
for(j=4; j<12; j++)
{
@@ -745,7 +745,10 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc)
void draw_menu(pixel *vid_buf, int i, int hover)
{
- drawrect(vid_buf, (XRES+BARSIZE)-16, (i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16), 14, 14, 255, 255, 255, 255);
+ if(i==SEC&&SEC!=0)
+ drawrect(vid_buf, (XRES+BARSIZE)-16, (i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16), 14, 14, 0, 255, 255, 255);
+ else
+ drawrect(vid_buf, (XRES+BARSIZE)-16, (i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16), 14, 14, 255, 255, 255, 255);
if(hover==i)
{
fillrect(vid_buf, (XRES+BARSIZE)-16, (i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16), 14, 14, 255, 255, 255, 255);
@@ -1107,23 +1110,56 @@ void draw_air(pixel *vid)
int x, y, i, j;
pixel c;
- if(cmode == 2)
+ if(cmode == CM_PERS)
return;
for(y=0; y<YRES/CELL; y++)
for(x=0; x<XRES/CELL; x++)
{
- if(cmode)
+ if(cmode == CM_PRESS)
{
if(pv[y][x] > 0.0f)
c = PIXRGB(clamp_flt(pv[y][x], 0.0f, 8.0f), 0, 0);
else
c = PIXRGB(0, 0, clamp_flt(-pv[y][x], 0.0f, 8.0f));
}
- else
+ else if(cmode == CM_VEL)
+ {
c = PIXRGB(clamp_flt(fabsf(vx[y][x]), 0.0f, 8.0f),
clamp_flt(pv[y][x], 0.0f, 8.0f),
clamp_flt(fabsf(vy[y][x]), 0.0f, 8.0f));
+ }
+ else if(cmode == CM_CRACK)
+ {
+ int r;
+ int g;
+ int b;
+ r = clamp_flt(fabsf(vx[y][x]), 0.0f, 24.0f) + clamp_flt(fabsf(vy[y][x]), 0.0f, 20.0f);
+ g = clamp_flt(fabsf(vx[y][x]), 0.0f, 20.0f) + clamp_flt(fabsf(vy[y][x]), 0.0f, 24.0f);
+ b = clamp_flt(fabsf(vx[y][x]), 0.0f, 24.0f) + clamp_flt(fabsf(vy[y][x]), 0.0f, 20.0f);
+ if(pv[y][x] > 0.0f)
+ {
+ r += clamp_flt(pv[y][x], 0.0f, 16.0f);
+ if(r>255)
+ r=255;
+ if(g>255)
+ g=255;
+ if(b>255)
+ b=255;
+ c = PIXRGB(r, g, b);
+ }
+ else
+ {
+ b += clamp_flt(-pv[y][x], 0.0f, 16.0f);
+ if(r>255)
+ r=255;
+ if(g>255)
+ g=255;
+ if(b>255)
+ b=255;
+ c = PIXRGB(r, g, b);
+ }
+ }
for(j=0; j<CELL; j++)
for(i=0; i<CELL; i++)
vid[(x*CELL+i) + (y*CELL+j)*(XRES+BARSIZE)] = c;
@@ -1268,9 +1304,20 @@ void draw_parts(pixel *vid)
int cr, cg, cb;
float fr, fg, fb;
float pt = R_TEMP;
+ if(GRID_MODE)
+ {
+ for(ny=0;ny<YRES;ny++)
+ for(nx=0;nx<XRES;nx++)
+ {
+ if(ny%(4*GRID_MODE)==0)
+ blendpixel(vid, nx, ny, 100, 100, 100, 80);
+ if(nx%(4*GRID_MODE)==0)
+ blendpixel(vid, nx, ny, 100, 100, 100, 80);
+ }
+ }
for(i = 0; i<NPART; i++) {
#ifdef OpenGL
- if(cmode == 6) //If fire mode
+ if(cmode == CM_FANCY) //If fancy mode
{
if(t==PT_MWAX)
@@ -1328,7 +1375,6 @@ void draw_parts(pixel *vid)
nx = (int)(parts[i].x+0.5f);
ny = (int)(parts[i].y+0.5f);
-
if(cmode!=CM_HEAT)
{
if(t==PT_STKM) //Just draw head here
@@ -1356,7 +1402,37 @@ void draw_parts(pixel *vid)
isplayer = 1; //It's a secret. Tssss...
}
- if(t==PT_MWAX&&cmode == 6)
+ if(cmode==CM_NOTHING && t!=PT_PIPE && t!=PT_SWCH && t!=PT_LCRY && t!=PT_PUMP)//nothing display but show needed color changes
+ {
+ cr = PIXR(ptypes[t].pcolors);
+ cg = PIXG(ptypes[t].pcolors);
+ cb = PIXB(ptypes[t].pcolors);
+ blendpixel(vid, nx, ny, cr, cg, cb, 255);
+ }
+ if(cmode==CM_GRAD)
+ {
+ float frequency = 0.05;
+ int q = parts[i].temp;
+ cr = sin(frequency*q) * 16 + PIXR(ptypes[t].pcolors);
+ cg = sin(frequency*q) * 16 + PIXG(ptypes[t].pcolors);
+ cb = sin(frequency*q) * 16 + PIXB(ptypes[t].pcolors);
+ if(cr>=255)
+ cr = 255;
+ if(cg>=255)
+ cg = 255;
+ if(cb>=255)
+ cb = 255;
+ if(cr<=0)
+ cr = 0;
+ if(cg<=0)
+ cg = 0;
+ if(cb<=0)
+ cb = 0;
+ blendpixel(vid, nx, ny, cr, cg, cb, 255);
+
+
+ }
+ else if(t==PT_MWAX&&cmode == CM_FANCY)
{
for(x=-1; x<=1; x++)
{
@@ -1372,6 +1448,189 @@ void draw_parts(pixel *vid)
}
}
+ else if(t==PT_CRAC)
+ {
+ cr = PIXR(ptypes[t].pcolors) - parts[i].life*15;
+ cg = PIXG(ptypes[t].pcolors) - parts[i].life*15;
+ cb = PIXB(ptypes[t].pcolors) - parts[i].life*15;
+ if(cr<=50)
+ cr = 50;
+ if(cg<=50)
+ cg = 50;
+ if(cb<=20)
+ cb = 20;
+ blendpixel(vid, nx, ny, cr, cg, cb, 255);
+
+ }
+ else if(t==PT_DEUT)
+ {
+
+ if(parts[i].life>=700&&(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY))
+ {
+ x = nx/CELL;
+ y = ny/CELL;
+ cr = 20;
+ cg = 20;
+ cb = 20;
+ cg += fire_g[y][x];
+ if(cg > 255) cg = 255;
+ fire_g[y][x] = cg;
+ cb += fire_b[y][x];
+ if(cb > 255) cb = 255;
+ fire_b[y][x] = cb;
+ cr += fire_r[y][x];
+ if(cr > 255) cr = 255;
+ fire_r[y][x] = cr;
+ }
+ else
+ {
+ cr = PIXR(ptypes[t].pcolors) + parts[i].life*1;
+ cg = PIXG(ptypes[t].pcolors) + parts[i].life*2;
+ cb = PIXB(ptypes[t].pcolors) + parts[i].life*4;
+ if(cr>=255)
+ cr = 255;
+ if(cg>=255)
+ cg = 255;
+ if(cb>=255)
+ cb = 255;
+ blendpixel(vid, nx, ny, cr, cg, cb, 255);
+
+ }
+
+ }
+ else if(t==PT_DUST && parts[i].life >= 1)
+ {
+ x = nx;
+ y = ny;
+ if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY)
+ {
+ vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(parts[i].tmp,parts[i].ctype,parts[i].flags);
+ cg = parts[i].tmp/4;
+ cb = parts[i].ctype/4;
+ cr = parts[i].flags/4;
+ x = nx/CELL;
+ y = ny/CELL;
+ cg += fire_g[y][x];
+ if(cg > 255) cg = 255;
+ fire_g[y][x] = cg;
+ cb += fire_b[y][x];
+ if(cb > 255) cb = 255;
+ fire_b[y][x] = cb;
+ cr += fire_r[y][x];
+ if(cr > 255) cr = 255;
+ fire_r[y][x] = cr;
+ }
+ else
+ blendpixel(vid,x,y,parts[i].tmp,parts[i].ctype,parts[i].flags,255);
+ }
+ else if(t==PT_GRAV)
+ {
+ cr = 20;
+ cg = 20;
+ cb = 20;
+ if(parts[i].vx>0)
+ {
+ cr += (parts[i].vx)*GRAV_R;
+ cg += (parts[i].vx)*GRAV_G;
+ cb += (parts[i].vx)*GRAV_B;
+ }
+ if(parts[i].vy>0)
+ {
+ cr += (parts[i].vy)*GRAV_G;
+ cg += (parts[i].vy)*GRAV_B;
+ cb += (parts[i].vy)*GRAV_R;
+
+ }
+ if(parts[i].vx<0)
+ {
+ cr -= (parts[i].vx)*GRAV_B;
+ cg -= (parts[i].vx)*GRAV_R;
+ cb -= (parts[i].vx)*GRAV_G;
+
+ }
+ if(parts[i].vy<0)
+ {
+ cr -= (parts[i].vy)*GRAV_R2;
+ cg -= (parts[i].vy)*GRAV_G2;
+ cb -= (parts[i].vy)*GRAV_B2;
+ }
+ if(cr>255)
+ cr=255;
+ if(cg>255)
+ cg=255;
+ if(cb>255)
+ cb=255;
+ blendpixel(vid, nx, ny, cr, cg, cb, 255);
+ }
+ else if(t==PT_WIFI)
+ {
+ float frequency = 0.25;
+ int q = parts[i].tmp;
+ cr = sin(frequency*q + 0) * 127 + 128;
+ cg = sin(frequency*q + 2) * 127 + 128;
+ cb = sin(frequency*q + 4) * 127 + 128;
+ blendpixel(vid, nx, ny, cr, cg, cb, 255);
+ }
+ else if(t==PT_PIPE)
+ {
+ if(parts[i].ctype==2)
+ {
+ cr = 50;
+ cg = 1;
+ cb = 1;
+ }
+ else if(parts[i].ctype==3)
+ {
+ cr = 1;
+ cg = 50;
+ cb = 1;
+ }
+ else if(parts[i].ctype==4)
+ {
+ cr = 1;
+ cg = 1;
+ cb = 50;
+ }
+ else if(parts[i].temp<272.15&&parts[i].ctype!=1)
+ {
+ if(parts[i].temp>173.25&&parts[i].temp<273.15)
+ {
+ cr = 50;
+ cg = 1;
+ cb = 1;
+ }
+ if(parts[i].temp>73.25&&parts[i].temp<=173.15)
+ {
+ cr = 1;
+ cg = 50;
+ cb = 1;
+ }
+ if(parts[i].temp>=0&&parts[i].temp<=73.15)
+ {
+ cr = 1;
+ cg = 1;
+ cb = 50;
+ }
+ }
+ else
+ {
+ cr = PIXR(ptypes[t].pcolors);
+ cg = PIXG(ptypes[t].pcolors);
+ cb = PIXB(ptypes[t].pcolors);
+ }
+ if(parts[i].tmp)
+ {
+ cr = PIXR(ptypes[parts[i].tmp].pcolors);
+ cg = PIXG(ptypes[parts[i].tmp].pcolors);
+ cb = PIXB(ptypes[parts[i].tmp].pcolors);
+ }
+ blendpixel(vid, nx, ny, cr, cg, cb, 255);
+
+
+
+ }
+ else if(t==PT_INVIS && (pv[ny/CELL][nx/CELL]>4.0f ||pv[ny/CELL][nx/CELL]<-4.0f))
+ blendpixel(vid, nx, ny, 15, 0, 150, 100);
else if(t==PT_ACID)
{
if(parts[i].life>255) parts[i].life = 255;
@@ -1381,7 +1640,7 @@ void draw_parts(pixel *vid)
cr = PIXR(ptypes[t].pcolors)/s;
cg = PIXG(ptypes[t].pcolors)/s;
cb = PIXB(ptypes[t].pcolors)/s;
- if(cmode==6) {
+ if(cmode==CM_FANCY) {
for(x=-1; x<=1; x++)
{
for(y=-1; y<=1; y++)
@@ -1396,7 +1655,7 @@ void draw_parts(pixel *vid)
blendpixel(vid, nx, ny, cr, cg, cb, 255);
}
- if(cmode==4)
+ if(cmode==CM_BLOB)
{
blendpixel(vid, nx+1, ny, cr, cg, cb, 223);
blendpixel(vid, nx-1, ny, cr, cg, cb, 223);
@@ -1409,7 +1668,7 @@ void draw_parts(pixel *vid)
blendpixel(vid, nx-1, ny+1, cr, cg, cb, 112);
}
}
- else if(t==PT_OIL&&cmode == 6)
+ else if(t==PT_OIL&&cmode == CM_FANCY)
{
for(x=-1; x<=1; x++)
{
@@ -1424,7 +1683,7 @@ void draw_parts(pixel *vid)
}
else if(t==PT_NEUT)
{
- if(cmode == 3||cmode==4 || cmode==6)
+ if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY)
{
vid[ny*(XRES+BARSIZE)+nx] = ptypes[t].pcolors;
cg = 8;
@@ -1453,7 +1712,7 @@ void draw_parts(pixel *vid)
blendpixel(vid, nx+1, ny+1, cr, cg, cb, 32);
blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32);
}
- } else if(t==PT_PLUT&&cmode == 6)
+ } else if(t==PT_PLUT&&cmode == CM_FANCY)
{
int tempx;
int tempy;
@@ -1473,7 +1732,7 @@ void draw_parts(pixel *vid)
blendpixel(vid, nx-tempx, ny-tempy, cr, cg, cb, 5);
}
}
- } else if(t==PT_URAN&&cmode == 6)
+ } else if(t==PT_URAN&&cmode == CM_FANCY)
{
int tempx;
int tempy;
@@ -1493,7 +1752,7 @@ void draw_parts(pixel *vid)
blendpixel(vid, nx-tempx, ny-tempy, cr, cg, cb, 5);
}
}
- } else if(t==PT_SLTW&&cmode == 6)
+ } else if(t==PT_SLTW&&cmode == CM_FANCY)
{
for(x=-1; x<=1; x++)
{
@@ -1506,9 +1765,33 @@ void draw_parts(pixel *vid)
}
}
}
+ else if(t==PT_FILT)
+ {
+ int temp_bin = (int)((parts[i].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;
+ cg = 0;
+ cb = 0;
+ cr = 0;
+ for(x=0; x<12; x++) {
+ cr += (parts[i].ctype >> (x+18)) & 1;
+ cb += (parts[i].ctype >> x) & 1;
+ }
+ for(x=0; x<14; x++)
+ cg += (parts[i].ctype >> (x+9)) & 1;
+ x = 624/(cr+cg+cb+1);
+ cr *= x;
+ cg *= x;
+ cb *= x;
+ cr = cr>255?255:cr;
+ cg = cg>255?255:cg;
+ cb = cb>255?255:cb;
+ blendpixel(vid, nx, ny, cr, cg, cb, 127);
+ }
else if(t==PT_PHOT)
{
- if(cmode == 3||cmode==4 || cmode==6)
+ if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY)
{
cg = 0;
cb = 0;
@@ -1575,7 +1858,7 @@ void draw_parts(pixel *vid)
y = ny;
blendpixel(vid,x,y,17,217,24,255);
}
- else if(t==PT_LNTG&&cmode == 6)
+ else if(t==PT_LNTG&&cmode == CM_FANCY)
{
for(x=-1; x<=1; x++)
{
@@ -1590,7 +1873,7 @@ void draw_parts(pixel *vid)
}
else if(t==PT_SMKE)
{
- if(cmode == 3||cmode==4 || cmode==6)
+ if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY)
{
x = nx/CELL;
y = ny/CELL;
@@ -1623,7 +1906,7 @@ void draw_parts(pixel *vid)
}
}
}
- else if(t==PT_WATR&&cmode == 6)
+ else if(t==PT_WATR&&cmode == CM_FANCY)
{
for(x=-1; x<=1; x++)
{
@@ -1636,7 +1919,7 @@ void draw_parts(pixel *vid)
}
}
- } else if(t==PT_DSTW&&cmode == 6)
+ } else if(t==PT_DSTW&&cmode == CM_FANCY)
{
for(x=-1; x<=1; x++)
{
@@ -1649,7 +1932,7 @@ void draw_parts(pixel *vid)
}
}
}
- else if(t==PT_NITR&&cmode == 6)
+ else if(t==PT_NITR&&cmode == CM_FANCY)
{
for(x=-1; x<=1; x++)
{
@@ -1663,7 +1946,7 @@ void draw_parts(pixel *vid)
}
}
- else if(t==PT_LRBD&&cmode == 6)
+ else if(t==PT_LRBD&&cmode == CM_FANCY)
{
for(x=-1; x<=1; x++)
{
@@ -1678,7 +1961,7 @@ void draw_parts(pixel *vid)
}
- else if(t==PT_NBLE&&cmode == 6)
+ else if(t==PT_NBLE&&cmode == CM_FANCY)
{
for(x=-1; x<=1; x++)
{
@@ -1694,7 +1977,7 @@ void draw_parts(pixel *vid)
}
}
- else if(t==PT_GAS&&cmode == 6)
+ else if(t==PT_GAS&&cmode == CM_FANCY)
{
for(x=-1; x<=1; x++)
{
@@ -1712,7 +1995,7 @@ void draw_parts(pixel *vid)
}
else if(t==PT_WTRV)
{
- if(cmode == 3||cmode==4 || cmode==6)
+ if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY)
{
x = nx/CELL;
y = ny/CELL;
@@ -1747,7 +2030,7 @@ void draw_parts(pixel *vid)
}
else if(t==PT_THDR)
{
- if(cmode == 3||cmode==4 || cmode==6)
+ if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY)
{
vid[ny*(XRES+BARSIZE)+nx] = ptypes[t].pcolors;
cg = 16;
@@ -1792,7 +2075,7 @@ void draw_parts(pixel *vid)
fr = 2 * pv[ny/CELL][nx/CELL];
}
vid[ny*(XRES+BARSIZE)+nx] = PIXRGB((int)restrict_flt(0x44 + fr*8, 0, 255), (int)restrict_flt(0x88 + fg*8, 0, 255), (int)restrict_flt(0x44 + fb*8, 0, 255));
- if(cmode == 3||cmode==4 || cmode==6)
+ if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY)
{
x = nx/CELL;
y = ny/CELL;
@@ -1806,7 +2089,7 @@ void draw_parts(pixel *vid)
if(fr > 255) fr = 255;
fire_r[y][x] = fr;
}
- if(cmode == 4) {
+ if(cmode == CM_BLOB) {
uint8 R = (int)restrict_flt(0x44 + fr*8, 0, 255);
uint8 G = (int)restrict_flt(0x88 + fg*8, 0, 255);
uint8 B = (int)restrict_flt(0x44 + fb*8, 0, 255);
@@ -1826,7 +2109,7 @@ void draw_parts(pixel *vid)
{
uint8 GR = 0x50+(parts[i].life*10);
vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(GR, GR, GR);
- if(cmode == 4) {
+ if(cmode == CM_BLOB) {
blendpixel(vid, nx+1, ny, GR, GR, GR, 223);
blendpixel(vid, nx-1, ny, GR, GR, GR, 223);
blendpixel(vid, nx, ny+1, GR, GR, GR, 223);
@@ -1842,7 +2125,7 @@ void draw_parts(pixel *vid)
{
uint8 GR = 0x3B+(parts[i].life*19);
vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(GR, GR, 10);
- if(cmode == 4) {
+ if(cmode == CM_BLOB) {
blendpixel(vid, nx+1, ny, GR, GR, 10, 223);
blendpixel(vid, nx-1, ny, GR, GR, 10, 223);
blendpixel(vid, nx, ny+1, GR, GR, 10, 223);
@@ -1858,7 +2141,7 @@ void draw_parts(pixel *vid)
{
uint8 GR = 0x3B+(parts[i].life*19);
vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(GR, 10, 10);
- if(cmode == 4) {
+ if(cmode == CM_BLOB) {
blendpixel(vid, nx+1, ny, GR, 10, 10, 223);
blendpixel(vid, nx-1, ny, GR, 10, 10, 223);
blendpixel(vid, nx, ny+1, GR, 10, 10, 223);
@@ -1870,6 +2153,22 @@ void draw_parts(pixel *vid)
blendpixel(vid, nx-1, ny+1, GR, 10, 10, 112);
}
}
+ else if(t==PT_PUMP)
+ {
+ uint8 GR = 0x3B+(parts[i].life*19);
+ vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(10, 10, GR);
+ if(cmode == CM_BLOB) {
+ blendpixel(vid, nx+1, ny, 10, 10, GR, 223);
+ blendpixel(vid, nx-1, ny, 10, 10, GR, 223);
+ blendpixel(vid, nx, ny+1, 10, 10, GR, 223);
+ blendpixel(vid, nx, ny-1, 10, 10, GR, 223);
+
+ blendpixel(vid, nx+1, ny-1, 10, 10, GR, 112);
+ blendpixel(vid, nx-1, ny-1, 10, 10, GR, 112);
+ blendpixel(vid, nx+1, ny+1, 10, 10, GR, 112);
+ blendpixel(vid, nx-1, ny+1, 10, 10, GR, 112);
+ }
+ }
else if(t==PT_PLSM)
{
float ttemp = (float)parts[i].life;
@@ -1877,7 +2176,7 @@ void draw_parts(pixel *vid)
uint8 R = plasma_data[caddress];
uint8 G = plasma_data[caddress+1];
uint8 B = plasma_data[caddress+2];
- if(cmode == 3||cmode==4 || cmode==6)
+ if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY)
{
cr = R/8;
cg = G/8;
@@ -1916,7 +2215,7 @@ void draw_parts(pixel *vid)
uint8 R = hflm_data[caddress];
uint8 G = hflm_data[caddress+1];
uint8 B = hflm_data[caddress+2];
- if(cmode == 3||cmode==4 || cmode==6)
+ if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY)
{
cr = R/8;
cg = G/8;
@@ -1955,7 +2254,7 @@ void draw_parts(pixel *vid)
uint8 R = firw_data[caddress];
uint8 G = firw_data[caddress+1];
uint8 B = firw_data[caddress+2];
- if(cmode == 3||cmode==4 || cmode==6)
+ if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY)
{
cr = R/2;
cg = G/2;
@@ -1995,7 +2294,7 @@ void draw_parts(pixel *vid)
uint8 R = flm_data[caddress];
uint8 G = flm_data[caddress+1];
uint8 B = flm_data[caddress+2];
- if(cmode == 3||cmode==4 || cmode==6)
+ if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY)
{
cr = R/8;
cg = G/8;
@@ -2083,7 +2382,7 @@ void draw_parts(pixel *vid)
blendpixel(vid, nx-1, ny, cr, cg, cb, 64);
blendpixel(vid, nx, ny+1, cr, cg, cb, 64);
blendpixel(vid, nx, ny-1, cr, cg, cb, 64);
- if(cmode == 3||cmode==4 || cmode==6)
+ if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY)
{
cr /= 32;
cg /= 32;
@@ -2104,7 +2403,7 @@ void draw_parts(pixel *vid)
else if(t==PT_LAVA || t==PT_SPRK)
{
vid[ny*(XRES+BARSIZE)+nx] = ptypes[t].pcolors;
- if(cmode == 3 || cmode==4 || cmode==6)
+ if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY)
{
if(t == PT_LAVA)
{
@@ -2173,7 +2472,7 @@ void draw_parts(pixel *vid)
//blendpixel(vid, nx+1, ny, R, G, B, 255);
}
}
- if(cmode == 4&&t!=PT_FIRE&&t!=PT_PLSM&&t!=PT_HFLM&&t!=PT_NONE&&t!=PT_ACID&&t!=PT_LCRY&&t!=PT_GLOW&&t!=PT_SWCH&&t!=PT_SMKE&&t!=PT_WTRV&&!(t==PT_FIRW&&parts[i].tmp==3))
+ if(cmode == CM_BLOB&&t!=PT_FIRE&&t!=PT_PLSM&&t!=PT_HFLM&&t!=PT_NONE&&t!=PT_ACID&&t!=PT_LCRY&&t!=PT_GLOW&&t!=PT_SWCH&&t!=PT_SMKE&&t!=PT_WTRV&&!(t==PT_FIRW&&parts[i].tmp==3))
{
if(t==PT_PHOT) {
cg = 0;
@@ -2223,7 +2522,7 @@ void draw_parts(pixel *vid)
void render_signs(pixel *vid_buf)
{
- int i, j, x, y, w, h, dx, dy;
+ int i, j, x, y, w, h, dx, dy,mx,my,b=1,bq;
char buff[30]; //Buffer
for(i=0; i<MAXSIGNS; i++)
if(signs[i].text[0])
@@ -2238,7 +2537,6 @@ void render_signs(pixel *vid_buf)
sprintf(buff, "Pressure: %3.2f", pv[signs[i].y/CELL][signs[i].x/CELL]); //...pressure
drawtext(vid_buf, x+3, y+3, buff, 255, 255, 255, 255);
}
-
if(strcmp(signs[i].text, "{t}")==0)
{
if((pmap[signs[i].y][signs[i].x]>>8)>0 && (pmap[signs[i].y][signs[i].x]>>8)<NPART)
@@ -2251,6 +2549,7 @@ void render_signs(pixel *vid_buf)
//Usual text
if(strcmp(signs[i].text, "{p}") && strcmp(signs[i].text, "{t}"))
drawtext(vid_buf, x+3, y+3, signs[i].text, 255, 255, 255, 255);
+
x = signs[i].x;
y = signs[i].y;
dx = 1 - signs[i].ju;
@@ -2261,6 +2560,15 @@ void render_signs(pixel *vid_buf)
x+=dx;
y+=dy;
}
+ if(MSIGN==i)
+ {
+ bq = b;
+ b = SDL_GetMouseState(&mx, &my);
+ mx /= sdl_scale;
+ my /= sdl_scale;
+ signs[i].x = mx;
+ signs[i].y = my;
+ }
}
}
@@ -2630,17 +2938,33 @@ corrupt:
return 1;
}
-void render_cursor(pixel *vid, int x, int y, int t, int r)
+void render_cursor(pixel *vid, int x, int y, int t, int rx, int ry)
{
- int i,j,c;
+ int i,j,c;
if(t<PT_NUM||t==SPC_AIR||t==SPC_HEAT||t==SPC_COOL||t==SPC_VACUUM)
{
- if(r<=0)
+ if(rx<=0)
xor_pixel(x, y, vid);
- else
- for(j=0; j<=r; j++)
- for(i=0; i<=r; i++)
- if(i*i+j*j<=r*r && ((i+1)*(i+1)+j*j>r*r || i*i+(j+1)*(j+1)>r*r))
+ else if(ry<=0)
+ xor_pixel(x, y, vid);
+ if(rx+ry<=0)
+ xor_pixel(x, y, vid);
+ else if(CURRENT_BRUSH==SQUARE_BRUSH)
+ {
+ for(j=0; j<=ry; j++)
+ for(i=0; i<=rx; i++)
+ if(i*j<=ry*rx && ((i+1)>rx || (j+1)>ry))
+ {
+ xor_pixel(x+i, y+j, vid);
+ xor_pixel(x-i, y-j, vid);
+ if(i&&j)xor_pixel(x+i, y-j, vid);
+ if(i&&j)xor_pixel(x-i, y+j, vid);
+ }
+ }
+ else if(CURRENT_BRUSH==CIRCLE_BRUSH)
+ for(j=0; j<=ry; j++)
+ for(i=0; i<=rx; i++)
+ if((pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1 && ((pow(i+1,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))>1 || (pow(i,2))/(pow(rx,2))+(pow(j+1,2))/(pow(ry,2))>1))
{
xor_pixel(x+i, y+j, vid);
if(j) xor_pixel(x+i, y-j, vid);
@@ -2651,7 +2975,7 @@ void render_cursor(pixel *vid, int x, int y, int t, int r)
else
{
int tc;
- c = (r/CELL) * CELL;
+ c = (rx/CELL) * CELL;
x = (x/CELL) * CELL;
y = (y/CELL) * CELL;
diff --git a/src/interface.c b/src/interface.c
index 00aa020..044b65c 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -101,11 +101,16 @@ void add_sign_ui(pixel *vid_buf, int mx, int my)
int i, w, h, x, y, nm=0, ju;
int x0=(XRES-192)/2,y0=(YRES-80)/2,b=1,bq;
ui_edit ed;
-
+
// check if it is an existing sign
for(i=0; i<MAXSIGNS; i++)
if(signs[i].text[0])
{
+ if(i == MSIGN)
+ {
+ MSIGN = -1;
+ return;
+ }
get_sign_pos(i, &x, &y, &w, &h);
if(mx>=x && mx<=x+w && my>=y && my<=y+h)
break;
@@ -120,7 +125,6 @@ void add_sign_ui(pixel *vid_buf, int mx, int my)
}
if(i >= MAXSIGNS)
return;
-
if(nm)
{
signs[i].x = mx;
@@ -166,12 +170,18 @@ void add_sign_ui(pixel *vid_buf, int mx, int my)
draw_icon(vid_buf, x0+68, y0+42, 0x9E, ju == 1);
draw_icon(vid_buf, x0+86, y0+42, 0x9F, ju == 2);
+
+
+
+
if(!nm)
{
drawtext(vid_buf, x0+138, y0+45, "\x86", 160, 48, 32, 255);
drawtext(vid_buf, x0+138, y0+45, "\x85", 255, 255, 255, 255);
drawtext(vid_buf, x0+152, y0+46, "Delete", 255, 255, 255, 255);
drawrect(vid_buf, x0+134, y0+42, 50, 15, 255, 255, 255, 255);
+ drawrect(vid_buf,x0+104,y0+42,26,15,255,255,255,255);
+ drawtext(vid_buf, x0+110, y0+48, "Mv.", 255, 255, 255, 255);
}
drawtext(vid_buf, x0+5, y0+69, "OK", 255, 255, 255, 255);
@@ -188,6 +198,11 @@ void add_sign_ui(pixel *vid_buf, int mx, int my)
if(b && !bq && mx>=x0+86 && mx<=x0+103 && my>=y0+42 && my<=y0+59)
ju = 2;
+ if(!nm && b && !bq && mx>=x0+104 && mx<=x0+130 && my>=y0+42 && my<=y0+59)
+ {
+ MSIGN = i;
+ break;
+ }
if(b && !bq && mx>=x0+9 && mx<x0+23 && my>=y0+22 && my<y0+36)
break;
if(b && !bq && mx>=x0 && mx<x0+192 && my>=y0+64 && my<=y0+80)
@@ -513,28 +528,37 @@ void draw_svf_ui(pixel *vid_buf)
switch(cmode)
{
- case 0:
+ case CM_VEL:
drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x98", 128, 160, 255, 255);
break;
- case 1:
+ case CM_PRESS:
drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x99", 255, 212, 32, 255);
break;
- case 2:
+ case CM_PERS:
drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x9A", 212, 212, 212, 255);
break;
- case 3:
+ case CM_FIRE:
drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x9B", 255, 0, 0, 255);
drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x9C", 255, 255, 64, 255);
break;
- case 4:
+ case CM_BLOB:
drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xBF", 55, 255, 55, 255);
break;
- case 5:
+ case CM_HEAT:
drawtext(vid_buf, XRES-27+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xBE", 255, 0, 0, 255);
drawtext(vid_buf, XRES-27+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xBD", 255, 255, 255, 255);
break;
- case 6:
+ case CM_FANCY:
drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xC4", 100, 150, 255, 255);
+ break;
+ case CM_NOTHING:
+ drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x00", 100, 150, 255, 255);
+ break;
+ case CM_CRACK:
+ drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x00", 100, 150, 255, 255);
+ break;
+ case CM_GRAD:
+ drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x00", 100, 150, 255, 255);
break;
}
drawrect(vid_buf, XRES-32+BARSIZE/*478*/, YRES+(MENUSIZE-16), 14, 14, 255, 255, 255, 255);
@@ -1460,32 +1484,42 @@ void menu_ui(pixel *vid_buf, int i, int *sl, int *sr)
void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx, int my)
{
int h,x,y,n=0,height,width,sy,rows=0;
+ SEC = SEC2;
mx /= sdl_scale;
my /= sdl_scale;
rows = ceil((float)msections[i].itemcount/16.0f);
height = (ceil((float)msections[i].itemcount/16.0f)*18);
width = restrict_flt(msections[i].itemcount*31, 0, 16*31);
h = -1;
- x = XRES-BARSIZE-26;
+ x = XRES-BARSIZE-18;
y = YRES+1;
sy = y;
if(i==SC_WALL)
{
- for(n = 122; n<122+UI_WALLCOUNT; n++)
+ for(n = UI_WALLSTART; n<UI_WALLSTART+UI_WALLCOUNT; n++)
{
if(n!=SPC_AIR&&n!=SPC_HEAT&&n!=SPC_COOL&&n!=SPC_VACUUM)
{
- if(x-26<=20)
+ if(x-18<=20)
{
- x = XRES-BARSIZE-26;
+ x = XRES-BARSIZE-18;
y += 19;
}
- x -= draw_tool_xy(vid_buf, x, y, n, mwalls[n-122].colour)+5;
+ x -= draw_tool_xy(vid_buf, x, y, n, mwalls[n-UI_WALLSTART].colour)+5;
if(!bq && mx>=x+32 && mx<x+58 && my>=y && my< y+15)
{
drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255);
h = n;
}
+ if(!bq && mx>=x+32 && mx<x+58 && my>=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT)))
+ {
+ drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255);
+ h = n;
+ }
+ else if(n==SLALT)
+ {
+ drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255);
+ }
else if(n==*sl)
{
drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255);
@@ -1499,21 +1533,30 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx,
}
else if(i==SC_SPECIAL)
{
- for(n = 122; n<122+UI_WALLCOUNT; n++)
+ for(n = UI_WALLSTART; n<UI_WALLSTART+UI_WALLCOUNT; n++)
{
if(n==SPC_AIR||n==SPC_HEAT||n==SPC_COOL||n==SPC_VACUUM)
{
- if(x-26<=20)
+ if(x-18<=20)
{
- x = XRES-BARSIZE-26;
+ x = XRES-BARSIZE-18;
y += 19;
}
- x -= draw_tool_xy(vid_buf, x, y, n, mwalls[n-122].colour)+5;
+ x -= draw_tool_xy(vid_buf, x, y, n, mwalls[n-UI_WALLSTART].colour)+5;
if(!bq && mx>=x+32 && mx<x+58 && my>=y && my< y+15)
{
drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255);
h = n;
}
+ if(!bq && mx>=x+32 && mx<x+58 && my>=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT)))
+ {
+ drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255);
+ h = n;
+ }
+ else if(n==SLALT)
+ {
+ drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255);
+ }
else if(n==*sl)
{
drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255);
@@ -1528,9 +1571,9 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx,
{
if(ptypes[n].menusection==i&&ptypes[n].menu==1)
{
- if(x-26<=20)
+ if(x-18<=20)
{
- x = XRES-BARSIZE-26;
+ x = XRES-BARSIZE-18;
y += 19;
}
x -= draw_tool_xy(vid_buf, x, y, n, ptypes[n].pcolors)+5;
@@ -1539,6 +1582,15 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx,
drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255);
h = n;
}
+ if(!bq && mx>=x+32 && mx<x+58 && my>=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT)))
+ {
+ drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255);
+ h = n;
+ }
+ else if(n==SLALT)
+ {
+ drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255);
+ }
else if(n==*sl)
{
drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255);
@@ -1556,9 +1608,9 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx,
{
if(ptypes[n].menusection==i&&ptypes[n].menu==1)
{
- if(x-26<=20)
+ if(x-18<=20)
{
- x = XRES-BARSIZE-26;
+ x = XRES-BARSIZE-18;
y += 19;
}
x -= draw_tool_xy(vid_buf, x, y, n, ptypes[n].pcolors)+5;
@@ -1567,6 +1619,15 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx,
drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255);
h = n;
}
+ if(!bq && mx>=x+32 && mx<x+58 && my>=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT)))
+ {
+ drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255);
+ h = n;
+ }
+ else if(n==SLALT)
+ {
+ drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255);
+ }
else if(n==*sl)
{
drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255);
@@ -1578,27 +1639,64 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx,
}
}
}
+ if(!bq&&mx>=sdl_scale*((XRES+BARSIZE)-16) && mx<sdl_scale*(XRES+BARSIZE-1) &&my>= sdl_scale*((i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16)) && my<sdl_scale*((i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16)+15))
+ {
+
+ if(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))
+ if(i>=0&&i<SC_TOTAL)
+ SEC = i;
+ }
if(h==-1)
{
drawtext(vid_buf, XRES-textwidth((char *)msections[i].name)-BARSIZE, sy-10, (char *)msections[i].name, 255, 255, 255, 255);
}
- else if(i==SC_WALL||(i==SC_SPECIAL&&h>=122))
+ else if(i==SC_WALL||(i==SC_SPECIAL&&h>=UI_WALLSTART))
{
- drawtext(vid_buf, XRES-textwidth((char *)mwalls[h-122].descs)-BARSIZE, sy-10, (char *)mwalls[h-122].descs, 255, 255, 255, 255);
+ drawtext(vid_buf, XRES-textwidth((char *)mwalls[h-UI_WALLSTART].descs)-BARSIZE, sy-10, (char *)mwalls[h-UI_WALLSTART].descs, 255, 255, 255, 255);
}
else
{
drawtext(vid_buf, XRES-textwidth((char *)ptypes[h].descs)-BARSIZE, sy-10, (char *)ptypes[h].descs, 255, 255, 255, 255);
}
+ if(b==1&&h==-1)
+ {
+ if(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT) && SEC>=0)
+ {
+ SLALT = -1;
+ SEC2 = SEC;
+ }
+ }
if(b==1&&h!=-1)
{
- *sl = h;
+ if(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))
+ {
+ SLALT = h;
+ SEC2 = -1;
+ }
+ else{
+ *sl = h;
+ }
+ }
+ if(b==4&&h==-1)
+ {
+ if(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT) && SEC>=0)
+ {
+ SLALT = -1;
+ SEC2 = SEC;
+ }
}
if(b==4&&h!=-1)
{
- *sr = h;
+ if(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))
+ {
+ SLALT = h;
+ SEC2 = -1;
+ }
+ else{
+ *sr = h;
+ }
}
}
@@ -1685,38 +1783,44 @@ void set_cmode(int cm)
{
cmode = cm;
itc = 51;
- if(cmode==4)
+ if(cmode==CM_BLOB)
{
memset(fire_r, 0, sizeof(fire_r));
memset(fire_g, 0, sizeof(fire_g));
memset(fire_b, 0, sizeof(fire_b));
strcpy(itc_msg, "Blob Display");
}
- else if(cmode==5)
+ else if(cmode==CM_HEAT)
{
strcpy(itc_msg, "Heat Display");
}
- else if(cmode==6)
+ else if(cmode==CM_FANCY)
{
memset(fire_r, 0, sizeof(fire_r));
memset(fire_g, 0, sizeof(fire_g));
memset(fire_b, 0, sizeof(fire_b));
strcpy(itc_msg, "Fancy Display");
}
- else if(cmode==3)
+ else if(cmode==CM_FIRE)
{
memset(fire_r, 0, sizeof(fire_r));
memset(fire_g, 0, sizeof(fire_g));
memset(fire_b, 0, sizeof(fire_b));
strcpy(itc_msg, "Fire Display");
}
- else if(cmode==2)
+ else if(cmode==CM_PERS)
{
memset(fire_bg, 0, XRES*YRES*PIXELSIZE);
strcpy(itc_msg, "Persistent Display");
}
- else if(cmode==1)
+ else if(cmode==CM_PRESS)
strcpy(itc_msg, "Pressure Display");
+ else if(cmode==CM_NOTHING)
+ strcpy(itc_msg, "Nothing Display");
+ else if(cmode==CM_CRACK)
+ strcpy(itc_msg, "Alternate Velocity Display");
+ else if(cmode==CM_GRAD)
+ strcpy(itc_msg, "Heat Gradient Display");
else
strcpy(itc_msg, "Velocity Display");
}
@@ -2542,7 +2646,6 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date)
drawrect(vid_buf, 50, 50, (XRES/2)+1, (YRES/2)+1, 255, 255, 255, 155);
drawrect(vid_buf, 50+(XRES/2)+1, 50, XRES+BARSIZE-100-((XRES/2)+1), YRES+MENUSIZE-100, 155, 155, 155, 255);
drawtext(vid_buf, 50+(XRES/4)-textwidth("Loading...")/2, 50+(YRES/4), "Loading...", 255, 255, 255, 128);
- //Also, The Game.
ed.x = 57+(XRES/2)+1;
ed.y = YRES+MENUSIZE-118;
diff --git a/src/main.c b/src/main.c
index d548a45..d191fad 100644
--- a/src/main.c
+++ b/src/main.c
@@ -6,6 +6,7 @@
* Copyright (c) 2010 Skresanov Savely
* Copyright (c) 2010 Bryan Hoyle
* Copyright (c) 2010 Nathan Cousins
+ * Copyright (c) 2010 cracker64
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,6 +22,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -28,6 +30,7 @@
#include <SDL/SDL.h>
#include <bzlib.h>
#include <time.h>
+
#ifdef WIN32
#include <direct.h>
#else
@@ -49,7 +52,7 @@
#include <icon.h>
static const char *it_msg =
- "\brThe Powder Toy\n"
+ "\brThe Powder Toy - http://powdertoy.co.uk/\n"
"\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\n"
"\n"
"\bgControl+C/V/X are Copy, Paste and cut respectively.\n"
@@ -66,18 +69,16 @@ static const char *it_msg =
"'L' will load the most recent stamp, 'K' shows a library of stamps you saved.\n"
"'C' will cycle the display mode (Fire, Blob, Velocity and Pressure). The numbers 1 to 7 will do the same\n"
"Use the mouse scroll wheel to change the tool size for particles.\n"
- "'Q' will quit the application.\n"
"The spacebar can be used to pause physics.\n"
"'P' will take a screenshot and save it into the current directory.\n"
"\n"
- "\brhttp://powdertoy.co.uk/\n"
"\bgCopyright (c) 2008-10 Stanislaw K Skowronek (\brhttp://powder.unaligned.org\bg, \bbirc.unaligned.org #wtf\bg)\n"
"\bgCopyright (c) 2010 Simon Robertshaw (\brhttp://powdertoy.co.uk\bg, \bbirc.freenode.net #powder\bg)\n"
"\bgCopyright (c) 2010 Skresanov Savely (Stickman)\n"
+ "\bgCopyright (c) 2010 cracker64\n"
"\bgCopyright (c) 2010 Bryan Hoyle (New elements)\n"
"\bgCopyright (c) 2010 Nathan Cousins (New elements, small engine mods.)\n"
"\n"
- "\bgSpecial thanks to Brian Ledbetter for maintaining ports.\n"
"\bgTo use online features such as saving, you need to register at: \brhttp://powdertoy.co.uk/Register.html"
;
@@ -99,6 +100,9 @@ int legacy_enable = 0; //Used to disable new features such as heat, will be set
int death = 0, framerender = 0;
int amd = 1;
int FPSB = 0;
+int MSIGN =-1;
+//int CGOL = 0;
+//int GSPEED = 1;//causes my .exe to crash..
sign signs[MAXSIGNS];
@@ -245,7 +249,7 @@ void *build_save(int *size, int x0, int y0, int w, int h)
d[p++] = bmap[y][x];
for(y=by0; y<by0+bh; y++)
for(x=bx0; x<bx0+bw; x++)
- if(bmap[y][x]==4)
+ if(bmap[y][x]==WL_FAN)
{
i = (int)(fvx[y][x]*64.0f+127.5f);
if(i<0) i=0;
@@ -254,7 +258,7 @@ void *build_save(int *size, int x0, int y0, int w, int h)
}
for(y=by0; y<by0+bh; y++)
for(x=bx0; x<bx0+bw; x++)
- if(bmap[y][x]==4)
+ if(bmap[y][x]==WL_FAN)
{
i = (int)(fvy[y][x]*64.0f+127.5f);
if(i<0) i=0;
@@ -325,7 +329,7 @@ void *build_save(int *size, int x0, int y0, int w, int h)
for(j=0; j<w*h; j++)
{
i = m[j];
- if(i && (parts[i-1].type==PT_CLNE || parts[i-1].type==PT_PCLN || parts[i-1].type==PT_SPRK || parts[i-1].type==PT_LAVA))
+ if(i && (parts[i-1].type==PT_CLNE || parts[i-1].type==PT_PCLN || parts[i-1].type==PT_SPRK || parts[i-1].type==PT_LAVA || parts[i-1].type==PT_PIPE))
d[p++] = parts[i-1].ctype;
}
@@ -481,7 +485,36 @@ int parse_save(void *save, int size, int replace, int x0, int y0)
for(x=bx0; x<bx0+bw; x++)
{
if(d[p])
+ {
bmap[y][x] = d[p];
+ if(bmap[y][x]==1)
+ bmap[y][x]=WL_WALL;
+ if(bmap[y][x]==2)
+ bmap[y][x]=WL_DESTROYALL;
+ if(bmap[y][x]==3)
+ bmap[y][x]=WL_ALLOWLIQUID;
+ if(bmap[y][x]==4)
+ bmap[y][x]=WL_FAN;
+ if(bmap[y][x]==5)
+ bmap[y][x]=WL_STREAM;
+ if(bmap[y][x]==6)
+ bmap[y][x]=WL_DETECT;
+ if(bmap[y][x]==7)
+ bmap[y][x]=WL_EWALL;
+ if(bmap[y][x]==8)
+ bmap[y][x]=WL_WALLELEC;
+ if(bmap[y][x]==9)
+ bmap[y][x]=WL_ALLOWAIR;
+ if(bmap[y][x]==10)
+ bmap[y][x]=WL_ALLOWSOLID;
+ if(bmap[y][x]==11)
+ bmap[y][x]=WL_ALLOWALLELEC;
+ if(bmap[y][x]==12)
+ bmap[y][x]=WL_EHOLE;
+ if(bmap[y][x]==13)
+ bmap[y][x]=WL_ALLOWGAS;
+ }
+
p++;
}
for(y=by0; y<by0+bh; y++)
@@ -514,6 +547,7 @@ int parse_save(void *save, int size, int replace, int x0, int y0)
//TODO: Possibly some server side translation
j = PT_DUST;//goto corrupt;
}
+ gol[x][y]=0;
if(j)// && !(isplayer == 1 && j==PT_STKM))
{
if(pmap[y][x])
@@ -529,6 +563,10 @@ int parse_save(void *save, int size, int replace, int x0, int y0)
else if(i < nf)
{
parts[fp[i]].type = j;
+ if(j == PT_COAL)
+ parts[fp[i]].tmp = 50;
+ if(j == PT_FUSE)
+ parts[fp[i]].tmp = 50;
if(j == PT_PHOT)
parts[fp[i]].ctype = 0x3fffffff;
parts[fp[i]].x = (float)x;
@@ -654,7 +692,7 @@ int parse_save(void *save, int size, int replace, int x0, int y0)
{
i = m[j];
ty = d[pty+j];
- if(i && (ty==PT_CLNE || (ty==PT_PCLN && ver>=43) || (ty==PT_SPRK && ver>=21) || (ty==PT_LAVA && ver>=34)))
+ if(i && (ty==PT_CLNE || (ty==PT_PCLN && ver>=43) || (ty==PT_SPRK && ver>=21) || (ty==PT_LAVA && ver>=34) || (ty==PT_PIPE && ver>=43)))
{
if(p >= size)
goto corrupt;
@@ -1003,7 +1041,7 @@ int main(int argc, char *argv[])
int vs = 0;
#endif
int x, y, b = 0, sl=1, sr=0, su=0, c, lb = 0, lx = 0, ly = 0, lm = 0;//, tx, ty;
- int da = 0, db = 0, it = 2047, mx, my, bs = 2;
+ int da = 0, db = 0, it = 2047, mx, my, bsx = 2, bsy = 2;
float nfvx, nfvy;
int load_mode=0, load_w=0, load_h=0, load_x=0, load_y=0, load_size=0;
void *load_data=NULL;
@@ -1118,7 +1156,7 @@ int main(int argc, char *argv[])
{
for(i=1; i<XRES/CELL; i++)
{
- if(bmap[j][i]==1 || bmap[j][i]==8 || (bmap[j][i]==7 && !emap[j][i]))
+ if(bmap[j][i]==WL_WALL || bmap[j][i]==WL_WALLELEC || (bmap[j][i]==WL_EWALL && !emap[j][i]))
{
vx[j][i] = 0.0f;
vx[j][i-1] = 0.0f;
@@ -1135,11 +1173,11 @@ int main(int argc, char *argv[])
#ifdef OpenGL
ClearScreen();
#else
- if(cmode==0 || cmode==1)
+ if(cmode==CM_VEL || cmode==CM_PRESS || cmode==CM_CRACK)
{
draw_air(vid_buf);
}
- else if(cmode==2)
+ else if(cmode==CM_PERS)
{
memcpy(vid_buf, fire_bg, XRES*YRES*PIXELSIZE);
memset(vid_buf+(XRES*YRES), 0, ((XRES+BARSIZE)*YRES*PIXELSIZE)-(XRES*YRES*PIXELSIZE));
@@ -1152,7 +1190,7 @@ int main(int argc, char *argv[])
update_particles(vid_buf);
draw_parts(vid_buf);
- if(cmode==2)
+ if(cmode==CM_PERS)
{
if(!fire_fc)
{
@@ -1164,7 +1202,7 @@ int main(int argc, char *argv[])
}
fire_fc = (fire_fc+1) % 3;
}
- if(cmode==3||cmode==4||cmode==6)
+ if(cmode==CM_FIRE||cmode==CM_BLOB||cmode==CM_FANCY)
render_fire(vid_buf);
render_signs(vid_buf);
@@ -1252,76 +1290,134 @@ int main(int argc, char *argv[])
}
if(sdl_key=='1')
{
- set_cmode(0);
+ set_cmode(CM_VEL);
}
if(sdl_key=='2')
{
- set_cmode(1);
+ set_cmode(CM_PRESS);
}
if(sdl_key=='3')
{
- set_cmode(2);
+ set_cmode(CM_PERS);
}
if(sdl_key=='4')
{
- set_cmode(3);
+ set_cmode(CM_FIRE);
}
if(sdl_key=='5')
{
- set_cmode(4);
+ set_cmode(CM_BLOB);
}
if(sdl_key=='6')
{
- set_cmode(5);
+ set_cmode(CM_HEAT);
}
if(sdl_key=='7')
{
- set_cmode(6);
+ set_cmode(CM_FANCY);
+ }
+ if(sdl_key=='8')
+ {
+ set_cmode(CM_NOTHING);
+ }
+ if(sdl_key=='9')
+ {
+ set_cmode(CM_CRACK);
+ }
+ if(sdl_key=='0')
+ {
+ set_cmode(CM_GRAD);
}
+ if(sdl_key==SDLK_TAB)
+ {
+ CURRENT_BRUSH =(CURRENT_BRUSH + 1)%BRUSH_NUM ;
+ }
if(sdl_key==SDLK_LEFTBRACKET) {
if(sdl_zoom_trig==1)
{
ZSIZE -= 1;
- if(ZSIZE>32)
- ZSIZE = 32;
+ if(ZSIZE>60)
+ ZSIZE = 60;
if(ZSIZE<2)
ZSIZE = 2;
ZFACTOR = 256/ZSIZE;
}
else
{
- if(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL))
- bs -= 1;
+ if(sdl_mod & (KMOD_LALT|KMOD_RALT) && !(sdl_mod & (KMOD_SHIFT|KMOD_CTRL)))
+ {
+ bsx -= 1;
+ bsy -= 1;
+ }
+ else if(sdl_mod & (KMOD_SHIFT) && !(sdl_mod & (KMOD_CTRL)))
+ {
+ bsx -= 1;
+ }
+ else if(sdl_mod & (KMOD_CTRL) && !(sdl_mod & (KMOD_SHIFT)))
+ {
+ bsy -= 1;
+ }
else
- bs -= ceil((bs/5)+0.5f);
- if(bs>1224)
- bs = 1224;
- if(bs<0)
- bs = 0;
+ {
+ bsx -= ceil((bsx/5)+0.5f);
+ bsy -= ceil((bsy/5)+0.5f);
+ }
+ if(bsx>1180)
+ bsx = 1180;
+ if(bsy>1180)
+ bsy = 1180;
+ if(bsx<0)
+ bsx = 0;
+ if(bsy<0)
+ bsy = 0;
}
}
if(sdl_key==SDLK_RIGHTBRACKET) {
if(sdl_zoom_trig==1)
{
ZSIZE += 1;
- if(ZSIZE>32)
- ZSIZE = 32;
+ if(ZSIZE>60)
+ ZSIZE = 60;
if(ZSIZE<2)
ZSIZE = 2;
ZFACTOR = 256/ZSIZE;
}
else
{
- if(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL))
- bs += 1;
+ if(sdl_mod & (KMOD_LALT|KMOD_RALT) && !(sdl_mod & (KMOD_SHIFT|KMOD_CTRL)))
+ {
+ bsx += 1;
+ bsy += 1;
+ }
+ else if(sdl_mod & (KMOD_SHIFT) && !(sdl_mod & (KMOD_CTRL)))
+ {
+ bsx += 1;
+ }
+ else if(sdl_mod & (KMOD_CTRL) && !(sdl_mod & (KMOD_SHIFT)))
+ {
+ bsy += 1;
+ }
else
- bs += ceil((bs/5)+0.5f);
- if(bs>1224)
- bs = 1224;
- if(bs<0)
- bs = 0;
+ {
+ bsx += ceil((bsx/5)+0.5f);
+ bsy += ceil((bsy/5)+0.5f);
+ }
+ if(bsx>1180)
+ bsx = 1180;
+ if(bsy>1180)
+ bsy = 1180;
+ if(bsx<0)
+ bsx = 0;
+ if(bsy<0)
+ bsy = 0;
}
}
+ if(sdl_key==SDLK_INSERT)
+ REPLACE_MODE = !REPLACE_MODE;
+ if(sdl_key=='g')
+ GRID_MODE = (GRID_MODE+1)%10;
+ if(sdl_key=='t')
+ VINE_MODE = !VINE_MODE;
if(sdl_key==SDLK_SPACE)
sys_pause = !sys_pause;
if(sdl_key=='h')
@@ -1357,7 +1453,7 @@ int main(int argc, char *argv[])
}
else if(sdl_key=='c')
{
- set_cmode((cmode+1) % 7);
+ set_cmode((cmode+1) % CM_COUNT);
if(it > 50)
it = 50;
}
@@ -1394,8 +1490,8 @@ int main(int argc, char *argv[])
if(sdl_zoom_trig==1)
{
ZSIZE += sdl_wheel;
- if(ZSIZE>32)
- ZSIZE = 32;
+ if(ZSIZE>60)
+ ZSIZE = 60;
if(ZSIZE<2)
ZSIZE = 2;
ZFACTOR = 256/ZSIZE;
@@ -1403,11 +1499,27 @@ int main(int argc, char *argv[])
}
else
{
- bs += sdl_wheel;
- if(bs>1224)
- bs = 1224;
- if(bs<0)
- bs = 0;
+ if(!(sdl_mod & (KMOD_SHIFT|KMOD_CTRL)))
+ {
+ bsx += sdl_wheel;
+ bsy += sdl_wheel;
+ }
+ else if(sdl_mod & (KMOD_SHIFT) && !(sdl_mod & (KMOD_CTRL)))
+ {
+ bsx += sdl_wheel;
+ }
+ else if(sdl_mod & (KMOD_CTRL) && !(sdl_mod & (KMOD_SHIFT)))
+ {
+ bsy += sdl_wheel;
+ }
+ if(bsx>1180)
+ bsx = 1180;
+ if(bsx<0)
+ bsx = 0;
+ if(bsy>1180)
+ bsy = 1180;
+ if(bsy<0)
+ bsy = 0;
sdl_wheel = 0;
/*if(su >= PT_NUM) {
if(sl < PT_NUM)
@@ -1794,9 +1906,9 @@ int main(int argc, char *argv[])
if(x>=(XRES+BARSIZE-(510-476)) && x<=(XRES+BARSIZE-(510-491)) && !bq)
{
if(b & SDL_BUTTON_LMASK)
- set_cmode((cmode+1) % 7);
+ set_cmode((cmode+1) % CM_COUNT);
if(b & SDL_BUTTON_RMASK)
- set_cmode((cmode+6) % 7);
+ set_cmode((cmode+(CM_COUNT-1)) % CM_COUNT);
save_presets(0);
}
if(x>=(XRES+BARSIZE-(510-494)) && x<=(XRES+BARSIZE-(510-509)) && !bq)
@@ -1808,7 +1920,7 @@ int main(int argc, char *argv[])
{
c = (b&1) ? sl : sr;
su = c;
- if(c==126)
+ if(c==WL_SIGN+100)
{
if(!bq)
add_sign_ui(vid_buf, x, y);
@@ -1818,18 +1930,18 @@ int main(int argc, char *argv[])
if(lm == 1)
{
xor_line(lx, ly, x, y, vid_buf);
- if(c==127 && lx>=0 && ly>=0 && lx<XRES && ly<YRES && bmap[ly/CELL][lx/CELL]==4)
+ if(c==WL_FAN+100 && lx>=0 && ly>=0 && lx<XRES && ly<YRES && bmap[ly/CELL][lx/CELL]==WL_FAN)
{
nfvx = (x-lx)*0.005f;
nfvy = (y-ly)*0.005f;
- flood_parts(lx, ly, 255, -1, 4);
+ flood_parts(lx, ly, WL_FANHELPER, -1, WL_FAN);
for(j=0; j<YRES/CELL; j++)
for(i=0; i<XRES/CELL; i++)
- if(bmap[j][i] == 255)
+ if(bmap[j][i] == WL_FANHELPER)
{
fvx[j][i] = nfvx;
fvy[j][i] = nfvy;
- bmap[j][i] = 4;
+ bmap[j][i] = WL_FAN;
}
}
}
@@ -1842,14 +1954,14 @@ int main(int argc, char *argv[])
}
else
{
- create_line(lx, ly, x, y, bs, c);
+ create_line(lx, ly, x, y, bsx, bsy, c);
lx = x;
ly = y;
}
}
else
{
- if((sdl_mod & (KMOD_LSHIFT|KMOD_RSHIFT)) && !(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)))
+ if((sdl_mod & (KMOD_LSHIFT|KMOD_RSHIFT)) && !(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL|KMOD_LALT)))
{
lx = x;
ly = y;
@@ -1863,16 +1975,18 @@ int main(int argc, char *argv[])
lb = b;
lm = 2;
}
- else if((sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)) && (sdl_mod & (KMOD_LSHIFT|KMOD_RSHIFT)))
+ else if((sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)) && (sdl_mod & (KMOD_LSHIFT|KMOD_RSHIFT)) && !(sdl_mod & (KMOD_LALT)))
{
- if(c!=125&&c!=SPC_AIR&&c!=SPC_HEAT&&c!=SPC_COOL&&c!=SPC_VACUUM)
+ if(sdl_mod & (KMOD_CAPS))
+ c = 0;
+ if(c!=WL_STREAM&&c!=SPC_AIR&&c!=SPC_HEAT&&c!=SPC_COOL&&c!=SPC_VACUUM&&!REPLACE_MODE)
flood_parts(x, y, c, -1, -1);
lx = x;
ly = y;
lb = 0;
lm = 0;
}
- else if((sdl_mod & (KMOD_LALT||KMOD_RALT)) || b==SDL_BUTTON_MIDDLE)
+ else if(((sdl_mod & (KMOD_LALT|KMOD_RALT)) && !(sdl_mod & (KMOD_SHIFT))) || b==SDL_BUTTON_MIDDLE)
{
if(y>0 && y<sdl_scale*YRES && x>0 && x<sdl_scale*XRES)
{
@@ -1914,7 +2028,7 @@ int main(int argc, char *argv[])
cb_emap[cby][cbx] = emap[cby][cbx];
}
- create_parts(x, y, bs, c);
+ create_parts(x, y, bsx, bsy, c);
lx = x;
ly = y;
lb = b;
@@ -1933,8 +2047,8 @@ int main(int argc, char *argv[])
su = c;
if(lm == 1)
{
- if(c!=127 || lx<0 || ly<0 || lx>=XRES || ly>=YRES || bmap[ly/CELL][lx/CELL]!=4)
- create_line(lx, ly, x, y, bs, c);
+ if(c!=WL_FAN+100 || lx<0 || ly<0 || lx>=XRES || ly>=YRES || bmap[ly/CELL][lx/CELL]!=WL_FAN)
+ create_line(lx, ly, x, y, bsx, bsy, c);
}
else
create_box(lx, ly, x, y, c);
@@ -1958,7 +2072,7 @@ int main(int argc, char *argv[])
if(zoom_en!=1 && !load_mode && !save_mode)
{
- render_cursor(vid_buf, mx/sdl_scale, my/sdl_scale, su, bs);
+ render_cursor(vid_buf, mx/sdl_scale, my/sdl_scale, su, bsx, bsy);
mousex = mx/sdl_scale;
mousey = my/sdl_scale;
}
@@ -2071,16 +2185,23 @@ int main(int argc, char *argv[])
}
if(currentTime-pastFPS>=1000)
{
-#ifdef BETA
- sprintf(uitext, "Version %d (Beta %d) FPS:%d", SAVE_VERSION, MINOR_VERSION, FPS);
- //printf("%s\n", uitext);
-#else
- sprintf(uitext, "Version %d.%d FPS:%d", SAVE_VERSION, MINOR_VERSION, FPS);
-#endif
FPSB = FPS;
FPS = 0;
pastFPS = currentTime;
}
+
+#ifdef BETA
+ sprintf(uitext, "Version %d Beta %d FPS:%d Parts:%d", SAVE_VERSION, MINOR_VERSION, FPSB, NUM_PARTS);
+#else
+ sprintf(uitext, "Version %d.%d FPS:%d", SAVE_VERSION, MINOR_VERSION, FPSB);
+#endif
+ if(REPLACE_MODE)
+ strappend(uitext, " [REPLACE MODE]");
+ if(sdl_mod&(KMOD_CAPS))
+ strappend(uitext, " [CAP LOCKS]");
+ if(GRID_MODE)
+ sprintf(uitext, "%s [GRID: %d]", uitext, GRID_MODE);
+
if(sdl_zoom_trig||zoom_en)
{
if(zoom_x<XRES/2)
diff --git a/src/misc.c b/src/misc.c
index e64fef7..87615cd 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -280,4 +280,4 @@ int cpu_check(void)
#endif
#endif
return 0;
-} \ No newline at end of file
+}
diff --git a/src/powder.c b/src/powder.c
index 86f0427..f6cc143 100644
--- a/src/powder.c
+++ b/src/powder.c
@@ -76,25 +76,27 @@ static int eval_move(int pt, int nx, int ny, unsigned *rr)
(r&0xFF)==PT_CLNE || (r&0xFF)==PT_PCLN ||
(r&0xFF)==PT_GLOW || (r&0xFF)==PT_WATR ||
(r&0xFF)==PT_DSTW || (r&0xFF)==PT_SLTW ||
- ((r&0xFF)==PT_LCRY&&parts[r>>8].life > 5)))
+ (r&0xFF)==PT_ISOZ || (r&0xFF)==PT_ISZS ||
+ (r&0xFF)==PT_FILT ||
+ ((r&0xFF)==PT_LCRY&&parts[r>>8].life > 5)))
return 2;
if(pt==PT_STKM) //Stick man's head shouldn't collide
return 2;
- if(bmap[ny/CELL][nx/CELL]==13 && ptypes[pt].falldown!=0 && pt!=PT_FIRE && pt!=PT_SMKE)
+ 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]==3)
+ if(ptypes[pt].falldown!=2 && bmap[ny/CELL][nx/CELL]==WL_ALLOWLIQUID)
return 0;
- if((pt==PT_NEUT ||pt==PT_PHOT) && bmap[ny/CELL][nx/CELL]==7 && !emap[ny/CELL][nx/CELL])
+ if((pt==PT_NEUT ||pt==PT_PHOT) && bmap[ny/CELL][nx/CELL]==WL_EWALL && !emap[ny/CELL][nx/CELL])
return 0;
-
- if(bmap[ny/CELL][nx/CELL]==9)
+ if(bmap[ny/CELL][nx/CELL]==WL_EHOLE && !emap[ny/CELL][nx/CELL])
+ return 2;
+ if(bmap[ny/CELL][nx/CELL]==WL_ALLOWAIR)
return 0;
- if(ptypes[pt].falldown!=1 && bmap[ny/CELL][nx/CELL]==10)
+ 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;
@@ -127,7 +129,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;
/* half-silvered mirror */
if(!e && parts[i].type==PT_PHOT &&
(((r&0xFF)==PT_BMTL && rand()<RAND_MAX/2) ||
@@ -155,7 +158,13 @@ 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);
@@ -178,17 +187,17 @@ int try_move(int i, int x, int y, int nx, int ny)
return 0;
}
- if((pmap[ny][nx]&0xFF)==PT_CNCT)
- return 0;
+ if((pmap[ny][nx]&0xFF)==PT_CNCT)
+ return 0;
if(parts[i].type==PT_CNCT && y<ny && (pmap[y+1][x]&0xFF)==PT_CNCT)
return 0;
- if(bmap[ny/CELL][nx/CELL]==12 && !emap[y/CELL][x/CELL])
+ if(bmap[ny/CELL][nx/CELL]==WL_EHOLE && !emap[y/CELL][x/CELL])
return 1;
- if((bmap[y/CELL][x/CELL]==12 && !emap[y/CELL][x/CELL]) && (bmap[ny/CELL][nx/CELL]!=12 && !emap[ny/CELL][nx/CELL]))
+ if((bmap[y/CELL][x/CELL]==WL_EHOLE && !emap[y/CELL][x/CELL]) && (bmap[ny/CELL][nx/CELL]!=WL_EHOLE && !emap[ny/CELL][nx/CELL]))
return 0;
- if(r && (r>>8)<NPART && ptypes[r&0xFF].falldown!=2 && bmap[y/CELL][x/CELL]==3)
+ if(r && (r>>8)<NPART && ptypes[r&0xFF].falldown!=2 && bmap[y/CELL][x/CELL]==WL_ALLOWLIQUID)
return 0;
if(parts[i].type == PT_PHOT)
@@ -377,11 +386,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)
{
- 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)
{
- 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;
}
@@ -390,6 +405,25 @@ inline int create_part(int p, int x, int y, int t)
return -1;
}
}
+ if(t==PT_INST2)
+ if((pmap[y][x]&0xFF)==PT_INST)
+ {
+ parts[pmap[y][x]>>8].type = PT_INST2;
+ parts[pmap[y][x]>>8].life += 5;
+ pmap[y][x] = (pmap[y][x]&~0xFF) | PT_INST2;
+ return pmap[y][x]>>8;
+ }
+ if(t==PT_INST3)
+ if((pmap[y][x]&0xFF)==PT_INST||(pmap[y][x]&0xFF)==PT_INST2)
+ {
+ parts[pmap[y][x]>>8].type = PT_INST3;
+ if(parts[pmap[y][x]>>8].life%4==0)
+ parts[pmap[y][x]>>8].life -=0;
+ else
+ parts[pmap[y][x]>>8].life -= 2;
+ pmap[y][x] = (pmap[y][x]&~0xFF) | PT_INST3;
+ return pmap[y][x]>>8;
+ }
if(t==SPC_AIR)
{
pv[y/CELL][x/CELL] += 0.03f;
@@ -435,6 +469,8 @@ inline int create_part(int p, int x, int y, int t)
(pmap[y][x]&0xFF)!=PT_IRON &&
(pmap[y][x]&0xFF)!=PT_INWR)
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;
@@ -479,16 +515,25 @@ 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_FUSE) {
parts[i].life = 50;
parts[i].tmp = 50;
}
+ if(t==PT_PUMP)
+ parts[i].life= 10;
if(t==PT_FSEP)
parts[i].life = 50;
if(t==PT_COAL) {
parts[i].life = 110;
parts[i].tmp = 50;
}
+ if(t==PT_FRZW)
+ parts[i].life = 100;
+ if(t==PT_PIPE)
+ parts[i].life = 60;
if(t==PT_BCOL)
parts[i].life = 110;
if(t==PT_FIRE)
@@ -524,7 +569,7 @@ inline int create_part(int p, int x, int y, int t)
parts[i].vy = 3.0f*sinf(a);
}
- if(t!=PT_STKM && t!=PT_PHOT && t!=PT_NEUT)
+ if(t!=PT_STKM)// && t!=PT_PHOT && t!=PT_NEUT) is this needed? it breaks floodfill
pmap[y][x] = t|(i<<8);
else if(t==PT_STKM)
{
@@ -669,9 +714,18 @@ inline void delete_part(int x, int y)
i = pmap[y][x];
if(!i || (i>>8)>=NPART)
return;
-
- kill_part(i>>8);
- pmap[y][x] = 0; // just in case
+ if((parts[i>>8].type==SLALT)||SLALT==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;
}
#if defined(WIN32) && !defined(__GNUC__)
@@ -680,7 +734,7 @@ _inline int is_wire(int x, int y)
inline int is_wire(int x, int y)
#endif
{
- return bmap[y][x]==6 || bmap[y][x]==7 || bmap[y][x]==3 || bmap[y][x]==8 || bmap[y][x]==11 || bmap[y][x]==12;
+ return bmap[y][x]==WL_DETECT || bmap[y][x]==WL_EWALL || bmap[y][x]==WL_ALLOWLIQUID || bmap[y][x]==WL_WALLELEC || bmap[y][x]==WL_ALLOWALLELEC || bmap[y][x]==WL_EHOLE;
}
#if defined(WIN32) && !defined(__GNUC__)
@@ -689,7 +743,7 @@ _inline int is_wire_off(int x, int y)
inline int is_wire_off(int x, int y)
#endif
{
- return (bmap[y][x]==6 || bmap[y][x]==7 || bmap[y][x]==3 || bmap[y][x]==8 || bmap[y][x]==11 || bmap[y][x]==12) && emap[y][x]<8;
+ return (bmap[y][x]==WL_DETECT || bmap[y][x]==WL_EWALL || bmap[y][x]==WL_ALLOWLIQUID || bmap[y][x]==WL_WALLELEC || bmap[y][x]==WL_ALLOWALLELEC || bmap[y][x]==WL_EHOLE) && emap[y][x]<8;
}
int get_wavelength_bin(int *wm)
@@ -775,20 +829,30 @@ void set_emap(int x, int y)
}
#if defined(WIN32) && !defined(__GNUC__)
-_inline int parts_avg(int ci, int ni)
+_inline int parts_avg(int ci, int ni,int t)//t is the particle you are looking for
#else
-inline int parts_avg(int ci, int ni)
+inline int parts_avg(int ci, int ni,int t)
#endif
{
- int pmr = pmap[(int)((parts[ci].y + parts[ni].y)/2)][(int)((parts[ci].x + parts[ni].x)/2)];
- if((pmr>>8) < NPART && (pmr>>8) >= 1)
- {
- return parts[pmr>>8].type;
- }
- 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;
+ }
}
@@ -824,6 +888,247 @@ 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(ISGRAV==1)
+ {
+ ISGRAV = 0;
+ GRAV ++;
+ GRAV_R = 60;
+ GRAV_G = 0;
+ GRAV_B = 0;
+ GRAV_R2 = 30;
+ GRAV_G2 = 30;
+ GRAV_B2 = 0;
+ for(int 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(int nnx=0;nnx<9;nnx++)
+ for(int 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(int nnx=0;nnx<9;nnx++)
+ for(int 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
+ {
+ 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(int golnum=1;golnum<NGOL;golnum++)
+ if(parts[r>>8].type==golnum+77)
+ {
+ gol[nx][ny] = golnum;
+ for(int nnx=-1;nnx<2;nnx++)
+ for(int 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(int golnum = 1;golnum<NGOL;golnum++)
+ for(int goldelete = 0;goldelete<9;goldelete++)
+ {
+ if(neighbors==goldelete&&gol[nx][ny]==0&&grule[golnum][goldelete]>=2&&gol2[nx][ny][golnum]>=(goldelete%2)+goldelete/2)
+ {
+ create_part(-1,nx,ny,golnum+77);
+ }
+ 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(int z = 1;z<NGOL;z++)
+ gol2[nx][ny][z] = 0;
+ }
+ }
+ if(ISWIRE==1)
+ {
+ CGOL = 0;
+ ISWIRE = 0;
+ }
+ if(CGOL==1)
+ {
+ for(int q = 0;q<25;q++)
+ wireless[q] = 0;
+ }
for(i=start; i<(NPART-starti); i+=inc)
if(parts[i].type)
{
@@ -833,14 +1138,11 @@ void update_particles_i(pixel *vid, int start, int inc)
ly = parts[i].y;
t = parts[i].type;
- if(sys_pause&&!framerender)
- return;
-
- if(parts[i].life && t!=PT_ACID && t!=PT_COAL && t!=PT_WOOD && t!=PT_NBLE && t!=PT_SWCH && t!=PT_STKM && t!=PT_FUSE && t!=PT_FSEP && t!=PT_BCOL)
+ if(parts[i].life && t!=PT_ACID && t!=PT_COAL && t!=PT_WOOD && t!=PT_NBLE && t!=PT_SWCH && t!=PT_STKM && t!=PT_FUSE && t!=PT_FSEP && t!=PT_BCOL && t!=PT_GOL && t!=PT_CRAC && t!=PT_DEUT)
{
- if(!(parts[i].life==10&&(parts[i].type==PT_LCRY||parts[i].type==PT_PCLN||parts[i].type==PT_HSWC)))
+ if(!(parts[i].life==10&&(parts[i].type==PT_LCRY||parts[i].type==PT_PCLN||parts[i].type==PT_HSWC||parts[i].type==PT_PUMP)) && !(parts[i].life%4==0 && parts[i].type==PT_INST))
parts[i].life--;
- if(parts[i].life<=0 && t!=PT_METL && t!=PT_IRON && t!=PT_FIRW && t!=PT_PCLN && t!=PT_HSWC && t!=PT_WATR && t!=PT_RBDM && t!=PT_LRBD && t!=PT_SLTW && t!=PT_BRMT && t!=PT_PSCN && t!=PT_NSCN && t!=PT_NTCT && t!=PT_PTCT && t!=PT_BMTL && t!=PT_SPRK && t!=PT_LAVA && t!=PT_ETRD&&t!=PT_LCRY && t!=PT_INWR && t!=PT_GLOW)
+ if(parts[i].life<=0 && t!=PT_METL && t!=PT_IRON && t!=PT_FIRW && t!=PT_PCLN && t!=PT_HSWC && t!=PT_PUMP && t!=PT_WATR && t!=PT_RBDM && t!=PT_LRBD && t!=PT_SLTW && t!=PT_BRMT && t!=PT_PSCN && t!=PT_NSCN && t!=PT_NTCT && t!=PT_PTCT && t!=PT_BMTL && t!=PT_SPRK && t!=PT_LAVA && t!=PT_ETRD&&t!=PT_LCRY && t!=PT_INWR && t!=PT_GLOW && t!= PT_FOG && t!=PT_PIPE && t!=PT_FRZW &&(t!=PT_ICEI&&parts[i].ctype!=PT_FRZW)&&t!=PT_INST && t!=PT_SHLD1&& t!=PT_SHLD2&& t!=PT_SHLD3&& t!=PT_SHLD4)
{
kill_part(i);
continue;
@@ -858,6 +1160,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;
}
}
@@ -872,15 +1176,15 @@ void update_particles_i(pixel *vid, int start, int inc)
if(x<0 || y<0 || x>=XRES || y>=YRES ||
- ((bmap[y/CELL][x/CELL]==1 ||
- bmap[y/CELL][x/CELL]==8 ||
- bmap[y/CELL][x/CELL]==9 ||
- (bmap[y/CELL][x/CELL]==2) ||
- (bmap[y/CELL][x/CELL]==3 && ptypes[t].falldown!=2) ||
- (bmap[y/CELL][x/CELL]==10 && ptypes[t].falldown!=1) ||
- (bmap[y/CELL][x/CELL]==13 && ptypes[t].falldown!=0 && parts[i].type!=PT_FIRE && parts[i].type!=PT_SMKE) ||
- (bmap[y/CELL][x/CELL]==6 && (t==PT_METL || t==PT_SPRK)) ||
- (bmap[y/CELL][x/CELL]==7 && !emap[y/CELL][x/CELL])) && (t!=PT_STKM)))
+ ((bmap[y/CELL][x/CELL]==WL_WALL ||
+ bmap[y/CELL][x/CELL]==WL_WALLELEC ||
+ bmap[y/CELL][x/CELL]==WL_ALLOWAIR ||
+ (bmap[y/CELL][x/CELL]==WL_DESTROYALL) ||
+ (bmap[y/CELL][x/CELL]==WL_ALLOWLIQUID && ptypes[t].falldown!=2) ||
+ (bmap[y/CELL][x/CELL]==WL_ALLOWSOLID && ptypes[t].falldown!=1) ||
+ (bmap[y/CELL][x/CELL]==WL_ALLOWGAS && ptypes[t].falldown!=0 && parts[i].type!=PT_FIRE && parts[i].type!=PT_SMKE) ||
+ (bmap[y/CELL][x/CELL]==WL_DETECT && (t==PT_METL || t==PT_SPRK)) ||
+ (bmap[y/CELL][x/CELL]==WL_EWALL && !emap[y/CELL][x/CELL])) && (t!=PT_STKM)))
{
kill_part(i);
continue;
@@ -888,20 +1192,50 @@ 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;
- 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)
- {
- 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_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]);
+ }
+ }
+
}
else
{
@@ -928,7 +1262,7 @@ void update_particles_i(pixel *vid, int start, int inc)
parts[i].vx *= ptypes[t].loss;
parts[i].vy *= ptypes[t].loss;
- if(t==PT_GOO && !parts[i].life)
+ if((t==PT_GOO) && !parts[i].life)
{
if(pv[y/CELL][x/CELL]>1.0f)
{
@@ -937,10 +1271,27 @@ void update_particles_i(pixel *vid, int start, int inc)
parts[i].life = rand()%80+300;
}
}
+ else if((t==PT_BCLN) && !parts[i].life)
+ {
+ if(pv[y/CELL][x/CELL]>4.0f)
+ {
+ parts[i].vx += ptypes[t].advection*vx[y/CELL][x/CELL];
+ parts[i].vy += ptypes[t].advection*vy[y/CELL][x/CELL];
+ parts[i].life = rand()%40+80;
+ }
+ }
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(ptypes[t].diffusion)
@@ -984,7 +1335,7 @@ void update_particles_i(pixel *vid, int start, int inc)
iy += dy;
nx = (int)(ix+0.5f);
ny = (int)(iy+0.5f);
- if(nx<0 || ny<0 || nx>=XRES || ny>=YRES || pmap[ny][nx] || (bmap[ny/CELL][nx/CELL] && bmap[ny/CELL][nx/CELL]!=5))
+ if(nx<0 || ny<0 || nx>=XRES || ny>=YRES || pmap[ny][nx] || (bmap[ny/CELL][nx/CELL] && bmap[ny/CELL][nx/CELL]!=WL_STREAM))
{
parts[i].x = ix;
parts[i].y = iy;
@@ -998,7 +1349,7 @@ void update_particles_i(pixel *vid, int start, int inc)
for(ny=-1; ny<2; ny++)
if(x+nx>=0 && y+ny>0 &&
x+nx<XRES && y+ny<YRES &&
- (!bmap[(y+ny)/CELL][(x+nx)/CELL] || bmap[(y+ny)/CELL][(x+nx)/CELL]==5))
+ (!bmap[(y+ny)/CELL][(x+nx)/CELL] || bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_STREAM))
{
if(!pmap[y+ny][x+nx])
a = 1;
@@ -1026,15 +1377,29 @@ void update_particles_i(pixel *vid, int start, int inc)
t = parts[i].type = PT_BRMT;
if(t==PT_BMTL && pv[y/CELL][x/CELL]>1.0f && parts[i].tmp==1)
t = parts[i].type = PT_BRMT;
- if(t==PT_BRCK && pv[y/CELL][x/CELL]>2.8f)
+ 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)
+ t = parts[i].type = PT_BRMT;
+ 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)
+ t = parts[i].type = PT_PSTE;
+ 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)
+ t = parts[i].type = PT_NONE;
+ 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)
+ t = parts[i].type = PT_NONE;
//if(t==PT_GLAS && pv[y/CELL][x/CELL]>4.0f)
// t = parts[i].type = PT_BGLA;
if(t==PT_GLAS)
{
parts[i].pavg[0] = parts[i].pavg[1];
parts[i].pavg[1] = pv[y/CELL][x/CELL];
- if(parts[i].pavg[1]-parts[i].pavg[0] > 0.05f || parts[i].pavg[1]-parts[i].pavg[0] < -0.05f)
+ if(parts[i].pavg[1]-parts[i].pavg[0] > 0.25f || parts[i].pavg[1]-parts[i].pavg[0] < -0.25f)
{
parts[i].type = PT_BGLA;
}
@@ -1046,13 +1411,26 @@ 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))
+ {
+ t = PT_PHOT;
+ float rr = (rand()%228+128)/127.0f;
+ float a = (rand()%8) * 0.78540f;
+ parts[i].life = 680;
+ parts[i].ctype = 0x3FFFFFFF;
+ parts[i].vx = rr*cosf(a);
+ parts[i].vy = rr*sinf(a);
+ 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_SPRK&&parts[i].ctype==PT_ETRD&&parts[i].life==1)
{
nearp = nearest_part(i, PT_ETRD);
- if(nearp!=-1&&parts_avg(i, nearp)!=PT_INSL)
+ if(nearp!=-1&&parts_avg(i, nearp, PT_INSL)!=PT_INSL)
{
- create_line((int)parts[i].x, (int)parts[i].y, (int)parts[nearp].x, (int)parts[nearp].y, 0, PT_PLSM);
+ create_line((int)parts[i].x, (int)parts[i].y, (int)parts[nearp].x, (int)parts[nearp].y, 0, 0, PT_PLSM);
t = parts[i].type = PT_ETRD;
parts[i].ctype = PT_NONE;
parts[i].life = 20;
@@ -1080,7 +1458,7 @@ 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_NONE&&parts[i].type!=PT_NONE&&ptypes[parts[r>>8].type].hconduct>0&&!(parts[r>>8].type==PT_HSWC&&parts[r>>8].life!=10))
+ if(parts[r>>8].type!=PT_NONE&&parts[i].type!=PT_NONE&&ptypes[parts[r>>8].type].hconduct>0&&!(parts[r>>8].type==PT_HSWC&&parts[r>>8].life!=10)&&!(parts[i].type==PT_PHOT&&parts[r>>8].type==PT_FILT))
{
h_count++;
c_heat += parts[r>>8].temp;
@@ -1098,7 +1476,7 @@ 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_NONE&&parts[i].type!=PT_NONE&&ptypes[parts[r>>8].type].hconduct>0&&!(parts[r>>8].type==PT_HSWC&&parts[r>>8].life!=10))
+ if(parts[r>>8].type!=PT_NONE&&parts[i].type!=PT_NONE&&ptypes[parts[r>>8].type].hconduct>0&&!(parts[r>>8].type==PT_HSWC&&parts[r>>8].life!=10)&&!(parts[i].type==PT_PHOT&&parts[r>>8].type==PT_FILT))
{
parts[r>>8].temp = parts[i].temp;
}
@@ -1173,7 +1551,8 @@ void update_particles_i(pixel *vid, int start, int inc)
else
{
t = parts[i].type = pstates[t].gas;
- pv[y/CELL][x/CELL] += 0.50f;
+ if(t!=PT_A_AS)
+ pv[y/CELL][x/CELL] += 0.50f;
if(t==PT_FIRE)
parts[i].life = rand()%50+120;
if(t==PT_HFLM)
@@ -1239,14 +1618,14 @@ void update_particles_i(pixel *vid, int start, int inc)
t = PT_SPRK;
}
}
- else if(bmap[ny][nx]==6 || bmap[ny][nx]==7 || bmap[ny][nx]==3 || bmap[ny][nx]==8 || bmap[ny][nx]==11 || bmap[ny][nx]==12)
+ else if(bmap[ny][nx]==WL_DETECT || bmap[ny][nx]==WL_EWALL || bmap[ny][nx]==WL_ALLOWLIQUID || bmap[ny][nx]==WL_WALLELEC || bmap[ny][nx]==WL_ALLOWALLELEC || bmap[ny][nx]==WL_EHOLE)
set_emap(nx, ny);
}
}
nx = x/CELL;
ny = y/CELL;
- if(bmap[ny][nx]==6 && emap[ny][nx]<8)
+ if(bmap[ny][nx]==WL_DETECT && emap[ny][nx]<8)
set_emap(nx, ny);
fe = 0;
@@ -1284,6 +1663,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;
+
+ }
for(nx=-2; nx<3; nx++)
for(ny=-2; ny<3; ny++)
if(x+nx>=0 && y+ny>0 &&
@@ -1521,7 +1907,7 @@ void update_particles_i(pixel *vid, int start, int inc)
r = pmap[y+ny][x+nx];
if((r>>8)>=NPART || !r)
continue;
- if((r&0xFF)==PT_SPRK && parts[r>>8].ctype==PT_METL && parts_avg(i, r>>8)!=PT_INSL)
+ if((r&0xFF)==PT_SPRK && parts[r>>8].ctype==PT_METL && parts_avg(i, r>>8,PT_INSL)!=PT_INSL)
{
parts[i].temp = 473.0f;
}
@@ -1547,10 +1933,59 @@ void update_particles_i(pixel *vid, int start, int inc)
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(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;
+ }
}
+ 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++)
@@ -1610,7 +2045,11 @@ 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))
+ {
+ t = parts[i].type = PT_PSTE;
+ parts[r>>8].type = PT_NONE;
}
}
}
@@ -1633,6 +2072,8 @@ void update_particles_i(pixel *vid, int start, int inc)
{
parts[r>>8].type = PT_SLTW;
}
+ 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;
@@ -1707,8 +2148,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)
{
- 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)
{
@@ -1754,6 +2198,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_GUNP && 15>(rand()%1000))
parts[r>>8].type = PT_DUST;
if((r&0xFF)==PT_DYST && 15>(rand()%1000))
@@ -1777,6 +2237,10 @@ 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))
+ parts[r>>8].type = PT_FWRK;
+ if((r&0xFF)==PT_FWRK && 5>(rand()%100))
+ parts[r>>8].ctype = PT_DUST;
/*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||
@@ -1802,10 +2266,345 @@ void update_particles_i(pixel *vid, int start, int inc)
parts[i].vy *= 0.995;
}
}
+ 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_ISOZ && 5>(rand()%2000))
+ {
+ parts[i].vx *= 0.90;
+ parts[i].vy *= 0.90;
+ parts[r>>8].type = PT_PHOT;
+ float a = (rand()%8) * 0.78540f;
+ float rr = (rand()%128+128)/127.0f;
+ parts[r>>8].life = 680;
+ parts[r>>8].ctype = 0x3FFFFFFF;
+ parts[r>>8].vx = rr*cosf(a);
+ parts[r>>8].vy = rr*sinf(a);
+ 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;
+ float rr = (rand()%228+128)/127.0f;
+ float a = (rand()%8) * 0.78540f;
+ parts[r>>8].life = 680;
+ parts[r>>8].ctype = 0x3FFFFFFF;
+ parts[r>>8].vx = rr*cosf(a);
+ parts[r>>8].vy = rr*sinf(a);
+ pv[y/CELL][x/CELL] -= 15.0f * CFDS;
+ }
+ }
}
else if(t==PT_MORT) {
create_part(-1, x, y-1, PT_SMKE);
}
+ else if(t==PT_GOL||t==PT_HLIF||t==PT_ASIM||t==PT_2x2||t==PT_DANI||t==PT_AMOE||t==PT_MOVE||t==PT_PGOL||t==PT_DMOE||t==PT_34||t==PT_LLIF||t==PT_STAN)
+ {
+ 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_CRAC)
+ {
+ 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(int 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))
+ {
+ 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)
+ {
+ 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))
+ {
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART || !r)
+ continue;
+ 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;
+ }
+ }
+ for(int 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(int 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))
+ {
+ t = parts[i].type = parts[r>>8].type;
+ parts[i].ctype = parts[r>>8].ctype;
+ parts[i].life = parts[r>>8].life;
+ parts[i].tmp = parts[r>>8].tmp;
+ parts[i].temp = parts[r>>8].temp;
+ parts[i].vx = parts[r>>8].vx;
+ parts[i].vy = parts[r>>8].vy;
+ parts[r>>8].type = PT_WARP;
+ parts[r>>8].life = rand()%90+1;
+ 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++)
@@ -1841,6 +2640,304 @@ 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(int o = 0;o<3;o++)
+ for(int 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)
+ {
+ create_part(-1,x+nx,y+ny,parts[i].tmp);
+ 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[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[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))
+ {
+ 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++)
+ 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()%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)
+ {
+ 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_INST2,PT_INST,-1);//add life
+ parts[r>>8].type==parts[r>>8].ctype;
+ }
+ else if(parts[r>>8].type==PT_NSCN&&parts[r>>8].life==0&&(parts[i].life>=4)&&parts[i].life%4<=1)
+ {
+ create_part(-1,x+nx,y+ny,PT_SPRK);
+ flood_parts(x,y,PT_INST3,PT_INST,-1);//sub life
+ }
+ else if(parts[r>>8].type==PT_SWCH&&parts[r>>8].life==10&&(parts[i].life>=4)&&parts[i].life%4<=1)
+ {
+ parts[r>>8].type=PT_SPRK;
+ parts[r>>8].ctype=PT_SWCH;
+ parts[r>>8].life=4;
+ flood_parts(x,y,PT_INST3,PT_INST,-1);//sub life
+ }
+ }
+ }
+ else if(t==PT_INST2)
+ {
+ if(parts[i].life%4<=1)
+ t = parts[pmap[y][x]>>8].type=PT_INST;
+ }
+ else if(t==PT_INST3)
+ {
+ if(parts[i].life%4<=1)
+ t = parts[pmap[y][x]>>8].type=PT_INST;
+ }
+ else if(t==PT_PRTI)
+ {
+ int count =0;
+ 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 ++;
+ 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(int nnx=0;nnx<8;nnx++)
+ if(!portal[count-1][nnx])
+ {
+ portal[count-1][nnx] = parts[r>>8].type;
+ 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 count = 0;
+ 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 ++;
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART || r)
+ continue;
+ if(!r)
+ {
+ for(int nnx =0 ;nnx<8;nnx++)
+ {
+ int randomness = count + rand()%3-1;
+ if(randomness<1)
+ randomness=1;
+ if(randomness>8)
+ randomness=8;
+ if(portal[randomness-1][nnx]==PT_SPRK)//todo. make it look better
+ {
+ create_part(-1,x+1,y,portal[randomness-1][nnx]);
+ create_part(-1,x+1,y+1,portal[randomness-1][nnx]);
+ create_part(-1,x+1,y-1,portal[randomness-1][nnx]);
+ create_part(-1,x,y-1,portal[randomness-1][nnx]);
+ create_part(-1,x,y+1,portal[randomness-1][nnx]);
+ create_part(-1,x-1,y+1,portal[randomness-1][nnx]);
+ create_part(-1,x-1,y,portal[randomness-1][nnx]);
+ create_part(-1,x-1,y-1,portal[randomness-1][nnx]);
+ portal[randomness-1][nnx] = 0;
+ break;
+ }
+ else if(portal[randomness-1][nnx])
+ {
+ create_part(-1,x+nx,y+ny,portal[randomness-1][nnx]);
+ portal[randomness-1][nnx] = 0;
+ break;
+ }
+ }
+ }
+ }
+ }
+ else if(t==PT_WIFI)
+ {
+ CGOL = 1;
+ int temprange = 100;
+ for(int temp = 0; temp < 2500; temp += temprange)
+ if(parts[i].temp-273.15>temp&&parts[i].temp-273.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))
+ {
+ 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])
+ {
+ parts[r>>8].type = PT_SPRK;
+ parts[r>>8].ctype = PT_NSCN;
+ 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])
+ {
+ parts[r>>8].type = parts[r>>8].ctype;
+ wireless[parts[i].tmp] = 1;
+ ISWIRE = 1;
+ }
+ }
+ }
else if(t==PT_PCLN)
{
for(nx=-2; nx<3; nx++)
@@ -1911,6 +3008,192 @@ void update_particles_i(pixel *vid, int start, int inc)
}
}
}
+ else if(t==PT_PUMP)
+ {
+ for(nx=-2; nx<3; nx++)
+ for(ny=-2; ny<3; ny++)
+ if(x+nx>=0 && y+ny>0 &&
+ x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART || !r)
+ continue;
+ rt = parts[r>>8].type;
+ if(rt==PT_SPRK)
+ {
+ if(parts[r>>8].ctype==PT_PSCN)
+ {
+ parts[i].life = 10;
+ }
+ else if(parts[r>>8].ctype==PT_NSCN)
+ {
+ parts[i].life = 9;
+ }
+ }
+ if(rt==PT_PUMP)
+ {
+ if(parts[i].life==10&&parts[r>>8].life<10&&parts[r>>8].life>0)
+ {
+ parts[i].life = 9;
+ }
+ else if(parts[i].life==0&&parts[r>>8].life==10)
+ {
+ parts[i].life = 10;
+ }
+ }
+ }
+ }
+ 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))
+ {
+ 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(int nnx=-1;nnx<2;nnx++)
+ for(int 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))
+ {
+ 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(int nnx=-1;nnx<2;nnx++)
+ for(int 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))
+ {
+ 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(int nnx=-1;nnx<2;nnx++)
+ for(int 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))
+ {
+ 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(int nnx=-1;nnx<2;nnx++)
+ for(int 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++)
@@ -1965,7 +3248,7 @@ void update_particles_i(pixel *vid, int start, int inc)
} else {
float newVel = parts[i].life/25;
parts[i].flags = parts[i].flags&0xFFFFFFFE;
- if((pmap[(int)(ly-newVel)][(int)lx]&0xFF)==PT_NONE) {
+ if((pmap[(int)(ly-newVel)][(int)lx]&0xFF)==PT_NONE && ly-newVel>0) {
parts[i].vy = -newVel;
ly-=newVel;
iy-=newVel;
@@ -2015,7 +3298,7 @@ void update_particles_i(pixel *vid, int start, int inc)
if((r>>8)>=NPART || !r)
continue;
rt = parts[r>>8].type;
- if(parts_avg(i,r>>8) != PT_INSL)
+ if(parts_avg(i,r>>8,PT_INSL) != PT_INSL)
{
if((rt==PT_METL||rt==PT_IRON||rt==PT_ETRD||rt==PT_BMTL||rt==PT_BRMT||rt==PT_LRBD||rt==PT_RBDM||rt==PT_PSCN||rt==PT_NSCN||rt==PT_NBLE)&&parts[r>>8].life==0 && abs(nx)+abs(ny) < 4)
{
@@ -2037,7 +3320,7 @@ void update_particles_i(pixel *vid, int start, int inc)
if((r>>8)>=NPART || !r)
continue;
rt = parts[r>>8].type;
- if(parts[r>>8].type == PT_SWCH&&parts_avg(i,r>>8)!=PT_INSL)
+ if(parts[r>>8].type == PT_SWCH&&parts_avg(i,r>>8,PT_INSL)!=PT_INSL)
{
if(parts[i].life==10&&parts[r>>8].life<10&&parts[r>>8].life>0)
{
@@ -2051,7 +3334,7 @@ void update_particles_i(pixel *vid, int start, int inc)
}
}
if(t==PT_SWCH)
- if((parts[i].life>0&&parts[i].life<10)|| parts[i].life == 11)
+ if((parts[i].life>0&&parts[i].life<10)|| parts[i].life > 10)
{
parts[i].life--;
}
@@ -2065,12 +3348,12 @@ void update_particles_i(pixel *vid, int start, int inc)
r = pmap[y+ny][x+nx];
if((r>>8)>=NPART || !r)
continue;
- if(bmap[(y+ny)/CELL][(x+nx)/CELL] && bmap[(y+ny)/CELL][(x+nx)/CELL]!=5)
+ if(bmap[(y+ny)/CELL][(x+nx)/CELL] && bmap[(y+ny)/CELL][(x+nx)/CELL]!=WL_STREAM)
continue;
rt = parts[r>>8].type;
if((a || ptypes[rt].explosive) && ((rt!=PT_RBDM && rt!=PT_LRBD && rt!=PT_INSL && rt!=PT_SWCH) || t!=PT_SPRK) &&
!(t==PT_PHOT && rt==PT_INSL) &&
- (t!=PT_LAVA || parts[i].life>0 || (rt!=PT_STNE && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_METL && rt!=PT_IRON && rt!=PT_ETRD && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SWCH && rt!=PT_INWR)) &&
+ (t!=PT_LAVA || parts[i].life>0 || (rt!=PT_STNE && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_METL && rt!=PT_IRON && rt!=PT_ETRD && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SWCH && rt!=PT_INWR)) && !(rt==PT_CRAC && parts[r>>8].life>0) &&
ptypes[rt].flammable && (ptypes[rt].flammable + (int)(pv[(y+ny)/CELL][(x+nx)/CELL]*10.0f))>(rand()%1000))
{
parts[r>>8].type = PT_FIRE;
@@ -2143,36 +3426,36 @@ void update_particles_i(pixel *vid, int start, int inc)
//If so turn the SPRK that covers the SWCH back into SWCH and turn it off
if(rt==PT_SPRK && parts[r>>8].ctype == PT_SWCH && t==PT_SPRK)
{
- pavg = parts_avg(r>>8, i);
+ pavg = parts_avg(r>>8, i,PT_INSL);
if(parts[i].ctype == PT_NSCN&&pavg != PT_INSL)
{
parts[r>>8].type = PT_SWCH;
parts[r>>8].ctype = PT_NONE;
- parts[r>>8].life = 0;
+ parts[r>>8].life = 9;
}
}
- pavg = parts_avg(i, r>>8);
+ pavg = parts_avg(i, r>>8,PT_INSL);
if(rt==PT_SWCH && t==PT_SPRK)
{
- pavg = parts_avg(r>>8, i);
- if(parts[i].ctype == PT_PSCN&&pavg != PT_INSL)
+ pavg = parts_avg(r>>8, i,PT_INSL);
+ if(parts[i].ctype == PT_PSCN&&pavg != PT_INSL && parts[r>>8].life<10)
parts[r>>8].life = 10;
if(parts[i].ctype == PT_NSCN&&pavg != PT_INSL)
parts[r>>8].life = 9;
- if(!(parts[i].ctype == PT_PSCN||parts[i].ctype == PT_NSCN)&&parts[r>>8].life >= 10&&pavg != PT_INSL) //Life can be 11 too, so don't just check for 10
+ if(!(parts[i].ctype == PT_PSCN||parts[i].ctype == PT_NSCN)&&parts[r>>8].life == 10&&pavg != PT_INSL)
{
parts[r>>8].type = PT_SPRK;
parts[r>>8].ctype = PT_SWCH;
parts[r>>8].life = 4;
}
}
- pavg = parts_avg(i, r>>8);
+ pavg = parts_avg(i, r>>8,PT_INSL);
if(pavg != PT_INSL)
{
if(t==PT_SPRK && (rt==PT_METL||rt==PT_IRON||rt==PT_ETRD||rt==PT_BMTL||rt==PT_BRMT||rt==PT_LRBD||rt==PT_RBDM||rt==PT_PSCN||rt==PT_NSCN||rt==PT_NBLE) && parts[r>>8].life==0 &&
(parts[i].life<3 || ((r>>8)<i && parts[i].life<4)) && abs(nx)+abs(ny)<4)
{
- if(!(rt==PT_PSCN&&parts[i].ctype==PT_NSCN)&&!(rt!=PT_PSCN&&!(rt==PT_NSCN&&parts[i].temp>=373.0f)&&parts[i].ctype==PT_NTCT)&&!(rt!=PT_PSCN&&!(rt==PT_NSCN&&parts[i].temp<=373.0f)&&parts[i].ctype==PT_PTCT)&&!(rt!=PT_PSCN&&!(rt==PT_NSCN)&&parts[i].ctype==PT_INWR) && pavg != PT_INSL &&!(parts[i].ctype==PT_SWCH&&(rt==PT_PSCN||rt==PT_NSCN)) )
+ if(!(rt==PT_PSCN&&parts[i].ctype==PT_NSCN)&&!(rt!=PT_PSCN&&!(rt==PT_NSCN&&parts[i].temp>=373.0f)&&parts[i].ctype==PT_NTCT)&&!(rt!=PT_PSCN&&!(rt==PT_NSCN&&parts[i].temp<=373.0f)&&parts[i].ctype==PT_PTCT)&&!(rt!=PT_PSCN&&!(rt==PT_NSCN)&&parts[i].ctype==PT_INWR) && pavg != PT_INSL &&!(parts[i].ctype==PT_SWCH&&(rt==PT_PSCN||rt==PT_NSCN))&&!(parts[i].ctype==PT_INST&&rt!=PT_NSCN) )
{
parts[r>>8].type = PT_SPRK;
parts[r>>8].life = 4;
@@ -2246,10 +3529,10 @@ void update_particles_i(pixel *vid, int start, int inc)
parts[i].temp = 3500;
pv[y/CELL][x/CELL] += 1;
}
- if(t==PT_SPRK&&parts[i].ctype==PT_SWCH&&parts[i].life<=1)
+ if(t==PT_SPRK&&parts[i].ctype==PT_SWCH&&parts[i].life<=0)
{
parts[i].type = PT_SWCH;
- parts[i].life = 11;
+ parts[i].life = 14;
}
}
}
@@ -2414,9 +3697,9 @@ killed:
}
//Charge detector wall if foot inside
- if(bmap[(int)(player[8]+0.5)/CELL][(int)(player[7]+0.5)/CELL]==6)
+ if(bmap[(int)(player[8]+0.5)/CELL][(int)(player[7]+0.5)/CELL]==WL_DETECT)
set_emap((int)player[7]/CELL, (int)player[8]/CELL);
- if(bmap[(int)(player[16]+0.5)/CELL][(int)(player[15]+0.5)/CELL]==6)
+ if(bmap[(int)(player[16]+0.5)/CELL][(int)(player[15]+0.5)/CELL]==WL_DETECT)
set_emap((int)(player[15]+0.5)/CELL, (int)(player[16]+0.5)/CELL);
//Searching for particles near head
@@ -2443,7 +3726,7 @@ killed:
parts[i].life -= (102-parts[i].life)/2;
kill_part(pmap[ny+y][nx+x]>>8);
}
- if(bmap[(ny+y)/CELL][(nx+x)/CELL]==4)
+ if(bmap[(ny+y)/CELL][(nx+x)/CELL]==WL_FAN)
player[2] = SPC_AIR;
}
@@ -2465,7 +3748,7 @@ killed:
else
{
if(player[2] == SPC_AIR)
- create_parts(nx + 3*((((int)player[1])&0x02) == 0x02) - 3*((((int)player[1])&0x01) == 0x01), ny, 4, SPC_AIR);
+ create_parts(nx + 3*((((int)player[1])&0x02) == 0x02) - 3*((((int)player[1])&0x01) == 0x01), ny, 4, 4, SPC_AIR);
else
create_part(-1, nx, ny, player[2]);
@@ -2667,6 +3950,27 @@ killed:
}
}
+ if(t==PT_BCLN)
+ {
+ if(!parts[i].ctype)
+ {
+ 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 &&
+ 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_STKM &&
+ (pmap[y+ny][x+nx]&0xFF)!=0xFF)
+ parts[i].ctype = pmap[y+ny][x+nx]&0xFF;
+ }
+ else {
+ create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype);
+ }
+
+ }
if(parts[i].type==PT_PCLN)
{
if(!parts[i].ctype)
@@ -2853,7 +4157,7 @@ killed:
s = 1;
break;
}
- if((pmap[y][j]&255)!=t || (bmap[y/CELL][j/CELL] && bmap[y/CELL][j/CELL]!=5))
+ if((pmap[y][j]&255)!=t || (bmap[y/CELL][j/CELL] && bmap[y/CELL][j/CELL]!=WL_STREAM))
break;
}
if(parts[i].vy>0)
@@ -2861,14 +4165,14 @@ killed:
else
r = -1;
if(s)
- for(j=y+r; j>=0 && j<YRES && j>=y-rt && j<x+rt; j+=r)
+ for(j=y+r; j>=0 && j<YRES && j>=y-rt && j<y+rt; j+=r)
{
if(try_move(i, x, y, x, j))
{
parts[i].y += j-y;
break;
}
- if((pmap[j][x]&255)!=t || (bmap[j/CELL][x/CELL] && bmap[j/CELL][x/CELL]!=5))
+ if((pmap[j][x]&255)!=t || (bmap[j/CELL][x/CELL] && bmap[j/CELL][x/CELL]!=WL_STREAM))
{
s = 0;
break;
@@ -2993,6 +4297,7 @@ void update_particles(pixel *vid)
isplayer = 0; //Needed for player spawning
memset(pmap, 0, sizeof(pmap));
r = rand()%2;
+ NUM_PARTS = 0;
for(j=0; j<NPART; j++)
{
i = r ? (NPART-1-j) : j;
@@ -3005,6 +4310,7 @@ void update_particles(pixel *vid)
if(t!=PT_NEUT || (pmap[y][x]&0xFF)!=PT_GLAS)
pmap[y][x] = t|(i<<8);
}
+ NUM_PARTS ++;
}
else
{
@@ -3013,13 +4319,13 @@ void update_particles(pixel *vid)
}
}
pfree=l;
- if(cmode==4)
+ if(cmode==CM_BLOB)
{
for(y=0; y<YRES/CELL; y++)
{
for(x=0; x<XRES/CELL; x++)
{
- if(bmap[y][x]==1)
+ if(bmap[y][x]==WL_WALL)
for(j=0; j<CELL; j++)
for(i=0; i<CELL; i++)
{
@@ -3028,14 +4334,14 @@ void update_particles(pixel *vid)
drawblob(vid, (x*CELL+i), (y*CELL+j), 0x80, 0x80, 0x80);
}
- if(bmap[y][x]==2)
+ if(bmap[y][x]==WL_DESTROYALL)
for(j=0; j<CELL; j+=2)
for(i=(j>>1)&1; i<CELL; i+=2)
{
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
drawblob(vid, (x*CELL+i), (y*CELL+j), 0x80, 0x80, 0x80);
}
- if(bmap[y][x]==3)
+ if(bmap[y][x]==WL_ALLOWLIQUID)
{
for(j=0; j<CELL; j++)
for(i=0; i<CELL; i++)
@@ -3058,14 +4364,14 @@ void update_particles(pixel *vid)
fire_b[y][x] = cb;
}
}
- if(bmap[y][x]==4)
+ if(bmap[y][x]==WL_FAN)
for(j=0; j<CELL; j+=2)
for(i=(j>>1)&1; i<CELL; i+=2)
{
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x8080FF);
drawblob(vid, (x*CELL+i), (y*CELL+j), 0x80, 0x80, 0xFF);
}
- if(bmap[y][x]==6)
+ if(bmap[y][x]==WL_DETECT)
{
for(j=0; j<CELL; j+=2)
for(i=(j>>1)&1; i<CELL; i+=2)
@@ -3089,7 +4395,7 @@ void update_particles(pixel *vid)
fire_b[y][x] = cb;
}
}
- if(bmap[y][x]==7)
+ if(bmap[y][x]==WL_EWALL)
{
if(emap[y][x])
{
@@ -3125,7 +4431,7 @@ void update_particles(pixel *vid)
}
}
}
- if(bmap[y][x]==8)
+ if(bmap[y][x]==WL_WALLELEC)
{
for(j=0; j<CELL; j++)
for(i=0; i<CELL; i++)
@@ -3156,7 +4462,7 @@ void update_particles(pixel *vid)
fire_b[y][x] = cb;
}
}
- if(bmap[y][x]==11)
+ if(bmap[y][x]==WL_ALLOWALLELEC)
{
for(j=0; j<CELL; j++)
for(i=0; i<CELL; i++)
@@ -3183,7 +4489,7 @@ void update_particles(pixel *vid)
fire_b[y][x] = cb;
}
}
- if(bmap[y][x]==13)
+ if(bmap[y][x]==WL_ALLOWGAS)
{
for(j=0; j<CELL; j+=2)
{
@@ -3194,7 +4500,7 @@ void update_particles(pixel *vid)
}
}
}
- if(bmap[y][x]==9)
+ if(bmap[y][x]==WL_ALLOWAIR)
{
for(j=0; j<CELL; j+=2)
{
@@ -3205,7 +4511,7 @@ void update_particles(pixel *vid)
}
}
}
- if(bmap[y][x]==10)
+ if(bmap[y][x]==WL_ALLOWSOLID)
{
for(j=0; j<CELL; j+=2)
{
@@ -3216,7 +4522,7 @@ void update_particles(pixel *vid)
}
}
}
- if(bmap[y][x]==12)
+ if(bmap[y][x]==WL_EHOLE)
{
if(emap[y][x])
{
@@ -3272,18 +4578,18 @@ void update_particles(pixel *vid)
{
for(x=0; x<XRES/CELL; x++)
{
- if(bmap[y][x]==1)
+ if(bmap[y][x]==WL_WALL)
for(j=0; j<CELL; j++)
for(i=0; i<CELL; i++)
{
pmap[y*CELL+j][x*CELL+i] = 0x7FFFFFFF;
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
}
- if(bmap[y][x]==2)
+ if(bmap[y][x]==WL_DESTROYALL)
for(j=0; j<CELL; j+=2)
for(i=(j>>1)&1; i<CELL; i+=2)
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
- if(bmap[y][x]==3)
+ if(bmap[y][x]==WL_ALLOWLIQUID)
{
for(j=0; j<CELL; j++)
for(i=0; i<CELL; i++)
@@ -3303,11 +4609,11 @@ void update_particles(pixel *vid)
fire_b[y][x] = cb;
}
}
- if(bmap[y][x]==4)
+ if(bmap[y][x]==WL_FAN)
for(j=0; j<CELL; j+=2)
for(i=(j>>1)&1; i<CELL; i+=2)
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x8080FF);
- if(bmap[y][x]==6)
+ if(bmap[y][x]==WL_DETECT)
{
for(j=0; j<CELL; j+=2)
for(i=(j>>1)&1; i<CELL; i+=2)
@@ -3328,7 +4634,7 @@ void update_particles(pixel *vid)
fire_b[y][x] = cb;
}
}
- if(bmap[y][x]==7)
+ if(bmap[y][x]==WL_EWALL)
{
if(emap[y][x])
{
@@ -3358,7 +4664,7 @@ void update_particles(pixel *vid)
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
}
}
- if(bmap[y][x]==8)
+ if(bmap[y][x]==WL_WALLELEC)
{
for(j=0; j<CELL; j++)
for(i=0; i<CELL; i++)
@@ -3383,7 +4689,7 @@ void update_particles(pixel *vid)
fire_b[y][x] = cb;
}
}
- if(bmap[y][x]==11)
+ if(bmap[y][x]==WL_ALLOWALLELEC)
{
for(j=0; j<CELL; j++)
for(i=0; i<CELL; i++)
@@ -3407,7 +4713,7 @@ void update_particles(pixel *vid)
fire_b[y][x] = cb;
}
}
- if(bmap[y][x]==9)
+ if(bmap[y][x]==WL_ALLOWAIR)
{
for(j=0; j<CELL; j+=2)
{
@@ -3417,7 +4723,7 @@ void update_particles(pixel *vid)
}
}
}
- if(bmap[y][x]==13)
+ if(bmap[y][x]==WL_ALLOWGAS)
{
for(j=0; j<CELL; j+=2)
{
@@ -3427,7 +4733,7 @@ void update_particles(pixel *vid)
}
}
}
- if(bmap[y][x]==10)
+ if(bmap[y][x]==WL_ALLOWSOLID)
{
for(j=0; j<CELL; j+=2)
{
@@ -3437,7 +4743,7 @@ void update_particles(pixel *vid)
}
}
}
- if(bmap[y][x]==12)
+ if(bmap[y][x]==WL_EHOLE)
{
if(emap[y][x])
{
@@ -3490,7 +4796,7 @@ void update_particles(pixel *vid)
for(y=0; y<YRES/CELL; y++)
for(x=0; x<XRES/CELL; x++)
- if(bmap[y][x]==5)
+ if(bmap[y][x]==WL_STREAM)
{
lx = x*CELL + CELL*0.5f;
ly = y*CELL + CELL*0.5f;
@@ -3505,7 +4811,7 @@ void update_particles(pixel *vid)
j = ny/CELL;
lx += vx[j][i]*0.125f;
ly += vy[j][i]*0.125f;
- if(bmap[j][i]==5 && i!=x && j!=y)
+ if(bmap[j][i]==WL_STREAM && i!=x && j!=y)
break;
}
drawtext(vid, x*CELL, y*CELL-2, "\x8D", 255, 255, 255, 128);
@@ -3544,43 +4850,48 @@ void create_box(int x1, int y1, int x2, int y2, int c)
}
for(j=y1; j<=y2; j++)
for(i=x1; i<=x2; i++)
- create_parts(i, j, 1, c);
+ create_parts(i, j, 1, 1, c);
}
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(c>=122&&c<=122+UI_WALLCOUNT)
+ if(cm==PT_INST&&(co==PT_INST2||co==PT_INST3))
+ if((pmap[y][x]&0xFF)==PT_INST2 || (pmap[y][x]&0xFF)==PT_INST3)
+ 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;
}
else
cm = 0;
}
if(bm==-1)
{
- if(c==30)
+ if(c==WL_ERASE)
{
bm = bmap[y/CELL][x/CELL];
if(!bm)
return 0;
- if(bm==1)
+ if(bm==WL_WALL)
cm = 0xFF;
}
else
bm = 0;
}
- if((pmap[y][x]&0xFF)!=cm || bmap[y/CELL][x/CELL]!=bm)
+ if(((pmap[y][x]&0xFF)!=cm || bmap[y/CELL][x/CELL]!=bm )||( (sdl_mod & (KMOD_CAPS)) && cm!=SLALT))
return 1;
// go left as far as possible
@@ -3588,22 +4899,67 @@ 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;
+ {
+ if(cm!=PT_INST)
+ break;
+ else if((pmap[y][x1-1]&0xFF)!=PT_INST2&&(pmap[y][x1-1]&0xFF)!=PT_INST3)
+ break;
+ }
x1--;
}
while(x2<XRES-CELL)
{
if((pmap[y][x2+1]&0xFF)!=cm || bmap[y/CELL][(x2+1)/CELL]!=bm)
- break;
+ {
+ if(cm!=PT_INST)
+ break;
+ else if((pmap[y][x1+1]&0xFF)!=PT_INST2&&(pmap[y][x1+1]&0xFF)!=PT_INST3)
+ break;
+ }
x2++;
}
// fill span
for(x=x1; x<=x2; x++)
- if(!create_parts(x, y, 0, co))
+ {
+ if(!create_parts(x, y, 0, 0, co))
return 0;
-
+ }
// fill children
+ if(cm==PT_INST&&(co==PT_INST2||co==PT_INST3))//crossings for inst wire, same as walls
+ {
+ if(y>=CELL+dy && x1==x2 &&
+ ((pmap[y-1][x1-1]&0xFF)==PT_INST||((pmap[y-1][x1-1]&0xFF)==PT_INST3||(pmap[y-1][x1-1]&0xFF)==PT_INST2)) && ((pmap[y-1][x1]&0xFF)==PT_INST||((pmap[y-1][x1]&0xFF)==PT_INST3||(pmap[y-1][x1]&0xFF)==PT_INST2)) && ((pmap[y-1][x1+1]&0xFF)==PT_INST || ((pmap[y-1][x1+1]&0xFF)==PT_INST3||(pmap[y-1][x1+1]&0xFF)==PT_INST2)) &&
+ (pmap[y-2][x1-1]&0xFF)!=PT_INST && ((pmap[y-2][x1]&0xFF)==PT_INST ||((pmap[y-2][x1]&0xFF)==PT_INST3||(pmap[y-2][x1]&0xFF)==PT_INST2)) && (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)!=co)
+ {
+ 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)!=co) || (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_INST3||(pmap[y+1][x1-1]&0xFF)==PT_INST2)) && ((pmap[y+1][x1]&0xFF)==PT_INST||((pmap[y+1][x1]&0xFF)==PT_INST3||(pmap[y+1][x1]&0xFF)==PT_INST2)) && ((pmap[y+1][x1+1]&0xFF)==PT_INST || ((pmap[y+1][x1+1]&0xFF)==PT_INST3||(pmap[y+1][x1+1]&0xFF)==PT_INST2)) &&
+ (pmap[y+2][x1-1]&0xFF)!=PT_INST && ((pmap[y+2][x1]&0xFF)==PT_INST ||((pmap[y+2][x1]&0xFF)==PT_INST3||(pmap[y+2][x1]&0xFF)==PT_INST2)) && (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)!=co)
+ {
+ 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)!=co) || (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)
@@ -3614,149 +4970,137 @@ int flood_parts(int x, int y, int c, int cm, int bm)
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;
- return 1;
+ }
+ if(!(cm==PT_INST&&(co==PT_INST2||co==PT_INST3)))
+ return 1;
}
-int create_parts(int x, int y, int r, int c)
+int create_parts(int x, int y, int rx, int ry, int c)
{
- int i, j, f = 0, u, v, oy, ox, b = 0, dw = 0; //n;
-
- if(c == 125)
- {
- i = x / CELL;
- j = y / CELL;
- 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] == 5)
- return 1;
- bmap[j][i] = 5;
- return 1;
- }
- if(c == 127)
- {
- b = 4;
- dw = 1;
- }
- if(c == 122)
- {
- b = 8;
- dw = 1;
- }
- if(c == 123)
- {
- b = 7;
- dw = 1;
- }
- if(c == 124)
+ int i, j, f = 0, u, v, oy, ox, b = 0, dw = 0, stemp = 0;//n;
+
+ int wall = c - 100;
+ for(int r=UI_ACTUALSTART;r<=UI_ACTUALSTART+UI_WALLCOUNT;r++)
{
- b = 6;
- 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 == 128)
+ if(c == WL_FANHELPER)
{
- b = 3;
- dw = 1;
- }
- if(c == 129)
- {
- b = 2;
- dw = 1;
- }
- if(c == 130)
- {
- b = 0;
- dw = 1;
- }
- if(c == 131)
- {
- b = 1;
- dw = 1;
- }
- if(c == 132)
- {
- b = 9;
- dw = 1;
- }
- if(c == 133)
- {
- b = 10;
- dw = 1;
- }
- if(c == 134)
- {
- b = 11;
- dw = 1;
- }
- if(c == 135)
- {
- b = 12;
- dw = 1;
- }
- if(c == 140)
- {
- b = 13;
- dw = 1;
- }
- if(c == 255)
- {
- b = 255;
+ b = WL_FANHELPER;
dw = 1;
}
if(dw==1)
{
- r = r/CELL;
+ rx = rx/CELL;
x = x/CELL;
y = y/CELL;
- x -= r/2;
- y -= r/2;
- for (ox=x; ox<=x+r; ox++)
+ x -= rx/2;
+ y -= rx/2;
+ for (ox=x; ox<=x+rx; ox++)
{
- for (oy=y; oy<=y+r; oy++)
+ for (oy=y; oy<=y+rx; oy++)
{
if(ox>=0&&ox<XRES/CELL&&oy>=0&&oy<YRES/CELL)
{
i = ox;
j = oy;
- if(b==4)
+ 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;
+ }
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=-r; j<=r; j++)
- for(i=-r; i<=r; i++)
- if(i*i+j*j<=r*r)
+ 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))
create_part(-1, x+i, y+j, c);
return 1;
}
- if(c == 0)
+ if(c == 0 && !REPLACE_MODE)
{
- for(j=-r; j<=r; j++)
- for(i=-r; i<=r; i++)
- if(i*i+j*j<=r*r)
+ 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;
return 1;
}
-
- for(j=-r; j<=r; j++)
- for(i=-r; i<=r; i++)
- if(i*i+j*j<=r*r)
+ if(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))
+ {
+ 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(-1, x+i, y+j, c);
+ }
+ }
+ return 1;
+
+ }
+ 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(create_part(-1, x+i, y+j, c)==-1)
f = 1;
return !f;
}
-void create_line(int x1, int y1, int x2, int y2, int r, int c)
+void create_line(int x1, int y1, int x2, int y2, int rx, int ry, int c)
{
int cp=abs(y2-y1)>abs(x2-x1), x, y, dx, dy, sy;
float e, de;
@@ -3790,19 +5134,19 @@ void create_line(int x1, int y1, int x2, int y2, int r, int c)
for(x=x1; x<=x2; x++)
{
if(cp)
- create_parts(y, x, r, c);
+ create_parts(y, x, rx, ry, c);
else
- create_parts(x, y, r, c);
+ create_parts(x, y, rx, ry, c);
e += de;
if(e >= 0.5f)
{
y += sy;
- if(c==135 || c==140 || c==134 || c==133 || c==132 || c==131 || c==129 || c==128 || c==127 || c==125 || c==124 || c==123 || c==122 || !r)
+ if(c==WL_EHOLE || c==WL_ALLOWGAS || c==WL_ALLOWALLELEC || c==WL_ALLOWSOLID || c==WL_ALLOWAIR || c==WL_WALL || c==WL_DESTROYALL || c==WL_ALLOWLIQUID || c==WL_FAN || c==WL_STREAM || c==WL_DETECT || c==WL_EWALL || c==WL_WALLELEC || !(rx+ry))
{
if(cp)
- create_parts(y, x, r, c);
+ create_parts(y, x, rx, ry, c);
else
- create_parts(x, y, r, c);
+ create_parts(x, y, rx, ry, c);
}
e -= 1.0f;
}