summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFelix Wallin <nibbler.v1@gmail.com>2010-12-20 13:34:55 (GMT)
committer Felix Wallin <nibbler.v1@gmail.com>2010-12-20 13:34:55 (GMT)
commit14b4dfef87892ad744cbb8b6fbdc0bc80044d51b (patch)
treea50bde6af1f0df4ecc8ed512ccfd5a9010b93a0b /src
parentcb6597f9e192b13546295c030ad98bad4f041648 (diff)
downloadpowder-14b4dfef87892ad744cbb8b6fbdc0bc80044d51b.zip
powder-14b4dfef87892ad744cbb8b6fbdc0bc80044d51b.tar.gz
nice
Diffstat (limited to 'src')
-rw-r--r--src/graphics.c798
-rw-r--r--src/interface.c648
-rw-r--r--src/main.c476
-rw-r--r--src/powder.c3163
4 files changed, 2539 insertions, 2546 deletions
diff --git a/src/graphics.c b/src/graphics.c
index 3ea4c9c..a98b66b 100644
--- a/src/graphics.c
+++ b/src/graphics.c
@@ -745,10 +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)
{
- 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(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);
@@ -1008,22 +1008,22 @@ int textnwidth(char *s, int n)
void textnpos(char *s, int n, int w, int *cx, int *cy)
{
int x = 0;
- int y = 0;
- //TODO: Implement Textnheight for wrapped text
- for(; *s; s++)
+ int y = 0;
+ //TODO: Implement Textnheight for wrapped text
+ for(; *s; s++)
{
- if(!n){
+ if(!n) {
break;
- }
+ }
x += font_data[font_ptrs[(int)(*(unsigned char *)s)]];
- if(x>=w) {
- x = 0;
- y += FONT_H+2;
- }
+ if(x>=w) {
+ x = 0;
+ y += FONT_H+2;
+ }
n--;
}
*cx = x-1;
- *cy = y;
+ *cy = y;
}
int textwidthx(char *s, int w)
@@ -1048,10 +1048,10 @@ int textposxy(char *s, int width, int w, int h)
if(x+(cw/2) >= w && y+6 >= h)
break;
x += cw;
- if(x>=width) {
- x = 0;
- y += FONT_H+2;
- }
+ if(x>=width) {
+ x = 0;
+ y += FONT_H+2;
+ }
n++;
}
return n;
@@ -1124,42 +1124,42 @@ void draw_air(pixel *vid)
c = PIXRGB(0, 0, clamp_flt(-pv[y][x], 0.0f, 8.0f));
}
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);
- }
- }
+ }
+ 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;
@@ -1305,16 +1305,16 @@ void draw_parts(pixel *vid)
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(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 == CM_FANCY) //If fancy mode
@@ -1402,7 +1402,7 @@ void draw_parts(pixel *vid)
isplayer = 1; //It's a secret. Tssss...
}
- else if(t==PT_STKM2) //Just draw head here
+ else if(t==PT_STKM2) //Just draw head here
{
char buff[10]; //Buffer for HP
@@ -1427,82 +1427,82 @@ void draw_parts(pixel *vid)
isplayer2 = 1; //It's a secret. Tssss...
}
- if(cmode==CM_NOTHING && t!=PT_PIPE && t!=PT_SWCH && t!=PT_LCRY && t!=PT_PUMP && t!=PT_FILT && t!=PT_HSWC && t!=PT_PCLN && t!=PT_DEUT && t!=PT_WIFI)//nothing display but show needed color changes
- {
- if(t==PT_PHOT)
- {
- 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, 255);
- }
- else
- {
- cr = PIXR(ptypes[t].pcolors);
- cg = PIXG(ptypes[t].pcolors);
- cb = PIXB(ptypes[t].pcolors);
- blendpixel(vid, nx, ny, cr, cg, cb, 255);
- }
- }
- else if(cmode==CM_GRAD)//forgot to put else, broke nothing view
- {
- if((t==PT_METL||t==PT_BRMT||t==PT_BMTL)&&parts[i].temp>473&&parts[i].temp<1370)
- {
- float frequency = 0.00146;
- int q = parts[i].temp-473;
- cr = sin(frequency*q) * 226 + PIXR(ptypes[t].pcolors);
- cg = sin(frequency*q*4.55 +3.14) * 34 + PIXG(ptypes[t].pcolors);
- cb = sin(frequency*q*2.22 +3.14) * 64 + 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
- {
- float frequency = 0.05;
- int q = parts[i].temp-40;
- 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);
- }
-
- }
+ if(cmode==CM_NOTHING && t!=PT_PIPE && t!=PT_SWCH && t!=PT_LCRY && t!=PT_PUMP && t!=PT_FILT && t!=PT_HSWC && t!=PT_PCLN && t!=PT_DEUT && t!=PT_WIFI)//nothing display but show needed color changes
+ {
+ if(t==PT_PHOT)
+ {
+ 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, 255);
+ }
+ else
+ {
+ cr = PIXR(ptypes[t].pcolors);
+ cg = PIXG(ptypes[t].pcolors);
+ cb = PIXB(ptypes[t].pcolors);
+ blendpixel(vid, nx, ny, cr, cg, cb, 255);
+ }
+ }
+ else if(cmode==CM_GRAD)//forgot to put else, broke nothing view
+ {
+ if((t==PT_METL||t==PT_BRMT||t==PT_BMTL)&&parts[i].temp>473&&parts[i].temp<1370)
+ {
+ float frequency = 0.00146;
+ int q = parts[i].temp-473;
+ cr = sin(frequency*q) * 226 + PIXR(ptypes[t].pcolors);
+ cg = sin(frequency*q*4.55 +3.14) * 34 + PIXG(ptypes[t].pcolors);
+ cb = sin(frequency*q*2.22 +3.14) * 64 + 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
+ {
+ float frequency = 0.05;
+ int q = parts[i].temp-40;
+ 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++)
@@ -1519,30 +1519,30 @@ void draw_parts(pixel *vid)
}
}
- else if(t==PT_SPNG)
- {
+ else if(t==PT_SPNG)
+ {
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;
+ 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;
+ cr = 20;
+ cg = 20;
+ cb = 20;
cg += fire_g[y][x];
if(cg > 255) cg = 255;
fire_g[y][x] = cg;
@@ -1552,28 +1552,28 @@ void draw_parts(pixel *vid)
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)
+ }
+ 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)
+ 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;
@@ -1591,94 +1591,94 @@ void draw_parts(pixel *vid)
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.0628;
- 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);
- if(mousex==(nx) && mousey==(ny))
- {
- int z;
+ 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.0628;
+ 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);
+ if(mousex==(nx) && mousey==(ny))
+ {
+ int z;
for(z = 0; z<NPART; z++) {
- if(parts[z].type)
- {
- if(parts[z].type==PT_WIFI&&parts[z].tmp==parts[i].tmp)
- xor_line(nx,ny,(int)(parts[z].x+0.5f),(int)(parts[z].y+0.5f),vid);
- }
- }
- }
- }
- else if((t==PT_BIZR||t==PT_BIZRG)&&parts[i].ctype)
- {
- 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;
- if(fabs(parts[i].vx)+fabs(parts[i].vy)>0 &&(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY)) {
- fg = 0;
- fb = 0;
- fr = 0;
+ if(parts[z].type)
+ {
+ if(parts[z].type==PT_WIFI&&parts[z].tmp==parts[i].tmp)
+ xor_line(nx,ny,(int)(parts[z].x+0.5f),(int)(parts[z].y+0.5f),vid);
+ }
+ }
+ }
+ }
+ else if((t==PT_BIZR||t==PT_BIZRG)&&parts[i].ctype)
+ {
+ 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;
+ if(fabs(parts[i].vx)+fabs(parts[i].vy)>0 &&(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY)) {
+ fg = 0;
+ fb = 0;
+ fr = 0;
fg = cg/40 * fabs(parts[i].vx)+fabs(parts[i].vy);
fb = cb/40 * fabs(parts[i].vx)+fabs(parts[i].vy);
fr = cr/40 * fabs(parts[i].vx)+fabs(parts[i].vy);
- vid[ny*(XRES+BARSIZE)+nx] = PIXRGB((int)restrict_flt(cr, 0, 255), (int)restrict_flt(cg, 0, 255), (int)restrict_flt(cb, 0, 255));
+ vid[ny*(XRES+BARSIZE)+nx] = PIXRGB((int)restrict_flt(cr, 0, 255), (int)restrict_flt(cg, 0, 255), (int)restrict_flt(cb, 0, 255));
x = nx/CELL;
y = ny/CELL;
fg += fire_g[y][x];
@@ -1690,70 +1690,70 @@ void draw_parts(pixel *vid)
fr += fire_r[y][x];
if(fr > 255) fr = 255;
fire_r[y][x] = fr;
- }
- else
- 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
+ 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;
@@ -1888,45 +1888,45 @@ 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_BRAY && parts[i].tmp==0)
- {
- int trans = parts[i].life * 7;
- blendpixel(vid, nx, ny, PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors), trans);
- }
- else if(t==PT_BRAY && parts[i].tmp==1)
- {
- int trans = parts[i].life/4;
- blendpixel(vid, nx, ny, PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors), trans);
- }
- else if(t==PT_BRAY && parts[i].tmp==2)
- {
- int trans = parts[i].life*100;
- blendpixel(vid, nx, ny, 255, 150, 50, trans);
- }
+ 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_BRAY && parts[i].tmp==0)
+ {
+ int trans = parts[i].life * 7;
+ blendpixel(vid, nx, ny, PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors), trans);
+ }
+ else if(t==PT_BRAY && parts[i].tmp==1)
+ {
+ int trans = parts[i].life/4;
+ blendpixel(vid, nx, ny, PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors), trans);
+ }
+ else if(t==PT_BRAY && parts[i].tmp==2)
+ {
+ int trans = parts[i].life*100;
+ blendpixel(vid, nx, ny, 255, 150, 50, trans);
+ }
else if(t==PT_PHOT)
{
if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY)
@@ -2291,7 +2291,7 @@ void draw_parts(pixel *vid)
blendpixel(vid, nx-1, ny+1, GR, 10, 10, 112);
}
}
- else if(t==PT_PUMP)
+ else if(t==PT_PUMP)
{
uint8 GR = 0x3B+(parts[i].life*19);
vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(10, 10, GR);
@@ -2604,7 +2604,7 @@ void draw_parts(pixel *vid)
isplayer = 1; //It's a secret. Tssss...
}
- else if(t==PT_STKM2) //Stick man should be visible in heat mode
+ else if(t==PT_STKM2) //Stick man should be visible in heat mode
{
char buff[10]; //Buffer for HP
@@ -2723,15 +2723,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;
- }
+ if(MSIGN==i)
+ {
+ bq = b;
+ b = SDL_GetMouseState(&mx, &my);
+ mx /= sdl_scale;
+ my /= sdl_scale;
+ signs[i].x = mx;
+ signs[i].y = my;
+ }
}
}
@@ -2961,12 +2961,12 @@ pixel *prerender_save(void *save, int size, int *width, int *height)
if(!(j%2) && !(i%2))
fb[(ry+j)*w+(rx+i)] = PIXPACK(0xC0C0C0);
break;
- case 4:
- for(j=0; j<CELL; j+=2)
- for(i=(j>>1)&1; i<CELL; i+=2)
- fb[(ry+j)*w+(rx+i)] = PIXPACK(0x8080FF);
- k++;
- break;
+ case 4:
+ for(j=0; j<CELL; j+=2)
+ for(i=(j>>1)&1; i<CELL; i+=2)
+ fb[(ry+j)*w+(rx+i)] = PIXPACK(0x8080FF);
+ k++;
+ break;
case 6:
for(j=0; j<CELL; j+=2)
for(i=(j>>1)&1; i<CELL; i+=2)
@@ -2986,7 +2986,7 @@ pixel *prerender_save(void *save, int size, int *width, int *height)
else
fb[(ry+j)*w+(rx+i)] = PIXPACK(0x808080);
break;
- case WL_WALL:
+ case WL_WALL:
for(j=0; j<CELL; j++)
for(i=0; i<CELL; i++)
fb[(ry+j)*w+(rx+i)] = PIXPACK(0x808080);
@@ -3057,7 +3057,7 @@ pixel *prerender_save(void *save, int size, int *width, int *height)
draw_line(fb , x, y+3, x+1, y+6, 255, 255, 255, w);
draw_line(fb , x+1, y+6, x+3, y+12, 255, 255, 255, w);
}
- else if(j==PT_STKM2)
+ else if(j==PT_STKM2)
{
//Stickman drawing
for(k=-2; k<=1; k++)
@@ -3177,27 +3177,27 @@ corrupt:
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(rx<=0)
+ if(rx<=0)
xor_pixel(x, y, vid);
- else if(ry<=0)
+ else if(ry<=0)
xor_pixel(x, y, vid);
- if(rx+ry<=0)
+ 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==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++)
diff --git a/src/interface.c b/src/interface.c
index f58b2a4..3af4ab9 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -101,16 +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;
- }
+ 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;
@@ -181,8 +181,8 @@ void add_sign_ui(pixel *vid_buf, int mx, int my)
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);
+ 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);
@@ -200,10 +200,10 @@ void add_sign_ui(pixel *vid_buf, int mx, int my)
ju = 2;
if(!nm && b && !bq && mx>=x0+104 && mx<=x0+130 && my>=y0+42 && my<=y0+59)
- {
- MSIGN = i;
- break;
- }
+ {
+ 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)
@@ -246,25 +246,25 @@ void ui_edit_draw(pixel *vid_buf, ui_edit *ed)
if(ed->str[0])
{
- if(ed->multiline){
- drawtextwrap(vid_buf, ed->x, ed->y, ed->w-14, str, 255, 255, 255, 255);
- drawtext(vid_buf, ed->x+ed->w-11, ed->y-1, "\xAA", 128, 128, 128, 255);
- } else {
- drawtext(vid_buf, ed->x, ed->y, str, 255, 255, 255, 255);
- drawtext(vid_buf, ed->x+ed->w-11, ed->y-1, "\xAA", 128, 128, 128, 255);
- }
+ if(ed->multiline) {
+ drawtextwrap(vid_buf, ed->x, ed->y, ed->w-14, str, 255, 255, 255, 255);
+ drawtext(vid_buf, ed->x+ed->w-11, ed->y-1, "\xAA", 128, 128, 128, 255);
+ } else {
+ drawtext(vid_buf, ed->x, ed->y, str, 255, 255, 255, 255);
+ drawtext(vid_buf, ed->x+ed->w-11, ed->y-1, "\xAA", 128, 128, 128, 255);
+ }
}
else if(!ed->focus)
drawtext(vid_buf, ed->x, ed->y, ed->def, 128, 128, 128, 255);
if(ed->focus)
{
- if(ed->multiline){
- textnpos(str, ed->cursor, ed->w-14, &cx, &cy);
- } else {
- cx = textnwidth(str, ed->cursor);
- cy = 0;
- }
-
+ if(ed->multiline) {
+ textnpos(str, ed->cursor, ed->w-14, &cx, &cy);
+ } else {
+ cx = textnwidth(str, ed->cursor);
+ cy = 0;
+ }
+
for(i=-3; i<9; i++)
drawpixel(vid_buf, ed->x+cx, ed->y+i+cy, 255, 255, 255, 255);
}
@@ -290,35 +290,35 @@ void ui_edit_process(int mx, int my, int mb, ui_edit *ed)
else
str = ed->str;
- if(ed->multiline){
- if(mx>=ed->x+ed->w-11 && mx<ed->x+ed->w && my>=ed->y-5 && my<ed->y+11)
- {
- ed->focus = 1;
- ed->cursor = 0;
- ed->str[0] = 0;
- }
- else if(mx>=ed->x-ed->nx && mx<ed->x+ed->w && my>=ed->y-5 && my<ed->y+ed->h)
- {
- ed->focus = 1;
- ed->cursor = textposxy(str, ed->w-14, mx-ed->x, my-ed->y);
- }
- else
- ed->focus = 0;
- } else {
- if(mx>=ed->x+ed->w-11 && mx<ed->x+ed->w && my>=ed->y-5 && my<ed->y+11)
- {
- ed->focus = 1;
- ed->cursor = 0;
- ed->str[0] = 0;
- }
- else if(mx>=ed->x-ed->nx && mx<ed->x+ed->w && my>=ed->y-5 && my<ed->y+11)
- {
- ed->focus = 1;
- ed->cursor = textwidthx(str, mx-ed->x);
- }
- else
- ed->focus = 0;
- }
+ if(ed->multiline) {
+ if(mx>=ed->x+ed->w-11 && mx<ed->x+ed->w && my>=ed->y-5 && my<ed->y+11)
+ {
+ ed->focus = 1;
+ ed->cursor = 0;
+ ed->str[0] = 0;
+ }
+ else if(mx>=ed->x-ed->nx && mx<ed->x+ed->w && my>=ed->y-5 && my<ed->y+ed->h)
+ {
+ ed->focus = 1;
+ ed->cursor = textposxy(str, ed->w-14, mx-ed->x, my-ed->y);
+ }
+ else
+ ed->focus = 0;
+ } else {
+ if(mx>=ed->x+ed->w-11 && mx<ed->x+ed->w && my>=ed->y-5 && my<ed->y+11)
+ {
+ ed->focus = 1;
+ ed->cursor = 0;
+ ed->str[0] = 0;
+ }
+ else if(mx>=ed->x-ed->nx && mx<ed->x+ed->w && my>=ed->y-5 && my<ed->y+11)
+ {
+ ed->focus = 1;
+ ed->cursor = textwidthx(str, mx-ed->x);
+ }
+ else
+ ed->focus = 0;
+ }
}
if(ed->focus && sdl_key)
{
@@ -551,14 +551,14 @@ void draw_svf_ui(pixel *vid_buf)
break;
case CM_FANCY:
drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xC4", 100, 150, 255, 255);
- break;
+ break;
case CM_NOTHING:
drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x00", 100, 150, 255, 255);
- break;
+ break;
case CM_CRACK:
drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xD4", 255, 55, 55, 255);
- drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xD5", 55, 255, 55, 255);
- break;
+ drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xD5", 55, 255, 55, 255);
+ break;
case CM_GRAD:
drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xD3", 255, 50, 255, 255);
break;
@@ -1183,9 +1183,9 @@ int save_name_ui(pixel *vid_buf)
ed.focus = 1;
ed.hide = 0;
ed.cursor = strlen(svf_name);
- ed.multiline = 0;
+ ed.multiline = 0;
strcpy(ed.str, svf_name);
-
+
ed2.x = x0+13;
ed2.y = y0+45;
ed2.w = 166;
@@ -1195,7 +1195,7 @@ int save_name_ui(pixel *vid_buf)
ed2.focus = 0;
ed2.hide = 0;
ed2.cursor = strlen(svf_description);
- ed2.multiline = 1;
+ ed2.multiline = 1;
strcpy(ed2.str, svf_description);
cb.x = x0+10;
@@ -1216,7 +1216,7 @@ int save_name_ui(pixel *vid_buf)
drawtext(vid_buf, x0+8, y0+8, "New simulation name:", 255, 255, 255, 255);
drawtext(vid_buf, x0+10, y0+23, "\x82", 192, 192, 192, 255);
drawrect(vid_buf, x0+8, y0+20, 176, 16, 192, 192, 192, 255);
-
+
drawrect(vid_buf, x0+8, y0+40, 176, 95, 192, 192, 192, 255);
ui_edit_draw(vid_buf, &ed);
@@ -1230,8 +1230,8 @@ int save_name_ui(pixel *vid_buf)
drawtext(vid_buf, x0+5, y0+79+YRES/4, "Save simulation", 255, 255, 255, 255);
drawrect(vid_buf, x0, y0+74+YRES/4, 192, 16, 192, 192, 192, 255);
-
- draw_line(vid_buf, x0+192, y0, x0+192, y0+90+YRES/4, 150, 150, 150, XRES+BARSIZE);
+
+ draw_line(vid_buf, x0+192, y0, x0+192, y0+90+YRES/4, 150, 150, 150, XRES+BARSIZE);
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
@@ -1516,12 +1516,12 @@ 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)))
+ 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)
+ else if(n==SLALT)
{
drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255);
}
@@ -1558,7 +1558,7 @@ 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, 0, 255, 255, 255);
h = n;
}
- else if(n==SLALT)
+ else if(n==SLALT)
{
drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255);
}
@@ -1592,7 +1592,7 @@ 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, 0, 255, 255, 255);
h = n;
}
- else if(n==SLALT)
+ else if(n==SLALT)
{
drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255);
}
@@ -1629,7 +1629,7 @@ 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, 0, 255, 255, 255);
h = n;
}
- else if(n==SLALT)
+ else if(n==SLALT)
{
drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255);
}
@@ -1645,12 +1645,12 @@ 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(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))
+ if(i>=0&&i<SC_TOTAL)
+ SEC = i;
+ }
if(h==-1)
{
@@ -1667,41 +1667,41 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx,
if(b==1&&h==-1)
{
- if(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT) && SEC>=0)
- {
- SLALT = -1;
- SEC2 = SEC;
- }
+ if(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT) && SEC>=0)
+ {
+ SLALT = -1;
+ SEC2 = SEC;
+ }
}
if(b==1&&h!=-1)
{
- if(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))
- {
- SLALT = h;
- SEC2 = -1;
- }
- else{
- *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(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT) && SEC>=0)
+ {
+ SLALT = -1;
+ SEC2 = SEC;
+ }
}
if(b==4&&h!=-1)
{
- if(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))
- {
- SLALT = h;
- SEC2 = -1;
- }
- else{
- *sr = h;
- }
+ if(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))
+ {
+ SLALT = h;
+ SEC2 = -1;
+ }
+ else {
+ *sr = h;
+ }
}
}
@@ -1749,8 +1749,8 @@ int sdl_poll(void)
{
player[0] = (int)(player[0])|0x04; //Jump command
}
-
- if(event.key.keysym.sym == SDLK_d)
+
+ if(event.key.keysym.sym == SDLK_d)
{
player2[0] = (int)(player2[0])|0x02; //Go right command
}
@@ -1786,8 +1786,8 @@ int sdl_poll(void)
{
player[0] = (int)(player[0])&7;
}
-
- if(event.key.keysym.sym == SDLK_d || event.key.keysym.sym == SDLK_a)
+
+ if(event.key.keysym.sym == SDLK_d || event.key.keysym.sym == SDLK_a)
{
player2[1] = player2[0]; //Saving last movement
player2[0] = (int)(player2[0])&12; //Stop command
@@ -2013,7 +2013,7 @@ int search_ui(pixel *vid_buf)
ed.focus = 1;
ed.hide = 0;
ed.cursor = strlen(search_expr);
- ed.multiline = 0;
+ ed.multiline = 0;
strcpy(ed.str, search_expr);
sdl_wheel = 0;
@@ -2608,10 +2608,10 @@ int report_ui(pixel* vid_buf, char *save_id)
ed.def = "Report details";
ed.focus = 0;
ed.hide = 0;
- ed.multiline = 1;
+ ed.multiline = 1;
ed.cursor = 0;
strcpy(ed.str, "");
-
+
fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 192);
while(!sdl_poll())
{
@@ -2619,42 +2619,42 @@ int report_ui(pixel* vid_buf, char *save_id)
if(!b)
break;
}
- while(!sdl_poll()){
- fillrect(vid_buf, 200, 150, (XRES+BARSIZE-400), (YRES+MENUSIZE-300), 0,0,0, 255);
+ while(!sdl_poll()) {
+ fillrect(vid_buf, 200, 150, (XRES+BARSIZE-400), (YRES+MENUSIZE-300), 0,0,0, 255);
drawrect(vid_buf, 200, 150, (XRES+BARSIZE-400), (YRES+MENUSIZE-300), 255, 255, 255, 255);
-
+
drawrect(vid_buf, 205, 155, (XRES+BARSIZE-400)-10, (YRES+MENUSIZE-300)-28, 255, 255, 255, 170);
-
+
bq = b;
b = SDL_GetMouseState(&mx, &my);
mx /= sdl_scale;
my /= sdl_scale;
-
+
drawrect(vid_buf, 200, (YRES+MENUSIZE-150)-18, 50, 18, 255, 255, 255, 255);
drawtext(vid_buf, 213, (YRES+MENUSIZE-150)-13, "Cancel", 255, 255, 255, 255);
-
+
drawrect(vid_buf, (XRES+BARSIZE-400)+150, (YRES+MENUSIZE-150)-18, 50, 18, 255, 255, 255, 255);
drawtext(vid_buf, (XRES+BARSIZE-400)+163, (YRES+MENUSIZE-150)-13, "Report", 255, 255, 255, 255);
- if(mx>(XRES+BARSIZE-400)+150 && my>(YRES+MENUSIZE-150)-18 && mx<(XRES+BARSIZE-400)+200 && my<(YRES+MENUSIZE-150)){
- fillrect(vid_buf, (XRES+BARSIZE-400)+150, (YRES+MENUSIZE-150)-18, 50, 18, 255, 255, 255, 40);
- if(b){
- if(execute_report(vid_buf, save_id, ed.str)){
- info_ui(vid_buf, "Success", "This save has been reported");
- return 1;
- } else {
- return 0;
- }
- }
- }
- if(mx>200 && my>(YRES+MENUSIZE-150)-18 && mx<250 && my<(YRES+MENUSIZE-150)){
- fillrect(vid_buf, 200, (YRES+MENUSIZE-150)-18, 50, 18, 255, 255, 255, 40);
- if(b)
- return 0;
+ if(mx>(XRES+BARSIZE-400)+150 && my>(YRES+MENUSIZE-150)-18 && mx<(XRES+BARSIZE-400)+200 && my<(YRES+MENUSIZE-150)) {
+ fillrect(vid_buf, (XRES+BARSIZE-400)+150, (YRES+MENUSIZE-150)-18, 50, 18, 255, 255, 255, 40);
+ if(b) {
+ if(execute_report(vid_buf, save_id, ed.str)) {
+ info_ui(vid_buf, "Success", "This save has been reported");
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+ }
+ if(mx>200 && my>(YRES+MENUSIZE-150)-18 && mx<250 && my<(YRES+MENUSIZE-150)) {
+ fillrect(vid_buf, 200, (YRES+MENUSIZE-150)-18, 50, 18, 255, 255, 255, 40);
+ if(b)
+ return 0;
}
ui_edit_draw(vid_buf, &ed);
- sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
- ui_edit_process(mx, my, b, &ed);
+ sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
+ ui_edit_process(mx, my, b, &ed);
}
return 0;
}
@@ -2663,8 +2663,8 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date)
{
int b=1,bq,mx,my,ca=0,thumb_w,thumb_h,active=0,active_2=0,cc=0,ccy=0,cix=0,hasdrawninfo=0,hasdrawnthumb=0,authoritah=0,myown=0,queue_open=0,data_size=0,retval=0,bc=255,openable=1;
int nyd,nyu,ry,lv;
-
- char *uri, *uri_2, *o_uri;
+
+ char *uri, *uri_2, *o_uri;
void *data, *info_data;
save_info *info = malloc(sizeof(save_info));
void *http = NULL, *http_2 = NULL;
@@ -2672,7 +2672,7 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date)
int status, status_2, info_ready = 0, data_ready = 0;
time_t http_last_use = HTTP_TIMEOUT, http_last_use_2 = HTTP_TIMEOUT;
pixel *save_pic;// = malloc((XRES/2)*(YRES/2));
- ui_edit ed;
+ ui_edit ed;
pixel *old_vid=(pixel *)calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE);
fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 192);
@@ -2683,18 +2683,18 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date)
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);
- ed.x = 57+(XRES/2)+1;
- ed.y = YRES+MENUSIZE-118;
- ed.w = XRES+BARSIZE-114-((XRES/2)+1);
- ed.h = 48;
+ ed.x = 57+(XRES/2)+1;
+ ed.y = YRES+MENUSIZE-118;
+ ed.w = XRES+BARSIZE-114-((XRES/2)+1);
+ ed.h = 48;
ed.nx = 1;
ed.def = "Add comment";
ed.focus = 1;
ed.hide = 0;
- ed.multiline = 1;
+ ed.multiline = 1;
ed.cursor = 0;
strcpy(ed.str, "");
-
+
memcpy(old_vid, vid_buf, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE);
while(!sdl_poll())
@@ -2756,14 +2756,14 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date)
if(status == 200)
{
pixel *full_save = prerender_save(data, data_size, &imgw, &imgh);
- if(full_save!=NULL){
- save_pic = rescale_img(full_save, imgw, imgh, &thumb_w, &thumb_h, 2);
- data_ready = 1;
- free(full_save);
- } else {
- error_ui(vid_buf, 0, "Save may be from a newer version");
- break;
- }
+ if(full_save!=NULL) {
+ save_pic = rescale_img(full_save, imgw, imgh, &thumb_w, &thumb_h, 2);
+ data_ready = 1;
+ free(full_save);
+ } else {
+ error_ui(vid_buf, 0, "Save may be from a newer version");
+ break;
+ }
}
active = 0;
free(http);
@@ -2786,7 +2786,7 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date)
free(http_2);
http_2 = NULL;
}
-
+
if(data_ready && !hasdrawnthumb) {
draw_image(vid_buf, save_pic, 51, 51, thumb_w, thumb_h, 255);
hasdrawnthumb = 1;
@@ -2800,73 +2800,73 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date)
cix = drawtext(vid_buf, cix+4, (YRES/2)+72, "Date:", 255, 255, 255, 155);
cix = drawtext(vid_buf, cix+4, (YRES/2)+72, info->date, 255, 255, 255, 255);
drawtextwrap(vid_buf, 62, (YRES/2)+86, (XRES/2)-24, info->description, 255, 255, 255, 200);
-
- //Draw the score bars
- if(info->voteup>0||info->votedown>0)
- {
- lv = (info->voteup>info->votedown)?info->voteup:info->votedown;
- lv = (lv>10)?lv:10;
-
- if(50>lv)
- {
- ry = ((float)(50)/(float)lv);
- //if(lv<8)
- //{
- // ry = ry/(8-lv);
- //}
- nyu = info->voteup*ry;
- nyd = info->votedown*ry;
- }
- else
- {
- ry = ((float)lv/(float)(50));
- nyu = info->voteup/ry;
- nyd = info->votedown/ry;
- }
- nyu = nyu>50?50:nyu;
- nyd = nyd>50?50:nyd;
-
- fillrect(vid_buf, 48+(XRES/2)-51, (YRES/2)+53, 52, 6, 0, 107, 10, 255);
- fillrect(vid_buf, 48+(XRES/2)-51, (YRES/2)+59, 52, 6, 107, 10, 0, 255);
- drawrect(vid_buf, 48+(XRES/2)-51, (YRES/2)+53, 52, 6, 128, 128, 128, 255);
- drawrect(vid_buf, 48+(XRES/2)-51, (YRES/2)+59, 52, 6, 128, 128, 128, 255);
-
- fillrect(vid_buf, 48+(XRES/2)-nyu, (YRES/2)+54, nyu, 4, 57, 187, 57, 255);
- fillrect(vid_buf, 48+(XRES/2)-nyd, (YRES/2)+60, nyd, 4, 187, 57, 57, 255);
- }
+
+ //Draw the score bars
+ if(info->voteup>0||info->votedown>0)
+ {
+ lv = (info->voteup>info->votedown)?info->voteup:info->votedown;
+ lv = (lv>10)?lv:10;
+
+ if(50>lv)
+ {
+ ry = ((float)(50)/(float)lv);
+ //if(lv<8)
+ //{
+ // ry = ry/(8-lv);
+ //}
+ nyu = info->voteup*ry;
+ nyd = info->votedown*ry;
+ }
+ else
+ {
+ ry = ((float)lv/(float)(50));
+ nyu = info->voteup/ry;
+ nyd = info->votedown/ry;
+ }
+ nyu = nyu>50?50:nyu;
+ nyd = nyd>50?50:nyd;
+
+ fillrect(vid_buf, 48+(XRES/2)-51, (YRES/2)+53, 52, 6, 0, 107, 10, 255);
+ fillrect(vid_buf, 48+(XRES/2)-51, (YRES/2)+59, 52, 6, 107, 10, 0, 255);
+ drawrect(vid_buf, 48+(XRES/2)-51, (YRES/2)+53, 52, 6, 128, 128, 128, 255);
+ drawrect(vid_buf, 48+(XRES/2)-51, (YRES/2)+59, 52, 6, 128, 128, 128, 255);
+
+ fillrect(vid_buf, 48+(XRES/2)-nyu, (YRES/2)+54, nyu, 4, 57, 187, 57, 255);
+ fillrect(vid_buf, 48+(XRES/2)-nyd, (YRES/2)+60, nyd, 4, 187, 57, 57, 255);
+ }
ccy = 0;
for(cc=0; cc<info->comment_count; cc++) {
- if((ccy + 72 + ((textwidth(info->comments[cc])/(XRES+BARSIZE-100-((XRES/2)+1)-20)))*12)<(YRES+MENUSIZE-50)){
- drawtext(vid_buf, 60+(XRES/2)+1, ccy+60, info->commentauthors[cc], 255, 255, 255, 255);
- ccy += 12;
- ccy += drawtextwrap(vid_buf, 60+(XRES/2)+1, ccy+60, XRES+BARSIZE-100-((XRES/2)+1)-20, info->comments[cc], 255, 255, 255, 185);
- ccy += 10;
- if(ccy+52<YRES+MENUSIZE-50){ //Try not to draw off the screen.
- draw_line(vid_buf, 50+(XRES/2)+2, ccy+52, XRES+BARSIZE-50, ccy+52, 100, 100, 100, XRES+BARSIZE);
- }
- }
+ if((ccy + 72 + ((textwidth(info->comments[cc])/(XRES+BARSIZE-100-((XRES/2)+1)-20)))*12)<(YRES+MENUSIZE-50)) {
+ drawtext(vid_buf, 60+(XRES/2)+1, ccy+60, info->commentauthors[cc], 255, 255, 255, 255);
+ ccy += 12;
+ ccy += drawtextwrap(vid_buf, 60+(XRES/2)+1, ccy+60, XRES+BARSIZE-100-((XRES/2)+1)-20, info->comments[cc], 255, 255, 255, 185);
+ ccy += 10;
+ if(ccy+52<YRES+MENUSIZE-50) { //Try not to draw off the screen.
+ draw_line(vid_buf, 50+(XRES/2)+2, ccy+52, XRES+BARSIZE-50, ccy+52, 100, 100, 100, XRES+BARSIZE);
+ }
+ }
}
hasdrawninfo = 1;
myown = svf_login && !strcmp(info->author, svf_user);
- authoritah = svf_login && (!strcmp(info->author, svf_user) || svf_admin || svf_mod);
+ authoritah = svf_login && (!strcmp(info->author, svf_user) || svf_admin || svf_mod);
memcpy(old_vid, vid_buf, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE);
}
- if(info_ready && svf_login){
- //Render the comment box.
- fillrect(vid_buf, 50+(XRES/2)+1, YRES+MENUSIZE-125, XRES+BARSIZE-100-((XRES/2)+1), 75, 0, 0, 0, 255);
- drawrect(vid_buf, 50+(XRES/2)+1, YRES+MENUSIZE-125, XRES+BARSIZE-100-((XRES/2)+1), 75, 200, 200, 200, 255);
-
- drawrect(vid_buf, 54+(XRES/2)+1, YRES+MENUSIZE-121, XRES+BARSIZE-108-((XRES/2)+1), 48, 255, 255, 255, 200);
-
- ui_edit_draw(vid_buf, &ed);
-
- drawrect(vid_buf, XRES+BARSIZE-100, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, 255);
- drawtext(vid_buf, XRES+BARSIZE-90, YRES+MENUSIZE-63, "Submit", 255, 255, 255, 255);
- }
+ if(info_ready && svf_login) {
+ //Render the comment box.
+ fillrect(vid_buf, 50+(XRES/2)+1, YRES+MENUSIZE-125, XRES+BARSIZE-100-((XRES/2)+1), 75, 0, 0, 0, 255);
+ drawrect(vid_buf, 50+(XRES/2)+1, YRES+MENUSIZE-125, XRES+BARSIZE-100-((XRES/2)+1), 75, 200, 200, 200, 255);
+
+ drawrect(vid_buf, 54+(XRES/2)+1, YRES+MENUSIZE-121, XRES+BARSIZE-108-((XRES/2)+1), 48, 255, 255, 255, 200);
+
+ ui_edit_draw(vid_buf, &ed);
+
+ drawrect(vid_buf, XRES+BARSIZE-100, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, 255);
+ drawtext(vid_buf, XRES+BARSIZE-90, YRES+MENUSIZE-63, "Submit", 255, 255, 255, 255);
+ }
//Open Button
- bc = openable?255:150;
+ bc = openable?255:150;
drawrect(vid_buf, 50, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, bc);
drawtext(vid_buf, 73, YRES+MENUSIZE-63, "Open", 255, 255, 255, bc);
drawtext(vid_buf, 58, YRES+MENUSIZE-64, "\x81", 255, 255, 255, bc);
@@ -2881,102 +2881,102 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date)
drawtext(vid_buf, 168, YRES+MENUSIZE-63, "Report", 255, 255, 255, bc);
drawtext(vid_buf, 158, YRES+MENUSIZE-63, "!", 255, 255, 255, bc);
//Delete Button
- bc = authoritah?255:150;
- drawrect(vid_buf, 200, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, bc);
- drawtext(vid_buf, 218, YRES+MENUSIZE-63, "Delete", 255, 255, 255, bc);
- drawtext(vid_buf, 206, YRES+MENUSIZE-64, "\xAA", 255, 255, 255, bc);
- //Open in browser button
- bc = 255;
+ bc = authoritah?255:150;
+ drawrect(vid_buf, 200, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, bc);
+ drawtext(vid_buf, 218, YRES+MENUSIZE-63, "Delete", 255, 255, 255, bc);
+ drawtext(vid_buf, 206, YRES+MENUSIZE-64, "\xAA", 255, 255, 255, bc);
+ //Open in browser button
+ bc = 255;
drawrect(vid_buf, 250, YRES+MENUSIZE-68, 107, 18, 255, 255, 255, bc);
drawtext(vid_buf, 273, YRES+MENUSIZE-63, "Open in Browser", 255, 255, 255, bc);
drawtext(vid_buf, 258, YRES+MENUSIZE-64, "\x81", 255, 255, 255, bc);
-
- //Open Button
- if(sdl_key==SDLK_RETURN && openable) {
+
+ //Open Button
+ if(sdl_key==SDLK_RETURN && openable) {
queue_open = 1;
}
- if(mx > 50 && mx < 50+50 && my > YRES+MENUSIZE-68 && my < YRES+MENUSIZE-50 && openable && !queue_open) {
+ if(mx > 50 && mx < 50+50 && my > YRES+MENUSIZE-68 && my < YRES+MENUSIZE-50 && openable && !queue_open) {
fillrect(vid_buf, 50, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, 40);
if(b && !bq) {
- //Button Clicked
+ //Button Clicked
queue_open = 1;
}
}
- //Fav Button
- if(mx > 100 && mx < 100+50 && my > YRES+MENUSIZE-68 && my < YRES+MENUSIZE-50 && svf_login && !queue_open) {
+ //Fav Button
+ if(mx > 100 && mx < 100+50 && my > YRES+MENUSIZE-68 && my < YRES+MENUSIZE-50 && svf_login && !queue_open) {
fillrect(vid_buf, 100, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, 40);
- if(b && !bq) {
+ if(b && !bq) {
+ //Button Clicked
+ fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 192);
+ info_box(vid_buf, "Adding to favourites...");
+ execute_fav(vid_buf, save_id);
+ }
+ }
+ //Report Button
+ if(mx > 150 && mx < 150+50 && my > YRES+MENUSIZE-68 && my < YRES+MENUSIZE-50 && svf_login && info_ready && !queue_open) {
+ fillrect(vid_buf, 150, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, 40);
+ if(b && !bq) {
//Button Clicked
- fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 192);
- info_box(vid_buf, "Adding to favourites...");
- execute_fav(vid_buf, save_id);
- }
- }
- //Report Button
- if(mx > 150 && mx < 150+50 && my > YRES+MENUSIZE-68 && my < YRES+MENUSIZE-50 && svf_login && info_ready && !queue_open) {
- fillrect(vid_buf, 150, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, 40);
- if(b && !bq) {
+ if(report_ui(vid_buf, save_id)) {
+ retval = 0;
+ break;
+ }
+ }
+ }
+ //Delete Button
+ if(mx > 200 && mx < 200+50 && my > YRES+MENUSIZE-68 && my < YRES+MENUSIZE-50 && (authoritah || myown) && !queue_open) {
+ fillrect(vid_buf, 200, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, 40);
+ if(b && !bq) {
//Button Clicked
- if(report_ui(vid_buf, save_id)){
- retval = 0;
- break;
- }
- }
- }
- //Delete Button
- if(mx > 200 && mx < 200+50 && my > YRES+MENUSIZE-68 && my < YRES+MENUSIZE-50 && (authoritah || myown) && !queue_open) {
- fillrect(vid_buf, 200, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, 40);
- if(b && !bq) {
- //Button Clicked
- if(myown || !info->publish){
- if(confirm_ui(vid_buf, "Are you sure you wish to delete this?", "You will not be able recover it.", "Delete")){
- fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 192);
- info_box(vid_buf, "Deleting...");
- if(execute_delete(vid_buf, save_id)){
- retval = 0;
- break;
- }
- }
- } else {
- if(confirm_ui(vid_buf, "Are you sure?", "This save will be removed from the search index.", "Remove")){
- fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 192);
- info_box(vid_buf, "Removing...");
- if(execute_delete(vid_buf, save_id)){
- retval = 0;
- break;
- }
- }
- }
- }
- }
- //Open in browser button
- if(mx > 250 && mx < 250+107 && my > YRES+MENUSIZE-68 && my < YRES+MENUSIZE-50 && !queue_open) {
+ if(myown || !info->publish) {
+ if(confirm_ui(vid_buf, "Are you sure you wish to delete this?", "You will not be able recover it.", "Delete")) {
+ fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 192);
+ info_box(vid_buf, "Deleting...");
+ if(execute_delete(vid_buf, save_id)) {
+ retval = 0;
+ break;
+ }
+ }
+ } else {
+ if(confirm_ui(vid_buf, "Are you sure?", "This save will be removed from the search index.", "Remove")) {
+ fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 192);
+ info_box(vid_buf, "Removing...");
+ if(execute_delete(vid_buf, save_id)) {
+ retval = 0;
+ break;
+ }
+ }
+ }
+ }
+ }
+ //Open in browser button
+ if(mx > 250 && mx < 250+107 && my > YRES+MENUSIZE-68 && my < YRES+MENUSIZE-50 && !queue_open) {
fillrect(vid_buf, 250, YRES+MENUSIZE-68, 107, 18, 255, 255, 255, 40);
if(b && !bq) {
- //Button Clicked
- //TODO: Open link
- o_uri = malloc(7+strlen(SERVER)+41+strlen(save_id)*3);
- strcpy(o_uri, "http://" SERVER "/Browse/View.html?ID=");
- strcaturl(o_uri, save_id);
- open_link(o_uri);
- free(o_uri);
- }
- }
- //Submit Button
- if(mx > XRES+BARSIZE-100 && mx < XRES+BARSIZE-100+50 && my > YRES+MENUSIZE-68 && my < YRES+MENUSIZE-50 && svf_login && info_ready && !queue_open) {
- fillrect(vid_buf, XRES+BARSIZE-100, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, 40);
- if(b && !bq) {
- //Button Clicked
- fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 192);
- info_box(vid_buf, "Submitting Comment...");
- execute_submit(vid_buf, save_id, ed.str);
- ed.str[0] = 0;
- }
- }
- if(!(mx>50 && my>50 && mx<XRES+BARSIZE-50 && my<YRES+MENUSIZE-50) && b && !queue_open){
- retval = 0;
- break;
- }
+ //Button Clicked
+ //TODO: Open link
+ o_uri = malloc(7+strlen(SERVER)+41+strlen(save_id)*3);
+ strcpy(o_uri, "http://" SERVER "/Browse/View.html?ID=");
+ strcaturl(o_uri, save_id);
+ open_link(o_uri);
+ free(o_uri);
+ }
+ }
+ //Submit Button
+ if(mx > XRES+BARSIZE-100 && mx < XRES+BARSIZE-100+50 && my > YRES+MENUSIZE-68 && my < YRES+MENUSIZE-50 && svf_login && info_ready && !queue_open) {
+ fillrect(vid_buf, XRES+BARSIZE-100, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, 40);
+ if(b && !bq) {
+ //Button Clicked
+ fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 192);
+ info_box(vid_buf, "Submitting Comment...");
+ execute_submit(vid_buf, save_id, ed.str);
+ ed.str[0] = 0;
+ }
+ }
+ if(!(mx>50 && my>50 && mx<XRES+BARSIZE-50 && my<YRES+MENUSIZE-50) && b && !queue_open) {
+ retval = 0;
+ break;
+ }
if(queue_open) {
if(info_ready && data_ready) {
@@ -3026,34 +3026,34 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date)
drawtext(vid_buf, 50+(XRES/4)-textwidth("Loading...")/2, 50+(YRES/4), "Loading...", 255, 255, 255, 128);
}
}
- if(!info_ready || !data_ready){
- info_box(vid_buf, "Loading");
- }
+ if(!info_ready || !data_ready) {
+ info_box(vid_buf, "Loading");
+ }
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
memcpy(vid_buf, old_vid, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE);
- if(info_ready && svf_login){
- ui_edit_process(mx, my, b, &ed);
- }
+ if(info_ready && svf_login) {
+ ui_edit_process(mx, my, b, &ed);
+ }
- if(sdl_key==SDLK_ESCAPE){
- retval = 0;
+ if(sdl_key==SDLK_ESCAPE) {
+ retval = 0;
break;
- }
+ }
if(lasttime<TIMEOUT)
lasttime++;
}
- //Prevent those mouse clicks being passed down.
- while(!sdl_poll())
+ //Prevent those mouse clicks being passed down.
+ while(!sdl_poll())
{
b = SDL_GetMouseState(&mx, &my);
if(!b)
break;
}
- //Close open connections
- if(http)
+ //Close open connections
+ if(http)
http_async_req_close(http);
- if(http_2)
+ if(http_2)
http_async_req_close(http_2);
return retval;
}
@@ -3594,7 +3594,7 @@ int execute_delete(pixel *vid_buf, char *id)
if(result)
free(result);
- return 1;
+ return 1;
}
void execute_submit(pixel *vid_buf, char *id, char *message)
@@ -3665,7 +3665,7 @@ int execute_report(pixel *vid_buf, char *id, char *reason)
if(result)
free(result);
- return 1;
+ return 1;
}
void execute_fav(pixel *vid_buf, char *id)
@@ -3737,30 +3737,30 @@ int execute_vote(pixel *vid_buf, char *id, char *action)
free(result);
return 1;
}
-void open_link(char *uri){
+void open_link(char *uri) {
#ifdef WIN32
- ShellExecute(0, "OPEN", uri, NULL, NULL, 0);
+ ShellExecute(0, "OPEN", uri, NULL, NULL, 0);
#elif MACOSX
- //char *cmd[] = { "open", uri, (char *)0 };
- //execvp("open", cmd);
- //LSOpenCFURLRef(CFURLCreateWithString(NULL, CFStringCreateWithCString(NULL, uri, 0) ,NULL), NULL); //TODO: Get this crap working
- char *cmd = malloc(7+strlen(uri));
- strcpy(cmd, "open ");
- strappend(cmd, uri);
- system(cmd);
+ //char *cmd[] = { "open", uri, (char *)0 };
+ //execvp("open", cmd);
+ //LSOpenCFURLRef(CFURLCreateWithString(NULL, CFStringCreateWithCString(NULL, uri, 0) ,NULL), NULL); //TODO: Get this crap working
+ char *cmd = malloc(7+strlen(uri));
+ strcpy(cmd, "open ");
+ strappend(cmd, uri);
+ system(cmd);
#elif LIN32
- //execlp("xdg-open", "xdg-open", uri, (char *)0);
- char *cmd = malloc(11+strlen(uri));
- strcpy(cmd, "xdg-open ");
- strappend(cmd, uri);
- system(cmd);
+ //execlp("xdg-open", "xdg-open", uri, (char *)0);
+ char *cmd = malloc(11+strlen(uri));
+ strcpy(cmd, "xdg-open ");
+ strappend(cmd, uri);
+ system(cmd);
#elif LIN64
- //execlp("xdg-open", "xdg-open", uri, (char *)0);
- char *cmd = malloc(11+strlen(uri));
- strcpy(cmd, "xdg-open ");
- strappend(cmd, uri);
- system(cmd);
+ //execlp("xdg-open", "xdg-open", uri, (char *)0);
+ char *cmd = malloc(11+strlen(uri));
+ strcpy(cmd, "xdg-open ");
+ strappend(cmd, uri);
+ system(cmd);
#else
- printf("Cannot open browser\n");
+ printf("Cannot open browser\n");
#endif
}
diff --git a/src/main.c b/src/main.c
index 3e5bfb5..4b026bd 100644
--- a/src/main.c
+++ b/src/main.c
@@ -75,7 +75,7 @@ static const char *it_msg =
"\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 cracker64\n"
"\bgCopyright (c) 2010 Bryan Hoyle (New elements)\n"
"\bgCopyright (c) 2010 Nathan Cousins (New elements, small engine mods.)\n"
"\n"
@@ -307,24 +307,24 @@ 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){
- //Everybody loves a 16bit int
+ if(i) {
+ //Everybody loves a 16bit int
//d[p++] = (parts[i-1].life+3)/4;
- int ttlife = (int)parts[i-1].life;
+ int ttlife = (int)parts[i-1].life;
d[p++] = ((ttlife&0xFF00)>>8);
d[p++] = (ttlife&0x00FF);
- }
+ }
}
- for(j=0; j<w*h; j++)
+ for(j=0; j<w*h; j++)
{
i = m[j];
- if(i){
- //Now saving tmp!
+ if(i) {
+ //Now saving tmp!
//d[p++] = (parts[i-1].life+3)/4;
- int tttmp = (int)parts[i-1].tmp;
+ int tttmp = (int)parts[i-1].tmp;
d[p++] = ((tttmp&0xFF00)>>8);
d[p++] = (tttmp&0x00FF);
- }
+ }
}
for(j=0; j<w*h; j++)
{
@@ -427,18 +427,18 @@ int parse_save(void *save, int size, int replace, int x0, int y0)
}
else
{
- if(ver>=44){
- legacy_enable = c[3]&0x01;
- if(!sys_pause){
- sys_pause = (c[3]>>1)&0x01;
- }
- } else {
- if(c[3]==1||c[3]==0){
- legacy_enable = c[3];
- } else {
- legacy_beta = 1;
- }
- }
+ if(ver>=44) {
+ legacy_enable = c[3]&0x01;
+ if(!sys_pause) {
+ sys_pause = (c[3]>>1)&0x01;
+ }
+ } else {
+ if(c[3]==1||c[3]==0) {
+ legacy_enable = c[3];
+ } else {
+ legacy_beta = 1;
+ }
+ }
}
bw = c[6];
@@ -504,35 +504,35 @@ 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;
- }
+ 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++;
}
@@ -566,7 +566,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;
+ gol[x][y]=0;
if(j)// && !(isplayer == 1 && j==PT_STKM))
{
if(pmap[y][x])
@@ -582,10 +582,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_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;
@@ -636,7 +636,7 @@ int parse_save(void *save, int size, int replace, int x0, int y0)
player[18] = parts[i].y+12;
}
- if(parts[i].type == PT_STKM2)
+ if(parts[i].type == PT_STKM2)
{
//player[2] = PT_DUST;
@@ -671,46 +671,46 @@ int parse_save(void *save, int size, int replace, int x0, int y0)
i = m[j];
if(i)
{
- if(ver>=44){
- if(p >= size) {
- goto corrupt;
- }
- if(i <= NPART) {
- ttv = (d[p++])<<8;
- ttv |= (d[p++]);
- parts[i-1].life = ttv;
- } else {
- p+=2;
- }
- } else {
- if(p >= size)
- goto corrupt;
- if(i <= NPART)
- parts[i-1].life = d[p++]*4;
- else
- p++;
- }
+ if(ver>=44) {
+ if(p >= size) {
+ goto corrupt;
+ }
+ if(i <= NPART) {
+ ttv = (d[p++])<<8;
+ ttv |= (d[p++]);
+ parts[i-1].life = ttv;
+ } else {
+ p+=2;
+ }
+ } else {
+ if(p >= size)
+ goto corrupt;
+ if(i <= NPART)
+ parts[i-1].life = d[p++]*4;
+ else
+ p++;
+ }
+ }
+ }
+ if(ver>=44) {
+ for(j=0; j<w*h; j++)
+ {
+ i = m[j];
+ if(i)
+ {
+ if(p >= size) {
+ goto corrupt;
+ }
+ if(i <= NPART) {
+ ttv = (d[p++])<<8;
+ ttv |= (d[p++]);
+ parts[i-1].tmp = ttv;
+ } else {
+ p+=2;
+ }
+ }
}
}
- if(ver>=44){
- for(j=0; j<w*h; j++)
- {
- i = m[j];
- if(i)
- {
- if(p >= size) {
- goto corrupt;
- }
- if(i <= NPART) {
- ttv = (d[p++])<<8;
- ttv |= (d[p++]);
- parts[i-1].tmp = ttv;
- } else {
- p+=2;
- }
- }
- }
- }
for(j=0; j<w*h; j++)
{
i = m[j];
@@ -1097,7 +1097,7 @@ int main(int argc, char *argv[])
int pastFPS = 0;
int past = 0;
pixel *vid_buf=calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE);
- pixel *pers_bg=calloc((XRES+BARSIZE)*YRES, PIXELSIZE);
+ pixel *pers_bg=calloc((XRES+BARSIZE)*YRES, PIXELSIZE);
void *http_ver_check;
char *ver_data=NULL, *tmp;
int i, j, bq, fire_fc=0, do_check=0, old_version=0, http_ret=0, major, minor, old_ver_len;
@@ -1232,7 +1232,7 @@ int main(int argc, char *argv[])
if(!sys_pause||framerender)
{
- update_air();
+ update_air();
}
#ifdef OpenGL
ClearScreen();
@@ -1251,17 +1251,17 @@ int main(int argc, char *argv[])
memset(vid_buf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
}
#endif
-
- //Can't be too sure...
- if(bsx>1180)
- bsx = 1180;
- if(bsx<0)
- bsx = 0;
- if(bsy>1180)
- bsy = 1180;
- if(bsy<0)
- bsy = 0;
-
+
+ //Can't be too sure...
+ if(bsx>1180)
+ bsx = 1180;
+ if(bsx<0)
+ bsx = 0;
+ if(bsy>1180)
+ bsy = 1180;
+ if(bsy<0)
+ bsy = 0;
+
update_particles(vid_buf);
draw_parts(vid_buf);
@@ -1391,22 +1391,22 @@ int main(int argc, char *argv[])
{
set_cmode(CM_FANCY);
}
- if(sdl_key=='8')
+ if(sdl_key=='8')
{
set_cmode(CM_NOTHING);
}
- if(sdl_key=='9')
+ if(sdl_key=='9')
{
set_cmode(CM_GRAD);
}
- if(sdl_key=='0')
+ if(sdl_key=='0')
{
set_cmode(CM_CRACK);
}
- if(sdl_key==SDLK_TAB)
- {
- CURRENT_BRUSH =(CURRENT_BRUSH + 1)%BRUSH_NUM ;
- }
+ if(sdl_key==SDLK_TAB)
+ {
+ CURRENT_BRUSH =(CURRENT_BRUSH + 1)%BRUSH_NUM ;
+ }
if(sdl_key==SDLK_LEFTBRACKET) {
if(sdl_zoom_trig==1)
{
@@ -1420,30 +1420,30 @@ int main(int argc, char *argv[])
else
{
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;
- }
+ {
+ 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
- {
+ {
bsx -= ceil((bsx/5)+0.5f);
- bsy -= ceil((bsy/5)+0.5f);
- }
+ bsy -= ceil((bsy/5)+0.5f);
+ }
if(bsx>1180)
bsx = 1180;
- if(bsy>1180)
+ if(bsy>1180)
bsy = 1180;
if(bsx<0)
bsx = 0;
- if(bsy<0)
+ if(bsy<0)
bsy = 0;
}
}
@@ -1460,58 +1460,58 @@ int main(int argc, char *argv[])
else
{
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;
- }
+ {
+ 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
- {
+ {
bsx += ceil((bsx/5)+0.5f);
- bsy += ceil((bsy/5)+0.5f);
- }
+ bsy += ceil((bsy/5)+0.5f);
+ }
if(bsx>1180)
bsx = 1180;
- if(bsy>1180)
+ if(bsy>1180)
bsy = 1180;
if(bsx<0)
bsx = 0;
- if(bsy<0)
+ if(bsy<0)
bsy = 0;
}
}
- if(sdl_key=='d'&&(sdl_mod & (KMOD_CTRL)))
- DEBUG_MODE = !DEBUG_MODE;
- if(sdl_key=='i')
- {
- int nx, ny;
- for(nx = 0;nx<XRES/CELL;nx++)
- for(ny = 0;ny<YRES/CELL;ny++)
- {
- pv[ny][nx] = -pv[ny][nx];
- vx[ny][nx] = -vx[ny][nx];
- vy[ny][nx] = -vy[ny][nx];
- }
- }
- if((sdl_mod & (KMOD_RCTRL) )&&( sdl_mod & (KMOD_RALT)))
- active_menu = 11;
- if(sdl_key==SDLK_INSERT || sdl_key==SDLK_BACKQUOTE)
- REPLACE_MODE = !REPLACE_MODE;
- if(sdl_key=='g')
- {
- if(sdl_mod & (KMOD_SHIFT))
- GRID_MODE = (GRID_MODE+9)%10;
- else
- GRID_MODE = (GRID_MODE+1)%10;
- }
- if(sdl_key=='t')
+ if(sdl_key=='d'&&(sdl_mod & (KMOD_CTRL)))
+ DEBUG_MODE = !DEBUG_MODE;
+ if(sdl_key=='i')
+ {
+ int nx, ny;
+ for(nx = 0; nx<XRES/CELL; nx++)
+ for(ny = 0; ny<YRES/CELL; ny++)
+ {
+ pv[ny][nx] = -pv[ny][nx];
+ vx[ny][nx] = -vx[ny][nx];
+ vy[ny][nx] = -vy[ny][nx];
+ }
+ }
+ if((sdl_mod & (KMOD_RCTRL) )&&( sdl_mod & (KMOD_RALT)))
+ active_menu = 11;
+ if(sdl_key==SDLK_INSERT || sdl_key==SDLK_BACKQUOTE)
+ REPLACE_MODE = !REPLACE_MODE;
+ if(sdl_key=='g')
+ {
+ if(sdl_mod & (KMOD_SHIFT))
+ GRID_MODE = (GRID_MODE+9)%10;
+ else
+ GRID_MODE = (GRID_MODE+1)%10;
+ }
+ if(sdl_key=='t')
VINE_MODE = !VINE_MODE;
if(sdl_key==SDLK_SPACE)
sys_pause = !sys_pause;
@@ -1536,18 +1536,18 @@ int main(int argc, char *argv[])
}
}
}
- if(sdl_key=='r'&&(sdl_mod & (KMOD_CTRL))&&(sdl_mod & (KMOD_SHIFT)))
+ if(sdl_key=='r'&&(sdl_mod & (KMOD_CTRL))&&(sdl_mod & (KMOD_SHIFT)))
{
save_mode = 1;
copy_mode = 4;//invert
}
- else if(sdl_key=='r'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)))
+ else if(sdl_key=='r'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)))
{
save_mode = 1;
copy_mode = 3;//rotate
}
- else if(sdl_key=='r')
- GENERATION = 0;
+ else if(sdl_key=='r')
+ GENERATION = 0;
if(sdl_key=='x'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)))
{
save_mode = 1;
@@ -1606,24 +1606,24 @@ int main(int argc, char *argv[])
}
else
{
- 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(!(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)
+ if(bsy>1180)
bsy = 1180;
if(bsy<0)
bsy = 0;
@@ -1670,15 +1670,15 @@ int main(int argc, char *argv[])
#ifdef BETA
sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life);
#else
- if(DEBUG_MODE)
+ if(DEBUG_MODE)
{
int tctype = parts[cr>>8].ctype;
if(tctype>=PT_NUM)
tctype = 0;
sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[tctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life);
- //sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[parts[cr>>8].ctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life);
- } else {
- sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C", ptypes[cr&0xFF].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f);
+ //sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[parts[cr>>8].ctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life);
+ } else {
+ sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C", ptypes[cr&0xFF].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f);
}
#endif
}
@@ -1904,22 +1904,22 @@ int main(int argc, char *argv[])
copy_mode = 0;
clear_area(save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL);
}
- else if(copy_mode==3)//rotation
+ else if(copy_mode==3)//rotation
{
- if(save_h>save_w)
- save_w = save_h;
- rotate_area(save_x*CELL, save_y*CELL, save_w*CELL, save_w*CELL,0);//just do squares for now
- save_mode = 0;
- copy_mode = 0;
- }
- else if(copy_mode==4)//invertion
+ if(save_h>save_w)
+ save_w = save_h;
+ rotate_area(save_x*CELL, save_y*CELL, save_w*CELL, save_w*CELL,0);//just do squares for now
+ save_mode = 0;
+ copy_mode = 0;
+ }
+ else if(copy_mode==4)//invertion
{
- if(save_h>save_w)
- save_w = save_h;
- rotate_area(save_x*CELL, save_y*CELL, save_w*CELL, save_w*CELL,1);//just do squares for now
- save_mode = 0;
- copy_mode = 0;
- }
+ if(save_h>save_w)
+ save_w = save_h;
+ rotate_area(save_x*CELL, save_y*CELL, save_w*CELL, save_w*CELL,1);//just do squares for now
+ save_mode = 0;
+ copy_mode = 0;
+ }
else
{
stamp_save(save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL);
@@ -2033,11 +2033,11 @@ int main(int argc, char *argv[])
memset(fire_g, 0, sizeof(fire_g));
memset(fire_b, 0, sizeof(fire_b));
}
- if(x>=19 && x<=35 && svf_last && svf_open && !bq){
- //int tpval = sys_pause;
- parse_save(svf_last, svf_lsize, 1, 0, 0);
- //sys_pause = tpval;
- }
+ if(x>=19 && x<=35 && svf_last && svf_open && !bq) {
+ //int tpval = sys_pause;
+ parse_save(svf_last, svf_lsize, 1, 0, 0);
+ //sys_pause = tpval;
+ }
if(x>=(XRES+BARSIZE-(510-476)) && x<=(XRES+BARSIZE-(510-491)) && !bq)
{
if(b & SDL_BUTTON_LMASK)
@@ -2112,8 +2112,8 @@ int main(int argc, char *argv[])
}
else if((sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)) && (sdl_mod & (KMOD_LSHIFT|KMOD_RSHIFT)) && !(sdl_mod & (KMOD_LALT)))
{
- if(sdl_mod & (KMOD_CAPS))
- c = 0;
+ 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;
@@ -2200,14 +2200,14 @@ int main(int argc, char *argv[])
if(save_mode)
{
- if(copy_mode==3||copy_mode==4)//special drawing for rotate, can remove once it can do rectangles
- {
- if(save_h>save_w)
- save_w = save_h;
- xor_rect(vid_buf, save_x*CELL, save_y*CELL, save_w*CELL, save_w*CELL);
- }
- else
- xor_rect(vid_buf, save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL);
+ if(copy_mode==3||copy_mode==4)//special drawing for rotate, can remove once it can do rectangles
+ {
+ if(save_h>save_w)
+ save_w = save_h;
+ xor_rect(vid_buf, save_x*CELL, save_y*CELL, save_w*CELL, save_w*CELL);
+ }
+ else
+ xor_rect(vid_buf, save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL);
da = 51;
db = 269;
}
@@ -2331,22 +2331,22 @@ int main(int argc, char *argv[])
FPS = 0;
pastFPS = currentTime;
}
-
+
#ifdef BETA
- sprintf(uitext, "Version %d Beta %d FPS:%d Parts:%d", SAVE_VERSION, MINOR_VERSION, FPSB, NUM_PARTS);
+ sprintf(uitext, "Version %d Beta %d FPS:%d Parts:%d", SAVE_VERSION, MINOR_VERSION, FPSB, NUM_PARTS);
#else
- if(DEBUG_MODE)
- sprintf(uitext, "Version %d.%d FPS:%d Parts:%d Generation:%d", SAVE_VERSION, MINOR_VERSION, FPSB, NUM_PARTS,GENERATION);
- else
- sprintf(uitext, "Version %d.%d FPS:%d", SAVE_VERSION, MINOR_VERSION, FPSB);
+ if(DEBUG_MODE)
+ sprintf(uitext, "Version %d.%d FPS:%d Parts:%d Generation:%d", SAVE_VERSION, MINOR_VERSION, FPSB, NUM_PARTS,GENERATION);
+ 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(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)
@@ -2378,7 +2378,7 @@ int main(int argc, char *argv[])
else
player[2] = PT_DUST;
}
- if(isplayer2==0)
+ if(isplayer2==0)
{
if(ptypes[sr].falldown>0 || sr == PT_NEUT || sr == PT_PHOT)
player2[2] = sr;
diff --git a/src/powder.c b/src/powder.c
index be1c7cd..0e8e0f8 100644
--- a/src/powder.c
+++ b/src/powder.c
@@ -78,8 +78,8 @@ static int eval_move(int pt, int nx, int ny, unsigned *rr)
(r&0xFF)==PT_GLOW || (r&0xFF)==PT_WATR ||
(r&0xFF)==PT_DSTW || (r&0xFF)==PT_SLTW ||
(r&0xFF)==PT_ISOZ || (r&0xFF)==PT_ISZS ||
- (r&0xFF)==PT_FILT || (r&0xFF)==PT_INVIS ||
- ((r&0xFF)==PT_LCRY&&parts[r>>8].life > 5)))
+ (r&0xFF)==PT_FILT || (r&0xFF)==PT_INVIS ||
+ ((r&0xFF)==PT_LCRY&&parts[r>>8].life > 5)))
return 2;
if(pt==PT_STKM) //Stick man's head shouldn't collide
@@ -87,7 +87,7 @@ static int eval_move(int pt, int nx, int ny, unsigned *rr)
if(pt==PT_STKM2) //Stick man's head shouldn't collide
return 2;
if((pt==PT_BIZR||pt==PT_BIZRG)&&(r&0xFF)==PT_FILT)
- return 2;
+ return 2;
if(bmap[ny/CELL][nx/CELL]==WL_ALLOWGAS && ptypes[pt].falldown!=0 && pt!=PT_FIRE && pt!=PT_SMKE)
return 0;
if(ptypes[pt].falldown!=2 && bmap[ny/CELL][nx/CELL]==WL_ALLOWLIQUID)
@@ -101,22 +101,22 @@ static int eval_move(int pt, int nx, int ny, unsigned *rr)
if(ptypes[pt].falldown!=1 && bmap[ny/CELL][nx/CELL]==WL_ALLOWSOLID)
return 0;
- if(r && (r&0xFF) < PT_NUM){
- if(ptypes[pt].properties&TYPE_ENERGY && ptypes[(r&0xFF)].properties&TYPE_ENERGY)
- return 2;
-
- if(pt==PT_NEUT && ptypes[(r&0xFF)].properties&PROP_NEUTPASS)
- return 2;
- if(pt==PT_NEUT && ptypes[(r&0xFF)].properties&PROP_NEUTPENETRATE)
- return 1;
- if((r&0xFF)==PT_NEUT && ptypes[pt].properties&PROP_NEUTPENETRATE)
- return 0;
+ if(r && (r&0xFF) < PT_NUM) {
+ if(ptypes[pt].properties&TYPE_ENERGY && ptypes[(r&0xFF)].properties&TYPE_ENERGY)
+ return 2;
+
+ if(pt==PT_NEUT && ptypes[(r&0xFF)].properties&PROP_NEUTPASS)
+ return 2;
+ if(pt==PT_NEUT && ptypes[(r&0xFF)].properties&PROP_NEUTPENETRATE)
+ return 1;
+ if((r&0xFF)==PT_NEUT && ptypes[pt].properties&PROP_NEUTPENETRATE)
+ return 0;
}
-
+
if (r && ((r&0xFF) >= PT_NUM || (ptypes[pt].weight <= ptypes[(r&0xFF)].weight)))
return 0;
- if(pt == PT_PHOT)
+ if(pt == PT_PHOT)
return 2;
return 1;
@@ -133,8 +133,8 @@ int try_move(int i, int x, int y, int nx, int ny)
return 1;
e = eval_move(parts[i].type, nx, ny, &r);
- if((pmap[ny][nx]&0xFF)==PT_INVIS && (pv[ny/CELL][nx/CELL]>4.0f ||pv[ny/CELL][nx/CELL]<-4.0f))
- return 1;
+ if((pmap[ny][nx]&0xFF)==PT_INVIS && (pv[ny/CELL][nx/CELL]>4.0f ||pv[ny/CELL][nx/CELL]<-4.0f))
+ return 1;
/* half-silvered mirror */
if(!e && parts[i].type==PT_PHOT &&
(((r&0xFF)==PT_BMTL && rand()<RAND_MAX/2) ||
@@ -162,58 +162,58 @@ int try_move(int i, int x, int y, int nx, int ny)
parts[r>>8].life = 120;
create_gain_photon(i);
}
- if(parts[i].type == PT_PHOT && (r&0xFF)==PT_FILT)
- {
- int temp_bin = (int)((parts[r>>8].temp-273.0f)*0.025f);
- if(temp_bin < 0) temp_bin = 0;
- if(temp_bin > 25) temp_bin = 25;
- parts[i].ctype = 0x1F << temp_bin;
- }
- if(parts[i].type == PT_NEUT && (r&0xFF)==PT_GLAS) {
- if(rand() < RAND_MAX/10)
- create_cherenkov_photon(i);
- }
- if(parts[i].type == PT_PHOT && (r&0xFF)==PT_INVIS) {
- parts[i].type = PT_NEUT;
- parts[i].ctype = 0;
- }
- if((parts[i].type==PT_BIZR||parts[i].type==PT_BIZRG) && (r&0xFF)==PT_FILT)
- {
- int temp_bin = (int)((parts[r>>8].temp-273.0f)*0.025f);
- if(temp_bin < 0) temp_bin = 0;
- if(temp_bin > 25) temp_bin = 25;
- parts[i].ctype = 0x1F << temp_bin;
- }
+ if(parts[i].type == PT_PHOT && (r&0xFF)==PT_FILT)
+ {
+ int temp_bin = (int)((parts[r>>8].temp-273.0f)*0.025f);
+ if(temp_bin < 0) temp_bin = 0;
+ if(temp_bin > 25) temp_bin = 25;
+ parts[i].ctype = 0x1F << temp_bin;
+ }
+ if(parts[i].type == PT_NEUT && (r&0xFF)==PT_GLAS) {
+ if(rand() < RAND_MAX/10)
+ create_cherenkov_photon(i);
+ }
+ if(parts[i].type == PT_PHOT && (r&0xFF)==PT_INVIS) {
+ parts[i].type = PT_NEUT;
+ parts[i].ctype = 0;
+ }
+ if((parts[i].type==PT_BIZR||parts[i].type==PT_BIZRG) && (r&0xFF)==PT_FILT)
+ {
+ int temp_bin = (int)((parts[r>>8].temp-273.0f)*0.025f);
+ if(temp_bin < 0) temp_bin = 0;
+ if(temp_bin > 25) temp_bin = 25;
+ parts[i].ctype = 0x1F << temp_bin;
+ }
return 1;
}
if((r&0xFF)==PT_VOID)
{
- if(parts[i].type == PT_STKM)
- {
- death = 1;
- isplayer = 0;
- }
- if(parts[i].type == PT_STKM2)
- {
- death2 = 1;
- isplayer2 = 0;
- }
+ if(parts[i].type == PT_STKM)
+ {
+ death = 1;
+ isplayer = 0;
+ }
+ if(parts[i].type == PT_STKM2)
+ {
+ death2 = 1;
+ isplayer2 = 0;
+ }
parts[i].type=PT_NONE;
return 0;
}
if((r&0xFF)==PT_BHOL)
{
- if(parts[i].type == PT_STKM)
- {
- death = 1;
- isplayer = 0;
- }
- if(parts[i].type == PT_STKM2)
- {
- death2 = 1;
- isplayer2 = 0;
- }
+ if(parts[i].type == PT_STKM)
+ {
+ death = 1;
+ isplayer = 0;
+ }
+ if(parts[i].type == PT_STKM2)
+ {
+ death2 = 1;
+ isplayer2 = 0;
+ }
parts[i].type=PT_NONE;
if(!legacy_enable)
{
@@ -223,7 +223,7 @@ int try_move(int i, int x, int y, int nx, int ny)
return 0;
}
if((pmap[ny][nx]&0xFF)==PT_CNCT)
- return 0;
+ return 0;
if(parts[i].type==PT_CNCT && y<ny && (pmap[y+1][x]&0xFF)==PT_CNCT)
return 0;
@@ -283,7 +283,10 @@ static int is_boundary(int pt, int x, int y)
{
if(!is_blocking(pt,x,y))
return 0;
- if(is_blocking(pt,x,y-1) && is_blocking(pt,x,y+1) && is_blocking(pt,x-1,y) && is_blocking(pt,x+1,y))
+ if(is_blocking(pt,x,y-1)
+ && is_blocking(pt,x,y+1)
+ && is_blocking(pt,x-1,y)
+ && is_blocking(pt,x+1,y))
return 0;
return 1;
}
@@ -391,28 +394,29 @@ void kill_part(int i)
{
int x, y;
- if(parts[i].type != PT_PHOT) {
+ if(parts[i].type != PT_PHOT)
+ {
x = (int)(parts[i].x+0.5f);
y = (int)(parts[i].y+0.5f);
- if(parts[i].type == PT_STKM)
- {
- death = 1;
- isplayer = 0;
- }
- if(parts[i].type == PT_STKM2)
- {
- death2 = 1;
- isplayer2 = 0;
- }
- if(parts[i].type == PT_SPAWN)
- {
- ISSPAWN1 = 0;
- }
- if(parts[i].type == PT_SPAWN2)
- {
- ISSPAWN2 = 0;
- }
- if(x>=0 && y>=0 && x<XRES && y<YRES)
+ if(parts[i].type == PT_STKM)
+ {
+ death = 1;
+ isplayer = 0;
+ }
+ else if(parts[i].type == PT_STKM2)
+ {
+ death2 = 1;
+ isplayer2 = 0;
+ }
+ else if(parts[i].type == PT_SPAWN)
+ {
+ ISSPAWN1 = 0;
+ }
+ else if(parts[i].type == PT_SPAWN2)
+ {
+ ISSPAWN2 = 0;
+ }
+ else if(x>=0 && y>=0 && x<XRES && y<YRES)
pmap[y][x] = 0;
}
@@ -438,17 +442,17 @@ inline int create_part(int p, int x, int y, int t)
{
if(t==SPC_HEAT&&parts[pmap[y][x]>>8].temp<MAX_TEMP)
{
- if((pmap[y][x]&0xFF)==PT_PUMP)
- parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp + 0.1f, MIN_TEMP, MAX_TEMP);
- else
- parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp + 4.0f, MIN_TEMP, MAX_TEMP);
+ if((pmap[y][x]&0xFF)==PT_PUMP)
+ parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp + 0.1f, MIN_TEMP, MAX_TEMP);
+ else
+ parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp + 4.0f, MIN_TEMP, MAX_TEMP);
}
if(t==SPC_COOL&&parts[pmap[y][x]>>8].temp>MIN_TEMP)
{
- if((pmap[y][x]&0xFF)==PT_PUMP)
- parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp - 0.1f, MIN_TEMP, MAX_TEMP);
- else
- parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp - 4.0f, MIN_TEMP, MAX_TEMP);
+ if((pmap[y][x]&0xFF)==PT_PUMP)
+ parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp - 0.1f, MIN_TEMP, MAX_TEMP);
+ else
+ parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp - 4.0f, MIN_TEMP, MAX_TEMP);
}
return pmap[y][x]>>8;
}
@@ -459,28 +463,27 @@ inline int create_part(int p, int x, int y, int t)
}
if(t==SPC_AIR)
{
- pv[y/CELL][x/CELL] += 0.03f;
- if(y+CELL<YRES)
- pv[y/CELL+1][x/CELL] += 0.03f;
- if(x+CELL<XRES)
+ if(y + CELL < YRES && x + CELL < XRES)
+ pv[y/CELL][x/CELL] += 0.03f;
+ /* if(x+CELL<XRES)
{
pv[y/CELL][x/CELL+1] += 0.03f;
- if(y+CELL<YRES)
- pv[y/CELL+1][x/CELL+1] += 0.03f;
- }
+ pv[y/CELL+1][x/CELL+1] += 0.03f;
+ }*/
return -1;
}
if(t==SPC_VACUUM)
{
- pv[y/CELL][x/CELL] -= 0.03f;
- if(y+CELL<YRES)
- pv[y/CELL+1][x/CELL] -= 0.03f;
- if(x+CELL<XRES)
- {
- pv[y/CELL][x/CELL+1] -= 0.03f;
- if(y+CELL<YRES)
- pv[y/CELL+1][x/CELL+1] -= 0.03f;
- }
+ if (y + CELL < YRES && x + CELL < XRES)
+ pv[y/CELL][x/CELL] -= 0.03f;
+ /*if(y+CELL<YRES)
+ pv[y/CELL+1][x/CELL] -= 0.03f;
+ if(x+CELL<XRES)
+ {
+ pv[y/CELL][x/CELL+1] -= 0.03f;
+ if(y+CELL<YRES)
+ pv[y/CELL+1][x/CELL+1] -= 0.03f;
+ }*/
return -1;
}
@@ -500,11 +503,11 @@ inline int create_part(int p, int x, int y, int t)
(pmap[y][x]&0xFF)!=PT_BRMT &&
(pmap[y][x]&0xFF)!=PT_NBLE &&
(pmap[y][x]&0xFF)!=PT_IRON &&
- (pmap[y][x]&0xFF)!=PT_INST &&
+ (pmap[y][x]&0xFF)!=PT_INST &&
(pmap[y][x]&0xFF)!=PT_INWR)
return -1;
- if(parts[pmap[y][x]>>8].life!=0)
- return -1;
+ if(parts[pmap[y][x]>>8].life!=0)
+ return -1;
parts[pmap[y][x]>>8].type = PT_SPRK;
parts[pmap[y][x]>>8].life = 4;
parts[pmap[y][x]>>8].ctype = pmap[y][x]&0xFF;
@@ -512,15 +515,15 @@ inline int create_part(int p, int x, int y, int t)
return pmap[y][x]>>8;
}
if(t==PT_SPAWN&&ISSPAWN1)
- return -1;
+ return -1;
if(t==PT_SPAWN2&&ISSPAWN2)
- return -1;
+ return -1;
if(p==-1)//creating from anything but brush
{
- if(pmap[y][x])
- if((pmap[y][x]&0xFF)!=PT_SPAWN&&(pmap[y][x]&0xFF)!=PT_SPAWN2)
- if(t!=PT_STKM&&t!=PT_STKM2)
- return -1;
+ if(pmap[y][x])
+ if((pmap[y][x]&0xFF)!=PT_SPAWN&&(pmap[y][x]&0xFF)!=PT_SPAWN2)
+ if(t!=PT_STKM&&t!=PT_STKM2)
+ return -1;
if(pfree == -1)
return -1;
i = pfree;
@@ -529,13 +532,13 @@ inline int create_part(int p, int x, int y, int t)
else if(p==-2)//creating from brush
{
if(pmap[y][x])
- {
- if(((pmap[y][x]&0xFF)==PT_CLNE||(pmap[y][x]&0xFF)==PT_BCLN||(pmap[y][x]&0xFF)==PT_PCLN)&&(t!=PT_CLNE&&t!=PT_PCLN&&t!=PT_BCLN))
- {
- parts[pmap[y][x]>>8].ctype = t;
- }
+ {
+ if(((pmap[y][x]&0xFF)==PT_CLNE||(pmap[y][x]&0xFF)==PT_BCLN||(pmap[y][x]&0xFF)==PT_PCLN)&&(t!=PT_CLNE&&t!=PT_PCLN&&t!=PT_BCLN))
+ {
+ parts[pmap[y][x]>>8].ctype = t;
+ }
return -1;
- }
+ }
if(pfree == -1)
return -1;
i = pfree;
@@ -569,19 +572,19 @@ inline int create_part(int p, int x, int y, int t)
parts[i].life = 150;
}
End Testing*/
- if(t==PT_WARP) {
- parts[i].life = rand()%95+70;
- }
+ if(t==PT_WARP) {
+ parts[i].life = rand()%95+70;
+ }
if(t==PT_FUSE) {
parts[i].life = 50;
parts[i].tmp = 50;
}
if(t==PT_DEUT)
- parts[i].life = 10;
- if(t==PT_BRAY)
- parts[i].life = 30;
- if(t==PT_PUMP)
- parts[i].life= 10;
+ parts[i].life = 10;
+ if(t==PT_BRAY)
+ parts[i].life = 30;
+ if(t==PT_PUMP)
+ parts[i].life= 10;
if(t==PT_FSEP)
parts[i].life = 50;
if(t==PT_COAL) {
@@ -589,9 +592,9 @@ inline int create_part(int p, int x, int y, int t)
parts[i].tmp = 50;
}
if(t==PT_FRZW)
- parts[i].life = 100;
+ parts[i].life = 100;
if(t==PT_PIPE)
- parts[i].life = 60;
+ parts[i].life = 60;
if(t==PT_BCOL)
parts[i].life = 110;
if(t==PT_FIRE)
@@ -627,34 +630,34 @@ inline int create_part(int p, int x, int y, int t)
parts[i].vy = 3.0f*sinf(a);
}
if(t==PT_BIZR||t==PT_BIZRG)
- parts[i].ctype = 0x47FFFF;
+ parts[i].ctype = 0x47FFFF;
if(t!=PT_STKM&&t!=PT_STKM2)// && t!=PT_PHOT && t!=PT_NEUT) is this needed? it breaks floodfill
pmap[y][x] = t|(i<<8);
else if(t==PT_STKM)
{
if(isplayer==0)
{
- if(pmap[y][x]&0xFF==PT_SPAWN)
- {
- parts[pmap[y][x]>>8].type = PT_STKM;
- parts[pmap[y][x]>>8].vx = 0;
- parts[pmap[y][x]>>8].vy = 0;
- parts[pmap[y][x]>>8].life = 100;
- parts[pmap[y][x]>>8].ctype = 0;
- parts[pmap[y][x]>>8].temp = ptypes[t].heat;
-
- }
- else
- {
- parts[i].x = (float)x;
- parts[i].y = (float)y;
- parts[i].type = PT_STKM;
- parts[i].vx = 0;
- parts[i].vy = 0;
- parts[i].life = 100;
- parts[i].ctype = 0;
- parts[i].temp = ptypes[t].heat;
- }
+ if(pmap[y][x]&0xFF==PT_SPAWN)
+ {
+ parts[pmap[y][x]>>8].type = PT_STKM;
+ parts[pmap[y][x]>>8].vx = 0;
+ parts[pmap[y][x]>>8].vy = 0;
+ parts[pmap[y][x]>>8].life = 100;
+ parts[pmap[y][x]>>8].ctype = 0;
+ parts[pmap[y][x]>>8].temp = ptypes[t].heat;
+
+ }
+ else
+ {
+ parts[i].x = (float)x;
+ parts[i].y = (float)y;
+ parts[i].type = PT_STKM;
+ parts[i].vx = 0;
+ parts[i].vy = 0;
+ parts[i].life = 100;
+ parts[i].ctype = 0;
+ parts[i].temp = ptypes[t].heat;
+ }
@@ -680,35 +683,35 @@ inline int create_part(int p, int x, int y, int t)
isplayer = 1;
}
- //kill_part(playerspawn);
- create_part(-1,x,y,PT_SPAWN);
- ISSPAWN1 = 1;
+ //kill_part(playerspawn);
+ create_part(-1,x,y,PT_SPAWN);
+ ISSPAWN1 = 1;
}
else if(t==PT_STKM2)
{
if(isplayer2==0)
{
- if(pmap[y][x]&0xFF==PT_SPAWN2)
- {
- parts[pmap[y][x]>>8].type = PT_STKM2;
- parts[pmap[y][x]>>8].vx = 0;
- parts[pmap[y][x]>>8].vy = 0;
- parts[pmap[y][x]>>8].life = 100;
- parts[pmap[y][x]>>8].ctype = 0;
- parts[pmap[y][x]>>8].temp = ptypes[t].heat;
-
- }
- else
- {
- parts[i].x = (float)x;
- parts[i].y = (float)y;
- parts[i].type = PT_STKM2;
- parts[i].vx = 0;
- parts[i].vy = 0;
- parts[i].life = 100;
- parts[i].ctype = 0;
- parts[i].temp = ptypes[t].heat;
- }
+ if(pmap[y][x]&0xFF==PT_SPAWN2)
+ {
+ parts[pmap[y][x]>>8].type = PT_STKM2;
+ parts[pmap[y][x]>>8].vx = 0;
+ parts[pmap[y][x]>>8].vy = 0;
+ parts[pmap[y][x]>>8].life = 100;
+ parts[pmap[y][x]>>8].ctype = 0;
+ parts[pmap[y][x]>>8].temp = ptypes[t].heat;
+
+ }
+ else
+ {
+ parts[i].x = (float)x;
+ parts[i].y = (float)y;
+ parts[i].type = PT_STKM2;
+ parts[i].vx = 0;
+ parts[i].vy = 0;
+ parts[i].life = 100;
+ parts[i].ctype = 0;
+ parts[i].temp = ptypes[t].heat;
+ }
@@ -734,9 +737,9 @@ inline int create_part(int p, int x, int y, int t)
isplayer2 = 1;
}
- //kill_part(player2spawn);
- create_part(-1,x,y,PT_SPAWN2);
- ISSPAWN2 = 1;
+ //kill_part(player2spawn);
+ create_part(-1,x,y,PT_SPAWN2);
+ ISSPAWN2 = 1;
}
return i;
@@ -844,17 +847,17 @@ inline void delete_part(int x, int y)
if(!i || (i>>8)>=NPART)
return;
if((parts[i>>8].type==SLALT)||SLALT==0)
- {
- kill_part(i>>8);
- pmap[y][x] = 0;
- }
+ {
+ kill_part(i>>8);
+ pmap[y][x] = 0;
+ }
else if(ptypes[parts[i>>8].type].menusection==SEC)
- {
- kill_part(i>>8);
- pmap[y][x] = 0;
- }
- else
- return;
+ {
+ kill_part(i>>8);
+ pmap[y][x] = 0;
+ }
+ else
+ return;
}
#if defined(WIN32) && !defined(__GNUC__)
@@ -963,25 +966,25 @@ _inline int parts_avg(int ci, int ni,int t)//t is the particle you are looking f
inline int parts_avg(int ci, int ni,int t)
#endif
{
- if(t==PT_INSL)//to keep electronics working
- {
- int pmr = pmap[(int)((parts[ci].y + parts[ni].y)/2)][(int)((parts[ci].x + parts[ni].x)/2)];
- if((pmr>>8) < NPART && pmr)
- return parts[pmr>>8].type;
- else
- return PT_NONE;
- }
- else
- {
- int pmr2 = pmap[(int)((parts[ci].y + parts[ni].y)/2+0.5f)][(int)((parts[ci].x + parts[ni].x)/2+0.5f)];//seems to be more accurate.
- if((pmr2>>8) < NPART && pmr2)
- {
- if(parts[pmr2>>8].type==t)
- return t;
- }
- else
- return PT_NONE;
- }
+ if(t==PT_INSL)//to keep electronics working
+ {
+ int pmr = pmap[(int)((parts[ci].y + parts[ni].y)/2)][(int)((parts[ci].x + parts[ni].x)/2)];
+ if((pmr>>8) < NPART && pmr)
+ return parts[pmr>>8].type;
+ else
+ return PT_NONE;
+ }
+ else
+ {
+ int pmr2 = pmap[(int)((parts[ci].y + parts[ni].y)/2+0.5f)][(int)((parts[ci].x + parts[ni].x)/2+0.5f)];//seems to be more accurate.
+ if((pmr2>>8) < NPART && pmr2)
+ {
+ if(parts[pmr2>>8].type==t)
+ return t;
+ }
+ else
+ return PT_NONE;
+ }
}
@@ -1017,267 +1020,257 @@ void update_particles_i(pixel *vid, int start, int inc)
float c_heat = 0.0f;
int h_count = 0;
int starti = (start*-1);
- if(sys_pause&&!framerender)
- return;
+ if(sys_pause&&!framerender)
+ return;
if(ISGRAV==1)
- {
- ISGRAV = 0;
- GRAV ++;
- GRAV_R = 60;
- GRAV_G = 0;
- GRAV_B = 0;
- GRAV_R2 = 30;
- GRAV_G2 = 30;
- GRAV_B2 = 0;
- for( q = 0;q <= GRAV;q++)
- {
- if(GRAV_R >0 && GRAV_G==0)
- {
- GRAV_R--;
- GRAV_B++;
- }
- if(GRAV_B >0 && GRAV_R==0)
- {
- GRAV_B--;
- GRAV_G++;
- }
- if(GRAV_G >0 && GRAV_B==0)
- {
- GRAV_G--;
- GRAV_R++;
- }
- if(GRAV_R2 >0 && GRAV_G2==0)
- {
- GRAV_R2--;
- GRAV_B2++;
- }
- if(GRAV_B2 >0 && GRAV_R2==0)
- {
- GRAV_B2--;
- GRAV_G2++;
- }
- if(GRAV_G2 >0 && GRAV_B2==0)
- {
- GRAV_G2--;
- GRAV_R2++;
- }
- }
- if(GRAV>180) GRAV = 0;
-
- }
- if(ISLOVE==1)
- {
- ISLOVE = 0;
- for(ny=0;ny<YRES-4;ny++)
- {
- for(nx=0;nx<XRES-4;nx++)
- {
- r=pmap[ny][nx];
- if((r>>8)>=NPART || !r)
- {
- continue;
- }
- else if((ny<9||nx<9||ny>YRES-7||nx>XRES-10)&&parts[r>>8].type==PT_LOVE)
- parts[r>>8].type = PT_NONE;
- else if(parts[r>>8].type==PT_LOVE)
- {
- love[nx/9][ny/9] = 1;
- }
-
- }
- }
- for(nx=9;nx<=XRES-18;nx++)
- {
- for(ny=9;ny<=YRES-7;ny++)
- {
- if(love[nx/9][ny/9]==1)
- {
- for( nnx=0;nnx<9;nnx++)
- for( nny=0;nny<9;nny++)
- {
- if(ny+nny>0&&ny+nny<YRES&&nx+nnx>=0&&nx+nnx<XRES)
- {
- rt=pmap[ny+nny][nx+nnx];
- if((rt>>8)>=NPART)
- {
- continue;
- }
- if(!rt&&loverule[nnx][nny]==1)
- create_part(-1,nx+nnx,ny+nny,PT_LOVE);
- else if(!rt)
- continue;
- else if(parts[rt>>8].type==PT_LOVE&&loverule[nnx][nny]==0)
- parts[rt>>8].type=PT_NONE;
-
- }
- }
- }
- love[nx/9][ny/9]=0;
- }
- }
- }
- if(ISLOLZ==1)
- {
- ISLOLZ = 0;
- for(ny=0;ny<YRES-4;ny++)
- {
- for(nx=0;nx<XRES-4;nx++)
- {
- r=pmap[ny][nx];
- if((r>>8)>=NPART || !r)
- {
- continue;
- }
- else if((ny<9||nx<9||ny>YRES-7||nx>XRES-10)&&parts[r>>8].type==PT_LOLZ)
- parts[r>>8].type = PT_NONE;
- else if(parts[r>>8].type==PT_LOLZ)
- {
- lolz[nx/9][ny/9] = 1;
- }
-
- }
- }
- for(nx=9;nx<=XRES-18;nx++)
- {
- for(ny=9;ny<=YRES-7;ny++)
- {
- if(lolz[nx/9][ny/9]==1)
- {
- for( nnx=0;nnx<9;nnx++)
- for( nny=0;nny<9;nny++)
- {
- if(ny+nny>0&&ny+nny<YRES&&nx+nnx>=0&&nx+nnx<XRES)
- {
- rt=pmap[ny+nny][nx+nnx];
- if((rt>>8)>=NPART)
- {
- continue;
- }
- if(!rt&&lolzrule[nny][nnx]==1)
- create_part(-1,nx+nnx,ny+nny,PT_LOLZ);
- else if(!rt)
- continue;
- else if(parts[rt>>8].type==PT_LOLZ&&lolzrule[nny][nnx]==0)
- parts[rt>>8].type=PT_NONE;
-
- }
- }
- }
- lolz[nx/9][ny/9]=0;
- }
- }
- }
- if(ISGOL==1&&CGOL>=GSPEED)//GSPEED is frames per generation
- {
- int createdsomething = 0;
- for(nx=4;nx<XRES-4;nx++)
- for(ny=4;ny<YRES-4;ny++)
- {
- CGOL=0;
- ISGOL=0;
- r = pmap[ny][nx];
- if((r>>8)>=NPART || !r)
- {
- gol[nx][ny] = 0;
- continue;
- }
- else
- for( golnum=1;golnum<NGOL;golnum++)
- if(parts[r>>8].type==golnum+77)
- {
- gol[nx][ny] = golnum;
- for( nnx=-1;nnx<2;nnx++)
- for( nny=-1;nny<2;nny++)//it will count itself as its own neighbor, which is needed, but will have 1 extra for delete check
- {
- if(ny+nny<4&&nx+nnx<4){//any way to make wrapping code smaller?
- gol2[XRES-5][YRES-5][golnum] ++;
- gol2[XRES-5][YRES-5][0] ++;
- }
- else if(ny+nny<4&&nx+nnx>=XRES-4){
- gol2[4][YRES-5][golnum] ++;
- gol2[4][YRES-5][0] ++;
- }
- else if(ny+nny>=YRES-4&&nx+nnx<4){
- gol2[XRES-5][4][golnum] ++;
- gol2[XRES-5][4][0] ++;
- }
- else if(nx+nnx<4){
- gol2[XRES-5][ny+nny][golnum] ++;
- gol2[XRES-5][ny+nny][0] ++;
- }
- else if(ny+nny<4){
- gol2[nx+nnx][YRES-5][golnum] ++;
- gol2[nx+nnx][YRES-5][0] ++;
- }
- else if(ny+nny>=YRES-4&&nx+nnx>=XRES-4){
- gol2[4][4][golnum] ++;
- gol2[4][4][0] ++;
- }
- else if(ny+nny>=YRES-4){
- gol2[nx+nnx][4][golnum] ++;
- gol2[nx+nnx][4][0] ++;
- }
- else if(nx+nnx>=XRES-4){
- gol2[4][ny+nny][golnum] ++;
- gol2[4][ny+nny][0] ++;
- }
- else{
- gol2[nx+nnx][ny+nny][golnum] ++;
- gol2[nx+nnx][ny+nny][0] ++;
- }
- }
- }
- }
- for(nx=4;nx<XRES-4;nx++)
- for(ny=4;ny<YRES-4;ny++)
- {
- int neighbors = gol2[nx][ny][0];
- if(neighbors==0)
- continue;
- for( golnum = 1;golnum<NGOL;golnum++)
- for( goldelete = 0;goldelete<9;goldelete++)
- {
- if(neighbors==goldelete&&gol[nx][ny]==0&&grule[golnum][goldelete]>=2&&gol2[nx][ny][golnum]>=(goldelete%2)+goldelete/2)
- {
- if(create_part(-1,nx,ny,golnum+77))
- createdsomething = 1;
- }
- else if(neighbors-1==goldelete&&gol[nx][ny]==golnum&&(grule[golnum][goldelete]==0||grule[golnum][goldelete]==2))//subtract 1 because it counted itself
- parts[pmap[ny][nx]>>8].type = PT_NONE;
- }
- gol2[nx][ny][0] = 0;
- for( z = 1;z<NGOL;z++)
- gol2[nx][ny][z] = 0;
- }
- if(createdsomething)
- GENERATION ++;
- }
- //if(ISWIRE==1)
- //{
- // CGOL = 0;
- // ISWIRE = 0;
- //}
- if(ISWIRE==1)
- {
- for( q = 0;q<99;q++)
- if(!wireless[q][1])
- {
- wireless[q][0] = 0;
- }
- else
- wireless[q][1] = 0;
- }
+ {
+ ISGRAV = 0;
+ GRAV ++;
+ GRAV_R = 60;
+ GRAV_G = 0;
+ GRAV_B = 0;
+ GRAV_R2 = 30;
+ GRAV_G2 = 30;
+ GRAV_B2 = 0;
+ for( q = 0; q <= GRAV; q++)
+ {
+ if(GRAV_R >0 && GRAV_G==0)
+ {
+ GRAV_R--;
+ GRAV_B++;
+ }
+ if(GRAV_B >0 && GRAV_R==0)
+ {
+ GRAV_B--;
+ GRAV_G++;
+ }
+ if(GRAV_G >0 && GRAV_B==0)
+ {
+ GRAV_G--;
+ GRAV_R++;
+ }
+ if(GRAV_R2 >0 && GRAV_G2==0)
+ {
+ GRAV_R2--;
+ GRAV_B2++;
+ }
+ if(GRAV_B2 >0 && GRAV_R2==0)
+ {
+ GRAV_B2--;
+ GRAV_G2++;
+ }
+ if(GRAV_G2 >0 && GRAV_B2==0)
+ {
+ GRAV_G2--;
+ GRAV_R2++;
+ }
+ }
+ if(GRAV>180) GRAV = 0;
+
+ }
+ if(ISLOVE==1)
+ {
+ ISLOVE = 0;
+ for(ny=0; ny<YRES-4; ny++)
+ {
+ for(nx=0; nx<XRES-4; nx++)
+ {
+ r=pmap[ny][nx];
+ if((r>>8)>=NPART || !r)
+ {
+ continue;
+ }
+ else if((ny<9||nx<9||ny>YRES-7||nx>XRES-10)&&parts[r>>8].type==PT_LOVE)
+ parts[r>>8].type = PT_NONE;
+ else if(parts[r>>8].type==PT_LOVE)
+ {
+ love[nx/9][ny/9] = 1;
+ }
+
+ }
+ }
+ for(nx=9; nx<=XRES-18; nx++)
+ {
+ for(ny=9; ny<=YRES-7; ny++)
+ {
+ if(love[nx/9][ny/9]==1)
+ {
+ for( nnx=0; nnx<9; nnx++)
+ for( nny=0; nny<9; nny++)
+ {
+ if(ny+nny>0&&ny+nny<YRES&&nx+nnx>=0&&nx+nnx<XRES)
+ {
+ rt=pmap[ny+nny][nx+nnx];
+ if((rt>>8)>=NPART)
+ {
+ continue;
+ }
+ if(!rt&&loverule[nnx][nny]==1)
+ create_part(-1,nx+nnx,ny+nny,PT_LOVE);
+ else if(!rt)
+ continue;
+ else if(parts[rt>>8].type==PT_LOVE&&loverule[nnx][nny]==0)
+ parts[rt>>8].type=PT_NONE;
+
+ }
+ }
+ }
+ love[nx/9][ny/9]=0;
+ }
+ }
+ }
+ if(ISLOLZ==1)
+ {
+ ISLOLZ = 0;
+ for(ny=0; ny<YRES-4; ny++)
+ for(nx=0; nx<XRES-4; nx++)
+ {
+ r=pmap[ny][nx];
+ if((r>>8)>=NPART || !r)
+ continue;
+ else if((ny<9||nx<9||ny>YRES-7||nx>XRES-10)&&parts[r>>8].type==PT_LOLZ)
+ parts[r>>8].type = PT_NONE;
+ else if(parts[r>>8].type==PT_LOLZ)
+ lolz[nx/9][ny/9] = 1;
+
+ }
+ for(nx=9; nx<=XRES-18; nx++)
+ {
+ for(ny=9; ny<=YRES-7; ny++)
+ {
+ if(lolz[nx/9][ny/9]==1)
+ {
+ for( nnx=0; nnx<9; nnx++)
+ for( nny=0; nny<9; nny++)
+ if(ny+nny>0&&ny+nny<YRES&&nx+nnx>=0&&nx+nnx<XRES)
+ {
+ rt=pmap[ny+nny][nx+nnx];
+ if((rt>>8)>=NPART)
+ continue;
+ if(!rt&&lolzrule[nny][nnx]==1)
+ create_part(-1,nx+nnx,ny+nny,PT_LOLZ);
+ else if(!rt)
+ continue;
+ else if(parts[rt>>8].type==PT_LOLZ&&lolzrule[nny][nnx]==0)
+ parts[rt>>8].type=PT_NONE;
+
+ }
+ }
+ lolz[nx/9][ny/9]=0;
+ }
+ }
+ }
+ if(ISGOL==1&&CGOL>=GSPEED)//GSPEED is frames per generation
+ {
+ int createdsomething = 0;
+ for(nx=4; nx<XRES-4; nx++)
+ for(ny=4; ny<YRES-4; ny++)
+ {
+ CGOL=0;
+ ISGOL=0;
+ r = pmap[ny][nx];
+ if((r>>8)>=NPART || !r)
+ {
+ gol[nx][ny] = 0;
+ continue;
+ }
+ else
+ for( golnum=1; golnum<NGOL; golnum++)
+ if(parts[r>>8].type==golnum+77)
+ {
+ gol[nx][ny] = golnum;
+ for( nnx=-1; nnx<2; nnx++)
+ for( nny=-1; nny<2; nny++) //it will count itself as its own neighbor, which is needed, but will have 1 extra for delete check
+ {
+ if(ny+nny<4&&nx+nnx<4) { //any way to make wrapping code smaller?
+ gol2[XRES-5][YRES-5][golnum] ++;
+ gol2[XRES-5][YRES-5][0] ++;
+ }
+ else if(ny+nny<4&&nx+nnx>=XRES-4) {
+ gol2[4][YRES-5][golnum] ++;
+ gol2[4][YRES-5][0] ++;
+ }
+ else if(ny+nny>=YRES-4&&nx+nnx<4) {
+ gol2[XRES-5][4][golnum] ++;
+ gol2[XRES-5][4][0] ++;
+ }
+ else if(nx+nnx<4) {
+ gol2[XRES-5][ny+nny][golnum] ++;
+ gol2[XRES-5][ny+nny][0] ++;
+ }
+ else if(ny+nny<4) {
+ gol2[nx+nnx][YRES-5][golnum] ++;
+ gol2[nx+nnx][YRES-5][0] ++;
+ }
+ else if(ny+nny>=YRES-4&&nx+nnx>=XRES-4) {
+ gol2[4][4][golnum] ++;
+ gol2[4][4][0] ++;
+ }
+ else if(ny+nny>=YRES-4) {
+ gol2[nx+nnx][4][golnum] ++;
+ gol2[nx+nnx][4][0] ++;
+ }
+ else if(nx+nnx>=XRES-4) {
+ gol2[4][ny+nny][golnum] ++;
+ gol2[4][ny+nny][0] ++;
+ }
+ else {
+ gol2[nx+nnx][ny+nny][golnum] ++;
+ gol2[nx+nnx][ny+nny][0] ++;
+ }
+ }
+ }
+ }
+ for(nx=4; nx<XRES-4; nx++)
+ for(ny=4; ny<YRES-4; ny++)
+ {
+ int neighbors = gol2[nx][ny][0];
+ if(neighbors==0)
+ continue;
+ for( golnum = 1; golnum<NGOL; golnum++)
+ for( goldelete = 0; goldelete<9; goldelete++)
+ {
+ if(neighbors==goldelete&&gol[nx][ny]==0&&grule[golnum][goldelete]>=2&&gol2[nx][ny][golnum]>=(goldelete%2)+goldelete/2)
+ {
+ if(create_part(-1,nx,ny,golnum+77))
+ createdsomething = 1;
+ }
+ else if(neighbors-1==goldelete&&gol[nx][ny]==golnum&&(grule[golnum][goldelete]==0||grule[golnum][goldelete]==2))//subtract 1 because it counted itself
+ parts[pmap[ny][nx]>>8].type = PT_NONE;
+ }
+ gol2[nx][ny][0] = 0;
+ for( z = 1; z<NGOL; z++)
+ gol2[nx][ny][z] = 0;
+ }
+ if(createdsomething)
+ GENERATION ++;
+ }
+ //if(ISWIRE==1)
+ //{
+ // CGOL = 0;
+ // ISWIRE = 0;
+ //}
+ if(ISWIRE==1)
+ {
+ for( q = 0; q<99; q++)
+ if(!wireless[q][1])
+ {
+ wireless[q][0] = 0;
+ }
+ else
+ wireless[q][1] = 0;
+ }
for(i=start; i<(NPART-starti); i+=inc)
if(parts[i].type)
{
- lx = parts[i].x;
+ lx = parts[i].x;
ly = parts[i].y;
t = parts[i].type;
- if (ptypes[t].update_func)
- {
- if (ptypes[t].update_func (i))
- goto killed;
- }
+ if (ptypes[t].update_func)
+ {
+ if (ptypes[t].update_func (i))
+ goto killed;
+ }
//printf("parts[%d].type: %d\n", i, parts[i].type);
@@ -1303,8 +1296,8 @@ void update_particles_i(pixel *vid, int start, int inc)
parts[i].life = 64;
if(t == PT_SLTW)
parts[i].life = 54;
- if(t == PT_SWCH)
- parts[i].life = 15;
+ if(t == PT_SWCH)
+ parts[i].life = 15;
}
}
@@ -1335,49 +1328,49 @@ void update_particles_i(pixel *vid, int start, int inc)
vx[y/CELL][x/CELL] *= ptypes[t].airloss;
vy[y/CELL][x/CELL] *= ptypes[t].airloss;
- if(t==PT_ANAR)
- {
- vx[y/CELL][x/CELL] -= ptypes[t].airdrag*parts[i].vx;
- vy[y/CELL][x/CELL] -= ptypes[t].airdrag*parts[i].vy;
- }
- else
- {
- vx[y/CELL][x/CELL] += ptypes[t].airdrag*parts[i].vx;
- vy[y/CELL][x/CELL] += ptypes[t].airdrag*parts[i].vy;
- }
+ if(t==PT_ANAR)
+ {
+ vx[y/CELL][x/CELL] -= ptypes[t].airdrag*parts[i].vx;
+ vy[y/CELL][x/CELL] -= ptypes[t].airdrag*parts[i].vy;
+ }
+ else
+ {
+ vx[y/CELL][x/CELL] += ptypes[t].airdrag*parts[i].vx;
+ vy[y/CELL][x/CELL] += ptypes[t].airdrag*parts[i].vy;
+ }
if(t==PT_GAS||t==PT_NBLE||t==PT_PUMP)
{
- if(t==PT_PUMP && parts[i].life==10)
- {
- if(parts[i].temp>=256.0+273.15)
- parts[i].temp=256.0+273.15;
- if(parts[i].temp<= -256.0+273.15)
- parts[i].temp = -256.0+273.15;
-
- if(pv[y/CELL][x/CELL]<(parts[i].temp-273.15))
- pv[y/CELL][x/CELL] += 0.1f*((parts[i].temp-273.15)-pv[y/CELL][x/CELL]);
- if(y+CELL<YRES && pv[y/CELL+1][x/CELL]<(parts[i].temp-273.15))
- pv[y/CELL+1][x/CELL] += 0.1f*((parts[i].temp-273.15)-pv[y/CELL+1][x/CELL]);
- if(x+CELL<XRES)
- {
- pv[y/CELL][x/CELL+1] += 0.1f*((parts[i].temp-273.15)-pv[y/CELL][x/CELL+1]);
- if(y+CELL<YRES)
- pv[y/CELL+1][x/CELL+1] += 0.1f*((parts[i].temp-273.15)-pv[y/CELL+1][x/CELL+1]);
- }
- }
- else
- {
- if(pv[y/CELL][x/CELL]<3.5f)
- pv[y/CELL][x/CELL] += ptypes[t].hotair*(3.5f-pv[y/CELL][x/CELL]);
- if(y+CELL<YRES && pv[y/CELL+1][x/CELL]<3.5f)
- pv[y/CELL+1][x/CELL] += ptypes[t].hotair*(3.5f-pv[y/CELL+1][x/CELL]);
- if(x+CELL<XRES)
- {
- pv[y/CELL][x/CELL+1] += ptypes[t].hotair*(3.5f-pv[y/CELL][x/CELL+1]);
- if(y+CELL<YRES)
- pv[y/CELL+1][x/CELL+1] += ptypes[t].hotair*(3.5f-pv[y/CELL+1][x/CELL+1]);
- }
- }
+ if(t==PT_PUMP && parts[i].life==10)
+ {
+ if(parts[i].temp>=256.0+273.15)
+ parts[i].temp=256.0+273.15;
+ if(parts[i].temp<= -256.0+273.15)
+ parts[i].temp = -256.0+273.15;
+
+ if(pv[y/CELL][x/CELL]<(parts[i].temp-273.15))
+ pv[y/CELL][x/CELL] += 0.1f*((parts[i].temp-273.15)-pv[y/CELL][x/CELL]);
+ if(y+CELL<YRES && pv[y/CELL+1][x/CELL]<(parts[i].temp-273.15))
+ pv[y/CELL+1][x/CELL] += 0.1f*((parts[i].temp-273.15)-pv[y/CELL+1][x/CELL]);
+ if(x+CELL<XRES)
+ {
+ pv[y/CELL][x/CELL+1] += 0.1f*((parts[i].temp-273.15)-pv[y/CELL][x/CELL+1]);
+ if(y+CELL<YRES)
+ pv[y/CELL+1][x/CELL+1] += 0.1f*((parts[i].temp-273.15)-pv[y/CELL+1][x/CELL+1]);
+ }
+ }
+ else
+ {
+ if(pv[y/CELL][x/CELL]<3.5f)
+ pv[y/CELL][x/CELL] += ptypes[t].hotair*(3.5f-pv[y/CELL][x/CELL]);
+ if(y+CELL<YRES && pv[y/CELL+1][x/CELL]<3.5f)
+ pv[y/CELL+1][x/CELL] += ptypes[t].hotair*(3.5f-pv[y/CELL+1][x/CELL]);
+ if(x+CELL<XRES)
+ {
+ pv[y/CELL][x/CELL+1] += ptypes[t].hotair*(3.5f-pv[y/CELL][x/CELL+1]);
+ if(y+CELL<YRES)
+ pv[y/CELL+1][x/CELL+1] += ptypes[t].hotair*(3.5f-pv[y/CELL+1][x/CELL+1]);
+ }
+ }
}
else
@@ -1414,7 +1407,7 @@ void update_particles_i(pixel *vid, int start, int inc)
parts[i].life = rand()%80+300;
}
}
- else if((t==PT_BCLN) && !parts[i].life)
+ else if((t==PT_BCLN) && !parts[i].life)
{
if(pv[y/CELL][x/CELL]>4.0f)
{
@@ -1425,16 +1418,16 @@ void update_particles_i(pixel *vid, int start, int inc)
}
else
{
- if(t==PT_ANAR)
- {
- parts[i].vx -= ptypes[t].advection*vx[y/CELL][x/CELL];
- parts[i].vy -= ptypes[t].advection*vy[y/CELL][x/CELL] + ptypes[t].gravity;
- }
- else{
- parts[i].vx += ptypes[t].advection*vx[y/CELL][x/CELL];
- parts[i].vy += ptypes[t].advection*vy[y/CELL][x/CELL] + ptypes[t].gravity;
-
- }
+ if(t==PT_ANAR)
+ {
+ parts[i].vx -= ptypes[t].advection*vx[y/CELL][x/CELL];
+ parts[i].vy -= ptypes[t].advection*vy[y/CELL][x/CELL] + ptypes[t].gravity;
+ }
+ else {
+ parts[i].vx += ptypes[t].advection*vx[y/CELL][x/CELL];
+ parts[i].vy += ptypes[t].advection*vy[y/CELL][x/CELL] + ptypes[t].gravity;
+
+ }
}
if(ptypes[t].diffusion)
@@ -1508,18 +1501,18 @@ void update_particles_i(pixel *vid, int start, int inc)
if(t==PT_GAS && pv[y/CELL][x/CELL]>6.0f)
t = parts[i].type = PT_OIL;
if(t==PT_DESL && pv[y/CELL][x/CELL]>12.0f)
- {
+ {
t = parts[i].type = PT_FIRE;
- parts[i].life = rand()%50+120;
- }
+ parts[i].life = rand()%50+120;
+ }
}
if(t==PT_GAS && pv[y/CELL][x/CELL]<-6.0f)
t = parts[i].type = PT_OIL;
if(t==PT_DESL && pv[y/CELL][x/CELL]>5.0f)
- { // Only way I know to make it
- t = parts[i].type = PT_FIRE; // combust under pressure.
- parts[i].life = rand()%50+120;
- }
+ { // Only way I know to make it
+ t = parts[i].type = PT_FIRE; // combust under pressure.
+ parts[i].life = rand()%50+120;
+ }
if(t==PT_GAS && pv[y/CELL][x/CELL]>6.0f)
t = parts[i].type = PT_OIL;
if(t==PT_BMTL && pv[y/CELL][x/CELL]>2.5f)
@@ -1528,21 +1521,21 @@ void update_particles_i(pixel *vid, int start, int inc)
t = parts[i].type = PT_BRMT;
if(t==PT_BRCK && pv[y/CELL][x/CELL]>8.8f)
t = parts[i].type = PT_STNE;
- if(t==PT_PIPE && pv[y/CELL][x/CELL]>10.0f)
+ if(t==PT_PIPE && pv[y/CELL][x/CELL]>10.0f)
t = parts[i].type = PT_BRMT;
- if(t==PT_PSTE && pv[y/CELL][x/CELL]>0.5f)
+ if(t==PT_PSTE && pv[y/CELL][x/CELL]>0.5f)
t = parts[i].type = PT_PSTS;
- if(t==PT_PSTS && pv[y/CELL][x/CELL]<0.5f)
+ if(t==PT_PSTS && pv[y/CELL][x/CELL]<0.5f)
t = parts[i].type = PT_PSTE;
- if(t==PT_SHLD1 && pv[y/CELL][x/CELL]>7.0f)
+ if(t==PT_SHLD1 && pv[y/CELL][x/CELL]>7.0f)
t = parts[i].type = PT_NONE;
- if(t==PT_SHLD2 && pv[y/CELL][x/CELL]>15.0f)
+ if(t==PT_SHLD2 && pv[y/CELL][x/CELL]>15.0f)
t = parts[i].type = PT_NONE;
- if(t==PT_SHLD3 && pv[y/CELL][x/CELL]>25.0f)
+ if(t==PT_SHLD3 && pv[y/CELL][x/CELL]>25.0f)
t = parts[i].type = PT_NONE;
- if(t==PT_SHLD4 && pv[y/CELL][x/CELL]>40.0f)
+ if(t==PT_SHLD4 && pv[y/CELL][x/CELL]>40.0f)
t = parts[i].type = PT_NONE;
- if(t==PT_WIFI && pv[y/CELL][x/CELL]>15.0f)
+ if(t==PT_WIFI && pv[y/CELL][x/CELL]>15.0f)
t = parts[i].type = PT_BRMT;
//if(t==PT_GLAS && pv[y/CELL][x/CELL]>4.0f)
// t = parts[i].type = PT_BGLA;
@@ -1562,20 +1555,20 @@ void update_particles_i(pixel *vid, int start, int inc)
t = PT_NEUT;
create_part(i, x, y, t);
}
- if((t==PT_ISOZ||t==PT_ISZS) && 1>rand()%200 && ((int)(-4.0f*(pv[y/CELL][x/CELL])))>(rand()%1000))
+ if((t==PT_ISOZ||t==PT_ISZS) && 1>rand()%200 && ((int)(-4.0f*(pv[y/CELL][x/CELL])))>(rand()%1000))
{
t = PT_PHOT;
- rr = (rand()%228+128)/127.0f;
- rrr = (rand()%360)*3.14159f/180.0f;
- parts[i].life = 680;
- parts[i].ctype = 0x3FFFFFFF;
- parts[i].vx = rr*cosf(rrr);
- parts[i].vy = rr*sinf(rrr);
+ rr = (rand()%228+128)/127.0f;
+ rrr = (rand()%360)*3.14159f/180.0f;
+ parts[i].life = 680;
+ parts[i].ctype = 0x3FFFFFFF;
+ parts[i].vx = rr*cosf(rrr);
+ parts[i].vy = rr*sinf(rrr);
create_part(i, x, y, t);
}
- if(t==PT_PSTE)
- if(parts[i].temp>747.0f)
- t = parts[i].type = PT_BRCK;
+ if(t==PT_PSTE)
+ if(parts[i].temp>747.0f)
+ t = parts[i].type = PT_BRCK;
if(t==PT_SPRK&&parts[i].ctype==PT_ETRD&&parts[i].life==1)
{
nearp = nearest_part(i, PT_ETRD);
@@ -1701,15 +1694,15 @@ void update_particles_i(pixel *vid, int start, int inc)
}
else
{
- if((t==PT_BIZR||t==PT_BIZRG||t==PT_BIZRS)&&pt>=pstates[t].gtemp)
- {
- t = parts[i].type = pstates[t].gas;
- }
- else{
- t = parts[i].type = pstates[t].gas;
- pv[y/CELL][x/CELL] += 0.50f;
- }
-
+ if((t==PT_BIZR||t==PT_BIZRG||t==PT_BIZRS)&&pt>=pstates[t].gtemp)
+ {
+ t = parts[i].type = pstates[t].gas;
+ }
+ else {
+ t = parts[i].type = pstates[t].gas;
+ pv[y/CELL][x/CELL] += 0.50f;
+ }
+
if(t==PT_FIRE)
parts[i].life = rand()%50+120;
if(t==PT_HFLM)
@@ -1820,13 +1813,13 @@ void update_particles_i(pixel *vid, int start, int inc)
}
else if(t==PT_ICEI || t==PT_SNOW)
{
- if(parts[i].ctype==PT_FRZW)
- {
- parts[i].temp -= 1.0f;
- if(parts[i].temp<0)
- parts[i].temp = 0;
-
- }
+ if(parts[i].ctype==PT_FRZW)
+ {
+ parts[i].temp -= 1.0f;
+ if(parts[i].temp<0)
+ parts[i].temp = 0;
+
+ }
for(nx=-2; nx<3; nx++)
for(ny=-2; ny<3; ny++)
if(x+nx>=0 && y+ny>0 &&
@@ -1978,60 +1971,60 @@ void update_particles_i(pixel *vid, int start, int inc)
}
}
}
- else if(t==PT_ARAY && parts[i].life==0){
- for(nx=-1; nx<2; nx++){
- for(ny=-1; ny<2; ny++){
- if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny)){
- r = pmap[y+ny][x+nx];
+ else if(t==PT_ARAY && parts[i].life==0) {
+ for(nx=-1; nx<2; nx++) {
+ for(ny=-1; ny<2; ny++) {
+ if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny)) {
+ r = pmap[y+ny][x+nx];
if((r>>8)>=NPART || !r)
continue;
- if((r&0xFF)==PT_SPRK){
- int destroy = (parts[r>>8].ctype==PT_PSCN)?1:0;
- for (docontinue = 1, nxx = 0, nyy = 0, nxi = nx*-1, nyi = ny*-1; docontinue; nyy+=nyi, nxx+=nxi) {
- if(!(x+nxi+nxx<XRES && y+nyi+nyy<YRES && x+nxi+nxx >= 0 && y+nyi+nyy >= 0)){
- break;
- }
- r = pmap[y+nyi+nyy][x+nxi+nxx];
- if(!((r>>8)>=NPART)) {
- if(!r){
- int nr = create_part(-1, x+nxi+nxx, y+nyi+nyy, PT_BRAY);
- if(nr!=-1&&destroy){
- parts[nr].tmp = 2;
- parts[nr].life = 2;
- }
- } else if(!destroy) {
- if(parts[r>>8].type==PT_BRAY&&parts[r>>8].tmp==0){
- if(nyy!=0 || nxx!=0){
- parts[r>>8].type = PT_BRAY;
- parts[r>>8].life = 1020;
- parts[r>>8].tmp = 1;
- }
- docontinue = 0;
- } else if(parts[r>>8].type==PT_BRAY&&parts[r>>8].tmp==1){
- parts[r>>8].life = 1020;
- //docontinue = 1;
- } else if(parts[r>>8].type!=PT_INWR && parts[r>>8].type!=PT_ARAY) {
- if(nyy!=0 || nxx!=0){
- create_part(-1, x+nxi+nxx, y+nyi+nyy, PT_SPRK);
- }
- docontinue = 0;
- }
- } else if(destroy) {
- if(parts[r>>8].type==PT_BRAY){
- parts[r>>8].life = 1;
- docontinue = 1;
- } else {
- docontinue = 0;
- }
- }
- }
- }
- }
- //parts[i].life = 4;
- }
- }
- }
- }
+ if((r&0xFF)==PT_SPRK) {
+ int destroy = (parts[r>>8].ctype==PT_PSCN)?1:0;
+ for (docontinue = 1, nxx = 0, nyy = 0, nxi = nx*-1, nyi = ny*-1; docontinue; nyy+=nyi, nxx+=nxi) {
+ if(!(x+nxi+nxx<XRES && y+nyi+nyy<YRES && x+nxi+nxx >= 0 && y+nyi+nyy >= 0)) {
+ break;
+ }
+ r = pmap[y+nyi+nyy][x+nxi+nxx];
+ if(!((r>>8)>=NPART)) {
+ if(!r) {
+ int nr = create_part(-1, x+nxi+nxx, y+nyi+nyy, PT_BRAY);
+ if(nr!=-1&&destroy) {
+ parts[nr].tmp = 2;
+ parts[nr].life = 2;
+ }
+ } else if(!destroy) {
+ if(parts[r>>8].type==PT_BRAY&&parts[r>>8].tmp==0) {
+ if(nyy!=0 || nxx!=0) {
+ parts[r>>8].type = PT_BRAY;
+ parts[r>>8].life = 1020;
+ parts[r>>8].tmp = 1;
+ }
+ docontinue = 0;
+ } else if(parts[r>>8].type==PT_BRAY&&parts[r>>8].tmp==1) {
+ parts[r>>8].life = 1020;
+ //docontinue = 1;
+ } else if(parts[r>>8].type!=PT_INWR && parts[r>>8].type!=PT_ARAY) {
+ if(nyy!=0 || nxx!=0) {
+ create_part(-1, x+nxi+nxx, y+nyi+nyy, PT_SPRK);
+ }
+ docontinue = 0;
+ }
+ } else if(destroy) {
+ if(parts[r>>8].type==PT_BRAY) {
+ parts[r>>8].life = 1;
+ docontinue = 1;
+ } else {
+ docontinue = 0;
+ }
+ }
+ }
+ }
+ }
+ //parts[i].life = 4;
+ }
+ }
+ }
+ }
else if(t==PT_FUSE)
{
if(parts[i].life<=0) {
@@ -2138,70 +2131,70 @@ void update_particles_i(pixel *vid, int start, int inc)
{
t = parts[i].type = PT_PLNT;
parts[r>>8].type = PT_PLNT;
- parts[r>>8].life = 0;
+ parts[r>>8].life = 0;
}
else if((r&0xFF)==PT_LAVA && 1>(rand()%250))
{
parts[i].life = 4;
t = parts[i].type = PT_FIRE;
}
- else if((r&0xFF)==PT_SMKE && (1>rand()%250))
- {
- parts[r>>8].type = PT_NONE;
- parts[i].life = rand()%60 + 60;
- }
- else if((r&0xFF)==PT_WOOD && (1>rand()%20) && abs(nx+ny)<=2 && VINE_MODE)
- {
- int nnx = rand()%3 -1;
- int nny = rand()%3 -1;
- if(x+nx+nnx>=0 && y+ny+nny>0 &&
- x+nx+nnx<XRES && y+ny+nny<YRES && (nnx || nny))
- {
- if((pmap[y+ny+nny][x+nx+nnx]>>8)>=NPART||pmap[y+ny+nny][x+nx+nnx])
- continue;
- if(create_part(-1,x+nx+nnx,y+ny+nny,PT_VINE))
- parts[pmap[y+ny+nny][x+nx+nnx]>>8].temp = parts[i].temp;
- }
- }
+ else if((r&0xFF)==PT_SMKE && (1>rand()%250))
+ {
+ parts[r>>8].type = PT_NONE;
+ parts[i].life = rand()%60 + 60;
+ }
+ else if((r&0xFF)==PT_WOOD && (1>rand()%20) && abs(nx+ny)<=2 && VINE_MODE)
+ {
+ int nnx = rand()%3 -1;
+ int nny = rand()%3 -1;
+ if(x+nx+nnx>=0 && y+ny+nny>0 &&
+ x+nx+nnx<XRES && y+ny+nny<YRES && (nnx || nny))
+ {
+ if((pmap[y+ny+nny][x+nx+nnx]>>8)>=NPART||pmap[y+ny+nny][x+nx+nnx])
+ continue;
+ if(create_part(-1,x+nx+nnx,y+ny+nny,PT_VINE))
+ parts[pmap[y+ny+nny][x+nx+nnx]>>8].temp = parts[i].temp;
+ }
+ }
//if(t==PT_SNOW && (r&0xFF)==PT_WATR && 15>(rand()%1000))
//t = parts[i].type = PT_WATR;
}
- if(parts[i].life==2)
- {
- for(nx=-1; nx<2; nx++)
- for(ny=-1; ny<2; ny++)
- if(x+nx>=0 && y+ny>0 &&
- x+nx<XRES && y+ny<YRES && (nx || ny))
- {
- r = pmap[y+ny][x+nx];
- if((r>>8)>=NPART)
- continue;
- if(!r)
- create_part(-1,x+nx,y+ny,PT_O2);
- }
- parts[i].life = 0;
- }
+ if(parts[i].life==2)
+ {
+ for(nx=-1; nx<2; nx++)
+ for(ny=-1; ny<2; ny++)
+ if(x+nx>=0 && y+ny>0 &&
+ x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART)
+ continue;
+ if(!r)
+ create_part(-1,x+nx,y+ny,PT_O2);
+ }
+ parts[i].life = 0;
+ }
+ }
+ else if(t==PT_VINE)
+ {
+ nx=(rand()%3)-1;
+ ny=(rand()%3)-1;
+ if(x+nx>=0 && y+ny>0 &&
+ x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART)
+ continue;
+ if(1>rand()%15)
+ parts[i].type=PT_PLNT;
+ else if(!r)
+ {
+ create_part(-1,x+nx,y+ny,PT_VINE);
+ parts[pmap[y+ny][x+nx]>>8].temp = parts[i].temp;
+ parts[i].type=PT_PLNT;
+ }
+ }
}
- else if(t==PT_VINE)
- {
- nx=(rand()%3)-1;
- ny=(rand()%3)-1;
- if(x+nx>=0 && y+ny>0 &&
- x+nx<XRES && y+ny<YRES && (nx || ny))
- {
- r = pmap[y+ny][x+nx];
- if((r>>8)>=NPART)
- continue;
- if(1>rand()%15)
- parts[i].type=PT_PLNT;
- else if(!r)
- {
- create_part(-1,x+nx,y+ny,PT_VINE);
- parts[pmap[y+ny][x+nx]>>8].temp = parts[i].temp;
- parts[i].type=PT_PLNT;
- }
- }
- }
else if(t==PT_THRM)
{
for(nx=-2; nx<3; nx++)
@@ -2262,10 +2255,10 @@ void update_particles_i(pixel *vid, int start, int inc)
parts[i].life = 4;
t = parts[i].type = PT_FIRE;
}
- if(((r&0xFF)==PT_CNCT&&t==PT_WATR) && 1>(rand()%500))
+ if(((r&0xFF)==PT_CNCT&&t==PT_WATR) && 1>(rand()%500))
{
t = parts[i].type = PT_PSTE;
- parts[r>>8].type = PT_NONE;
+ parts[r>>8].type = PT_NONE;
}
}
}
@@ -2288,8 +2281,8 @@ void update_particles_i(pixel *vid, int start, int inc)
{
parts[r>>8].type = PT_NONE;
}
- if((r&0xFF)==PT_PLNT&&5>(rand()%1000))
- parts[r>>8].type = PT_NONE;
+ if((r&0xFF)==PT_PLNT&&5>(rand()%1000))
+ parts[r>>8].type = PT_NONE;
if(((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && pt>12.0f && 1>(rand()%500))
{
parts[i].life = 4;
@@ -2364,11 +2357,11 @@ void update_particles_i(pixel *vid, int start, int inc)
}
else if(((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && ptypes[parts[r>>8].type].hardness>(rand()%1000))&&parts[i].life>=50)
{
- if(parts_avg(i, r>>8,PT_GLAS)!= PT_GLAS)
- {
- parts[i].life--;
- parts[r>>8].type = PT_NONE;
- }
+ if(parts_avg(i, r>>8,PT_GLAS)!= PT_GLAS)
+ {
+ parts[i].life--;
+ parts[r>>8].type = PT_NONE;
+ }
}
else if (parts[i].life==50)
{
@@ -2399,11 +2392,11 @@ void update_particles_i(pixel *vid, int start, int inc)
if(33>rand()%100)
{
create_part(r>>8, x+nx, y+ny, rand()%3 ? PT_LAVA : PT_URAN);
- parts[r>>8].temp = MAX_TEMP;
- if(parts[r>>8].type==PT_LAVA){
- parts[r>>8].tmp = 100;
- parts[r>>8].ctype = PT_PLUT;
- }
+ parts[r>>8].temp = MAX_TEMP;
+ if(parts[r>>8].type==PT_LAVA) {
+ parts[r>>8].tmp = 100;
+ parts[r>>8].ctype = PT_PLUT;
+ }
}
else
{
@@ -2414,22 +2407,22 @@ void update_particles_i(pixel *vid, int start, int inc)
pv[y/CELL][x/CELL] += 10.0f * CFDS; //Used to be 2, some people said nukes weren't powerful enough
fe ++;
}
- if((r&0xFF)==PT_DEUT && (rt+1)>(rand()%1000))
- {
-
- create_part(r>>8, x+nx, y+ny, PT_NEUT);
- parts[r>>8].vx = 0.25f*parts[r>>8].vx + parts[i].vx;
- parts[r>>8].vy = 0.25f*parts[r>>8].vy + parts[i].vy;
- if(parts[r>>8].life>0)
- {
- parts[r>>8].life --;
- parts[r>>8].temp += (parts[r>>8].life*17);
- pv[y/CELL][x/CELL] += 6.0f * CFDS;
-
- }
- else
- parts[r>>8].type = PT_NONE;
- }
+ if((r&0xFF)==PT_DEUT && (rt+1)>(rand()%1000))
+ {
+
+ create_part(r>>8, x+nx, y+ny, PT_NEUT);
+ parts[r>>8].vx = 0.25f*parts[r>>8].vx + parts[i].vx;
+ parts[r>>8].vy = 0.25f*parts[r>>8].vy + parts[i].vy;
+ if(parts[r>>8].life>0)
+ {
+ parts[r>>8].life --;
+ parts[r>>8].temp += (parts[r>>8].life*17);
+ pv[y/CELL][x/CELL] += 6.0f * CFDS;
+
+ }
+ else
+ parts[r>>8].type = PT_NONE;
+ }
if((r&0xFF)==PT_GUNP && 15>(rand()%1000))
parts[r>>8].type = PT_DUST;
if((r&0xFF)==PT_DYST && 15>(rand()%1000))
@@ -2453,15 +2446,15 @@ void update_particles_i(pixel *vid, int start, int inc)
parts[r>>8].type = PT_GAS;
if((r&0xFF)==PT_COAL && 5>(rand()%100))
parts[r>>8].type = PT_WOOD;
- if((r&0xFF)==PT_DUST && 5>(rand()%100))
+ if((r&0xFF)==PT_DUST && 5>(rand()%100))
parts[r>>8].type = PT_FWRK;
- if((r&0xFF)==PT_FWRK && 5>(rand()%100))
+ if((r&0xFF)==PT_FWRK && 5>(rand()%100))
parts[r>>8].ctype = PT_DUST;
- if((r&0xFF)==PT_ACID && 5>(rand()%100))
- {
+ if((r&0xFF)==PT_ACID && 5>(rand()%100))
+ {
parts[r>>8].type = PT_ISOZ;
- parts[r>>8].life = 0;
- }
+ parts[r>>8].life = 0;
+ }
/*if(parts[r>>8].type>1 && parts[r>>8].type!=PT_NEUT && parts[r>>8].type-1!=PT_NEUT && parts[r>>8].type-1!=PT_STKM &&
(ptypes[parts[r>>8].type-1].menusection==SC_LIQUID||
ptypes[parts[r>>8].type-1].menusection==SC_EXPLOSIVE||
@@ -2487,7 +2480,7 @@ void update_particles_i(pixel *vid, int start, int inc)
parts[i].vy *= 0.995;
}
}
- for(nx=-1; nx<2; nx++)
+ for(nx=-1; nx<2; nx++)
for(ny=-1; ny<2; ny++)
if(x+nx>=0 && y+ny>0 &&
x+nx<XRES && y+ny<YRES && (nx || ny))
@@ -2495,165 +2488,165 @@ void update_particles_i(pixel *vid, int start, int inc)
r = pmap[y+ny][x+nx];
if((r>>8)>=NPART || !r)
continue;
- if((r&0xFF)==PT_ISOZ && 5>(rand()%2000))
- {
- parts[i].vx *= 0.90;
+ if((r&0xFF)==PT_ISOZ && 5>(rand()%2000))
+ {
+ parts[i].vx *= 0.90;
parts[i].vy *= 0.90;
parts[r>>8].type = PT_PHOT;
- rrr = (rand()%360)*3.14159f/180.0f;
- rr = (rand()%128+128)/127.0f;
- parts[r>>8].life = 680;
- parts[r>>8].ctype = 0x3FFFFFFF;
- parts[r>>8].vx = rr*cosf(rrr);
- parts[r>>8].vy = rr*sinf(rrr);
- pv[y/CELL][x/CELL] -= 15.0f * CFDS;
- }
- if((r&0xFF)==PT_ISZS && 5>(rand()%2000))
- {
- parts[i].vx *= 0.90;
+ rrr = (rand()%360)*3.14159f/180.0f;
+ rr = (rand()%128+128)/127.0f;
+ parts[r>>8].life = 680;
+ parts[r>>8].ctype = 0x3FFFFFFF;
+ parts[r>>8].vx = rr*cosf(rrr);
+ parts[r>>8].vy = rr*sinf(rrr);
+ pv[y/CELL][x/CELL] -= 15.0f * CFDS;
+ }
+ if((r&0xFF)==PT_ISZS && 5>(rand()%2000))
+ {
+ parts[i].vx *= 0.90;
parts[i].vy *= 0.90;
parts[r>>8].type = PT_PHOT;
- rr = (rand()%228+128)/127.0f;
- rrr = (rand()%360)*3.14159f/180.0f;
- parts[r>>8].life = 680;
- parts[r>>8].ctype = 0x3FFFFFFF;
- parts[r>>8].vx = rr*cosf(rrr);
- parts[r>>8].vy = rr*sinf(rrr);
- pv[y/CELL][x/CELL] -= 15.0f * CFDS;
- }
- }
+ rr = (rand()%228+128)/127.0f;
+ rrr = (rand()%360)*3.14159f/180.0f;
+ parts[r>>8].life = 680;
+ parts[r>>8].ctype = 0x3FFFFFFF;
+ parts[r>>8].vx = rr*cosf(rrr);
+ parts[r>>8].vy = rr*sinf(rrr);
+ pv[y/CELL][x/CELL] -= 15.0f * CFDS;
+ }
+ }
+ }
+ else if(t==PT_GLOW)
+ {
+ for(nx=-1; nx<2; nx++)
+ for(ny=-1; ny<2; ny++)
+ if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART || !r)
+ continue;
+ if(parts[r>>8].type==PT_WATR&&5>(rand()%2000))
+ {
+ t = parts[i].type = PT_NONE;
+ parts[r>>8].type = PT_DEUT;
+ parts[r>>8].life = 10;
+ }
+ }
}
- else if(t==PT_GLOW)
- {
- for(nx=-1; nx<2; nx++)
- for(ny=-1; ny<2; ny++)
- if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
- {
- r = pmap[y+ny][x+nx];
- if((r>>8)>=NPART || !r)
- continue;
- if(parts[r>>8].type==PT_WATR&&5>(rand()%2000))
- {
- t = parts[i].type = PT_NONE;
- parts[r>>8].type = PT_DEUT;
- parts[r>>8].life = 10;
- }
- }
- }
else if(t==PT_MORT) {
create_part(-1, x, y-1, PT_SMKE);
}
- else if(t>77&&t<77+NGOL)
- {
- if(parts[i].temp>0)
- parts[i].temp -= 50.0f;
- ISGOL=1;
- }
- else if(t==PT_LOVE)
- ISLOVE=1;
- else if(t==PT_LOLZ)
- ISLOLZ=1;
- else if(t==PT_GRAV)
- ISGRAV=1;
- else if(t==PT_SPNG)
- {
- if(pv[y/CELL][x/CELL]<=3&&pv[y/CELL][x/CELL]>=-3)
- {
- for(nx=-1; nx<2; nx++)
- for(ny=-1; ny<2; ny++)
- if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
- {
- r = pmap[y+ny][x+nx];
- if((r>>8)>=NPART || !r || parts[i].temp>374.0f)
- continue;
- if(parts[r>>8].type==PT_WATR&&33>=rand()/(RAND_MAX/100)+1)
- {
- parts[i].life++;
- parts[r>>8].type=PT_NONE;
- }
- }
- }
- else
- for(nx=-1; nx<2; nx++)
- for(ny=-1; ny<2; ny++)
- if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
- {
- r = pmap[y+ny][x+nx];
- if((r>>8)>=NPART)
- continue;
- if((bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALLELEC||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_EWALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_DESTROYALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALL||
- bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWAIR||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWSOLID||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWGAS))
- continue;
- if((!r)&&parts[i].life>=1)//if nothing then create water
- {
- create_part(-1,x+nx,y+ny,PT_WATR);
- parts[i].life--;
- }
- }
- for( trade = 0; trade<9;trade ++)
- {
- nx = rand()%5-2;
- ny = rand()%5-2;
- if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
- {
- r = pmap[y+ny][x+nx];
- if((r>>8)>=NPART || !r)
- continue;
- if(parts[r>>8].type==t&&(parts[i].life>parts[r>>8].life)&&parts[i].life>0)//diffusion
- {
- int temp = parts[i].life - parts[r>>8].life;
- if(temp ==1)
- {
- parts[r>>8].life ++;
- parts[i].life --;
- trade = 9;
- }
- else if(temp>0)
- {
- parts[r>>8].life += temp/2;
- parts[i].life -= temp/2;
- trade = 9;
- }
- }
- }
- }
- for(nx=-1; nx<2; nx++)
- for(ny=-1; ny<2; ny++)
- if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
- {
- r = pmap[y+ny][x+nx];
- if((r>>8)>=NPART || !r)
- continue;
- if(parts[r>>8].type==PT_FIRE&&parts[i].life>0)
- {
- if(parts[i].life<=2)
- parts[i].life --;
- parts[i].life -= parts[i].life/3;
- }
- }
- if(parts[i].temp>=374)
- for(nx=-1; nx<2; nx++)
- for(ny=-1; ny<2; ny++)
- if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
- {
- r = pmap[y+ny][x+nx];
- if((r>>8)>=NPART)
- continue;
- if((bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALLELEC||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWLIQUID||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_DESTROYALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWSOLID))
- continue;
- if((!r)&&parts[i].life>=1)//if nothing then create steam
- {
- create_part(-1,x+nx,y+ny,PT_WTRV);
- parts[i].life--;
- parts[i].temp -= 40.0f;
- }
- }
- }
- else if(t==PT_FOG)
- {
- if(parts[i].temp>=373.15)
- t = parts[i].type = PT_WTRV;
- for(nx=-1; nx<2; nx++)
+ else if(t>77&&t<77+NGOL)
+ {
+ if(parts[i].temp>0)
+ parts[i].temp -= 50.0f;
+ ISGOL=1;
+ }
+ else if(t==PT_LOVE)
+ ISLOVE=1;
+ else if(t==PT_LOLZ)
+ ISLOLZ=1;
+ else if(t==PT_GRAV)
+ ISGRAV=1;
+ else if(t==PT_SPNG)
+ {
+ if(pv[y/CELL][x/CELL]<=3&&pv[y/CELL][x/CELL]>=-3)
+ {
+ for(nx=-1; nx<2; nx++)
+ for(ny=-1; ny<2; ny++)
+ if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART || !r || parts[i].temp>374.0f)
+ continue;
+ if(parts[r>>8].type==PT_WATR&&33>=rand()/(RAND_MAX/100)+1)
+ {
+ parts[i].life++;
+ parts[r>>8].type=PT_NONE;
+ }
+ }
+ }
+ else
+ for(nx=-1; nx<2; nx++)
+ for(ny=-1; ny<2; ny++)
+ if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART)
+ continue;
+ if((bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALLELEC||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_EWALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_DESTROYALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALL||
+ bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWAIR||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWSOLID||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWGAS))
+ continue;
+ if((!r)&&parts[i].life>=1)//if nothing then create water
+ {
+ create_part(-1,x+nx,y+ny,PT_WATR);
+ parts[i].life--;
+ }
+ }
+ for( trade = 0; trade<9; trade ++)
+ {
+ nx = rand()%5-2;
+ ny = rand()%5-2;
+ if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART || !r)
+ continue;
+ if(parts[r>>8].type==t&&(parts[i].life>parts[r>>8].life)&&parts[i].life>0)//diffusion
+ {
+ int temp = parts[i].life - parts[r>>8].life;
+ if(temp ==1)
+ {
+ parts[r>>8].life ++;
+ parts[i].life --;
+ trade = 9;
+ }
+ else if(temp>0)
+ {
+ parts[r>>8].life += temp/2;
+ parts[i].life -= temp/2;
+ trade = 9;
+ }
+ }
+ }
+ }
+ for(nx=-1; nx<2; nx++)
+ for(ny=-1; ny<2; ny++)
+ if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART || !r)
+ continue;
+ if(parts[r>>8].type==PT_FIRE&&parts[i].life>0)
+ {
+ if(parts[i].life<=2)
+ parts[i].life --;
+ parts[i].life -= parts[i].life/3;
+ }
+ }
+ if(parts[i].temp>=374)
+ for(nx=-1; nx<2; nx++)
+ for(ny=-1; ny<2; ny++)
+ if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART)
+ continue;
+ if((bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALLELEC||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWLIQUID||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_DESTROYALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWSOLID))
+ continue;
+ if((!r)&&parts[i].life>=1)//if nothing then create steam
+ {
+ create_part(-1,x+nx,y+ny,PT_WTRV);
+ parts[i].life--;
+ parts[i].temp -= 40.0f;
+ }
+ }
+ }
+ else if(t==PT_FOG)
+ {
+ if(parts[i].temp>=373.15)
+ t = parts[i].type = PT_WTRV;
+ for(nx=-1; nx<2; nx++)
for(ny=-1; ny<2; ny++)
if(x+nx>=0 && y+ny>0 &&
x+nx<XRES && y+ny<YRES && (nx || ny))
@@ -2661,21 +2654,21 @@ void update_particles_i(pixel *vid, int start, int inc)
r = pmap[y+ny][x+nx];
if((r>>8)>=NPART || !r)
continue;
- if(pstates[parts[r>>8].type].state==ST_SOLID&&5>=rand()%50&&parts[i].life==0&&!(parts[r>>8].type==PT_CLNE||parts[r>>8].type==PT_PCLN))
- {
- t = parts[i].type = PT_RIME;
- }
- if(parts[r>>8].type==PT_SPRK)
+ if(pstates[parts[r>>8].type].state==ST_SOLID&&5>=rand()%50&&parts[i].life==0&&!(parts[r>>8].type==PT_CLNE||parts[r>>8].type==PT_PCLN))
+ {
+ t = parts[i].type = PT_RIME;
+ }
+ if(parts[r>>8].type==PT_SPRK)
{
- parts[i].life += rand()%20;
- }
- }
- }
- else if(t==PT_RIME)
- {
- parts[i].vx = 0;
- parts[i].vy = 0;
- for(nx=-1; nx<2; nx++)
+ parts[i].life += rand()%20;
+ }
+ }
+ }
+ else if(t==PT_RIME)
+ {
+ parts[i].vx = 0;
+ parts[i].vy = 0;
+ for(nx=-1; nx<2; nx++)
for(ny=-1; ny<2; ny++)
if(x+nx>=0 && y+ny>0 &&
x+nx<XRES && y+ny<YRES && (nx || ny))
@@ -2686,160 +2679,160 @@ void update_particles_i(pixel *vid, int start, int inc)
rt = parts[r>>8].type;
if(rt==PT_SPRK)
{
- t = parts[i].type = PT_FOG;
- parts[i].life = rand()%50 + 60;
- }
- else if(rt==PT_FOG&&parts[r>>8].life>0)
- {
- t = parts[i].type = PT_FOG;
- parts[i].life = parts[r>>8].life;
- }
- }
- }
- else if(t==PT_DEUT)
- {
- int maxlife = ((10000/(parts[i].temp + 1))-1);
- if((10000%((int)parts[i].temp+1))>rand()%((int)parts[i].temp+1))
- maxlife ++;
- if(parts[i].life < maxlife)
- {
- for(nx=-1; nx<2; nx++)
- for(ny=-1; ny<2; ny++)
- if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
- {
- r = pmap[y+ny][x+nx];
- if((r>>8)>=NPART || !r || (parts[i].life >=maxlife))
- continue;
- if(parts[r>>8].type==PT_DEUT&&33>=rand()/(RAND_MAX/100)+1)
- {
- if((parts[i].life + parts[r>>8].life + 1) <= maxlife)
- {
- parts[i].life += parts[r>>8].life + 1;
- parts[r>>8].type=PT_NONE;
- }
- }
- }
- }
- else
- for(nx=-1; nx<2; nx++)
- for(ny=-1; ny<2; ny++)
- if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
- {
- r = pmap[y+ny][x+nx];
- if((r>>8)>=NPART || (parts[i].life<=maxlife))
- continue;
- if((bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALLELEC||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_EWALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_DESTROYALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALL||
- bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWAIR||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWSOLID||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWGAS))
- continue;
- if((!r)&&parts[i].life>=1)//if nothing then create deut
- {
- create_part(-1,x+nx,y+ny,PT_DEUT);
- parts[i].life--;
- parts[pmap[y+ny][x+nx]>>8].temp = parts[i].temp;
- parts[pmap[y+ny][x+nx]>>8].life = 0;
- }
- }
- for( trade = 0; trade<4;trade ++)
- {
- nx = rand()%5-2;
- ny = rand()%5-2;
- if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
- {
- r = pmap[y+ny][x+nx];
- if((r>>8)>=NPART || !r)
- continue;
- if(parts[r>>8].type==t&&(parts[i].life>parts[r>>8].life)&&parts[i].life>0)//diffusion
- {
- int temp = parts[i].life - parts[r>>8].life;
- if(temp ==1)
- {
- parts[r>>8].life ++;
- parts[i].life --;
- }
- else if(temp>0)
- {
- parts[r>>8].life += temp/2;
- parts[i].life -= temp/2;
- }
- }
- }
- }
- }
- else if(t==PT_WARP)
- {
- for( trade = 0; trade<5;trade ++)
- {
- nx = rand()%3-1;
- ny = rand()%3-1;
- if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
- {
- r = pmap[y+ny][x+nx];
- if((r>>8)>=NPART || !r)
- continue;
- if(parts[r>>8].type!=PT_WARP&&parts[r>>8].type!=PT_STKM&&parts[r>>8].type!=PT_DMND&&parts[r>>8].type!=PT_CLNE&&parts[r>>8].type!=PT_BCLN&&parts[r>>8].type!=PT_PCLN&&(10>=rand()%200))
- {
- parts[i].x = parts[r>>8].x;
- parts[i].y = parts[r>>8].y;
- parts[r>>8].x = x;
- parts[r>>8].y = y;
- parts[i].life += 4;
- trade = 5;
- }
- }
- }
- }
- else if(t==PT_FWRK)
- {
- if((parts[i].temp>400&&(9+parts[i].temp/40)>rand()%100000&&parts[i].life==0&&!pmap[y-1][x])||parts[i].ctype==PT_DUST)
- {
- create_part(-1, x , y-1 , PT_FWRK);
- r = pmap[y-1][x];
- if(parts[r>>8].type==PT_FWRK)
- {
- parts[r>>8].vy = rand()%8-22;
- parts[r>>8].vx = rand()%20-rand()%20;
- parts[r>>8].life=rand()%15+25;
- t=parts[i].type=PT_NONE;
- }
- }
- if(parts[i].life>1)
- {
- if(parts[i].life>=45&&parts[i].type==PT_FWRK)
- parts[i].life=0;
- }
- if((parts[i].life<3&&parts[i].life>0)||parts[i].vy>6&&parts[i].life>0)
- {
- int q = (rand()%255+1);
- int w = (rand()%255+1);
- int e = (rand()%255+1);
- for(nx=-1; nx<2; nx++)
- for(ny=-2; ny<3; ny++)
- if(x+nx>=0 && y+ny>0 &&
- x+nx<XRES && y+ny<YRES)
- {
- if(5>=rand()%8)
- {
- if(!pmap[y+ny][x+nx])
- {
- create_part(-1, x+nx, y+ny , PT_DUST);
- pv[y/CELL][x/CELL] += 2.00f*CFDS;
- a= pmap[y+ny][x+nx];
- if(parts[a>>8].type==PT_DUST)
- {
- parts[a>>8].vy = -(rand()%10-1);
- parts[a>>8].vx = ((rand()%2)*2-1)*rand()%(5+5)+(parts[i].vx)*2 ;
- parts[a>>8].life= rand()%37+18;
- parts[a>>8].tmp=q;
- parts[a>>8].flags=w;
- parts[a>>8].ctype=e;
- parts[a>>8].temp= rand()%20+6000;
- }
- }
- }
- }
- t=parts[i].type=PT_NONE;
- }
- }
+ t = parts[i].type = PT_FOG;
+ parts[i].life = rand()%50 + 60;
+ }
+ else if(rt==PT_FOG&&parts[r>>8].life>0)
+ {
+ t = parts[i].type = PT_FOG;
+ parts[i].life = parts[r>>8].life;
+ }
+ }
+ }
+ else if(t==PT_DEUT)
+ {
+ int maxlife = ((10000/(parts[i].temp + 1))-1);
+ if((10000%((int)parts[i].temp+1))>rand()%((int)parts[i].temp+1))
+ maxlife ++;
+ if(parts[i].life < maxlife)
+ {
+ for(nx=-1; nx<2; nx++)
+ for(ny=-1; ny<2; ny++)
+ if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART || !r || (parts[i].life >=maxlife))
+ continue;
+ if(parts[r>>8].type==PT_DEUT&&33>=rand()/(RAND_MAX/100)+1)
+ {
+ if((parts[i].life + parts[r>>8].life + 1) <= maxlife)
+ {
+ parts[i].life += parts[r>>8].life + 1;
+ parts[r>>8].type=PT_NONE;
+ }
+ }
+ }
+ }
+ else
+ for(nx=-1; nx<2; nx++)
+ for(ny=-1; ny<2; ny++)
+ if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART || (parts[i].life<=maxlife))
+ continue;
+ if((bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALLELEC||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_EWALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_DESTROYALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALL||
+ bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWAIR||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWSOLID||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWGAS))
+ continue;
+ if((!r)&&parts[i].life>=1)//if nothing then create deut
+ {
+ create_part(-1,x+nx,y+ny,PT_DEUT);
+ parts[i].life--;
+ parts[pmap[y+ny][x+nx]>>8].temp = parts[i].temp;
+ parts[pmap[y+ny][x+nx]>>8].life = 0;
+ }
+ }
+ for( trade = 0; trade<4; trade ++)
+ {
+ nx = rand()%5-2;
+ ny = rand()%5-2;
+ if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART || !r)
+ continue;
+ if(parts[r>>8].type==t&&(parts[i].life>parts[r>>8].life)&&parts[i].life>0)//diffusion
+ {
+ int temp = parts[i].life - parts[r>>8].life;
+ if(temp ==1)
+ {
+ parts[r>>8].life ++;
+ parts[i].life --;
+ }
+ else if(temp>0)
+ {
+ parts[r>>8].life += temp/2;
+ parts[i].life -= temp/2;
+ }
+ }
+ }
+ }
+ }
+ else if(t==PT_WARP)
+ {
+ for( trade = 0; trade<5; trade ++)
+ {
+ nx = rand()%3-1;
+ ny = rand()%3-1;
+ if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART || !r)
+ continue;
+ if(parts[r>>8].type!=PT_WARP&&parts[r>>8].type!=PT_STKM&&parts[r>>8].type!=PT_DMND&&parts[r>>8].type!=PT_CLNE&&parts[r>>8].type!=PT_BCLN&&parts[r>>8].type!=PT_PCLN&&(10>=rand()%200))
+ {
+ parts[i].x = parts[r>>8].x;
+ parts[i].y = parts[r>>8].y;
+ parts[r>>8].x = x;
+ parts[r>>8].y = y;
+ parts[i].life += 4;
+ trade = 5;
+ }
+ }
+ }
+ }
+ else if(t==PT_FWRK)
+ {
+ if((parts[i].temp>400&&(9+parts[i].temp/40)>rand()%100000&&parts[i].life==0&&!pmap[y-1][x])||parts[i].ctype==PT_DUST)
+ {
+ create_part(-1, x , y-1 , PT_FWRK);
+ r = pmap[y-1][x];
+ if(parts[r>>8].type==PT_FWRK)
+ {
+ parts[r>>8].vy = rand()%8-22;
+ parts[r>>8].vx = rand()%20-rand()%20;
+ parts[r>>8].life=rand()%15+25;
+ t=parts[i].type=PT_NONE;
+ }
+ }
+ if(parts[i].life>1)
+ {
+ if(parts[i].life>=45&&parts[i].type==PT_FWRK)
+ parts[i].life=0;
+ }
+ if((parts[i].life<3&&parts[i].life>0)||parts[i].vy>6&&parts[i].life>0)
+ {
+ int q = (rand()%255+1);
+ int w = (rand()%255+1);
+ int e = (rand()%255+1);
+ for(nx=-1; nx<2; nx++)
+ for(ny=-2; ny<3; ny++)
+ if(x+nx>=0 && y+ny>0 &&
+ x+nx<XRES && y+ny<YRES)
+ {
+ if(5>=rand()%8)
+ {
+ if(!pmap[y+ny][x+nx])
+ {
+ create_part(-1, x+nx, y+ny , PT_DUST);
+ pv[y/CELL][x/CELL] += 2.00f*CFDS;
+ a= pmap[y+ny][x+nx];
+ if(parts[a>>8].type==PT_DUST)
+ {
+ parts[a>>8].vy = -(rand()%10-1);
+ parts[a>>8].vx = ((rand()%2)*2-1)*rand()%(5+5)+(parts[i].vx)*2 ;
+ parts[a>>8].life= rand()%37+18;
+ parts[a>>8].tmp=q;
+ parts[a>>8].flags=w;
+ parts[a>>8].ctype=e;
+ parts[a>>8].temp= rand()%20+6000;
+ }
+ }
+ }
+ }
+ t=parts[i].type=PT_NONE;
+ }
+ }
else if(t==PT_LCRY)
{
for(nx=-1; nx<2; nx++)
@@ -2875,127 +2868,127 @@ void update_particles_i(pixel *vid, int start, int inc)
}
}
}
- else if(t==PT_PIPE)
- {
- if(!parts[i].ctype && parts[i].life<=10)
- {
- if(parts[i].temp<272.15)
- {
- if(parts[i].temp>173.25&&parts[i].temp<273.15)
- {
- parts[i].ctype = 2;
- parts[i].life = 0;
- }
- if(parts[i].temp>73.25&&parts[i].temp<=173.15)
- {
- parts[i].ctype = 3;
- parts[i].life = 0;
- }
- if(parts[i].temp>=0&&parts[i].temp<=73.15)
- {
- parts[i].ctype = 4;
- parts[i].life = 0;
- }
- }
- else
- {
- for(nx=-2; nx<3; nx++)
- for(ny=-2; ny<3; ny++)
- if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
- {
- r = pmap[y+ny][x+nx];
- if((r>>8)>=NPART )
- continue;
- if(!r)
- create_part(-1,x+nx,y+ny,PT_BRCK);
- }
- if(parts[i].life==1)
- parts[i].ctype = 1;
- }
- }
- if(parts[i].ctype==1)
- {
- for(nx=-1; nx<2; nx++)
- for(ny=-1; ny<2; ny++)
- if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
- {
- r = pmap[y+ny][x+nx];
- if((r>>8)>=NPART)
- continue;
- if(!r&&!parts[i].life)
- parts[i].life=50;
- }
- if(parts[i].life==2)
- {
- parts[i].ctype = 2;
- parts[i].life = 6;
- }
- }
- if(parts[i].ctype>1)
- for( q = 0;q<3;q++)
- for( ctype = 2;ctype<5;ctype++)
- {
- if(parts[i].ctype==ctype)
- {
- if(parts[i].life==3)
- {
- for(nx=-1; nx<2; nx++)
- for(ny=-1; ny<2; ny++)
- if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
- {
- r = pmap[y+ny][x+nx];
- if((r>>8)>=NPART || !r)
- continue;
- if(parts[r>>8].type==PT_PIPE&&parts[r>>8].ctype==1)
- {
- parts[r>>8].ctype = (((ctype)%3)+2);//reverse
- parts[r>>8].life = 6;
- }
- }
- }
- else
- {
- nx = rand()%3-1;
- ny = rand()%3-1;
- if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
- {
- r = pmap[y+ny][x+nx];
- if((r>>8)>=NPART)
- continue;
- else if(!r&&parts[i].tmp!=0)
- {
- if(create_part(-1,x+nx,y+ny,parts[i].tmp))
- {
- parts[pmap[y+ny][x+nx]>>8].temp = parts[i].temp;//pipe saves temp and life now
- parts[pmap[y+ny][x+nx]>>8].life = parts[i].flags;
- }
- parts[i].tmp = 0;
- continue;
- }
- else if(!r)
- continue;
- else if(parts[i].tmp == 0 && (ptypes[parts[r>>8].type].falldown!= 0 || pstates[parts[r>>8].type].state == ST_GAS))
- {
- parts[i].tmp = parts[r>>8].type;
- parts[i].temp = parts[r>>8].temp;
- parts[i].flags = parts[r>>8].life;
- parts[r>>8].type = PT_NONE;
- }
- else if(parts[r>>8].type==PT_PIPE && parts[r>>8].ctype!=(((ctype)%3)+2) && parts[r>>8].tmp==0&&parts[i].tmp>0)
- {
- parts[r>>8].tmp = parts[i].tmp;
- parts[r>>8].temp = parts[i].temp;
- parts[r>>8].flags = parts[i].flags;
- parts[i].tmp = 0;
- }
- }
- }
- }
- }
- }
- else if(t==PT_FRZZ)
- {
- for(nx=-1; nx<2; nx++)
+ else if(t==PT_PIPE)
+ {
+ if(!parts[i].ctype && parts[i].life<=10)
+ {
+ if(parts[i].temp<272.15)
+ {
+ if(parts[i].temp>173.25&&parts[i].temp<273.15)
+ {
+ parts[i].ctype = 2;
+ parts[i].life = 0;
+ }
+ if(parts[i].temp>73.25&&parts[i].temp<=173.15)
+ {
+ parts[i].ctype = 3;
+ parts[i].life = 0;
+ }
+ if(parts[i].temp>=0&&parts[i].temp<=73.15)
+ {
+ parts[i].ctype = 4;
+ parts[i].life = 0;
+ }
+ }
+ else
+ {
+ for(nx=-2; nx<3; nx++)
+ for(ny=-2; ny<3; ny++)
+ if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART )
+ continue;
+ if(!r)
+ create_part(-1,x+nx,y+ny,PT_BRCK);
+ }
+ if(parts[i].life==1)
+ parts[i].ctype = 1;
+ }
+ }
+ if(parts[i].ctype==1)
+ {
+ for(nx=-1; nx<2; nx++)
+ for(ny=-1; ny<2; ny++)
+ if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART)
+ continue;
+ if(!r&&!parts[i].life)
+ parts[i].life=50;
+ }
+ if(parts[i].life==2)
+ {
+ parts[i].ctype = 2;
+ parts[i].life = 6;
+ }
+ }
+ if(parts[i].ctype>1)
+ for( q = 0; q<3; q++)
+ for( ctype = 2; ctype<5; ctype++)
+ {
+ if(parts[i].ctype==ctype)
+ {
+ if(parts[i].life==3)
+ {
+ for(nx=-1; nx<2; nx++)
+ for(ny=-1; ny<2; ny++)
+ if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART || !r)
+ continue;
+ if(parts[r>>8].type==PT_PIPE&&parts[r>>8].ctype==1)
+ {
+ parts[r>>8].ctype = (((ctype)%3)+2);//reverse
+ parts[r>>8].life = 6;
+ }
+ }
+ }
+ else
+ {
+ nx = rand()%3-1;
+ ny = rand()%3-1;
+ if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART)
+ continue;
+ else if(!r&&parts[i].tmp!=0)
+ {
+ if(create_part(-1,x+nx,y+ny,parts[i].tmp))
+ {
+ parts[pmap[y+ny][x+nx]>>8].temp = parts[i].temp;//pipe saves temp and life now
+ parts[pmap[y+ny][x+nx]>>8].life = parts[i].flags;
+ }
+ parts[i].tmp = 0;
+ continue;
+ }
+ else if(!r)
+ continue;
+ else if(parts[i].tmp == 0 && (ptypes[parts[r>>8].type].falldown!= 0 || pstates[parts[r>>8].type].state == ST_GAS))
+ {
+ parts[i].tmp = parts[r>>8].type;
+ parts[i].temp = parts[r>>8].temp;
+ parts[i].flags = parts[r>>8].life;
+ parts[r>>8].type = PT_NONE;
+ }
+ else if(parts[r>>8].type==PT_PIPE && parts[r>>8].ctype!=(((ctype)%3)+2) && parts[r>>8].tmp==0&&parts[i].tmp>0)
+ {
+ parts[r>>8].tmp = parts[i].tmp;
+ parts[r>>8].temp = parts[i].temp;
+ parts[r>>8].flags = parts[i].flags;
+ parts[i].tmp = 0;
+ }
+ }
+ }
+ }
+ }
+ }
+ else if(t==PT_FRZZ)
+ {
+ for(nx=-1; nx<2; nx++)
for(ny=-1; ny<2; ny++)
if(x+nx>=0 && y+ny>0 &&
x+nx<XRES && y+ny<YRES && (nx || ny))
@@ -3003,18 +2996,18 @@ void update_particles_i(pixel *vid, int start, int inc)
r = pmap[y+ny][x+nx];
if((r>>8)>=NPART || !r)
continue;
- if(parts[r>>8].type==PT_WATR&&5>rand()%100)
- {
- parts[r>>8].type=PT_FRZW;
- parts[r>>8].life = 100;
- t = parts[i].type = PT_NONE;
- }
-
- }
- }
- else if(t==PT_FRZW)
- {
- for(nx=-1; nx<2; nx++)
+ if(parts[r>>8].type==PT_WATR&&5>rand()%100)
+ {
+ parts[r>>8].type=PT_FRZW;
+ parts[r>>8].life = 100;
+ t = parts[i].type = PT_NONE;
+ }
+
+ }
+ }
+ else if(t==PT_FRZW)
+ {
+ for(nx=-1; nx<2; nx++)
for(ny=-1; ny<2; ny++)
if(x+nx>=0 && y+ny>0 &&
x+nx<XRES && y+ny<YRES && (nx || ny))
@@ -3022,31 +3015,31 @@ void update_particles_i(pixel *vid, int start, int inc)
r = pmap[y+ny][x+nx];
if((r>>8)>=NPART || !r)
continue;
- if(parts[r>>8].type==PT_WATR&&5>rand()%70)
- {
- parts[r>>8].type=PT_FRZW;
- }
- }
- if(parts[i].life==0&&13>rand()%2500)
- {
- t = parts[i].type=PT_ICEI;
- parts[i].ctype=PT_FRZW;
- parts[i].temp -= 200.0f;
- if(parts[i].temp<0)
- parts[i].temp = 0;
- }
- else if((100-(parts[i].life))>rand()%50000)
- {
- t = parts[i].type=PT_ICEI;
- parts[i].ctype=PT_FRZW;
- parts[i].temp -= 200.0f;
- if(parts[i].temp<0)
- parts[i].temp = 0;
- }
- }
- else if(t==PT_INST)
- {
- for(nx=-2; nx<3; nx++)
+ if(parts[r>>8].type==PT_WATR&&5>rand()%70)
+ {
+ parts[r>>8].type=PT_FRZW;
+ }
+ }
+ if(parts[i].life==0&&13>rand()%2500)
+ {
+ t = parts[i].type=PT_ICEI;
+ parts[i].ctype=PT_FRZW;
+ parts[i].temp -= 200.0f;
+ if(parts[i].temp<0)
+ parts[i].temp = 0;
+ }
+ else if((100-(parts[i].life))>rand()%50000)
+ {
+ t = parts[i].type=PT_ICEI;
+ parts[i].ctype=PT_FRZW;
+ parts[i].temp -= 200.0f;
+ if(parts[i].temp<0)
+ parts[i].temp = 0;
+ }
+ }
+ else if(t==PT_INST)
+ {
+ for(nx=-2; nx<3; nx++)
for(ny=-2; ny<3; ny++)
if(x+nx>=0 && y+ny>0 &&
x+nx<XRES && y+ny<YRES && (nx || ny) && abs(nx)+abs(ny)<4)
@@ -3054,101 +3047,101 @@ void update_particles_i(pixel *vid, int start, int inc)
r = pmap[y+ny][x+nx];
if((r>>8)>=NPART || !r)
continue;
- else if(parts[r>>8].type==PT_SPRK&&(parts[r>>8].ctype==PT_PSCN)&&(parts[r>>8].life>=3)&&parts[i].life%4==0)
- {
- flood_parts(x,y,PT_SPRK,PT_INST,-1);//add life
- parts[r>>8].type==parts[r>>8].ctype;
- }
- }
- }
- else if(t==PT_PRTI)
- {
- int temprange = 100;
- int count =0;
- for( temp = 0; temp < MAX_TEMP; temp += temprange)
- if(parts[i].temp-73.15>temp&&parts[i].temp-73.15 <temp+temprange)
- parts[i].tmp = temp/100;
- for(ny=-1; ny<2; ny++)
+ else if(parts[r>>8].type==PT_SPRK&&(parts[r>>8].ctype==PT_PSCN)&&(parts[r>>8].life>=3)&&parts[i].life%4==0)
+ {
+ flood_parts(x,y,PT_SPRK,PT_INST,-1);//add life
+ parts[r>>8].type==parts[r>>8].ctype;
+ }
+ }
+ }
+ else if(t==PT_PRTI)
+ {
+ int temprange = 100;
+ int count =0;
+ for( temp = 0; temp < MAX_TEMP; temp += temprange)
+ if(parts[i].temp-73.15>temp&&parts[i].temp-73.15 <temp+temprange)
+ parts[i].tmp = temp/100;
+ for(ny=-1; ny<2; ny++)
for(nx=-1; nx<2; nx++)
if(x+nx>=0 && y+ny>0 &&
x+nx<XRES && y+ny<YRES && (nx || ny))
{
- count ++;
+ count ++;
r = pmap[y+ny][x+nx];
if((r>>8)>=NPART || !r)
continue;
- if(parts[r>>8].type==PT_SPRK || (parts[r>>8].type!=PT_PRTI && parts[r>>8].type!=PT_PRTO && (ptypes[parts[r>>8].type].falldown!= 0 || pstates[parts[r>>8].type].state == ST_GAS)))
- for( nnx=0;nnx<8;nnx++)
- if(!portal[parts[i].tmp][count-1][nnx])
- {
- portal[parts[i].tmp][count-1][nnx] = parts[r>>8].type;
- portaltemp[parts[i].tmp][count-1][nnx] = parts[r>>8].temp;
- if(parts[r>>8].type==PT_SPRK)
- parts[r>>8].type = parts[r>>8].ctype;
- else
- parts[r>>8].type = PT_NONE;
- break;
- }
- }
- }
- else if(t==PT_PRTO)
- {
- int temprange = 100;
- int count = 0;
- for( temp = 0; temp < MAX_TEMP; temp += temprange)
- if(parts[i].temp-73.15>temp&&parts[i].temp-73.15 <temp+temprange)
- parts[i].tmp = temp/100;
- for(ny=1; ny>-2; ny--)
+ if(parts[r>>8].type==PT_SPRK || (parts[r>>8].type!=PT_PRTI && parts[r>>8].type!=PT_PRTO && (ptypes[parts[r>>8].type].falldown!= 0 || pstates[parts[r>>8].type].state == ST_GAS)))
+ for( nnx=0; nnx<8; nnx++)
+ if(!portal[parts[i].tmp][count-1][nnx])
+ {
+ portal[parts[i].tmp][count-1][nnx] = parts[r>>8].type;
+ portaltemp[parts[i].tmp][count-1][nnx] = parts[r>>8].temp;
+ if(parts[r>>8].type==PT_SPRK)
+ parts[r>>8].type = parts[r>>8].ctype;
+ else
+ parts[r>>8].type = PT_NONE;
+ break;
+ }
+ }
+ }
+ else if(t==PT_PRTO)
+ {
+ int temprange = 100;
+ int count = 0;
+ for( temp = 0; temp < MAX_TEMP; temp += temprange)
+ if(parts[i].temp-73.15>temp&&parts[i].temp-73.15 <temp+temprange)
+ parts[i].tmp = temp/100;
+ for(ny=1; ny>-2; ny--)
for(nx=1; nx>-2; nx--)
if(x+nx>=0 && y+ny>0 &&
x+nx<XRES && y+ny<YRES && (nx || ny))
{
- count ++;
+ count ++;
r = pmap[y+ny][x+nx];
if((r>>8)>=NPART || r)
continue;
- if(!r)
- {
- for( nnx =0 ;nnx<8;nnx++)
- {
- int randomness = count + rand()%3-1;
- if(randomness<1)
- randomness=1;
- if(randomness>8)
- randomness=8;
- if(portal[parts[i].tmp][randomness-1][nnx]==PT_SPRK)//todo. make it look better
- {
- create_part(-1,x+1,y,portal[parts[i].tmp][randomness-1][nnx]);
- create_part(-1,x+1,y+1,portal[parts[i].tmp][randomness-1][nnx]);
- create_part(-1,x+1,y-1,portal[parts[i].tmp][randomness-1][nnx]);
- create_part(-1,x,y-1,portal[parts[i].tmp][randomness-1][nnx]);
- create_part(-1,x,y+1,portal[parts[i].tmp][randomness-1][nnx]);
- create_part(-1,x-1,y+1,portal[parts[i].tmp][randomness-1][nnx]);
- create_part(-1,x-1,y,portal[parts[i].tmp][randomness-1][nnx]);
- create_part(-1,x-1,y-1,portal[parts[i].tmp][randomness-1][nnx]);
- portal[parts[i].tmp][randomness-1][nnx] = 0;
- portaltemp[parts[i].tmp][randomness-1][nnx] = 0;
- break;
- }
- else if(portal[parts[i].tmp][randomness-1][nnx])
- {
- create_part(-1,x+nx,y+ny,portal[parts[i].tmp][randomness-1][nnx]);
- parts[pmap[y+ny][x+nx]>>8].temp = portaltemp[parts[i].tmp][randomness-1][nnx];
- portal[parts[i].tmp][randomness-1][nnx] = 0;
- portaltemp[parts[i].tmp][randomness-1][nnx] = 0;
- break;
- }
- }
- }
- }
- }
- else if(t==PT_WIFI)
- {
- int temprange = 100;
- for( temp = 0; temp < MAX_TEMP; temp += temprange)
- if(parts[i].temp-73.15>temp&&parts[i].temp-73.15 <temp+temprange)
- parts[i].tmp = temp/100;
- for(ny=-1; ny<2; ny++)
+ if(!r)
+ {
+ for( nnx =0 ; nnx<8; nnx++)
+ {
+ int randomness = count + rand()%3-1;
+ if(randomness<1)
+ randomness=1;
+ if(randomness>8)
+ randomness=8;
+ if(portal[parts[i].tmp][randomness-1][nnx]==PT_SPRK)//todo. make it look better
+ {
+ create_part(-1,x+1,y,portal[parts[i].tmp][randomness-1][nnx]);
+ create_part(-1,x+1,y+1,portal[parts[i].tmp][randomness-1][nnx]);
+ create_part(-1,x+1,y-1,portal[parts[i].tmp][randomness-1][nnx]);
+ create_part(-1,x,y-1,portal[parts[i].tmp][randomness-1][nnx]);
+ create_part(-1,x,y+1,portal[parts[i].tmp][randomness-1][nnx]);
+ create_part(-1,x-1,y+1,portal[parts[i].tmp][randomness-1][nnx]);
+ create_part(-1,x-1,y,portal[parts[i].tmp][randomness-1][nnx]);
+ create_part(-1,x-1,y-1,portal[parts[i].tmp][randomness-1][nnx]);
+ portal[parts[i].tmp][randomness-1][nnx] = 0;
+ portaltemp[parts[i].tmp][randomness-1][nnx] = 0;
+ break;
+ }
+ else if(portal[parts[i].tmp][randomness-1][nnx])
+ {
+ create_part(-1,x+nx,y+ny,portal[parts[i].tmp][randomness-1][nnx]);
+ parts[pmap[y+ny][x+nx]>>8].temp = portaltemp[parts[i].tmp][randomness-1][nnx];
+ portal[parts[i].tmp][randomness-1][nnx] = 0;
+ portaltemp[parts[i].tmp][randomness-1][nnx] = 0;
+ break;
+ }
+ }
+ }
+ }
+ }
+ else if(t==PT_WIFI)
+ {
+ int temprange = 100;
+ for( temp = 0; temp < MAX_TEMP; temp += temprange)
+ if(parts[i].temp-73.15>temp&&parts[i].temp-73.15 <temp+temprange)
+ parts[i].tmp = temp/100;
+ for(ny=-1; ny<2; ny++)
for(nx=-1; nx<2; nx++)
if(x+nx>=0 && y+ny>0 &&
x+nx<XRES && y+ny<YRES && (nx || ny))
@@ -3156,27 +3149,27 @@ void update_particles_i(pixel *vid, int start, int inc)
r = pmap[y+ny][x+nx];
if((r>>8)>=NPART || !r)
continue;
- if(parts[r>>8].type==PT_NSCN&&parts[r>>8].life==0 && wireless[parts[i].tmp][0])
- {
- parts[r>>8].type = PT_SPRK;
- parts[r>>8].ctype = PT_NSCN;
- parts[r>>8].life = 4;
- }
- else if(parts[r>>8].type==PT_PSCN&&parts[r>>8].life==0 && wireless[parts[i].tmp][0])
- {
- parts[r>>8].type = PT_SPRK;
- parts[r>>8].ctype = PT_PSCN;
- parts[r>>8].life = 4;
- }
- else if(parts[r>>8].type==PT_SPRK && parts[r>>8].ctype!=PT_NSCN && parts[r>>8].life>=3 && !wireless[parts[i].tmp][0])
- {
- //parts[r>>8].type = parts[r>>8].ctype;
- wireless[parts[i].tmp][0] = 1;
- wireless[parts[i].tmp][1] = 1;
- ISWIRE = 1;
- }
- }
- }
+ if(parts[r>>8].type==PT_NSCN&&parts[r>>8].life==0 && wireless[parts[i].tmp][0])
+ {
+ parts[r>>8].type = PT_SPRK;
+ parts[r>>8].ctype = PT_NSCN;
+ parts[r>>8].life = 4;
+ }
+ else if(parts[r>>8].type==PT_PSCN&&parts[r>>8].life==0 && wireless[parts[i].tmp][0])
+ {
+ parts[r>>8].type = PT_SPRK;
+ parts[r>>8].ctype = PT_PSCN;
+ parts[r>>8].life = 4;
+ }
+ else if(parts[r>>8].type==PT_SPRK && parts[r>>8].ctype!=PT_NSCN && parts[r>>8].life>=3 && !wireless[parts[i].tmp][0])
+ {
+ //parts[r>>8].type = parts[r>>8].ctype;
+ wireless[parts[i].tmp][0] = 1;
+ wireless[parts[i].tmp][1] = 1;
+ ISWIRE = 1;
+ }
+ }
+ }
else if(t==PT_PCLN)
{
for(nx=-2; nx<3; nx++)
@@ -3247,7 +3240,7 @@ void update_particles_i(pixel *vid, int start, int inc)
}
}
}
- else if(t==PT_PUMP)
+ else if(t==PT_PUMP)
{
for(nx=-2; nx<3; nx++)
for(ny=-2; ny<3; ny++)
@@ -3282,9 +3275,9 @@ void update_particles_i(pixel *vid, int start, int inc)
}
}
}
- else if(t==PT_SHLD1)
- {
- for(nx=-1; nx<2; nx++)
+ else if(t==PT_SHLD1)
+ {
+ for(nx=-1; nx<2; nx++)
for(ny=-1; ny<2; ny++)
if(x+nx>=0 && y+ny>0 &&
x+nx<XRES && y+ny<YRES && (nx || ny))
@@ -3292,31 +3285,31 @@ void update_particles_i(pixel *vid, int start, int inc)
r = pmap[y+ny][x+nx];
if((r>>8)>=NPART || !r)
continue;
- else if(parts[r>>8].type==PT_SPRK&&parts[i].life==0)
- for( nnx=-1;nnx<2;nnx++)
- for( nny=-1;nny<2;nny++)
- {
- if(7>rand()%200&&parts[i].life==0)
- {
- t = parts[i].type = PT_SHLD2;
- parts[i].life = 7;
- }
- else if(!pmap[y+ny+nny][x+nx+nnx])
- {
- create_part(-1,x+nx+nnx,y+ny+nny,PT_SHLD1);
- //parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7;
- }
- }
- else if(parts[r>>8].type==PT_SHLD3&&4>rand()%10)
- {
- t = parts[i].type=PT_SHLD2;
- parts[i].life = 7;
- }
- }
- }
- else if(t==PT_SHLD2)
- {
- for(nx=-1; nx<2; nx++)
+ else if(parts[r>>8].type==PT_SPRK&&parts[i].life==0)
+ for( nnx=-1; nnx<2; nnx++)
+ for( nny=-1; nny<2; nny++)
+ {
+ if(7>rand()%200&&parts[i].life==0)
+ {
+ t = parts[i].type = PT_SHLD2;
+ parts[i].life = 7;
+ }
+ else if(!pmap[y+ny+nny][x+nx+nnx])
+ {
+ create_part(-1,x+nx+nnx,y+ny+nny,PT_SHLD1);
+ //parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7;
+ }
+ }
+ else if(parts[r>>8].type==PT_SHLD3&&4>rand()%10)
+ {
+ t = parts[i].type=PT_SHLD2;
+ parts[i].life = 7;
+ }
+ }
+ }
+ else if(t==PT_SHLD2)
+ {
+ for(nx=-1; nx<2; nx++)
for(ny=-1; ny<2; ny++)
if(x+nx>=0 && y+ny>0 &&
x+nx<XRES && y+ny<YRES && (nx || ny))
@@ -3324,35 +3317,35 @@ void update_particles_i(pixel *vid, int start, int inc)
r = pmap[y+ny][x+nx];
if((r>>8)>=NPART)
continue;
- if(!r && parts[i].life>0)
- create_part(-1,x+nx,y+ny,PT_SHLD1);
- if(!r)
- continue;
- else if(parts[r>>8].type==PT_SPRK&&parts[i].life==0)
- for( nnx=-1;nnx<2;nnx++)
- for( nny=-1;nny<2;nny++)
- {
- if(3>rand()%200&&parts[i].life==0)
- {
- t = parts[i].type = PT_SHLD3;
- parts[i].life = 7;
- }
- else if(!pmap[y+ny+nny][x+nx+nnx])
- {
- create_part(-1,x+nx+nnx,y+ny+nny,PT_SHLD1);
- parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7;
- }
- }
- else if(parts[r>>8].type==PT_SHLD4&&4>rand()%10)
- {
- t = parts[i].type=PT_SHLD3;
- parts[i].life = 7;
- }
- }
- }
- else if(t==PT_SHLD3)
- {
- for(nx=-1; nx<2; nx++)
+ if(!r && parts[i].life>0)
+ create_part(-1,x+nx,y+ny,PT_SHLD1);
+ if(!r)
+ continue;
+ else if(parts[r>>8].type==PT_SPRK&&parts[i].life==0)
+ for( nnx=-1; nnx<2; nnx++)
+ for( nny=-1; nny<2; nny++)
+ {
+ if(3>rand()%200&&parts[i].life==0)
+ {
+ t = parts[i].type = PT_SHLD3;
+ parts[i].life = 7;
+ }
+ else if(!pmap[y+ny+nny][x+nx+nnx])
+ {
+ create_part(-1,x+nx+nnx,y+ny+nny,PT_SHLD1);
+ parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7;
+ }
+ }
+ else if(parts[r>>8].type==PT_SHLD4&&4>rand()%10)
+ {
+ t = parts[i].type=PT_SHLD3;
+ parts[i].life = 7;
+ }
+ }
+ }
+ else if(t==PT_SHLD3)
+ {
+ for(nx=-1; nx<2; nx++)
for(ny=-1; ny<2; ny++)
if(x+nx>=0 && y+ny>0 &&
x+nx<XRES && y+ny<YRES && (nx || ny))
@@ -3360,43 +3353,43 @@ void update_particles_i(pixel *vid, int start, int inc)
r = pmap[y+ny][x+nx];
if((r>>8)>=NPART)
continue;
- if(!r)
- {
- if(1>rand()%2500)
- {
- create_part(-1,x+nx,y+ny,PT_SHLD1);
- parts[pmap[y+ny][x+nx]>>8].life=7;
- t = parts[i].type = PT_SHLD2;
- }
- else
- continue;
-
- }
- if(parts[r>>8].type==PT_SHLD1 && parts[i].life>3)
- {
- parts[r>>8].type = PT_SHLD2;
- parts[r>>8].life=7;
- }
- else if(parts[r>>8].type==PT_SPRK&&parts[i].life==0)
- for( nnx=-1;nnx<2;nnx++)
- for( nny=-1;nny<2;nny++)
- {
- if(2>rand()%3000&&parts[i].life==0)
- {
- t = parts[i].type = PT_SHLD4;
- parts[i].life = 7;
- }
- else if(!pmap[y+ny+nny][x+nx+nnx])
- {
- create_part(-1,x+nx+nnx,y+ny+nny,PT_SHLD1);
- parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7;
- }
- }
- }
- }
- else if(t==PT_SHLD4)
- {
- for(nx=-1; nx<2; nx++)
+ if(!r)
+ {
+ if(1>rand()%2500)
+ {
+ create_part(-1,x+nx,y+ny,PT_SHLD1);
+ parts[pmap[y+ny][x+nx]>>8].life=7;
+ t = parts[i].type = PT_SHLD2;
+ }
+ else
+ continue;
+
+ }
+ if(parts[r>>8].type==PT_SHLD1 && parts[i].life>3)
+ {
+ parts[r>>8].type = PT_SHLD2;
+ parts[r>>8].life=7;
+ }
+ else if(parts[r>>8].type==PT_SPRK&&parts[i].life==0)
+ for( nnx=-1; nnx<2; nnx++)
+ for( nny=-1; nny<2; nny++)
+ {
+ if(2>rand()%3000&&parts[i].life==0)
+ {
+ t = parts[i].type = PT_SHLD4;
+ parts[i].life = 7;
+ }
+ else if(!pmap[y+ny+nny][x+nx+nnx])
+ {
+ create_part(-1,x+nx+nnx,y+ny+nny,PT_SHLD1);
+ parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7;
+ }
+ }
+ }
+ }
+ else if(t==PT_SHLD4)
+ {
+ for(nx=-1; nx<2; nx++)
for(ny=-1; ny<2; ny++)
if(x+nx>=0 && y+ny>0 &&
x+nx<XRES && y+ny<YRES && (nx || ny))
@@ -3404,35 +3397,35 @@ void update_particles_i(pixel *vid, int start, int inc)
r = pmap[y+ny][x+nx];
if((r>>8)>=NPART)
continue;
- if(!r)
- {
- if(1>rand()%5500)
- {
- create_part(-1,x+nx,y+ny,PT_SHLD1);
- parts[pmap[y+ny][x+nx]>>8].life=7;
- t = parts[i].type = PT_SHLD2;
- }
- else
- continue;
-
- }
- if(parts[r>>8].type==PT_SHLD2 && parts[i].life>3)
- {
- parts[r>>8].type = PT_SHLD3;
- parts[r>>8].life = 7;
- }
- else if(parts[r>>8].type==PT_SPRK&&parts[i].life==0)
- for( nnx=-1;nnx<2;nnx++)
- for( nny=-1;nny<2;nny++)
- {
- if(!pmap[y+ny+nny][x+nx+nnx])
- {
- create_part(-1,x+nx+nnx,y+ny+nny,PT_SHLD1);
- parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7;
- }
- }
- }
- }
+ if(!r)
+ {
+ if(1>rand()%5500)
+ {
+ create_part(-1,x+nx,y+ny,PT_SHLD1);
+ parts[pmap[y+ny][x+nx]>>8].life=7;
+ t = parts[i].type = PT_SHLD2;
+ }
+ else
+ continue;
+
+ }
+ if(parts[r>>8].type==PT_SHLD2 && parts[i].life>3)
+ {
+ parts[r>>8].type = PT_SHLD3;
+ parts[r>>8].life = 7;
+ }
+ else if(parts[r>>8].type==PT_SPRK&&parts[i].life==0)
+ for( nnx=-1; nnx<2; nnx++)
+ for( nny=-1; nny<2; nny++)
+ {
+ if(!pmap[y+ny+nny][x+nx+nnx])
+ {
+ create_part(-1,x+nx+nnx,y+ny+nny,PT_SHLD1);
+ parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7;
+ }
+ }
+ }
+ }
else if(t==PT_AMTR)
{
for(nx=-1; nx<2; nx++)
@@ -3451,7 +3444,7 @@ void update_particles_i(pixel *vid, int start, int inc)
{
parts[i].type = PT_NONE;
kill_part(i);
- goto killed;
+ goto killed;
}
parts[r>>8].life = 0;
parts[r>>8].type = PT_NONE;
@@ -3517,11 +3510,11 @@ void update_particles_i(pixel *vid, int start, int inc)
}
pv[y/CELL][x/CELL] += 20;
kill_part(i);
- goto killed;
+ goto killed;
} else if(parts[i].tmp>=3) {
if(parts[i].life<=0) {
kill_part(i);
- goto killed;
+ goto killed;
}
}
}
@@ -3570,11 +3563,11 @@ void update_particles_i(pixel *vid, int start, int inc)
parts[i].life = 10;
}
}
- else if(parts[r>>8].type == PT_SPRK && parts[r>>8].ctype==PT_SWCH && parts[i].life<10&&parts_avg(i,r>>8,PT_INSL)!=PT_INSL)
- {
- parts[r>>8].type = parts[r>>8].ctype;
- parts[r>>8].life = 9;
- }
+ else if(parts[r>>8].type == PT_SPRK && parts[r>>8].ctype==PT_SWCH && parts[i].life<10&&parts_avg(i,r>>8,PT_INSL)!=PT_INSL)
+ {
+ parts[r>>8].type = parts[r>>8].ctype;
+ parts[r>>8].life = 9;
+ }
}
}
if(t==PT_SWCH)
@@ -4174,7 +4167,7 @@ killed:
isplayer = 1;
}
- if(t==PT_STKM2)
+ if(t==PT_STKM2)
{
float dt = 0.9;///(FPSB*FPSB); //Delta time in square
//Tempirature handling
@@ -4564,24 +4557,24 @@ killed:
isplayer2 = 1;
}
- if(t==PT_SPAWN)
- {
- if(death==1)
- {
- playerspawn = create_part(-1,x,y,PT_STKM);
- isplayer = 1;
- }
- death = 0;
- }
- if(t==PT_SPAWN2)
- {
- if(death2==1)
- {
- player2spawn = create_part(-1,x,y,PT_STKM2);
- isplayer2 = 1;
- }
- death2 = 0;
- }
+ if(t==PT_SPAWN)
+ {
+ if(death==1)
+ {
+ playerspawn = create_part(-1,x,y,PT_STKM);
+ isplayer = 1;
+ }
+ death = 0;
+ }
+ if(t==PT_SPAWN2)
+ {
+ if(death2==1)
+ {
+ player2spawn = create_part(-1,x,y,PT_STKM2);
+ isplayer2 = 1;
+ }
+ death2 = 0;
+ }
if(t==PT_CLNE)
{
if(!parts[i].ctype)
@@ -4592,10 +4585,10 @@ killed:
x+nx<XRES && y+ny<YRES &&
pmap[y+ny][x+nx] &&
(pmap[y+ny][x+nx]&0xFF)!=PT_CLNE &&
- (pmap[y+ny][x+nx]&0xFF)!=PT_BCLN &&
- (pmap[y+ny][x+nx]&0xFF)!=PT_PCLN &&
+ (pmap[y+ny][x+nx]&0xFF)!=PT_BCLN &&
+ (pmap[y+ny][x+nx]&0xFF)!=PT_PCLN &&
(pmap[y+ny][x+nx]&0xFF)!=PT_STKM &&
- (pmap[y+ny][x+nx]&0xFF)!=PT_STKM2 &&
+ (pmap[y+ny][x+nx]&0xFF)!=PT_STKM2 &&
(pmap[y+ny][x+nx]&0xFF)!=0xFF)
parts[i].ctype = pmap[y+ny][x+nx]&0xFF;
}
@@ -4604,7 +4597,7 @@ killed:
}
}
- if(t==PT_BCLN)
+ if(t==PT_BCLN)
{
if(!parts[i].ctype)
{
@@ -4614,10 +4607,10 @@ killed:
x+nx<XRES && y+ny<YRES &&
pmap[y+ny][x+nx] &&
(pmap[y+ny][x+nx]&0xFF)!=PT_CLNE &&
- (pmap[y+ny][x+nx]&0xFF)!=PT_BCLN &&
- (pmap[y+ny][x+nx]&0xFF)!=PT_PCLN &&
+ (pmap[y+ny][x+nx]&0xFF)!=PT_BCLN &&
+ (pmap[y+ny][x+nx]&0xFF)!=PT_PCLN &&
(pmap[y+ny][x+nx]&0xFF)!=PT_STKM &&
- (pmap[y+ny][x+nx]&0xFF)!=PT_STKM2 &&
+ (pmap[y+ny][x+nx]&0xFF)!=PT_STKM2 &&
(pmap[y+ny][x+nx]&0xFF)!=0xFF)
parts[i].ctype = pmap[y+ny][x+nx]&0xFF;
}
@@ -4636,12 +4629,12 @@ killed:
pmap[y+ny][x+nx] &&
(pmap[y+ny][x+nx]&0xFF)!=PT_CLNE &&
(pmap[y+ny][x+nx]&0xFF)!=PT_PCLN &&
- (pmap[y+ny][x+nx]&0xFF)!=PT_BCLN &&
+ (pmap[y+ny][x+nx]&0xFF)!=PT_BCLN &&
(pmap[y+ny][x+nx]&0xFF)!=PT_SPRK &&
(pmap[y+ny][x+nx]&0xFF)!=PT_NSCN &&
(pmap[y+ny][x+nx]&0xFF)!=PT_PSCN &&
(pmap[y+ny][x+nx]&0xFF)!=PT_STKM &&
- (pmap[y+ny][x+nx]&0xFF)!=PT_STKM2 &&
+ (pmap[y+ny][x+nx]&0xFF)!=PT_STKM2 &&
(pmap[y+ny][x+nx]&0xFF)!=0xFF)
parts[i].ctype = pmap[y+ny][x+nx]&0xFF;
if(parts[i].ctype && parts[i].life==10) {
@@ -4656,13 +4649,13 @@ killed:
}
}
}
- else if(parts[i].ctype>77&&parts[i].ctype<77+NGOL) {
+ else if(parts[i].ctype>77&&parts[i].ctype<77+NGOL) {
for(nx=-1; nx<2; nx++) {
for(ny=-1; ny<2; ny++) {
create_part(-1, x+nx, y+ny, parts[i].ctype);
}
}
- }else {
+ } else {
create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype);
}
}
@@ -4899,14 +4892,14 @@ killed:
continue;
}
} else {
- if(t!=PT_NEUT)
- kill_part(i);
+ if(t!=PT_NEUT)
+ kill_part(i);
continue;
}
if(!parts[i].ctype) {
- if(t!=PT_NEUT)
- kill_part(i);
+ if(t!=PT_NEUT)
+ kill_part(i);
continue;
}
}
@@ -4975,7 +4968,7 @@ void update_particles(pixel *vid)
if(t!=PT_NEUT || (pmap[y][x]&0xFF)!=PT_GLAS)
pmap[y][x] = t|(i<<8);
}
- NUM_PARTS ++;
+ NUM_PARTS ++;
}
else
{
@@ -5486,8 +5479,8 @@ void update_particles(pixel *vid)
void rotate_area(int area_x, int area_y, int area_w, int area_h, int invert)
{
- //TODO: MSCC doesn't like arrays who's size is determined at runtime.
- #if !(defined(WIN32) && !defined(__GNUC__))
+ //TODO: MSCC doesn't like arrays who's size is determined at runtime.
+#if !(defined(WIN32) && !defined(__GNUC__))
int cx = 0;
int cy = 0;
unsigned tpmap[area_h][area_w];
@@ -5498,57 +5491,57 @@ void rotate_area(int area_x, int area_y, int area_w, int area_h, int invert)
{
for(cx=0; cx<area_w; cx++)//save walls to temp
{
- if(area_x + cx<XRES&&area_y + cy<YRES)
- {
- if(bmap[(cy+area_y)/CELL][(cx+area_x)/CELL])
- tbmap[cy/CELL][cx/CELL] = bmap[(cy+area_y)/CELL][(cx+area_x)/CELL];
- else
- tbmap[cy/CELL][cx/CELL] = 0;
- }
+ if(area_x + cx<XRES&&area_y + cy<YRES)
+ {
+ if(bmap[(cy+area_y)/CELL][(cx+area_x)/CELL])
+ tbmap[cy/CELL][cx/CELL] = bmap[(cy+area_y)/CELL][(cx+area_x)/CELL];
+ else
+ tbmap[cy/CELL][cx/CELL] = 0;
+ }
}
}
for(cy=0; cy<area_h; cy++)
{
for(cx=0; cx<area_w; cx++)//save particles to temp
{
- if((area_x + cx<XRES&&area_y + cy<YRES))
- {
- tpmap[cy][cx] = pmap[(int)(cy+area_y+0.5f)][(int)(cx+area_x+0.5f)];
- }
- else
- tpmap[(int)(cy+0.5f)][(int)(cx+0.5f)] = 0;
+ if((area_x + cx<XRES&&area_y + cy<YRES))
+ {
+ tpmap[cy][cx] = pmap[(int)(cy+area_y+0.5f)][(int)(cx+area_x+0.5f)];
+ }
+ else
+ tpmap[(int)(cy+0.5f)][(int)(cx+0.5f)] = 0;
}
}
for(cy=0; cy<area_w; cy++)
{
for(cx=0; cx<area_h; cx++)//rotate temp arrays
{
- if(invert)
- {
- rtbmap[cy/CELL][((area_h-1)-cx)/CELL] = tbmap[cy/CELL][cx/CELL];
- rtpmap[cy][(area_h-1)-cx] = tpmap[(int)(cy+0.5f)][(int)(cx+0.5f)];
- }
- else
- {
- rtbmap[((area_h-1)-cx)/CELL][cy/CELL] = tbmap[cy/CELL][cx/CELL];
- rtpmap[(area_h-1)-cx][cy] = tpmap[(int)(cy+0.5f)][(int)(cx+0.5f)];
- }
- }
+ if(invert)
+ {
+ rtbmap[cy/CELL][((area_h-1)-cx)/CELL] = tbmap[cy/CELL][cx/CELL];
+ rtpmap[cy][(area_h-1)-cx] = tpmap[(int)(cy+0.5f)][(int)(cx+0.5f)];
+ }
+ else
+ {
+ rtbmap[((area_h-1)-cx)/CELL][cy/CELL] = tbmap[cy/CELL][cx/CELL];
+ rtpmap[(area_h-1)-cx][cy] = tpmap[(int)(cy+0.5f)][(int)(cx+0.5f)];
+ }
+ }
}
for(cy=0; cy<area_w; cy++)
{
for(cx=0; cx<area_h; cx++)//move particles and walls
{
- if(area_x + cx<XRES&&area_y + cy<YRES)
- {
- if((rtpmap[cy][cx]>>8)<=NPART&&rtpmap[cy][cx])
- {
- parts[rtpmap[(int)(cy+0.5f)][(int)(cx+0.5f)]>>8].x = area_x +cx;
- parts[rtpmap[(int)(cy+0.5f)][(int)(cx+0.5f)]>>8].y = area_y +cy;
- }
- bmap[(area_y+cy)/CELL][(area_x+cx)/CELL] = rtbmap[cy/CELL][cx/CELL];
- }
- }
+ if(area_x + cx<XRES&&area_y + cy<YRES)
+ {
+ if((rtpmap[cy][cx]>>8)<=NPART&&rtpmap[cy][cx])
+ {
+ parts[rtpmap[(int)(cy+0.5f)][(int)(cx+0.5f)]>>8].x = area_x +cx;
+ parts[rtpmap[(int)(cy+0.5f)][(int)(cx+0.5f)]>>8].y = area_y +cy;
+ }
+ bmap[(area_y+cy)/CELL][(area_x+cx)/CELL] = rtbmap[cy/CELL][cx/CELL];
+ }
+ }
}
#endif
}
@@ -5592,21 +5585,21 @@ int flood_parts(int x, int y, int c, int cm, int bm)
int x1, x2, dy = (c<PT_NUM)?1:CELL;
int co = c;
if(cm==PT_INST&&co==PT_SPRK)
- if((pmap[y][x]&0xFF)==PT_SPRK)
- return 0;
+ if((pmap[y][x]&0xFF)==PT_SPRK)
+ return 0;
if(c>=UI_WALLSTART&&c<=UI_WALLSTART+UI_WALLCOUNT)
{
c = c-100;
}
if(cm==-1)
{
- if(c==0)
+ if(c==0)
{
cm = pmap[y][x]&0xFF;
if(!cm)
return 0;
- if(REPLACE_MODE && cm!=SLALT)
- return 0;
+ if(REPLACE_MODE && cm!=SLALT)
+ return 0;
}
else
cm = 0;
@@ -5633,17 +5626,17 @@ int flood_parts(int x, int y, int c, int cm, int bm)
while(x1>=CELL)
{
if((pmap[y][x1-1]&0xFF)!=cm || bmap[y/CELL][(x1-1)/CELL]!=bm)
- {
- break;
- }
+ {
+ break;
+ }
x1--;
}
while(x2<XRES-CELL)
{
if((pmap[y][x2+1]&0xFF)!=cm || bmap[y/CELL][(x2+1)/CELL]!=bm)
- {
- break;
- }
+ {
+ break;
+ }
x2++;
}
@@ -5656,70 +5649,70 @@ int flood_parts(int x, int y, int c, int cm, int bm)
// fill children
if(cm==PT_INST&&co==PT_SPRK)//wire crossing for INST
{
- if(y>=CELL+dy && x1==x2 &&
- ((pmap[y-1][x1-1]&0xFF)==PT_INST||(pmap[y-1][x1-1]&0xFF)==PT_SPRK) && ((pmap[y-1][x1]&0xFF)==PT_INST||(pmap[y-1][x1]&0xFF)==PT_SPRK) && ((pmap[y-1][x1+1]&0xFF)==PT_INST || (pmap[y-1][x1+1]&0xFF)==PT_SPRK) &&
- (pmap[y-2][x1-1]&0xFF)!=PT_INST && ((pmap[y-2][x1]&0xFF)==PT_INST ||(pmap[y-2][x1]&0xFF)==PT_SPRK) && (pmap[y-2][x1+1]&0xFF)!=PT_INST)
- flood_parts(x1, y-2, co, cm, bm);
- else if(y>=CELL+dy)
- for(x=x1; x<=x2; x++)
- if((pmap[y-1][x]&0xFF)!=PT_SPRK)
- {
- if(x==x1 || x==x2 || y>=YRES-CELL-1 ||
- (pmap[y-1][x-1]&0xFF)==PT_INST || (pmap[y-1][x+1]&0xFF)==PT_INST ||
- (pmap[y+1][x-1]&0xFF)==PT_INST || ((pmap[y+1][x]&0xFF)!=PT_INST&&(pmap[y+1][x]&0xFF)!=PT_SPRK) || (pmap[y+1][x+1]&0xFF)==PT_INST)
- flood_parts(x, y-dy, co, cm, bm);
+ if(y>=CELL+dy && x1==x2 &&
+ ((pmap[y-1][x1-1]&0xFF)==PT_INST||(pmap[y-1][x1-1]&0xFF)==PT_SPRK) && ((pmap[y-1][x1]&0xFF)==PT_INST||(pmap[y-1][x1]&0xFF)==PT_SPRK) && ((pmap[y-1][x1+1]&0xFF)==PT_INST || (pmap[y-1][x1+1]&0xFF)==PT_SPRK) &&
+ (pmap[y-2][x1-1]&0xFF)!=PT_INST && ((pmap[y-2][x1]&0xFF)==PT_INST ||(pmap[y-2][x1]&0xFF)==PT_SPRK) && (pmap[y-2][x1+1]&0xFF)!=PT_INST)
+ flood_parts(x1, y-2, co, cm, bm);
+ else if(y>=CELL+dy)
+ for(x=x1; x<=x2; x++)
+ if((pmap[y-1][x]&0xFF)!=PT_SPRK)
+ {
+ if(x==x1 || x==x2 || y>=YRES-CELL-1 ||
+ (pmap[y-1][x-1]&0xFF)==PT_INST || (pmap[y-1][x+1]&0xFF)==PT_INST ||
+ (pmap[y+1][x-1]&0xFF)==PT_INST || ((pmap[y+1][x]&0xFF)!=PT_INST&&(pmap[y+1][x]&0xFF)!=PT_SPRK) || (pmap[y+1][x+1]&0xFF)==PT_INST)
+ flood_parts(x, y-dy, co, cm, bm);
- }
+ }
- if(y<YRES-CELL-dy && x1==x2 &&
- ((pmap[y+1][x1-1]&0xFF)==PT_INST||(pmap[y+1][x1-1]&0xFF)==PT_SPRK) && ((pmap[y+1][x1]&0xFF)==PT_INST||(pmap[y+1][x1]&0xFF)==PT_SPRK) && ((pmap[y+1][x1+1]&0xFF)==PT_INST || (pmap[y+1][x1+1]&0xFF)==PT_SPRK) &&
- (pmap[y+2][x1-1]&0xFF)!=PT_INST && ((pmap[y+2][x1]&0xFF)==PT_INST ||(pmap[y+2][x1]&0xFF)==PT_SPRK) && (pmap[y+2][x1+1]&0xFF)!=PT_INST)
- flood_parts(x1, y+2, co, cm, bm);
- else if(y<YRES-CELL-dy)
+ if(y<YRES-CELL-dy && x1==x2 &&
+ ((pmap[y+1][x1-1]&0xFF)==PT_INST||(pmap[y+1][x1-1]&0xFF)==PT_SPRK) && ((pmap[y+1][x1]&0xFF)==PT_INST||(pmap[y+1][x1]&0xFF)==PT_SPRK) && ((pmap[y+1][x1+1]&0xFF)==PT_INST || (pmap[y+1][x1+1]&0xFF)==PT_SPRK) &&
+ (pmap[y+2][x1-1]&0xFF)!=PT_INST && ((pmap[y+2][x1]&0xFF)==PT_INST ||(pmap[y+2][x1]&0xFF)==PT_SPRK) && (pmap[y+2][x1+1]&0xFF)!=PT_INST)
+ flood_parts(x1, y+2, co, cm, bm);
+ else if(y<YRES-CELL-dy)
for(x=x1; x<=x2; x++)
- if((pmap[y+1][x]&0xFF)!=PT_SPRK)
- {
- if(x==x1 || x==x2 || y<0 ||
- (pmap[y+1][x-1]&0xFF)==PT_INST || (pmap[y+1][x+1]&0xFF)==PT_INST ||
- (pmap[y-1][x-1]&0xFF)==PT_INST || ((pmap[y-1][x]&0xFF)!=PT_INST&&(pmap[y-1][x]&0xFF)!=PT_SPRK) || (pmap[y-1][x+1]&0xFF)==PT_INST)
- flood_parts(x, y+dy, co, cm, bm);
-
- }
+ if((pmap[y+1][x]&0xFF)!=PT_SPRK)
+ {
+ if(x==x1 || x==x2 || y<0 ||
+ (pmap[y+1][x-1]&0xFF)==PT_INST || (pmap[y+1][x+1]&0xFF)==PT_INST ||
+ (pmap[y-1][x-1]&0xFF)==PT_INST || ((pmap[y-1][x]&0xFF)!=PT_INST&&(pmap[y-1][x]&0xFF)!=PT_SPRK) || (pmap[y-1][x+1]&0xFF)==PT_INST)
+ flood_parts(x, y+dy, co, cm, bm);
+
+ }
}
else
{
- if(y>=CELL+dy)
- for(x=x1; x<=x2; x++)
- if((pmap[y-dy][x]&0xFF)==cm && bmap[(y-dy)/CELL][x/CELL]==bm)
- if(!flood_parts(x, y-dy, co, cm, bm))
- return 0;
- if(y<YRES-CELL-dy)
- for(x=x1; x<=x2; x++)
- if((pmap[y+dy][x]&0xFF)==cm && bmap[(y+dy)/CELL][x/CELL]==bm)
- if(!flood_parts(x, y+dy, co, cm, bm))
- return 0;
+ if(y>=CELL+dy)
+ for(x=x1; x<=x2; x++)
+ if((pmap[y-dy][x]&0xFF)==cm && bmap[(y-dy)/CELL][x/CELL]==bm)
+ if(!flood_parts(x, y-dy, co, cm, bm))
+ return 0;
+ if(y<YRES-CELL-dy)
+ for(x=x1; x<=x2; x++)
+ if((pmap[y+dy][x]&0xFF)==cm && bmap[(y+dy)/CELL][x/CELL]==bm)
+ if(!flood_parts(x, y+dy, co, cm, bm))
+ return 0;
}
if(!(cm==PT_INST&&co==PT_SPRK))
- return 1;
+ return 1;
}
int create_parts(int x, int y, int rx, int ry, int c)
{
int i, j, r, f = 0, u, v, oy, ox, b = 0, dw = 0, stemp = 0;//n;
-
+
int wall = c - 100;
- for(r=UI_ACTUALSTART;r<=UI_ACTUALSTART+UI_WALLCOUNT;r++)
+ for(r=UI_ACTUALSTART; r<=UI_ACTUALSTART+UI_WALLCOUNT; r++)
{
- if(wall==r)
- {
- if(c == SPC_AIR || c == SPC_HEAT || c == SPC_COOL || c == SPC_VACUUM)
- break;
- if(wall == WL_ERASE)
- b = 0;
- else
- b = wall;
- dw = 1;
- }
+ if(wall==r)
+ {
+ if(c == SPC_AIR || c == SPC_HEAT || c == SPC_COOL || c == SPC_VACUUM)
+ break;
+ if(wall == WL_ERASE)
+ b = 0;
+ else
+ b = wall;
+ dw = 1;
+ }
}
if(c == WL_FANHELPER)
{
@@ -5741,68 +5734,68 @@ int create_parts(int x, int y, int rx, int ry, int c)
{
i = ox;
j = oy;
- if(((sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))|| sdl_mod & (KMOD_CAPS) ))
- {
- if(bmap[j][i]==SLALT-100)
- b = 0;
- else
- continue;
- }
+ if(((sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))|| sdl_mod & (KMOD_CAPS) ))
+ {
+ if(bmap[j][i]==SLALT-100)
+ b = 0;
+ else
+ continue;
+ }
if(b==WL_FAN)
{
fvx[j][i] = 0.0f;
fvy[j][i] = 0.0f;
}
- if(b==WL_STREAM)
- {
- i = x + rx/2;
- j = y + rx/2;
- for(v=-1; v<2; v++)
- for(u=-1; u<2; u++)
- if(i+u>=0 && i+u<XRES/CELL &&
- j+v>=0 && j+v<YRES/CELL &&
- bmap[j+v][i+u] == WL_STREAM)
- return 1;
- bmap[j][i] = WL_STREAM;
- continue;
- }
+ if(b==WL_STREAM)
+ {
+ i = x + rx/2;
+ j = y + rx/2;
+ for(v=-1; v<2; v++)
+ for(u=-1; u<2; u++)
+ if(i+u>=0 && i+u<XRES/CELL &&
+ j+v>=0 && j+v<YRES/CELL &&
+ bmap[j+v][i+u] == WL_STREAM)
+ return 1;
+ bmap[j][i] = WL_STREAM;
+ continue;
+ }
bmap[j][i] = b;
}
}
}
return 1;
}
-
+
if(((sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))|| sdl_mod & (KMOD_CAPS) )&& !REPLACE_MODE)
- {
+ {
for(j=-ry; j<=ry; j++)
for(i=-rx; i<=rx; i++)
if((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx))
delete_part(x+i, y+j);
return 1;
- }
+ }
if(c == SPC_AIR || c == SPC_HEAT || c == SPC_COOL || c == SPC_VACUUM)
{
for(j=-ry; j<=ry; j++)
for(i=-rx; i<=rx; i++)
if((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx))
- if(!REPLACE_MODE)
- create_part(-2, x+i, y+j, c);
- else if((pmap[y+j][x+i]&0xFF)==SLALT&&SLALT!=0)
- create_part(-2, x+i, y+j, c);
+ if(!REPLACE_MODE)
+ create_part(-2, x+i, y+j, c);
+ else if((pmap[y+j][x+i]&0xFF)==SLALT&&SLALT!=0)
+ create_part(-2, x+i, y+j, c);
return 1;
}
if(c == 0 && !REPLACE_MODE)
{
- stemp = SLALT;
- SLALT = 0;
+ stemp = SLALT;
+ SLALT = 0;
for(j=-ry; j<=ry; j++)
for(i=-rx; i<=rx; i++)
if((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx))
delete_part(x+i, y+j);
- SLALT = stemp;
+ SLALT = stemp;
return 1;
}
if(REPLACE_MODE)
@@ -5810,18 +5803,18 @@ int create_parts(int x, int y, int rx, int ry, int c)
for(j=-ry; j<=ry; j++)
for(i=-rx; i<=rx; i++)
if((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx))
- {
- if((pmap[y+j][x+i]&0xFF)!=SLALT&&SLALT!=0)
- continue;
- if((pmap[y+j][x+i]))
- {
- delete_part(x+i, y+j);
- if(c!=0)
- create_part(-2, x+i, y+j, c);
- }
- }
- return 1;
-
+ {
+ if((pmap[y+j][x+i]&0xFF)!=SLALT&&SLALT!=0)
+ continue;
+ if((pmap[y+j][x+i]))
+ {
+ delete_part(x+i, y+j);
+ if(c!=0)
+ create_part(-2, x+i, y+j, c);
+ }
+ }
+ return 1;
+
}
for(j=-ry; j<=ry; j++)
for(i=-rx; i<=rx; i++)