summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--air.c141
-rw-r--r--air.h21
-rw-r--r--defines.h8
-rw-r--r--graphics.c678
-rw-r--r--graphics.h6
-rwxr-xr-xhmap.h7
-rw-r--r--interface.c15
-rw-r--r--interface.h1
-rw-r--r--main.c3388
-rw-r--r--powder.c2547
-rw-r--r--powder.h59
11 files changed, 3475 insertions, 3396 deletions
diff --git a/air.c b/air.c
new file mode 100644
index 0000000..55108d6
--- /dev/null
+++ b/air.c
@@ -0,0 +1,141 @@
+#include <math.h>
+#include "air.h"
+#include "powder.h"
+#include "defines.h"
+float kernel[9];
+
+float vx[YRES/CELL][XRES/CELL], ovx[YRES/CELL][XRES/CELL];
+float vy[YRES/CELL][XRES/CELL], ovy[YRES/CELL][XRES/CELL];
+float pv[YRES/CELL][XRES/CELL], opv[YRES/CELL][XRES/CELL];
+
+float cb_vx[YRES/CELL][XRES/CELL], cb_ovx[YRES/CELL][XRES/CELL];
+float cb_vy[YRES/CELL][XRES/CELL], cb_ovy[YRES/CELL][XRES/CELL];
+float cb_pv[YRES/CELL][XRES/CELL], cb_opv[YRES/CELL][XRES/CELL];
+
+float fvx[YRES/CELL][XRES/CELL], fvy[YRES/CELL][XRES/CELL];
+
+void make_kernel(void)
+{
+ int i, j;
+ float s = 0.0f;
+ for(j=-1; j<2; j++)
+ for(i=-1; i<2; i++)
+ {
+ kernel[(i+1)+3*(j+1)] = expf(-2.0f*(i*i+j*j));
+ s += kernel[(i+1)+3*(j+1)];
+ }
+ s = 1.0f / s;
+ for(j=-1; j<2; j++)
+ for(i=-1; i<2; i++)
+ kernel[(i+1)+3*(j+1)] *= s;
+}
+void update_air(void)
+{
+ int x, y, i, j;
+ float dp, dx, dy, f, tx, ty;
+
+ for(y=1; y<YRES/CELL; y++)
+ for(x=1; x<XRES/CELL; x++)
+ {
+ dp = 0.0f;
+ dp += vx[y][x-1] - vx[y][x];
+ dp += vy[y-1][x] - vy[y][x];
+ pv[y][x] *= PLOSS;
+ pv[y][x] += dp*TSTEPP;
+ }
+
+ for(y=0; y<YRES/CELL-1; y++)
+ for(x=0; x<XRES/CELL-1; x++)
+ {
+ dx = dy = 0.0f;
+ dx += pv[y][x] - pv[y][x+1];
+ dy += pv[y][x] - pv[y+1][x];
+ vx[y][x] *= VLOSS;
+ vy[y][x] *= VLOSS;
+ vx[y][x] += dx*TSTEPV;
+ vy[y][x] += dy*TSTEPV;
+ if(bmap[y][x]==1 || bmap[y][x+1]==1 ||
+ bmap[y][x]==8 || bmap[y][x+1]==8 ||
+ (bmap[y][x]==7 && !emap[y][x]) ||
+ (bmap[y][x+1]==7 && !emap[y][x+1]))
+ vx[y][x] = 0;
+ if(bmap[y][x]==1 || bmap[y+1][x]==1 ||
+ bmap[y][x]==8 || bmap[y+1][x]==8 ||
+ (bmap[y][x]==7 && !emap[y][x]) ||
+ (bmap[y+1][x]==7 && !emap[y+1][x]))
+ vy[y][x] = 0;
+ }
+
+ for(y=0; y<YRES/CELL; y++)
+ for(x=0; x<XRES/CELL; x++)
+ {
+ dx = 0.0f;
+ dy = 0.0f;
+ dp = 0.0f;
+ for(j=-1; j<2; j++)
+ for(i=-1; i<2; i++)
+ if(y+j>0 && y+j<YRES/CELL-1 &&
+ x+i>0 && x+i<XRES/CELL-1 &&
+ bmap[y+j][x+i]!=1 &&
+ bmap[y+j][x+i]!=8 &&
+ (bmap[y+j][x+i]!=7 || emap[y+j][x+i]))
+ {
+ f = kernel[i+1+(j+1)*3];
+ dx += vx[y+j][x+i]*f;
+ dy += vy[y+j][x+i]*f;
+ dp += pv[y+j][x+i]*f;
+ }
+ else
+ {
+ f = kernel[i+1+(j+1)*3];
+ dx += vx[y][x]*f;
+ dy += vy[y][x]*f;
+ dp += pv[y][x]*f;
+ }
+
+ tx = x - dx*0.7f;
+ ty = y - dy*0.7f;
+ i = (int)tx;
+ j = (int)ty;
+ tx -= i;
+ ty -= j;
+ if(i>=2 && i<XRES/CELL-3 &&
+ j>=2 && j<YRES/CELL-3)
+ {
+ dx *= 1.0f - VADV;
+ dy *= 1.0f - VADV;
+
+ dx += VADV*(1.0f-tx)*(1.0f-ty)*vx[j][i];
+ dy += VADV*(1.0f-tx)*(1.0f-ty)*vy[j][i];
+
+ dx += VADV*tx*(1.0f-ty)*vx[j][i+1];
+ dy += VADV*tx*(1.0f-ty)*vy[j][i+1];
+
+ dx += VADV*(1.0f-tx)*ty*vx[j+1][i];
+ dy += VADV*(1.0f-tx)*ty*vy[j+1][i];
+
+ dx += VADV*tx*ty*vx[j+1][i+1];
+ dy += VADV*tx*ty*vy[j+1][i+1];
+ }
+
+ if(bmap[y][x] == 4)
+ {
+ dx += fvx[y][x];
+ dy += fvy[y][x];
+ }
+
+ if(dp > 256.0f) dp = 256.0f;
+ if(dp < -256.0f) dp = -256.0f;
+ if(dx > 256.0f) dx = 256.0f;
+ if(dx < -256.0f) dx = -256.0f;
+ if(dy > 256.0f) dy = 256.0f;
+ if(dy < -256.0f) dy = -256.0f;
+
+ ovx[y][x] = dx;
+ ovy[y][x] = dy;
+ opv[y][x] = dp;
+ }
+ memcpy(vx, ovx, sizeof(vx));
+ memcpy(vy, ovy, sizeof(vy));
+ memcpy(pv, opv, sizeof(pv));
+} \ No newline at end of file
diff --git a/air.h b/air.h
index add56b0..d9e04f6 100644
--- a/air.h
+++ b/air.h
@@ -1,14 +1,21 @@
#ifndef AIR_H
#define AIR_H
+#include "defines.h"
-float vx[YRES/CELL][XRES/CELL], ovx[YRES/CELL][XRES/CELL];
-float vy[YRES/CELL][XRES/CELL], ovy[YRES/CELL][XRES/CELL];
-float pv[YRES/CELL][XRES/CELL], opv[YRES/CELL][XRES/CELL];
+extern float vx[YRES/CELL][XRES/CELL], ovx[YRES/CELL][XRES/CELL];
+extern float vy[YRES/CELL][XRES/CELL], ovy[YRES/CELL][XRES/CELL];
+extern float pv[YRES/CELL][XRES/CELL], opv[YRES/CELL][XRES/CELL];
-float cb_vx[YRES/CELL][XRES/CELL], ovx[YRES/CELL][XRES/CELL];
-float cb_vy[YRES/CELL][XRES/CELL], ovy[YRES/CELL][XRES/CELL];
-float cb_pv[YRES/CELL][XRES/CELL], opv[YRES/CELL][XRES/CELL];
+extern float cb_vx[YRES/CELL][XRES/CELL], cb_ovx[YRES/CELL][XRES/CELL];
+extern float cb_vy[YRES/CELL][XRES/CELL], cb_ovy[YRES/CELL][XRES/CELL];
+extern float cb_pv[YRES/CELL][XRES/CELL], cb_opv[YRES/CELL][XRES/CELL];
-float fvx[YRES/CELL][XRES/CELL], fvy[YRES/CELL][XRES/CELL];
+extern float fvx[YRES/CELL][XRES/CELL], fvy[YRES/CELL][XRES/CELL];
+
+extern float kernel[9];
+
+void make_kernel(void);
+
+void update_air(void);
#endif \ No newline at end of file
diff --git a/defines.h b/defines.h
index 5b5daaa..aa27b90 100644
--- a/defines.h
+++ b/defines.h
@@ -28,4 +28,12 @@ static unsigned char ZSIZE = ZSIZE_D;
typedef unsigned char uint8;
+extern int legacy_enable;
+
+extern int sys_pause;
+extern int framerender;
+
+extern int mousex, mousey;
+extern int death;
+
#endif \ No newline at end of file
diff --git a/graphics.c b/graphics.c
index 15f50c6..0f6c040 100644
--- a/graphics.c
+++ b/graphics.c
@@ -1,16 +1,21 @@
+#include <math.h>
+#include <SDL/SDL.h>
#include "defines.h"
#include "air.h"
#include "powder.h"
#include "graphics.h"
#include "font.h"
#include "misc.h"
-#include <math.h>
-#include <SDL/SDL.h>
+
unsigned cmode = 3;
SDL_Surface *sdl_scrn;
int sdl_scale = 1;
+unsigned char fire_r[YRES/CELL][XRES/CELL];
+unsigned char fire_g[YRES/CELL][XRES/CELL];
+unsigned char fire_b[YRES/CELL][XRES/CELL];
+
pixel *rescale_img(pixel *src, int sw, int sh, int *qw, int *qh, int f)
{
int i,j,x,y,w,h,r,g,b,c;
@@ -1095,4 +1100,673 @@ void xor_rect(pixel *vid, int x, int y, int w, int h)
xor_pixel(x, y+i, vid);
xor_pixel(x+w-1, y+i, vid);
}
+}
+
+void draw_parts(pixel *vid)
+{
+ int i, j, x, y, t, nx, ny, r, a, cr,cg,cb, s, rt, fe, nt, lpv, nearp, pavg;
+ float mv, dx, dy, ix, iy, lx, ly, d, pp;
+ float pt = R_TEMP;
+ for(i = 0; i<NPART; i++){
+ t = parts[i].type;
+ nx = (int)(parts[i].x+0.5f);
+ ny = (int)(parts[i].y+0.5f);
+
+ if(cmode!=CM_HEAT)
+ {
+ if(t==PT_STKM) //Just draw head here
+ {
+ char buff[10]; //Buffer for HP
+
+ if(mousex>(nx-3) && mousex<(nx+3) && mousey<(ny+3) && mousey>(ny-3)) //If mous is in the head
+ {
+ sprintf(buff, "%3d", (int)parts[i].life); //Show HP
+ drawtext(vid, mousex-8-2*(parts[i].life<100)-2*(parts[i].life<10), mousey-12, buff, 255, 255, 255, 255);
+ }
+
+ for(r=-2; r<=1; r++) //Here I use r variable not as I should, but I think you will excuse me :-p
+ {
+ s = XRES+BARSIZE;
+ vid[(ny-2)*s+nx+r] = ptypes[(int)player[2]].pcolors;
+ vid[(ny+2)*s+nx+r+1] = ptypes[(int)player[2]].pcolors;
+ vid[(ny+r+1)*s+nx-2] = ptypes[(int)player[2]].pcolors;
+ vid[(ny+r)*s+nx+2] = ptypes[(int)player[2]].pcolors;
+ }
+ draw_line(vid , nx, ny+3, player[3], player[4], 255, 255, 255, s);
+ draw_line(vid , player[3], player[4], player[7], player[8], 255, 255, 255, s);
+ draw_line(vid , nx, ny+3, player[11], player[12], 255, 255, 255, s);
+ draw_line(vid , player[11], player[12], player[15], player[16], 255, 255, 255, s);
+
+ isplayer = 1; //It's a secret. Tssss...
+ }
+ if(t==PT_MWAX&&cmode == 6)
+ {
+ for(x=-1; x<=1; x++)
+ {
+ for(y=-1; y<=1; y++)
+ {
+ if ((abs(x) == 0) && (abs(y) == 0))
+ blendpixel(vid,x+nx,y+ny,224,224,170,255);
+ else if (abs(y) != 0 && abs(x) != 0)
+ blendpixel(vid,x+nx,y+ny,224,224,170,20);
+ else
+ blendpixel(vid,x+nx,y+ny,224,224,170,40);
+ }
+ }
+
+ }
+ else if(t==PT_ACID)
+ {
+ if(parts[i].life>255) parts[i].life = 255;
+ if(parts[i].life<47) parts[i].life = 48;
+ s = (255/((parts[i].life-46)*28));
+ if(s==0) s = 1;
+ cr = PIXR(ptypes[t].pcolors)/s;
+ cg = PIXG(ptypes[t].pcolors)/s;
+ cb = PIXB(ptypes[t].pcolors)/s;
+ if(cmode==6){
+ for(x=-1; x<=1; x++)
+ {
+ for(y=-1; y<=1; y++)
+ {
+ if ((abs(x) == 0) && (abs(y) == 0))
+ blendpixel(vid,x+nx,y+ny,cr,cg,cb,100);
+ else if (abs(y) != 0 || abs(x) != 0)
+ blendpixel(vid,x+nx,y+ny,cr,cg,cb,40);
+ }
+ }
+ } else {
+ blendpixel(vid, nx, ny, cr, cg, cb, 255);
+ }
+
+ if(cmode==4)
+ {
+ blendpixel(vid, nx+1, ny, cr, cg, cb, 223);
+ blendpixel(vid, nx-1, ny, cr, cg, cb, 223);
+ blendpixel(vid, nx, ny+1, cr, cg, cb, 223);
+ blendpixel(vid, nx, ny-1, cr, cg, cb, 223);
+
+ blendpixel(vid, nx+1, ny-1, cr, cg, cb, 112);
+ blendpixel(vid, nx-1, ny-1, cr, cg, cb, 112);
+ blendpixel(vid, nx+1, ny+1, cr, cg, cb, 112);
+ blendpixel(vid, nx-1, ny+1, cr, cg, cb, 112);
+ }
+ }
+ else if(t==PT_OILL&&cmode == 6)
+ {
+ for(x=-1; x<=1; x++)
+ {
+ for(y=-1; y<=1; y++)
+ {
+ if ((abs(x) == 0) && (abs(y) == 0))
+ blendpixel(vid,x+nx,y+ny,64,64,16,100);
+ else if (abs(y) != 0 || abs(x) != 0)
+ blendpixel(vid,x+nx,y+ny,64,64,16,40);
+ }
+ }
+ }
+ else if(t==PT_NEUT)
+ {
+ if(cmode == 3||cmode==4 || cmode==6)
+ {
+ vid[ny*(XRES+BARSIZE)+nx] = ptypes[t].pcolors;
+ cg = 8;
+ cb = 12;
+ x = nx/CELL;
+ y = ny/CELL;
+ cg += fire_g[y][x];
+ if(cg > 255) cg = 255;
+ fire_g[y][x] = cg;
+ cb += fire_b[y][x];
+ if(cb > 255) cb = 255;
+ fire_b[y][x] = cb;
+ }
+ else
+ {
+ cr = 0x20;
+ cg = 0xE0;
+ cb = 0xFF;
+ blendpixel(vid, nx, ny, cr, cg, cb, 192);
+ blendpixel(vid, nx+1, ny, cr, cg, cb, 96);
+ blendpixel(vid, nx-1, ny, cr, cg, cb, 96);
+ blendpixel(vid, nx, ny+1, cr, cg, cb, 96);
+ blendpixel(vid, nx, ny-1, cr, cg, cb, 96);
+ blendpixel(vid, nx+1, ny-1, cr, cg, cb, 32);
+ blendpixel(vid, nx-1, ny+1, cr, cg, cb, 32);
+ blendpixel(vid, nx+1, ny+1, cr, cg, cb, 32);
+ blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32);
+ }
+ } else if(t==PT_PLUT&&cmode == 6)
+ {
+ int tempx;
+ int tempy;
+ cr = 0x40;
+ cg = 0x70;
+ cb = 0x20;
+ blendpixel(vid, nx, ny, cr, cg, cb, 192);
+ blendpixel(vid, nx+1, ny, cr, cg, cb, 96);
+ blendpixel(vid, nx-1, ny, cr, cg, cb, 96);
+ blendpixel(vid, nx, ny+1, cr, cg, cb, 96);
+ blendpixel(vid, nx, ny-1, cr, cg, cb, 96);
+ for(tempx = 2; tempx < 10; tempx++) {
+ for(tempy = 2; tempy < 10; tempy++) {
+ blendpixel(vid, nx+tempx, ny-tempy, cr, cg, cb, 5);
+ blendpixel(vid, nx-tempx, ny+tempy, cr, cg, cb, 5);
+ blendpixel(vid, nx+tempx, ny+tempy, cr, cg, cb, 5);
+ blendpixel(vid, nx-tempx, ny-tempy, cr, cg, cb, 5);
+ }
+ }
+ } else if(t==PT_URAN&&cmode == 6)
+ {
+ int tempx;
+ int tempy;
+ cr = 0x70;
+ cg = 0x70;
+ cb = 0x20;
+ blendpixel(vid, nx, ny, cr, cg, cb, 192);
+ blendpixel(vid, nx+1, ny, cr, cg, cb, 96);
+ blendpixel(vid, nx-1, ny, cr, cg, cb, 96);
+ blendpixel(vid, nx, ny+1, cr, cg, cb, 96);
+ blendpixel(vid, nx, ny-1, cr, cg, cb, 96);
+ for(tempx = 2; tempx < 10; tempx++) {
+ for(tempy = 2; tempy < 10; tempy++) {
+ blendpixel(vid, nx+tempx, ny-tempy, cr, cg, cb, 5);
+ blendpixel(vid, nx-tempx, ny+tempy, cr, cg, cb, 5);
+ blendpixel(vid, nx+tempx, ny+tempy, cr, cg, cb, 5);
+ blendpixel(vid, nx-tempx, ny-tempy, cr, cg, cb, 5);
+ }
+ }
+ } else if(t==PT_SLTW&&cmode == 6)
+ {
+ for(x=-1; x<=1; x++)
+ {
+ for(y=-1; y<=1; y++)
+ {
+ if ((abs(x) == 0) && (abs(y) == 0))
+ blendpixel(vid,x+nx,y+ny,64,80,240,100);
+ else if (abs(y) != 0 || abs(x) != 0)
+ blendpixel(vid,x+nx,y+ny,64,80,240,50);
+ }
+ }
+ }
+ else if(t==PT_PHOT)
+ {
+ if(cmode == 3||cmode==4 || cmode==6)
+ {
+ vid[ny*(XRES+BARSIZE)+nx] = ptypes[t].pcolors;
+ cg = 12;
+ cb = 12;
+ cr = 12;
+ x = nx/CELL;
+ y = ny/CELL;
+ cg += fire_g[y][x];
+ if(cg > 255) cg = 255;
+ fire_g[y][x] = cg;
+ cb += fire_b[y][x];
+ if(cb > 255) cb = 255;
+ fire_b[y][x] = cb;
+ cr += fire_r[y][x];
+ if(cr > 255) cr = 255;
+ fire_r[y][x] = cr;
+ }
+ else
+ {
+ cr = 0xFF;
+ cg = 0xFF;
+ cb = 0xFF;
+ blendpixel(vid, nx, ny, cr, cg, cb, 192);
+ blendpixel(vid, nx+1, ny, cr, cg, cb, 96);
+ blendpixel(vid, nx-1, ny, cr, cg, cb, 96);
+ blendpixel(vid, nx, ny+1, cr, cg, cb, 96);
+ blendpixel(vid, nx, ny-1, cr, cg, cb, 96);
+ blendpixel(vid, nx+1, ny-1, cr, cg, cb, 32);
+ blendpixel(vid, nx-1, ny+1, cr, cg, cb, 32);
+ blendpixel(vid, nx+1, ny+1, cr, cg, cb, 32);
+ blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32);
+ }
+ }
+ else if(t==PT_SWCH && parts[i].life == 10)
+ {
+ x = nx;
+ y = ny;
+ blendpixel(vid,x,y,17,217,24,255);
+ }
+ else if(t==PT_LNTG&&cmode == 6)
+ {
+ for(x=-1; x<=1; x++)
+ {
+ for(y=-1; y<=1; y++)
+ {
+ if ((abs(x) == 0) && (abs(y) == 0))
+ blendpixel(vid,x+nx,y+ny,128,160,223,100);
+ else if (abs(y) != 0 || abs(x) != 0)
+ blendpixel(vid,x+nx,y+ny,128,160,223,50);
+ }
+ }
+ }
+ else if(t==PT_SMKE)
+ {
+ if(cmode == 3||cmode==4 || cmode==6)
+ {
+ x = nx/CELL;
+ y = ny/CELL;
+ cg = 10;
+ cb = 10;
+ cr = 10;
+ cg += fire_g[y][x];
+ if(cg > 50) cg = 50;
+ fire_g[y][x] = cg;
+ cb += fire_b[y][x];
+ if(cb > 50) cb = 50;
+ fire_b[y][x] = cb;
+ cr += fire_r[y][x];
+ if(cr > 50) cr = 50;
+ fire_r[y][x] = cr;
+ }
+ else
+ {
+ for(x=-3; x<4; x++)
+ {
+ for(y=-3; y<4; y++)
+ {
+ if (abs(x)+abs(y) <2 && !(abs(x)==2||abs(y)==2))
+ blendpixel(vid,x+nx,y+ny,100,100,100,30);
+ if(abs(x)+abs(y) <=3 && abs(x)+abs(y))
+ blendpixel(vid,x+nx,y+ny,100,100,100,10);
+ if (abs(x)+abs(y) == 2)
+ blendpixel(vid,x+nx,y+ny,100,100,100,20);
+ }
+ }
+ }
+ }
+ else if(t==PT_WATR&&cmode == 6)
+ {
+ for(x=-1; x<=1; x++)
+ {
+ for(y=-1; y<=1; y++)
+ {
+ if ((abs(x) == 0) && (abs(y) == 0))
+ blendpixel(vid,x+nx,y+ny,32,48,208,100);
+ else if (abs(y) != 0 || abs(x) != 0)
+ blendpixel(vid,x+nx,y+ny,32,48,208,50);
+ }
+ }
+
+ } else if(t==PT_DSTW&&cmode == 6)
+ {
+ for(x=-1; x<=1; x++)
+ {
+ for(y=-1; y<=1; y++)
+ {
+ if ((abs(x) == 0) && (abs(y) == 0))
+ blendpixel(vid,x+nx,y+ny,32,48,208,100);
+ else if (abs(y) != 0 || abs(x) != 0)
+ blendpixel(vid,x+nx,y+ny,32,48,208,50);
+ }
+ }
+ }
+ else if(t==PT_NITR&&cmode == 6)
+ {
+ for(x=-1; x<=1; x++)
+ {
+ for(y=-1; y<=1; y++)
+ {
+ if ((abs(x) == 0) && (abs(y) == 0))
+ blendpixel(vid,x+nx,y+ny,32,224,16,100);
+ else if (abs(y) != 0 || abs(x) != 0)
+ blendpixel(vid,x+nx,y+ny,32,224,16,50);
+ }
+ }
+
+ }
+ else if(t==PT_LRBD&&cmode == 6)
+ {
+ for(x=-1; x<=1; x++)
+ {
+ for(y=-1; y<=1; y++)
+ {
+ if ((abs(x) == 0) && (abs(y) == 0))
+ blendpixel(vid,x+nx,y+ny,170,170,170,100);
+ else if (abs(y) != 0 || abs(x) != 0)
+ blendpixel(vid,x+nx,y+ny,170,170,170,50);
+ }
+ }
+
+ }
+
+ else if(t==PT_NBLE&&cmode == 6)
+ {
+ for(x=-1; x<=1; x++)
+ {
+ for(y=-1; y<=1; y++)
+ {
+ if ((abs(x) == 0) && (abs(y) == 0))
+ blendpixel(vid,x+nx,y+ny,235,73,23,100);
+ else if (abs(y) != 0 && abs(x) != 0)
+ blendpixel(vid,x+nx,y+ny,235,73,23,30);
+ else
+ blendpixel(vid,x+nx,y+ny,235,73,23,50);
+ }
+ }
+
+ }
+ else if(t==PT_GASS&&cmode == 6)
+ {
+ for(x=-1; x<=1; x++)
+ {
+ for(y=-1; y<=1; y++)
+ {
+ if ((abs(x) == 0) && (abs(y) == 0))
+ blendpixel(vid,x+nx,y+ny,255,255,0,180);
+ else if (abs(y) != 0 && abs(x) != 0)
+ blendpixel(vid,x+nx,y+ny,255,255,0,50);
+ else
+ blendpixel(vid,x+nx,y+ny,255,255,0,80);
+ }
+ }
+
+ }
+ else if(t==PT_WTRV)
+ {
+ if(cmode == 3||cmode==4 || cmode==6)
+ {
+ x = nx/CELL;
+ y = ny/CELL;
+ cg = PIXG(ptypes[t].pcolors)/3;
+ cb = PIXB(ptypes[t].pcolors)/3;
+ cr = PIXR(ptypes[t].pcolors)/3;
+ cg += fire_g[y][x];
+ if(cg > PIXG(ptypes[t].pcolors)/2) cg = PIXG(ptypes[t].pcolors)/2;
+ fire_g[y][x] = cg;
+ cb += fire_b[y][x];
+ if(cb > PIXB(ptypes[t].pcolors)/2) cb = PIXB(ptypes[t].pcolors)/2;
+ fire_b[y][x] = cb;
+ cr += fire_r[y][x];
+ if(cr > PIXR(ptypes[t].pcolors)/2) cr = PIXR(ptypes[t].pcolors)/2;
+ fire_r[y][x] = cr;
+ }
+ else
+ {
+ for(x=-3; x<4; x++)
+ {
+ for(y=-3; y<4; y++)
+ {
+ if (abs(x)+abs(y) <2 && !(abs(x)==2||abs(y)==2))
+ blendpixel(vid,x+nx,y+ny, PIXR(ptypes[t].pcolors)/1.6, PIXG(ptypes[t].pcolors)/1.6, PIXB(ptypes[t].pcolors)/1.6, 30);
+ if(abs(x)+abs(y) <=3 && abs(x)+abs(y))
+ blendpixel(vid,x+nx,y+ny, PIXR(ptypes[t].pcolors)/1.6, PIXG(ptypes[t].pcolors)/1.6, PIXB(ptypes[t].pcolors)/1.6, 10);
+ if (abs(x)+abs(y) == 2)
+ blendpixel(vid,x+nx,y+ny, PIXR(ptypes[t].pcolors)/1.6, PIXG(ptypes[t].pcolors)/1.6, PIXB(ptypes[t].pcolors)/1.6, 20);
+ }
+ }
+ }
+ }
+ else if(t==PT_THDR)
+ {
+ if(cmode == 3||cmode==4 || cmode==6)
+ {
+ vid[ny*(XRES+BARSIZE)+nx] = ptypes[t].pcolors;
+ cg = 16;
+ cb = 20;
+ cr = 12;
+ x = nx/CELL;
+ y = ny/CELL;
+ cg += fire_g[y][x];
+ if(cg > 255) cg = 255;
+ fire_g[y][x] = cg;
+ cb += fire_b[y][x];
+ if(cb > 255) cb = 255;
+ fire_b[y][x] = cb;
+ cr += fire_r[y][x];
+ if(cr > 255) cr = 255;
+ fire_r[y][x] = cr;
+ }
+ else
+ {
+ cr = 0xFF;
+ cg = 0xFF;
+ cb = 0xA0;
+ blendpixel(vid, nx, ny, cr, cg, cb, 192);
+ blendpixel(vid, nx+1, ny, cr, cg, cb, 96);
+ blendpixel(vid, nx-1, ny, cr, cg, cb, 96);
+ blendpixel(vid, nx, ny+1, cr, cg, cb, 96);
+ blendpixel(vid, nx, ny-1, cr, cg, cb, 96);
+ blendpixel(vid, nx+1, ny-1, cr, cg, cb, 32);
+ blendpixel(vid, nx-1, ny+1, cr, cg, cb, 32);
+ blendpixel(vid, nx+1, ny+1, cr, cg, cb, 32);
+ blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32);
+ }
+ }
+ else if(t==PT_LCRY)
+ {
+ if(cmode == 3||cmode==4 || cmode==6)
+ {
+ //cr = R/8;
+ //cg = G/8;
+ //cb = B/8;
+ vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(0x50+(parts[i].life*10), 0x50+(parts[i].life*10), 0x50+(parts[i].life*10));
+ //x = nx/CELL;
+ //y = ny/CELL;
+ //cg += fire_g[y][x]; if(cg > 255) cg = 255; fire_g[y][x] = cg;
+ //cb += fire_b[y][x]; if(cb > 255) cb = 255; fire_b[y][x] = cb;
+ //cr += fire_r[y][x]; if(cr > 255) cr = 255; fire_r[y][x] = cr;
+ }
+ else
+ {
+ cr = 0x50+(parts[i].life*10);
+ cg = 0x50+(parts[i].life*10);
+ cb = 0x50+(parts[i].life*10);
+ blendpixel(vid, nx, ny, cr, cg, cb, 192);
+ blendpixel(vid, nx+1, ny, cr, cg, cb, 96);
+ blendpixel(vid, nx-1, ny, cr, cg, cb, 96);
+ blendpixel(vid, nx, ny+1, cr, cg, cb, 96);
+ blendpixel(vid, nx, ny-1, cr, cg, cb, 96);
+ blendpixel(vid, nx+1, ny-1, cr, cg, cb, 32);
+ blendpixel(vid, nx-1, ny+1, cr, cg, cb, 32);
+ blendpixel(vid, nx+1, ny+1, cr, cg, cb, 32);
+ blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32);
+ }
+ } else if(t==PT_PLSM)
+ {
+ float ttemp = parts[i].life;
+ int caddress = restrict_flt(restrict_flt(ttemp, 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3);
+ uint8 R = plasma_data[caddress];
+ uint8 G = plasma_data[caddress+1];
+ uint8 B = plasma_data[caddress+2];
+ if(cmode == 3||cmode==4 || cmode==6)
+ {
+ cr = R/8;
+ cg = G/8;
+ cb = B/8;
+ x = nx/CELL;
+ y = ny/CELL;
+ cg += fire_g[y][x];
+ if(cg > 255) cg = 255;
+ fire_g[y][x] = cg;
+ cb += fire_b[y][x];
+ if(cb > 255) cb = 255;
+ fire_b[y][x] = cb;
+ cr += fire_r[y][x];
+ if(cr > 255) cr = 255;
+ fire_r[y][x] = cr;
+ }
+ else
+ {
+ cr = R;
+ cg = G;
+ cb = B;
+ blendpixel(vid, nx, ny, cr, cg, cb, 192);
+ blendpixel(vid, nx+1, ny, cr, cg, cb, 96);
+ blendpixel(vid, nx-1, ny, cr, cg, cb, 96);
+ blendpixel(vid, nx, ny+1, cr, cg, cb, 96);
+ blendpixel(vid, nx, ny-1, cr, cg, cb, 96);
+ blendpixel(vid, nx+1, ny-1, cr, cg, cb, 32);
+ blendpixel(vid, nx-1, ny+1, cr, cg, cb, 32);
+ blendpixel(vid, nx+1, ny+1, cr, cg, cb, 32);
+ blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32);
+ }
+ }
+ else if(t==PT_FIRE && parts[i].life)
+ {
+ if(cmode == 3||cmode==4 || cmode==6)
+ {
+ cr = parts[i].life / 4;
+ cg = parts[i].life / 16;
+ cb = parts[i].life / 32;
+ if(cr>255) cr = 255;
+ if(cg>192) cg = 212;
+ if(cb>128) cb = 192;
+ x = nx/CELL;
+ y = ny/CELL;
+ cr += fire_r[y][x];
+ if(cr > 255) cr = 255;
+ fire_r[y][x] = cr;
+ cg += fire_g[y][x];
+ if(cg > 255) cg = 255;
+ fire_g[y][x] = cg;
+ cb += fire_b[y][x];
+ if(cb > 255) cb = 255;
+ fire_b[y][x] = cb;
+ }
+ else
+ {
+ cr = parts[i].life * 8;
+ cg = parts[i].life * 2;
+ cb = parts[i].life;
+ if(cr>255) cr = 255;
+ if(cg>192) cg = 212;
+ if(cb>128) cb = 192;
+ blendpixel(vid, nx, ny, cr, cg, cb, 255);
+ blendpixel(vid, nx+1, ny, cr, cg, cb, 96);
+ blendpixel(vid, nx-1, ny, cr, cg, cb, 96);
+ blendpixel(vid, nx, ny+1, cr, cg, cb, 96);
+ blendpixel(vid, nx, ny-1, cr, cg, cb, 96);
+ blendpixel(vid, nx+1, ny-1, cr, cg, cb, 32);
+ blendpixel(vid, nx-1, ny+1, cr, cg, cb, 32);
+ blendpixel(vid, nx+1, ny+1, cr, cg, cb, 32);
+ blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32);
+ }
+ }
+ else if(t==PT_LAVA && parts[i].life)
+ {
+ cr = parts[i].life * 2 + 0xE0;
+ cg = parts[i].life * 1 + 0x50;
+ cb = parts[i].life/2 + 0x10;
+ if(cr>255) cr = 255;
+ if(cg>192) cg = 192;
+ if(cb>128) cb = 128;
+ blendpixel(vid, nx, ny, cr, cg, cb, 255);
+ blendpixel(vid, nx+1, ny, cr, cg, cb, 64);
+ blendpixel(vid, nx-1, ny, cr, cg, cb, 64);
+ blendpixel(vid, nx, ny+1, cr, cg, cb, 64);
+ blendpixel(vid, nx, ny-1, cr, cg, cb, 64);
+ if(cmode == 3||cmode==4 || cmode==6)
+ {
+ cr /= 32;
+ cg /= 32;
+ cb /= 32;
+ x = nx/CELL;
+ y = ny/CELL;
+ cr += fire_r[y][x];
+ if(cr > 255) cr = 255;
+ fire_r[y][x] = cr;
+ cg += fire_g[y][x];
+ if(cg > 255) cg = 255;
+ fire_g[y][x] = cg;
+ cb += fire_b[y][x];
+ if(cb > 255) cb = 255;
+ fire_b[y][x] = cb;
+ }
+ }
+ else if(t==PT_LAVA || t==PT_SPRK)
+ {
+ vid[ny*(XRES+BARSIZE)+nx] = ptypes[t].pcolors;
+ if(cmode == 3 || cmode==4 || cmode==6)
+ {
+ if(t == PT_LAVA)
+ {
+ cr = 3;
+ cg = i%2;
+ cb = 0;
+ }
+ else
+ {
+ cr = 8;
+ cg = 12;
+ cb = 16;
+ }
+ x = nx/CELL;
+ y = ny/CELL;
+ cr += fire_r[y][x];
+ if(cr > 255) cr = 255;
+ fire_r[y][x] = cr;
+ cg += fire_g[y][x];
+ if(cg > 255) cg = 255;
+ fire_g[y][x] = cg;
+ cb += fire_b[y][x];
+ if(cb > 255) cb = 255;
+ fire_b[y][x] = cb;
+ }
+ }
+ else
+ vid[ny*(XRES+BARSIZE)+nx] = ptypes[t].pcolors;
+ }
+ else
+ {
+ float ttemp = parts[i].temp+(-MIN_TEMP);
+ int caddress = restrict_flt((int)( restrict_flt(ttemp, 0.0f, MAX_TEMP+(-MIN_TEMP)) / ((MAX_TEMP+(-MIN_TEMP))/512) ) *3, 0.0f, (512.0f*3)-3);
+ uint8 R = color_data[caddress];
+ uint8 G = color_data[caddress+1];
+ uint8 B = color_data[caddress+2];
+
+ if(t==PT_STKM) //Stick man should be visible in heat mode
+ {
+ char buff[10]; //Buffer for HP
+
+ if(mousex>(nx-3) && mousex<(nx+3) && mousey<(ny+3) && mousey>(ny-3)) //If mous is in the head
+ {
+ sprintf(buff, "%3d", (int)parts[i].life); //Show HP
+ drawtext(vid, mousex-8-2*(parts[i].life<100)-2*(parts[i].life<10), mousey-12, buff, 255, 255, 255, 255);
+ }
+
+ for(r=-2; r<=1; r++)
+ {
+ s = XRES+BARSIZE;
+ vid[(ny-2)*s+nx+r] = PIXRGB (R, G, B);
+ vid[(ny+2)*s+nx+r+1] = PIXRGB (R, G, B);
+ vid[(ny+r+1)*s+nx-2] = PIXRGB (R, G, B);
+ vid[(ny+r)*s+nx+2] = PIXRGB (R, G, B);
+ }
+ draw_line(vid , nx, ny+3, player[3], player[4], R, G, B, s);
+ draw_line(vid , player[3], player[4], player[7], player[8], R, G, B, s);
+ draw_line(vid , nx, ny+3, player[11], player[12], R, G, B, s);
+ draw_line(vid , player[11], player[12], player[15], player[16], R, G, B, s);
+ }
+ else
+ {
+ vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(R, G, B);
+ //blendpixel(vid, nx+1, ny, R, G, B, 255);
+ }
+ }
+ if(cmode == 4&&t!=PT_FIRE&&t!=PT_PLSM&&t!=PT_NONE&&t!=PT_ACID)
+ {
+ uint8 R = PIXR(ptypes[t].pcolors);
+ uint8 G = PIXG(ptypes[t].pcolors);
+ uint8 B = PIXB(ptypes[t].pcolors);
+
+ //if(vid[(ny-1)*YRES+(nx-1)]!=0){
+ // blendpixel(vid, nx, ny-1, R, G, B, 46);
+ //}
+
+ blendpixel(vid, nx+1, ny, R, G, B, 223);
+ blendpixel(vid, nx-1, ny, R, G, B, 223);
+ blendpixel(vid, nx, ny+1, R, G, B, 223);
+ blendpixel(vid, nx, ny-1, R, G, B, 223);
+
+ blendpixel(vid, nx+1, ny-1, R, G, B, 112);
+ blendpixel(vid, nx-1, ny-1, R, G, B, 112);
+ blendpixel(vid, nx+1, ny+1, R, G, B, 112);
+ blendpixel(vid, nx-1, ny+1, R, G, B, 112);
+ }
+ }
} \ No newline at end of file
diff --git a/graphics.h b/graphics.h
index 7779b09..3932a2f 100644
--- a/graphics.h
+++ b/graphics.h
@@ -1,6 +1,8 @@
#ifndef GRAPHICS_H
#define GRAPHICS_H
#include <SDL/SDL.h>
+#include "defines.h"
+#include "hmap.h"
#ifdef PIX16
#define PIXELSIZE 2
@@ -40,6 +42,10 @@ extern unsigned cmode;
extern SDL_Surface *sdl_scrn;
extern int sdl_scale;
+extern unsigned char fire_r[YRES/CELL][XRES/CELL];
+extern unsigned char fire_g[YRES/CELL][XRES/CELL];
+extern unsigned char fire_b[YRES/CELL][XRES/CELL];
+
pixel *rescale_img(pixel *src, int sw, int sh, int *qw, int *qh, int f);
void sdl_blit_1(int x, int y, int w, int h, pixel *src, int pitch);
diff --git a/hmap.h b/hmap.h
index a356fd2..8af6e71 100755
--- a/hmap.h
+++ b/hmap.h
@@ -17,5 +17,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
-unsigned char color_data[] = {0xD9,0xFF,0xFE,0xD4,0xFB,0xFC,0xCF,0xF6,0xF9,0xC9,0xF1,0xF6,0xC2,0xEB,0xF4,0xBB,0xE5,0xF0,0xB3,0xDE,0xED,0xAA,0xD6,0xE9,0xA1,0xCF,0xE5,0x98,0xC7,0xE2,0x8E,0xBF,0xDD,0x85,0xB6,0xD9,0x7B,0xAD,0xD5,0x71,0xA5,0xD0,0x67,0x9C,0xCC,0x5D,0x93,0xC7,0x53,0x8A,0xC3,0x4A,0x82,0xBE,0x41,0x79,0xB9,0x38,0x71,0xB5,0x30,0x69,0xB0,0x28,0x61,0xAC,0x21,0x5A,0xA8,0x1B,0x53,0xA3,0x16,0x4D,0x9F,0x12,0x47,0x9B,0x0F,0x42,0x98,0x0F,0x3D,0x94,0x0F,0x39,0x90,0x0F,0x34,0x8C,0x0F,0x30,0x89,0x0F,0x2C,0x85,0x0F,0x28,0x81,0x0F,0x24,0x7D,0x0F,0x20,0x7A,0x0F,0x1D,0x76,0x0F,0x1A,0x72,0x0F,0x16,0x6F,0x0F,0x13,0x6B,0x0F,0x11,0x67,0x10,0x0E,0x64,0x12,0x0C,0x60,0x15,0x0A,0x5D,0x18,0x08,0x59,0x1B,0x06,0x56,0x1D,0x04,0x53,0x20,0x03,0x4F,0x23,0x02,0x4C,0x26,0x01,0x49,0x29,0x01,0x46,0x2C,0x00,0x43,0x2F,0x00,0x40,0x30,0x00,0x3F,0x31,0x00,0x3F,0x31,0x00,0x3E,0x32,0x00,0x3E,0x32,0x00,0x3D,0x33,0x00,0x3D,0x33,0x00,0x3C,0x34,0x00,0x3C,0x34,0x00,0x3B,0x35,0x01,0x3B,0x36,0x01,0x3B,0x36,0x01,0x3A,0x37,0x01,0x3A,0x37,0x01,0x39,0x38,0x01,0x39,0x39,0x01,0x38,0x39,0x02,0x38,0x3A,0x02,0x37,0x3B,0x02,0x37,0x3B,0x02,0x36,0x3C,0x02,0x36,0x3C,0x03,0x35,0x3D,0x03,0x35,0x3E,0x03,0x34,0x3F,0x03,0x34,0x3F,0x04,0x34,0x40,0x04,0x33,0x41,0x04,0x33,0x41,0x04,0x32,0x42,0x05,0x32,0x43,0x05,0x31,0x43,0x05,0x31,0x44,0x06,0x30,0x45,0x06,0x30,0x46,0x06,0x30,0x46,0x07,0x2F,0x47,0x07,0x2F,0x48,0x08,0x2E,0x49,0x08,0x2E,0x49,0x08,0x2E,0x4A,0x09,0x2D,0x4B,0x09,0x2D,0x4C,0x09,0x2C,0x4C,0x0A,0x2C,0x4D,0x0A,0x2B,0x4E,0x0B,0x2B,0x4F,0x0B,0x2B,0x4F,0x0C,0x2A,0x50,0x0C,0x2A,0x51,0x0D,0x29,0x52,0x0D,0x29,0x53,0x0D,0x29,0x53,0x0E,0x28,0x54,0x0E,0x28,0x55,0x0F,0x27,0x56,0x0F,0x27,0x57,0x10,0x27,0x58,0x10,0x26,0x58,0x11,0x26,0x59,0x11,0x26,0x5A,0x12,0x25,0x5B,0x13,0x25,0x5C,0x13,0x24,0x5D,0x14,0x24,0x5D,0x14,0x24,0x5E,0x15,0x23,0x5F,0x15,0x23,0x60,0x16,0x23,0x61,0x16,0x22,0x62,0x17,0x22,0x62,0x18,0x22,0x63,0x18,0x21,0x64,0x19,0x21,0x65,0x19,0x21,0x66,0x1A,0x20,0x67,0x1B,0x20,0x67,0x1B,0x20,0x68,0x1C,0x1F,0x69,0x1C,0x1F,0x6A,0x1D,0x1F,0x6B,0x1E,0x1E,0x6C,0x1E,0x1E,0x6D,0x1F,0x1E,0x6D,0x1F,0x1D,0x6E,0x20,0x1D,0x6F,0x21,0x1D,0x70,0x21,0x1C,0x71,0x22,0x1C,0x72,0x23,0x1C,0x73,0x23,0x1B,0x73,0x24,0x1B,0x74,0x25,0x1B,0x75,0x25,0x1A,0x76,0x26,0x1A,0x77,0x27,0x1A,0x78,0x27,0x1A,0x78,0x28,0x19,0x79,0x29,0x19,0x7A,0x29,0x19,0x7B,0x2A,0x18,0x7C,0x2B,0x18,0x7D,0x2B,0x18,0x7E,0x2C,0x18,0x7E,0x2D,0x17,0x7F,0x2D,0x17,0x80,0x2E,0x17,0x81,0x2F,0x16,0x82,0x2F,0x16,0x82,0x30,0x16,0x83,0x31,0x16,0x84,0x31,0x15,0x85,0x32,0x15,0x86,0x33,0x15,0x87,0x33,0x15,0x87,0x34,0x14,0x88,0x35,0x14,0x89,0x36,0x14,0x8A,0x36,0x14,0x8A,0x37,0x13,0x8B,0x38,0x13,0x8C,0x38,0x13,0x8D,0x39,0x13,0x8E,0x3A,0x13,0x8E,0x3A,0x12,0x8F,0x3B,0x12,0x90,0x3C,0x12,0x91,0x3C,0x12,0x91,0x3D,0x11,0x92,0x3E,0x11,0x93,0x3E,0x11,0x94,0x3F,0x11,0x94,0x40,0x11,0x95,0x40,0x10,0x96,0x41,0x10,0x97,0x42,0x10,0x97,0x42,0x10,0x98,0x43,0x10,0x99,0x44,0x0F,0x99,0x44,0x0F,0x9A,0x45,0x0F,0x9A,0x45,0x0F,0x9B,0x46,0x0F,0x9C,0x47,0x0F,0x9C,0x47,0x0E,0x9D,0x48,0x0E,0x9D,0x48,0x0E,0x9E,0x49,0x0E,0x9E,0x49,0x0E,0x9F,0x4A,0x0D,0xA0,0x4B,0x0D,0xA0,0x4B,0x0D,0xA1,0x4C,0x0D,0xA1,0x4C,0x0D,0xA2,0x4D,0x0C,0xA2,0x4E,0x0C,0xA3,0x4E,0x0C,0xA4,0x4F,0x0C,0xA4,0x4F,0x0C,0xA5,0x50,0x0C,0xA5,0x51,0x0C,0xA6,0x51,0x0C,0xA7,0x52,0x0C,0xA7,0x53,0x0C,0xA8,0x53,0x0C,0xA8,0x54,0x0C,0xA9,0x55,0x0C,0xAA,0x55,0x0C,0xAA,0x56,0x0C,0xAB,0x57,0x0C,0xAB,0x57,0x0C,0xAC,0x58,0x0C,0xAC,0x59,0x0C,0xAD,0x59,0x0C,0xAE,0x5A,0x0C,0xAE,0x5B,0x0C,0xAF,0x5B,0x0C,0xAF,0x5C,0x0C,0xB0,0x5D,0x0C,0xB1,0x5D,0x0C,0xB1,0x5E,0x0C,0xB2,0x5F,0x0C,0xB2,0x5F,0x0C,0xB3,0x60,0x0C,0xB4,0x61,0x0C,0xB4,0x61,0x0C,0xB5,0x62,0x0C,0xB5,0x63,0x0C,0xB6,0x64,0x0C,0xB6,0x64,0x0C,0xB7,0x65,0x0C,0xB8,0x66,0x0C,0xB8,0x66,0x0C,0xB9,0x67,0x0C,0xB9,0x68,0x0C,0xBA,0x69,0x0C,0xBB,0x69,0x0C,0xBB,0x6A,0x0C,0xBC,0x6B,0x0C,0xBC,0x6B,0x0C,0xBD,0x6C,0x0C,0xBD,0x6D,0x0C,0xBE,0x6E,0x0C,0xBF,0x6E,0x0C,0xBF,0x6F,0x0C,0xC0,0x70,0x0C,0xC0,0x71,0x0C,0xC1,0x71,0x0C,0xC2,0x72,0x0C,0xC2,0x73,0x0C,0xC3,0x74,0x0C,0xC3,0x74,0x0C,0xC4,0x75,0x0C,0xC4,0x76,0x0C,0xC5,0x76,0x0C,0xC5,0x77,0x0C,0xC6,0x78,0x0C,0xC7,0x79,0x0C,0xC7,0x79,0x0C,0xC8,0x7A,0x0C,0xC8,0x7B,0x0C,0xC9,0x7C,0x0C,0xC9,0x7C,0x0C,0xCA,0x7D,0x0C,0xCB,0x7E,0x0C,0xCB,0x7F,0x0C,0xCC,0x7F,0x0C,0xCC,0x80,0x0C,0xCD,0x81,0x0C,0xCD,0x82,0x0C,0xCE,0x82,0x0C,0xCE,0x83,0x0C,0xCF,0x84,0x0C,0xCF,0x85,0x0C,0xD0,0x85,0x0C,0xD0,0x86,0x0C,0xD1,0x87,0x0C,0xD2,0x88,0x0C,0xD2,0x88,0x0C,0xD3,0x89,0x0C,0xD3,0x8A,0x0C,0xD4,0x8B,0x0C,0xD4,0x8B,0x0C,0xD5,0x8C,0x0C,0xD5,0x8D,0x0C,0xD6,0x8D,0x0C,0xD6,0x8E,0x0C,0xD7,0x8F,0x0C,0xD7,0x90,0x0C,0xD8,0x90,0x0C,0xD8,0x91,0x0C,0xD9,0x92,0x0C,0xD9,0x93,0x0C,0xDA,0x93,0x0C,0xDA,0x94,0x0C,0xDB,0x95,0x0C,0xDB,0x95,0x0C,0xDC,0x96,0x0C,0xDC,0x97,0x0C,0xDD,0x98,0x0C,0xDD,0x98,0x0C,0xDE,0x99,0x0C,0xDE,0x9A,0x0C,0xDE,0x9A,0x0C,0xDF,0x9B,0x0C,0xDF,0x9C,0x0C,0xE0,0x9D,0x0C,0xE0,0x9D,0x0C,0xE1,0x9E,0x0C,0xE1,0x9F,0x0C,0xE2,0x9F,0x0C,0xE2,0xA0,0x0C,0xE3,0xA1,0x0C,0xE3,0xA1,0x0C,0xE3,0xA2,0x0C,0xE4,0xA3,0x0C,0xE4,0xA3,0x0C,0xE5,0xA4,0x0C,0xE5,0xA5,0x0C,0xE5,0xA5,0x0C,0xE6,0xA6,0x0C,0xE6,0xA7,0x0C,0xE7,0xA7,0x0C,0xE7,0xA8,0x0C,0xE8,0xA9,0x0C,0xE8,0xA9,0x0C,0xE8,0xAA,0x0C,0xE9,0xAB,0x0C,0xE9,0xAB,0x0C,0xE9,0xAC,0x0C,0xEA,0xAC,0x0C,0xEA,0xAD,0x0C,0xEB,0xAE,0x0C,0xEB,0xAE,0x0C,0xEB,0xAF,0x0C,0xEC,0xB0,0x0C,0xEC,0xB0,0x0C,0xEC,0xB1,0x0C,0xED,0xB1,0x0C,0xED,0xB2,0x0C,0xED,0xB3,0x0C,0xEE,0xB3,0x0C,0xEE,0xB4,0x0C,0xEE,0xB4,0x0C,0xEF,0xB5,0x0C,0xEF,0xB5,0x0C,0xEF,0xB6,0x0C,0xF0,0xB7,0x0C,0xF0,0xB7,0x0C,0xF0,0xB8,0x0D,0xF1,0xB8,0x0E,0xF1,0xB9,0x0F,0xF1,0xBA,0x10,0xF1,0xBA,0x11,0xF2,0xBB,0x12,0xF2,0xBB,0x13,0xF2,0xBC,0x14,0xF3,0xBD,0x15,0xF3,0xBD,0x16,0xF3,0xBE,0x17,0xF3,0xBE,0x18,0xF4,0xBF,0x19,0xF4,0xC0,0x1B,0xF4,0xC0,0x1C,0xF4,0xC1,0x1D,0xF5,0xC1,0x1E,0xF5,0xC2,0x1F,0xF5,0xC3,0x21,0xF5,0xC3,0x22,0xF6,0xC4,0x23,0xF6,0xC4,0x25,0xF6,0xC5,0x26,0xF6,0xC6,0x28,0xF7,0xC6,0x29,0xF7,0xC7,0x2A,0xF7,0xC7,0x2C,0xF7,0xC8,0x2D,0xF7,0xC8,0x2F,0xF8,0xC9,0x31,0xF8,0xCA,0x32,0xF8,0xCA,0x34,0xF8,0xCB,0x35,0xF8,0xCB,0x37,0xF8,0xCC,0x38,0xF9,0xCC,0x3A,0xF9,0xCD,0x3C,0xF9,0xCE,0x3D,0xF9,0xCE,0x3F,0xF9,0xCF,0x41,0xF9,0xCF,0x43,0xFA,0xD0,0x44,0xFA,0xD0,0x46,0xFA,0xD1,0x48,0xFA,0xD2,0x4A,0xFA,0xD2,0x4B,0xFA,0xD3,0x4D,0xFA,0xD3,0x4F,0xFA,0xD4,0x51,0xFB,0xD4,0x53,0xFB,0xD5,0x54,0xFB,0xD5,0x56,0xFB,0xD6,0x58,0xFB,0xD7,0x5A,0xFB,0xD7,0x5C,0xFB,0xD8,0x5E,0xFB,0xD8,0x60,0xFB,0xD9,0x62,0xFC,0xD9,0x64,0xFC,0xDA,0x65,0xFC,0xDA,0x67,0xFC,0xDB,0x69,0xFC,0xDB,0x6B,0xFC,0xDC,0x6D,0xFC,0xDC,0x6F,0xFC,0xDD,0x71,0xFC,0xDD,0x73,0xFC,0xDE,0x75,0xFC,0xDE,0x77,0xFC,0xDF,0x79,0xFC,0xDF,0x7B,0xFD,0xE0,0x7D,0xFD,0xE0,0x7F,0xFD,0xE1,0x81,0xFD,0xE1,0x83,0xFD,0xE2,0x85,0xFD,0xE2,0x87,0xFD,0xE3,0x89,0xFD,0xE3,0x8B,0xFD,0xE4,0x8D,0xFD,0xE4,0x8F,0xFD,0xE5,0x91,0xFD,0xE5,0x93,0xFD,0xE6,0x95,0xFD,0xE6,0x97,0xFD,0xE7,0x99,0xFD,0xE7,0x9B,0xFD,0xE8,0x9C,0xFD,0xE8,0x9E,0xFD,0xE9,0xA0,0xFD,0xE9,0xA2,0xFD,0xEA,0xA4,0xFD,0xEA,0xA6,0xFD,0xEA,0xA8,0xFE,0xEB,0xAA,0xFE,0xEB,0xAC,0xFE,0xEC,0xAE,0xFE,0xEC,0xB0,0xFE,0xED,0xB2,0xFE,0xED,0xB3,0xFE,0xED,0xB5,0xFE,0xEE,0xB7,0xFE,0xEE,0xB9,0xFE,0xEF,0xBB,0xFE,0xEF,0xBD,0xFE,0xF0,0xBE,0xFE,0xF0,0xC0,0xFE,0xF0,0xC2,0xFE,0xF1,0xC4,0xFE,0xF1,0xC6,0xFE,0xF2,0xC7,0xFE,0xF2,0xC9,0xFE,0xF2,0xCB,0xFE,0xF3,0xCD,0xFE,0xF3,0xCE,0xFE,0xF4,0xD0,0xFE,0xF4,0xD2,0xFE,0xF4,0xD3,0xFE,0xF5,0xD5,0xFE,0xF5,0xD6,0xFE,0xF5,0xD8,0xFE,0xF6,0xDA,0xFE,0xF6,0xDB,0xFE,0xF6,0xDD,0xFE,0xF7,0xDE,0xFE,0xF7,0xE0,0xFE,0xF7,0xE1,0xFE,0xF8,0xE3,0xFE,0xF8,0xE4,0xFE,0xF8,0xE5,0xFE,0xF9,0xE7,0xFE,0xF9,0xE8,0xFE,0xF9,0xE9,0xFE,0xFA,0xEB,0xFE,0xFA,0xEC,0xFE,0xFA,0xED,0xFE,0xFB,0xEF,0xFE,0xFB,0xF0,0xFE,0xFB,0xF1,0xFE,0xFC,0xF2,0xFF,0xFC,0xF3,0xFF,0xFC,0xF5,0xFF,0xFC,0xF6,0xFF,0xFD,0xF7,0xFF,0xFD,0xF8,0xFF,0xFD,0xF9,0xFF,0xFE,0xFA,0xFF,0xFE,0xFB,0xFF,0xFE,0xFC,0xFF,0xFE,0xFC,0xFF,0xFF,0xFD,0xFF,0xFF,0xFE};
-unsigned char plasma_data[] = {0x00,0x00,0x00,0x03,0x00,0x00,0x05,0x00,0x00,0x09,0x00,0x00,0x0E,0x00,0x00,0x12,0x00,0x00,0x17,0x00,0x00,0x1C,0x00,0x00,0x22,0x00,0x00,0x27,0x00,0x00,0x2C,0x00,0x00,0x32,0x00,0x00,0x37,0x00,0x00,0x3C,0x00,0x00,0x41,0x00,0x00,0x45,0x00,0x00,0x4A,0x00,0x00,0x4D,0x00,0x00,0x51,0x00,0x00,0x53,0x00,0x00,0x55,0x00,0x00,0x55,0x00,0x02,0x55,0x02,0x03,0x55,0x03,0x06,0x55,0x03,0x07,0x55,0x05,0x09,0x55,0x06,0x0C,0x55,0x06,0x0F,0x55,0x07,0x10,0x55,0x09,0x13,0x55,0x0A,0x16,0x55,0x0C,0x1A,0x55,0x0C,0x1D,0x54,0x0E,0x20,0x53,0x10,0x23,0x54,0x11,0x26,0x53,0x13,0x2A,0x52,0x14,0x2E,0x51,0x15,0x31,0x50,0x17,0x35,0x50,0x19,0x38,0x4E,0x1A,0x3D,0x4D,0x1C,0x40,0x4D,0x1D,0x44,0x4C,0x1F,0x47,0x4B,0x21,0x4C,0x4A,0x23,0x4F,0x49,0x24,0x54,0x48,0x25,0x57,0x47,0x28,0x5B,0x46,0x29,0x5F,0x45,0x2B,0x62,0x44,0x2D,0x66,0x44,0x2E,0x6A,0x43,0x30,0x6E,0x42,0x32,0x72,0x41,0x33,0x76,0x40,0x35,0x79,0x3F,0x38,0x7C,0x3F,0x39,0x7F,0x3E,0x3B,0x83,0x3D,0x3D,0x86,0x3C,0x3F,0x8A,0x3B,0x40,0x8C,0x3B,0x43,0x8F,0x3B,0x44,0x92,0x3A,0x46,0x95,0x39,0x48,0x98,0x39,0x4A,0x9B,0x39,0x4C,0x9C,0x39,0x4E,0x9F,0x3A,0x4F,0xA1,0x39,0x51,0xA3,0x39,0x52,0xA4,0x39,0x54,0xA6,0x39,0x56,0xA7,0x39,0x57,0xA8,0x39,0x58,0xA8,0x3A,0x5A,0xA9,0x3A,0x5C,0xA8,0x3A,0x5D,0xA8,0x3B,0x5F,0xA8,0x3C,0x61,0xA8,0x3D,0x62,0xA8,0x3D,0x64,0xA9,0x3E,0x66,0xA8,0x3E,0x67,0xA9,0x3F,0x68,0xA8,0x40,0x6A,0xA8,0x41,0x6C,0xA8,0x42,0x6E,0xA8,0x42,0x70,0xA8,0x43,0x71,0xA8,0x44,0x73,0xA8,0x45,0x74,0xA9,0x46,0x76,0xA8,0x48,0x79,0xA8,0x49,0x7A,0xA7,0x4A,0x7C,0xA6,0x4A,0x7D,0xA5,0x4C,0x7F,0xA4,0x4D,0x81,0xA3,0x4E,0x83,0xA2,0x4E,0x85,0xA1,0x50,0x86,0xA0,0x51,0x88,0x9F,0x52,0x8A,0x9D,0x53,0x8B,0x9D,0x55,0x8D,0x9B,0x56,0x8F,0x9A,0x57,0x91,0x98,0x58,0x92,0x98,0x5A,0x94,0x97,0x5B,0x96,0x95,0x5C,0x97,0x94,0x5E,0x99,0x93,0x5F,0x9A,0x91,0x60,0x9C,0x90,0x61,0x9D,0x90,0x62,0x9F,0x8E,0x64,0xA1,0x8D,0x65,0xA2,0x8C,0x67,0xA3,0x8B,0x68,0xA5,0x8A,0x6A,0xA6,0x89,0x6A,0xA7,0x88,0x6B,0xA9,0x87,0x6D,0xAB,0x86,0x6E,0xAB,0x86,0x6F,0xAE,0x85,0x71,0xAE,0x85,0x72,0xAF,0x85,0x73,0xB0,0x84,0x75,0xB2,0x83,0x75,0xB2,0x83,0x77,0xB4,0x83,0x77,0xB5,0x83,0x79,0xB6,0x83,0x7A,0xB6,0x83,0x7B,0xB8,0x83,0x7D,0xB9,0x84,0x7E,0xB9,0x83,0x7F,0xBA,0x84,0x7F,0xBB,0x85,0x82,0xBC,0x85,0x83,0xBD,0x86,0x84,0xBD,0x87,0x85,0xBD,0x87,0x86,0xBE,0x88,0x88,0xBF,0x88,0x89,0xBF,0x89,0x8A,0xC0,0x8B,0x8B,0xC0,0x8C,0x8D,0xC1,0x8D,0x8F,0xC1,0x8E,0x90,0xC2,0x8F,0x91,0xC1,0x90,0x92,0xC2,0x91,0x94,0xC3,0x93,0x95,0xC3,0x93,0x97,0xC3,0x95,0x98,0xC3,0x96,0x99,0xC3,0x98,0x9B,0xC4,0x99,0x9C,0xC3,0x9A,0x9E,0xC4,0x9B,0x9F,0xC4,0x9D,0xA0,0xC4,0x9E,0xA2,0xC4,0x9F,0xA4,0xC4,0xA0,0xA5,0xC4,0xA2,0xA6,0xC4,0xA4,0xA8,0xC4,0xA5,0xA9,0xC5,0xA6,0xAA,0xC5,0xA8,0xAB,0xC4,0xA9,0xAC,0xC4,0xAA,0xAE,0xC4,0xAC,0xAF,0xC4,0xAD,0xB0,0xC4,0xAE,0xB2,0xC4,0xB0,0xB3,0xC4,0xB1,0xB4,0xC4,0xB3,0xB5,0xC5,0xB4,0xB6,0xC4,0xB6,0xB7,0xC4,0xB7,0xB8,0xC4,0xB7,0xBA,0xC4,0xB9,0xBA,0xC4,0xBA,0xBC,0xC4,0xBB,0xBC,0xC4,0xBC,0xBE,0xC4,0xBD,0xBF,0xC4,0xBE,0xBF,0xC4,0xBF,0xC0,0xC4,0xC0,0xC1,0xC4,0xC1,0xC2,0xC4,0xC2,0xC2,0xC4,0xC3,0xC4,0xC4,0xC3,0xC4,0xC4,0xC4}; \ No newline at end of file
+#ifndef HMAP_H
+#define HMAP_H
+static char color_data[] = {0xD9,0xFF,0xFE,0xD4,0xFB,0xFC,0xCF,0xF6,0xF9,0xC9,0xF1,0xF6,0xC2,0xEB,0xF4,0xBB,0xE5,0xF0,0xB3,0xDE,0xED,0xAA,0xD6,0xE9,0xA1,0xCF,0xE5,0x98,0xC7,0xE2,0x8E,0xBF,0xDD,0x85,0xB6,0xD9,0x7B,0xAD,0xD5,0x71,0xA5,0xD0,0x67,0x9C,0xCC,0x5D,0x93,0xC7,0x53,0x8A,0xC3,0x4A,0x82,0xBE,0x41,0x79,0xB9,0x38,0x71,0xB5,0x30,0x69,0xB0,0x28,0x61,0xAC,0x21,0x5A,0xA8,0x1B,0x53,0xA3,0x16,0x4D,0x9F,0x12,0x47,0x9B,0x0F,0x42,0x98,0x0F,0x3D,0x94,0x0F,0x39,0x90,0x0F,0x34,0x8C,0x0F,0x30,0x89,0x0F,0x2C,0x85,0x0F,0x28,0x81,0x0F,0x24,0x7D,0x0F,0x20,0x7A,0x0F,0x1D,0x76,0x0F,0x1A,0x72,0x0F,0x16,0x6F,0x0F,0x13,0x6B,0x0F,0x11,0x67,0x10,0x0E,0x64,0x12,0x0C,0x60,0x15,0x0A,0x5D,0x18,0x08,0x59,0x1B,0x06,0x56,0x1D,0x04,0x53,0x20,0x03,0x4F,0x23,0x02,0x4C,0x26,0x01,0x49,0x29,0x01,0x46,0x2C,0x00,0x43,0x2F,0x00,0x40,0x30,0x00,0x3F,0x31,0x00,0x3F,0x31,0x00,0x3E,0x32,0x00,0x3E,0x32,0x00,0x3D,0x33,0x00,0x3D,0x33,0x00,0x3C,0x34,0x00,0x3C,0x34,0x00,0x3B,0x35,0x01,0x3B,0x36,0x01,0x3B,0x36,0x01,0x3A,0x37,0x01,0x3A,0x37,0x01,0x39,0x38,0x01,0x39,0x39,0x01,0x38,0x39,0x02,0x38,0x3A,0x02,0x37,0x3B,0x02,0x37,0x3B,0x02,0x36,0x3C,0x02,0x36,0x3C,0x03,0x35,0x3D,0x03,0x35,0x3E,0x03,0x34,0x3F,0x03,0x34,0x3F,0x04,0x34,0x40,0x04,0x33,0x41,0x04,0x33,0x41,0x04,0x32,0x42,0x05,0x32,0x43,0x05,0x31,0x43,0x05,0x31,0x44,0x06,0x30,0x45,0x06,0x30,0x46,0x06,0x30,0x46,0x07,0x2F,0x47,0x07,0x2F,0x48,0x08,0x2E,0x49,0x08,0x2E,0x49,0x08,0x2E,0x4A,0x09,0x2D,0x4B,0x09,0x2D,0x4C,0x09,0x2C,0x4C,0x0A,0x2C,0x4D,0x0A,0x2B,0x4E,0x0B,0x2B,0x4F,0x0B,0x2B,0x4F,0x0C,0x2A,0x50,0x0C,0x2A,0x51,0x0D,0x29,0x52,0x0D,0x29,0x53,0x0D,0x29,0x53,0x0E,0x28,0x54,0x0E,0x28,0x55,0x0F,0x27,0x56,0x0F,0x27,0x57,0x10,0x27,0x58,0x10,0x26,0x58,0x11,0x26,0x59,0x11,0x26,0x5A,0x12,0x25,0x5B,0x13,0x25,0x5C,0x13,0x24,0x5D,0x14,0x24,0x5D,0x14,0x24,0x5E,0x15,0x23,0x5F,0x15,0x23,0x60,0x16,0x23,0x61,0x16,0x22,0x62,0x17,0x22,0x62,0x18,0x22,0x63,0x18,0x21,0x64,0x19,0x21,0x65,0x19,0x21,0x66,0x1A,0x20,0x67,0x1B,0x20,0x67,0x1B,0x20,0x68,0x1C,0x1F,0x69,0x1C,0x1F,0x6A,0x1D,0x1F,0x6B,0x1E,0x1E,0x6C,0x1E,0x1E,0x6D,0x1F,0x1E,0x6D,0x1F,0x1D,0x6E,0x20,0x1D,0x6F,0x21,0x1D,0x70,0x21,0x1C,0x71,0x22,0x1C,0x72,0x23,0x1C,0x73,0x23,0x1B,0x73,0x24,0x1B,0x74,0x25,0x1B,0x75,0x25,0x1A,0x76,0x26,0x1A,0x77,0x27,0x1A,0x78,0x27,0x1A,0x78,0x28,0x19,0x79,0x29,0x19,0x7A,0x29,0x19,0x7B,0x2A,0x18,0x7C,0x2B,0x18,0x7D,0x2B,0x18,0x7E,0x2C,0x18,0x7E,0x2D,0x17,0x7F,0x2D,0x17,0x80,0x2E,0x17,0x81,0x2F,0x16,0x82,0x2F,0x16,0x82,0x30,0x16,0x83,0x31,0x16,0x84,0x31,0x15,0x85,0x32,0x15,0x86,0x33,0x15,0x87,0x33,0x15,0x87,0x34,0x14,0x88,0x35,0x14,0x89,0x36,0x14,0x8A,0x36,0x14,0x8A,0x37,0x13,0x8B,0x38,0x13,0x8C,0x38,0x13,0x8D,0x39,0x13,0x8E,0x3A,0x13,0x8E,0x3A,0x12,0x8F,0x3B,0x12,0x90,0x3C,0x12,0x91,0x3C,0x12,0x91,0x3D,0x11,0x92,0x3E,0x11,0x93,0x3E,0x11,0x94,0x3F,0x11,0x94,0x40,0x11,0x95,0x40,0x10,0x96,0x41,0x10,0x97,0x42,0x10,0x97,0x42,0x10,0x98,0x43,0x10,0x99,0x44,0x0F,0x99,0x44,0x0F,0x9A,0x45,0x0F,0x9A,0x45,0x0F,0x9B,0x46,0x0F,0x9C,0x47,0x0F,0x9C,0x47,0x0E,0x9D,0x48,0x0E,0x9D,0x48,0x0E,0x9E,0x49,0x0E,0x9E,0x49,0x0E,0x9F,0x4A,0x0D,0xA0,0x4B,0x0D,0xA0,0x4B,0x0D,0xA1,0x4C,0x0D,0xA1,0x4C,0x0D,0xA2,0x4D,0x0C,0xA2,0x4E,0x0C,0xA3,0x4E,0x0C,0xA4,0x4F,0x0C,0xA4,0x4F,0x0C,0xA5,0x50,0x0C,0xA5,0x51,0x0C,0xA6,0x51,0x0C,0xA7,0x52,0x0C,0xA7,0x53,0x0C,0xA8,0x53,0x0C,0xA8,0x54,0x0C,0xA9,0x55,0x0C,0xAA,0x55,0x0C,0xAA,0x56,0x0C,0xAB,0x57,0x0C,0xAB,0x57,0x0C,0xAC,0x58,0x0C,0xAC,0x59,0x0C,0xAD,0x59,0x0C,0xAE,0x5A,0x0C,0xAE,0x5B,0x0C,0xAF,0x5B,0x0C,0xAF,0x5C,0x0C,0xB0,0x5D,0x0C,0xB1,0x5D,0x0C,0xB1,0x5E,0x0C,0xB2,0x5F,0x0C,0xB2,0x5F,0x0C,0xB3,0x60,0x0C,0xB4,0x61,0x0C,0xB4,0x61,0x0C,0xB5,0x62,0x0C,0xB5,0x63,0x0C,0xB6,0x64,0x0C,0xB6,0x64,0x0C,0xB7,0x65,0x0C,0xB8,0x66,0x0C,0xB8,0x66,0x0C,0xB9,0x67,0x0C,0xB9,0x68,0x0C,0xBA,0x69,0x0C,0xBB,0x69,0x0C,0xBB,0x6A,0x0C,0xBC,0x6B,0x0C,0xBC,0x6B,0x0C,0xBD,0x6C,0x0C,0xBD,0x6D,0x0C,0xBE,0x6E,0x0C,0xBF,0x6E,0x0C,0xBF,0x6F,0x0C,0xC0,0x70,0x0C,0xC0,0x71,0x0C,0xC1,0x71,0x0C,0xC2,0x72,0x0C,0xC2,0x73,0x0C,0xC3,0x74,0x0C,0xC3,0x74,0x0C,0xC4,0x75,0x0C,0xC4,0x76,0x0C,0xC5,0x76,0x0C,0xC5,0x77,0x0C,0xC6,0x78,0x0C,0xC7,0x79,0x0C,0xC7,0x79,0x0C,0xC8,0x7A,0x0C,0xC8,0x7B,0x0C,0xC9,0x7C,0x0C,0xC9,0x7C,0x0C,0xCA,0x7D,0x0C,0xCB,0x7E,0x0C,0xCB,0x7F,0x0C,0xCC,0x7F,0x0C,0xCC,0x80,0x0C,0xCD,0x81,0x0C,0xCD,0x82,0x0C,0xCE,0x82,0x0C,0xCE,0x83,0x0C,0xCF,0x84,0x0C,0xCF,0x85,0x0C,0xD0,0x85,0x0C,0xD0,0x86,0x0C,0xD1,0x87,0x0C,0xD2,0x88,0x0C,0xD2,0x88,0x0C,0xD3,0x89,0x0C,0xD3,0x8A,0x0C,0xD4,0x8B,0x0C,0xD4,0x8B,0x0C,0xD5,0x8C,0x0C,0xD5,0x8D,0x0C,0xD6,0x8D,0x0C,0xD6,0x8E,0x0C,0xD7,0x8F,0x0C,0xD7,0x90,0x0C,0xD8,0x90,0x0C,0xD8,0x91,0x0C,0xD9,0x92,0x0C,0xD9,0x93,0x0C,0xDA,0x93,0x0C,0xDA,0x94,0x0C,0xDB,0x95,0x0C,0xDB,0x95,0x0C,0xDC,0x96,0x0C,0xDC,0x97,0x0C,0xDD,0x98,0x0C,0xDD,0x98,0x0C,0xDE,0x99,0x0C,0xDE,0x9A,0x0C,0xDE,0x9A,0x0C,0xDF,0x9B,0x0C,0xDF,0x9C,0x0C,0xE0,0x9D,0x0C,0xE0,0x9D,0x0C,0xE1,0x9E,0x0C,0xE1,0x9F,0x0C,0xE2,0x9F,0x0C,0xE2,0xA0,0x0C,0xE3,0xA1,0x0C,0xE3,0xA1,0x0C,0xE3,0xA2,0x0C,0xE4,0xA3,0x0C,0xE4,0xA3,0x0C,0xE5,0xA4,0x0C,0xE5,0xA5,0x0C,0xE5,0xA5,0x0C,0xE6,0xA6,0x0C,0xE6,0xA7,0x0C,0xE7,0xA7,0x0C,0xE7,0xA8,0x0C,0xE8,0xA9,0x0C,0xE8,0xA9,0x0C,0xE8,0xAA,0x0C,0xE9,0xAB,0x0C,0xE9,0xAB,0x0C,0xE9,0xAC,0x0C,0xEA,0xAC,0x0C,0xEA,0xAD,0x0C,0xEB,0xAE,0x0C,0xEB,0xAE,0x0C,0xEB,0xAF,0x0C,0xEC,0xB0,0x0C,0xEC,0xB0,0x0C,0xEC,0xB1,0x0C,0xED,0xB1,0x0C,0xED,0xB2,0x0C,0xED,0xB3,0x0C,0xEE,0xB3,0x0C,0xEE,0xB4,0x0C,0xEE,0xB4,0x0C,0xEF,0xB5,0x0C,0xEF,0xB5,0x0C,0xEF,0xB6,0x0C,0xF0,0xB7,0x0C,0xF0,0xB7,0x0C,0xF0,0xB8,0x0D,0xF1,0xB8,0x0E,0xF1,0xB9,0x0F,0xF1,0xBA,0x10,0xF1,0xBA,0x11,0xF2,0xBB,0x12,0xF2,0xBB,0x13,0xF2,0xBC,0x14,0xF3,0xBD,0x15,0xF3,0xBD,0x16,0xF3,0xBE,0x17,0xF3,0xBE,0x18,0xF4,0xBF,0x19,0xF4,0xC0,0x1B,0xF4,0xC0,0x1C,0xF4,0xC1,0x1D,0xF5,0xC1,0x1E,0xF5,0xC2,0x1F,0xF5,0xC3,0x21,0xF5,0xC3,0x22,0xF6,0xC4,0x23,0xF6,0xC4,0x25,0xF6,0xC5,0x26,0xF6,0xC6,0x28,0xF7,0xC6,0x29,0xF7,0xC7,0x2A,0xF7,0xC7,0x2C,0xF7,0xC8,0x2D,0xF7,0xC8,0x2F,0xF8,0xC9,0x31,0xF8,0xCA,0x32,0xF8,0xCA,0x34,0xF8,0xCB,0x35,0xF8,0xCB,0x37,0xF8,0xCC,0x38,0xF9,0xCC,0x3A,0xF9,0xCD,0x3C,0xF9,0xCE,0x3D,0xF9,0xCE,0x3F,0xF9,0xCF,0x41,0xF9,0xCF,0x43,0xFA,0xD0,0x44,0xFA,0xD0,0x46,0xFA,0xD1,0x48,0xFA,0xD2,0x4A,0xFA,0xD2,0x4B,0xFA,0xD3,0x4D,0xFA,0xD3,0x4F,0xFA,0xD4,0x51,0xFB,0xD4,0x53,0xFB,0xD5,0x54,0xFB,0xD5,0x56,0xFB,0xD6,0x58,0xFB,0xD7,0x5A,0xFB,0xD7,0x5C,0xFB,0xD8,0x5E,0xFB,0xD8,0x60,0xFB,0xD9,0x62,0xFC,0xD9,0x64,0xFC,0xDA,0x65,0xFC,0xDA,0x67,0xFC,0xDB,0x69,0xFC,0xDB,0x6B,0xFC,0xDC,0x6D,0xFC,0xDC,0x6F,0xFC,0xDD,0x71,0xFC,0xDD,0x73,0xFC,0xDE,0x75,0xFC,0xDE,0x77,0xFC,0xDF,0x79,0xFC,0xDF,0x7B,0xFD,0xE0,0x7D,0xFD,0xE0,0x7F,0xFD,0xE1,0x81,0xFD,0xE1,0x83,0xFD,0xE2,0x85,0xFD,0xE2,0x87,0xFD,0xE3,0x89,0xFD,0xE3,0x8B,0xFD,0xE4,0x8D,0xFD,0xE4,0x8F,0xFD,0xE5,0x91,0xFD,0xE5,0x93,0xFD,0xE6,0x95,0xFD,0xE6,0x97,0xFD,0xE7,0x99,0xFD,0xE7,0x9B,0xFD,0xE8,0x9C,0xFD,0xE8,0x9E,0xFD,0xE9,0xA0,0xFD,0xE9,0xA2,0xFD,0xEA,0xA4,0xFD,0xEA,0xA6,0xFD,0xEA,0xA8,0xFE,0xEB,0xAA,0xFE,0xEB,0xAC,0xFE,0xEC,0xAE,0xFE,0xEC,0xB0,0xFE,0xED,0xB2,0xFE,0xED,0xB3,0xFE,0xED,0xB5,0xFE,0xEE,0xB7,0xFE,0xEE,0xB9,0xFE,0xEF,0xBB,0xFE,0xEF,0xBD,0xFE,0xF0,0xBE,0xFE,0xF0,0xC0,0xFE,0xF0,0xC2,0xFE,0xF1,0xC4,0xFE,0xF1,0xC6,0xFE,0xF2,0xC7,0xFE,0xF2,0xC9,0xFE,0xF2,0xCB,0xFE,0xF3,0xCD,0xFE,0xF3,0xCE,0xFE,0xF4,0xD0,0xFE,0xF4,0xD2,0xFE,0xF4,0xD3,0xFE,0xF5,0xD5,0xFE,0xF5,0xD6,0xFE,0xF5,0xD8,0xFE,0xF6,0xDA,0xFE,0xF6,0xDB,0xFE,0xF6,0xDD,0xFE,0xF7,0xDE,0xFE,0xF7,0xE0,0xFE,0xF7,0xE1,0xFE,0xF8,0xE3,0xFE,0xF8,0xE4,0xFE,0xF8,0xE5,0xFE,0xF9,0xE7,0xFE,0xF9,0xE8,0xFE,0xF9,0xE9,0xFE,0xFA,0xEB,0xFE,0xFA,0xEC,0xFE,0xFA,0xED,0xFE,0xFB,0xEF,0xFE,0xFB,0xF0,0xFE,0xFB,0xF1,0xFE,0xFC,0xF2,0xFF,0xFC,0xF3,0xFF,0xFC,0xF5,0xFF,0xFC,0xF6,0xFF,0xFD,0xF7,0xFF,0xFD,0xF8,0xFF,0xFD,0xF9,0xFF,0xFE,0xFA,0xFF,0xFE,0xFB,0xFF,0xFE,0xFC,0xFF,0xFE,0xFC,0xFF,0xFF,0xFD,0xFF,0xFF,0xFE};
+static char plasma_data[] = {0x00,0x00,0x00,0x03,0x00,0x00,0x05,0x00,0x00,0x09,0x00,0x00,0x0E,0x00,0x00,0x12,0x00,0x00,0x17,0x00,0x00,0x1C,0x00,0x00,0x22,0x00,0x00,0x27,0x00,0x00,0x2C,0x00,0x00,0x32,0x00,0x00,0x37,0x00,0x00,0x3C,0x00,0x00,0x41,0x00,0x00,0x45,0x00,0x00,0x4A,0x00,0x00,0x4D,0x00,0x00,0x51,0x00,0x00,0x53,0x00,0x00,0x55,0x00,0x00,0x55,0x00,0x02,0x55,0x02,0x03,0x55,0x03,0x06,0x55,0x03,0x07,0x55,0x05,0x09,0x55,0x06,0x0C,0x55,0x06,0x0F,0x55,0x07,0x10,0x55,0x09,0x13,0x55,0x0A,0x16,0x55,0x0C,0x1A,0x55,0x0C,0x1D,0x54,0x0E,0x20,0x53,0x10,0x23,0x54,0x11,0x26,0x53,0x13,0x2A,0x52,0x14,0x2E,0x51,0x15,0x31,0x50,0x17,0x35,0x50,0x19,0x38,0x4E,0x1A,0x3D,0x4D,0x1C,0x40,0x4D,0x1D,0x44,0x4C,0x1F,0x47,0x4B,0x21,0x4C,0x4A,0x23,0x4F,0x49,0x24,0x54,0x48,0x25,0x57,0x47,0x28,0x5B,0x46,0x29,0x5F,0x45,0x2B,0x62,0x44,0x2D,0x66,0x44,0x2E,0x6A,0x43,0x30,0x6E,0x42,0x32,0x72,0x41,0x33,0x76,0x40,0x35,0x79,0x3F,0x38,0x7C,0x3F,0x39,0x7F,0x3E,0x3B,0x83,0x3D,0x3D,0x86,0x3C,0x3F,0x8A,0x3B,0x40,0x8C,0x3B,0x43,0x8F,0x3B,0x44,0x92,0x3A,0x46,0x95,0x39,0x48,0x98,0x39,0x4A,0x9B,0x39,0x4C,0x9C,0x39,0x4E,0x9F,0x3A,0x4F,0xA1,0x39,0x51,0xA3,0x39,0x52,0xA4,0x39,0x54,0xA6,0x39,0x56,0xA7,0x39,0x57,0xA8,0x39,0x58,0xA8,0x3A,0x5A,0xA9,0x3A,0x5C,0xA8,0x3A,0x5D,0xA8,0x3B,0x5F,0xA8,0x3C,0x61,0xA8,0x3D,0x62,0xA8,0x3D,0x64,0xA9,0x3E,0x66,0xA8,0x3E,0x67,0xA9,0x3F,0x68,0xA8,0x40,0x6A,0xA8,0x41,0x6C,0xA8,0x42,0x6E,0xA8,0x42,0x70,0xA8,0x43,0x71,0xA8,0x44,0x73,0xA8,0x45,0x74,0xA9,0x46,0x76,0xA8,0x48,0x79,0xA8,0x49,0x7A,0xA7,0x4A,0x7C,0xA6,0x4A,0x7D,0xA5,0x4C,0x7F,0xA4,0x4D,0x81,0xA3,0x4E,0x83,0xA2,0x4E,0x85,0xA1,0x50,0x86,0xA0,0x51,0x88,0x9F,0x52,0x8A,0x9D,0x53,0x8B,0x9D,0x55,0x8D,0x9B,0x56,0x8F,0x9A,0x57,0x91,0x98,0x58,0x92,0x98,0x5A,0x94,0x97,0x5B,0x96,0x95,0x5C,0x97,0x94,0x5E,0x99,0x93,0x5F,0x9A,0x91,0x60,0x9C,0x90,0x61,0x9D,0x90,0x62,0x9F,0x8E,0x64,0xA1,0x8D,0x65,0xA2,0x8C,0x67,0xA3,0x8B,0x68,0xA5,0x8A,0x6A,0xA6,0x89,0x6A,0xA7,0x88,0x6B,0xA9,0x87,0x6D,0xAB,0x86,0x6E,0xAB,0x86,0x6F,0xAE,0x85,0x71,0xAE,0x85,0x72,0xAF,0x85,0x73,0xB0,0x84,0x75,0xB2,0x83,0x75,0xB2,0x83,0x77,0xB4,0x83,0x77,0xB5,0x83,0x79,0xB6,0x83,0x7A,0xB6,0x83,0x7B,0xB8,0x83,0x7D,0xB9,0x84,0x7E,0xB9,0x83,0x7F,0xBA,0x84,0x7F,0xBB,0x85,0x82,0xBC,0x85,0x83,0xBD,0x86,0x84,0xBD,0x87,0x85,0xBD,0x87,0x86,0xBE,0x88,0x88,0xBF,0x88,0x89,0xBF,0x89,0x8A,0xC0,0x8B,0x8B,0xC0,0x8C,0x8D,0xC1,0x8D,0x8F,0xC1,0x8E,0x90,0xC2,0x8F,0x91,0xC1,0x90,0x92,0xC2,0x91,0x94,0xC3,0x93,0x95,0xC3,0x93,0x97,0xC3,0x95,0x98,0xC3,0x96,0x99,0xC3,0x98,0x9B,0xC4,0x99,0x9C,0xC3,0x9A,0x9E,0xC4,0x9B,0x9F,0xC4,0x9D,0xA0,0xC4,0x9E,0xA2,0xC4,0x9F,0xA4,0xC4,0xA0,0xA5,0xC4,0xA2,0xA6,0xC4,0xA4,0xA8,0xC4,0xA5,0xA9,0xC5,0xA6,0xAA,0xC5,0xA8,0xAB,0xC4,0xA9,0xAC,0xC4,0xAA,0xAE,0xC4,0xAC,0xAF,0xC4,0xAD,0xB0,0xC4,0xAE,0xB2,0xC4,0xB0,0xB3,0xC4,0xB1,0xB4,0xC4,0xB3,0xB5,0xC5,0xB4,0xB6,0xC4,0xB6,0xB7,0xC4,0xB7,0xB8,0xC4,0xB7,0xBA,0xC4,0xB9,0xBA,0xC4,0xBA,0xBC,0xC4,0xBB,0xBC,0xC4,0xBC,0xBE,0xC4,0xBD,0xBF,0xC4,0xBE,0xBF,0xC4,0xBF,0xC0,0xC4,0xC0,0xC1,0xC4,0xC1,0xC2,0xC4,0xC2,0xC2,0xC4,0xC3,0xC4,0xC4,0xC3,0xC4,0xC4,0xC4};
+#endif \ No newline at end of file
diff --git a/interface.c b/interface.c
new file mode 100644
index 0000000..bb8f7cd
--- /dev/null
+++ b/interface.c
@@ -0,0 +1,15 @@
+#include "powder.h"
+#include "interface.h"
+
+
+void menu_count(void)
+{
+ int i=0;
+ msections[SC_WALL].itemcount = UI_WALLCOUNT-4;
+ msections[SC_SPECIAL].itemcount = 4;
+ for(i=0; i<PT_NUM; i++)
+ {
+ msections[ptypes[i].menusection].itemcount+=ptypes[i].menu;
+ }
+
+} \ No newline at end of file
diff --git a/interface.h b/interface.h
index 5816897..e37fa0c 100644
--- a/interface.h
+++ b/interface.h
@@ -63,4 +63,5 @@ static menu_section msections[] =
{"\xCC", "Special", 0},
};
+void menu_count(void);
#endif \ No newline at end of file
diff --git a/main.c b/main.c
index b166535..8252279 100644
--- a/main.c
+++ b/main.c
@@ -100,9 +100,7 @@ int legacy_enable = 0; //Used to disable new features such as heat, will be set
int death = 1, framerender = 0;
int amd = 1;
-unsigned char fire_r[YRES/CELL][XRES/CELL];
-unsigned char fire_g[YRES/CELL][XRES/CELL];
-unsigned char fire_b[YRES/CELL][XRES/CELL];
+
#define MAXSIGNS 16
@@ -116,29 +114,7 @@ struct sign
* AIR FLOW SIMULATOR *
***********************************************************/
-unsigned char bmap[YRES/CELL][XRES/CELL];
-unsigned char emap[YRES/CELL][XRES/CELL];
-
-unsigned char cb_bmap[YRES/CELL][XRES/CELL];
-unsigned char cb_emap[YRES/CELL][XRES/CELL];
-
int numCores = 4;
-float kernel[9];
-void make_kernel(void)
-{
- int i, j;
- float s = 0.0f;
- for(j=-1; j<2; j++)
- for(i=-1; i<2; i++)
- {
- kernel[(i+1)+3*(j+1)] = expf(-2.0f*(i*i+j*j));
- s += kernel[(i+1)+3*(j+1)];
- }
- s = 1.0f / s;
- for(j=-1; j<2; j++)
- for(i=-1; i<2; i++)
- kernel[(i+1)+3*(j+1)] *= s;
-}
int core_count()
{
@@ -165,3373 +141,13 @@ int core_count()
return numCPU;
}
-void update_air(void)
-{
- int x, y, i, j;
- float dp, dx, dy, f, tx, ty;
-
- for(y=1; y<YRES/CELL; y++)
- for(x=1; x<XRES/CELL; x++)
- {
- dp = 0.0f;
- dp += vx[y][x-1] - vx[y][x];
- dp += vy[y-1][x] - vy[y][x];
- pv[y][x] *= PLOSS;
- pv[y][x] += dp*TSTEPP;
- }
-
- for(y=0; y<YRES/CELL-1; y++)
- for(x=0; x<XRES/CELL-1; x++)
- {
- dx = dy = 0.0f;
- dx += pv[y][x] - pv[y][x+1];
- dy += pv[y][x] - pv[y+1][x];
- vx[y][x] *= VLOSS;
- vy[y][x] *= VLOSS;
- vx[y][x] += dx*TSTEPV;
- vy[y][x] += dy*TSTEPV;
- if(bmap[y][x]==1 || bmap[y][x+1]==1 ||
- bmap[y][x]==8 || bmap[y][x+1]==8 ||
- (bmap[y][x]==7 && !emap[y][x]) ||
- (bmap[y][x+1]==7 && !emap[y][x+1]))
- vx[y][x] = 0;
- if(bmap[y][x]==1 || bmap[y+1][x]==1 ||
- bmap[y][x]==8 || bmap[y+1][x]==8 ||
- (bmap[y][x]==7 && !emap[y][x]) ||
- (bmap[y+1][x]==7 && !emap[y+1][x]))
- vy[y][x] = 0;
- }
-
- for(y=0; y<YRES/CELL; y++)
- for(x=0; x<XRES/CELL; x++)
- {
- dx = 0.0f;
- dy = 0.0f;
- dp = 0.0f;
- for(j=-1; j<2; j++)
- for(i=-1; i<2; i++)
- if(y+j>0 && y+j<YRES/CELL-1 &&
- x+i>0 && x+i<XRES/CELL-1 &&
- bmap[y+j][x+i]!=1 &&
- bmap[y+j][x+i]!=8 &&
- (bmap[y+j][x+i]!=7 || emap[y+j][x+i]))
- {
- f = kernel[i+1+(j+1)*3];
- dx += vx[y+j][x+i]*f;
- dy += vy[y+j][x+i]*f;
- dp += pv[y+j][x+i]*f;
- }
- else
- {
- f = kernel[i+1+(j+1)*3];
- dx += vx[y][x]*f;
- dy += vy[y][x]*f;
- dp += pv[y][x]*f;
- }
-
- tx = x - dx*0.7f;
- ty = y - dy*0.7f;
- i = (int)tx;
- j = (int)ty;
- tx -= i;
- ty -= j;
- if(i>=2 && i<XRES/CELL-3 &&
- j>=2 && j<YRES/CELL-3)
- {
- dx *= 1.0f - VADV;
- dy *= 1.0f - VADV;
-
- dx += VADV*(1.0f-tx)*(1.0f-ty)*vx[j][i];
- dy += VADV*(1.0f-tx)*(1.0f-ty)*vy[j][i];
-
- dx += VADV*tx*(1.0f-ty)*vx[j][i+1];
- dy += VADV*tx*(1.0f-ty)*vy[j][i+1];
-
- dx += VADV*(1.0f-tx)*ty*vx[j+1][i];
- dy += VADV*(1.0f-tx)*ty*vy[j+1][i];
-
- dx += VADV*tx*ty*vx[j+1][i+1];
- dy += VADV*tx*ty*vy[j+1][i+1];
- }
-
- if(bmap[y][x] == 4)
- {
- dx += fvx[y][x];
- dy += fvy[y][x];
- }
-
- if(dp > 256.0f) dp = 256.0f;
- if(dp < -256.0f) dp = -256.0f;
- if(dx > 256.0f) dx = 256.0f;
- if(dx < -256.0f) dx = -256.0f;
- if(dy > 256.0f) dy = 256.0f;
- if(dy < -256.0f) dy = -256.0f;
-
- ovx[y][x] = dx;
- ovy[y][x] = dy;
- opv[y][x] = dp;
- }
- memcpy(vx, ovx, sizeof(vx));
- memcpy(vy, ovy, sizeof(vy));
- memcpy(pv, opv, sizeof(pv));
-}
-
-void *update_air_th(void *arg)
-{
- update_air();
- return NULL;
-}
-
/***********************************************************
* PARTICLE SIMULATOR *
***********************************************************/
-particle *parts;
-particle *cb_parts;
-
-float player[20]; //[0] is a command cell, [3]-[18] are legs positions, [19] is index
-int isplayer = 0; //It shows is player spawned or not
int mousex, mousey = 0; //They contain mouse position
-void menu_count(void)
-{
- int i=0;
- msections[SC_WALL].itemcount = UI_WALLCOUNT-4;
- msections[SC_SPECIAL].itemcount = 4;
- for(i=0; i<PT_NUM; i++)
- {
- msections[ptypes[i].menusection].itemcount+=ptypes[i].menu;
- }
-
-}
-
-int pfree;
-
-unsigned pmap[YRES][XRES];
-unsigned cb_pmap[YRES][XRES];
-
-int try_move(int i, int x, int y, int nx, int ny)
-{
- unsigned r;
-
-
- if(nx<0 || ny<0 || nx>=XRES || ny>=YRES)
- return 0;
- if(x==nx && y==ny)
- return 1;
- r = pmap[ny][nx];
- if(r && (r>>8)<NPART)
- r = (r&~0xFF) | parts[r>>8].type;
-
- if(parts[i].type==PT_PHOT&&((r&0xFF)==PT_GLAS||(r&0xFF)==PT_PHOT||(r&0xFF)==PT_CLNE||((r&0xFF)==PT_LCRY&&parts[r>>8].life > 5)))
- {
- return 1;
- }
-
- if((r&0xFF)==PT_VOID)
- {
- parts[i].type=PT_NONE;
- return 0;
- }
- if((r&0xFF)==PT_BHOL)
- {
- parts[i].type=PT_NONE;
- if(!legacy_enable)
- {
- parts[r>>8].temp = restrict_flt(parts[r>>8].temp+parts[i].temp/2, MIN_TEMP, MAX_TEMP);//3.0f;
- }
- return 0;
- }
-
- if(parts[i].type==PT_STKM) //Stick man's head shouldn't collide
- {
- return 1;
- }
-
- if(bmap[ny/CELL][nx/CELL]==12 && !emap[y/CELL][x/CELL])
- {
- return 1;
- }
- if(bmap[ny/CELL][nx/CELL]==13 && ptypes[parts[i].type].falldown!=0 && parts[i].type!=PT_FIRE)
- {
- return 0;
- }
- if((bmap[y/CELL][x/CELL]==12 && !emap[y/CELL][x/CELL]) && (bmap[ny/CELL][nx/CELL]!=12 && !emap[ny/CELL][nx/CELL]))
- {
- return 0;
- }
-
- if(ptypes[parts[i].type].falldown!=2 && bmap[ny/CELL][nx/CELL]==3)
- return 0;
- if((parts[i].type==PT_NEUT ||parts[i].type==PT_PHOT) && bmap[ny/CELL][nx/CELL]==7 && !emap[ny/CELL][nx/CELL])
- return 0;
- if(r && (r>>8)<NPART && ptypes[r&0xFF].falldown!=2 && bmap[y/CELL][x/CELL]==3)
- return 0;
-
- if(bmap[ny/CELL][nx/CELL]==9)
- return 0;
-
- if(ptypes[parts[i].type].falldown!=1 && bmap[ny/CELL][nx/CELL]==10)
- return 0;
-
- if (r && ((r&0xFF) >= PT_NUM || !can_move[parts[i].type][(r&0xFF)]))
- return 0;
-
- if(parts[i].type==PT_CNCT && y<ny && (pmap[y+1][x]&0xFF)==PT_CNCT)
- {
- return 0;
- }
-
- pmap[ny][nx] = (i<<8)|parts[i].type;
- pmap[y][x] = r;
- if(r && (r>>8)<NPART)
- {
- r >>= 8;
- parts[r].x += x-nx;
- parts[r].y += y-ny;
- }
-
- return 1;
-}
-
-void kill_part(int i)
-{
- int x, y;
- parts[i].type = PT_NONE;
-
- x = (int)(parts[i].x+0.5f);
- y = (int)(parts[i].y+0.5f);
-
- if(x>=0 && y>=0 && x<XRES && y<YRES)
- pmap[y][x] = 0;
-
- parts[i].life = pfree;
- pfree = i;
-}
-
-#ifdef WIN32
-_inline int create_part(int p, int x, int y, int t)
-#else
-inline int create_part(int p, int x, int y, int t)
-#endif
-{
- int i;
-
- if(x<0 || y<0 || x>=XRES || y>=YRES)
- return -1;
-
- if(t==SPC_HEAT||t==SPC_COOL)
- {
- if((pmap[y][x]&0xFF)!=PT_NONE&&(pmap[y][x]&0xFF)<PT_NUM)
- {
- if(t==SPC_HEAT&&parts[pmap[y][x]>>8].temp<MAX_TEMP)
- {
- parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp + 4.0f, MIN_TEMP, MAX_TEMP);
- }
- if(t==SPC_COOL&&parts[pmap[y][x]>>8].temp>MIN_TEMP)
- {
- parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp - 4.0f, MIN_TEMP, MAX_TEMP);
- }
- return pmap[y][x]>>8;
- }
- else
- {
- return -1;
- }
- }
- 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)
- {
- pv[y/CELL][x/CELL+1] += 0.03f;
- if(y+CELL<YRES)
- 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;
- }
- return -1;
- }
-
- if(t==PT_SPRK)
- {
- if((pmap[y][x]&0xFF)!=PT_METL &&
- (pmap[y][x]&0xFF)!=PT_PSCN &&
- (pmap[y][x]&0xFF)!=PT_NSCN &&
- (pmap[y][x]&0xFF)!=PT_NTCT &&
- (pmap[y][x]&0xFF)!=PT_PTCT &&
- (pmap[y][x]&0xFF)!=PT_WATR &&
- (pmap[y][x]&0xFF)!=PT_SLTW &&
- (pmap[y][x]&0xFF)!=PT_BMTL &&
- (pmap[y][x]&0xFF)!=PT_RBDM &&
- (pmap[y][x]&0xFF)!=PT_LRBD &&
- (pmap[y][x]&0xFF)!=PT_ETRD &&
- (pmap[y][x]&0xFF)!=PT_BRMT &&
- (pmap[y][x]&0xFF)!=PT_NBLE &&
- (pmap[y][x]&0xFF)!=PT_INWR)
- 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;
- pmap[y][x] = (pmap[y][x]&~0xFF) | PT_SPRK;
- return pmap[y][x]>>8;
- }
-
- if(p==-1)
- {
- if(pmap[y][x])
- return -1;
- if(pfree == -1)
- return -1;
- i = pfree;
- pfree = parts[i].life;
- }
- else
- i = p;
-
- if(t==PT_GLAS)
- {
- parts[i].pavg[1] = pv[y/CELL][x/CELL];
- }
- if(t!=PT_STKM)
- {
- parts[i].x = (float)x;
- parts[i].y = (float)y;
- parts[i].type = t;
- parts[i].vx = 0;
- parts[i].vy = 0;
- parts[i].life = 0;
- parts[i].ctype = 0;
- parts[i].temp = ptypes[t].heat;
- }
- if(t==PT_ACID)
- {
- parts[i].life = 75;
- }
- /*Testing
- if(t==PT_WOOD){
- parts[i].life = 150;
- }
- End Testing*/
- if(t==PT_FIRE)
- parts[i].life = rand()%50+120;
- if(t==PT_PLSM)
- parts[i].life = rand()%150+50;
- if(t==PT_LAVA)
- parts[i].life = rand()%120+240;
- if(t==PT_NBLE)
- parts[i].life = 0;
- if(t==PT_NEUT)
- {
- float r = (rand()%128+128)/127.0f;
- float a = (rand()%360)*3.14159f/180.0f;
- parts[i].life = rand()%480+480;
- parts[i].vx = r*cosf(a);
- parts[i].vy = r*sinf(a);
- }
- if(t==PT_PHOT)
- {
- float r = (rand()%3-1)*3;
- float a = (rand()%3-1)*3;
- parts[i].life = 680;
- if(a==0.0f&&r==0.0f)
- {
- parts[i].life = 0;
- parts[i].type = PT_NONE;
- return -1;
- }
- else
- {
- parts[i].vx = a;
- parts[i].vy = r;
- }
- //} else {
- // parts[i].life = 0;
- // parts[i].type = PT_NONE;
- //}/
- }
-
- if(t!=PT_STKM)
- pmap[y][x] = t|(i<<8);
- else
- {
- if(isplayer==0)
- {
- 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;
-
-
-
- player[3] = x-1; //Setting legs positions
- player[4] = y+6;
- player[5] = x-1;
- player[6] = y+6;
-
- player[7] = x-3;
- player[8] = y+12;
- player[9] = x-3;
- player[10] = y+12;
-
- player[11] = x+1;
- player[12] = y+6;
- player[13] = x+1;
- player[14] = y+6;
-
- player[15] = x+3;
- player[16] = y+12;
- player[17] = x+3;
- player[18] = y+12;
-
- isplayer = 1;
- }
- }
-
- return i;
-}
-
-#ifdef WIN32
-_inline void delete_part(int x, int y)
-#else
-inline void delete_part(int x, int y)
-#endif
-{
- unsigned i;
-
- if(x<0 || y<0 || x>=XRES || y>=YRES)
- return;
- i = pmap[y][x];
- if(!i || (i>>8)>=NPART)
- return;
-
- kill_part(i>>8);
- pmap[y][x] = 0; // just in case
-}
-
-#ifdef WIN32
-_inline int is_wire(int x, int y)
-#else
-inline int is_wire(int x, int y)
-#endif
-{
- return bmap[y][x]==6 || bmap[y][x]==7 || bmap[y][x]==3 || bmap[y][x]==8 || bmap[y][x]==11 || bmap[y][x]==12;
-}
-
-#ifdef WIN32
-_inline int is_wire_off(int x, int y)
-#else
-inline int is_wire_off(int x, int y)
-#endif
-{
- return (bmap[y][x]==6 || bmap[y][x]==7 || bmap[y][x]==3 || bmap[y][x]==8 || bmap[y][x]==11 || bmap[y][x]==12) && emap[y][x]<8;
-}
-
-void set_emap(int x, int y)
-{
- int x1, x2;
-
- if(!is_wire_off(x, y))
- return;
-
- // go left as far as possible
- x1 = x2 = x;
- while(x1>0)
- {
- if(!is_wire_off(x1-1, y))
- break;
- x1--;
- }
- while(x2<XRES/CELL-1)
- {
- if(!is_wire_off(x2+1, y))
- break;
- x2++;
- }
-
- // fill span
- for(x=x1; x<=x2; x++)
- emap[y][x] = 16;
-
- // fill children
-
- if(y>1 && x1==x2 &&
- is_wire(x1-1, y-1) && is_wire(x1, y-1) && is_wire(x1+1, y-1) &&
- !is_wire(x1-1, y-2) && is_wire(x1, y-2) && !is_wire(x1+1, y-2))
- set_emap(x1, y-2);
- else if(y>0)
- for(x=x1; x<=x2; x++)
- if(is_wire_off(x, y-1))
- {
- if(x==x1 || x==x2 || y>=YRES/CELL-1 ||
- is_wire(x-1, y-1) || is_wire(x+1, y-1) ||
- is_wire(x-1, y+1) || !is_wire(x, y+1) || is_wire(x+1, y+1))
- set_emap(x, y-1);
- }
-
- if(y<YRES/CELL-2 && x1==x2 &&
- is_wire(x1-1, y+1) && is_wire(x1, y+1) && is_wire(x1+1, y+1) &&
- !is_wire(x1-1, y+2) && is_wire(x1, y+2) && !is_wire(x1+1, y+2))
- set_emap(x1, y+2);
- else if(y<YRES/CELL-1)
- for(x=x1; x<=x2; x++)
- if(is_wire_off(x, y+1))
- {
- if(x==x1 || x==x2 || y<0 ||
- is_wire(x-1, y+1) || is_wire(x+1, y+1) ||
- is_wire(x-1, y-1) || !is_wire(x, y-1) || is_wire(x+1, y-1))
- set_emap(x, y+1);
- }
-}
-#ifdef WIN32
-_inline int parts_avg(int ci, int ni)
-#else
-inline int parts_avg(int ci, int ni)
-#endif
-{
- int pmr = pmap[(int)((parts[ci].y + parts[ni].y)/2)][(int)((parts[ci].x + parts[ni].x)/2)];
- if((pmr>>8) < NPART && (pmr>>8) >= 0)
- {
- return parts[pmr>>8].type;
- }
- else
- {
- return PT_NONE;
- }
-}
-int nearest_part(int ci, int t)
-{
- int distance = sqrt(pow(XRES, 2)+pow(YRES, 2));
- int ndistance = 0;
- int id = -1;
- int i = 0;
- int cx = (int)parts[ci].x;
- int cy = (int)parts[ci].y;
- for(i=0; i<NPART; i++)
- {
- if(parts[i].type==t&&!parts[i].life&&i!=ci)
- {
- ndistance = abs((cx-parts[i].x)+(cy-parts[i].y));// Faster but less accurate Older: sqrt(pow(cx-parts[i].x, 2)+pow(cy-parts[i].y, 2));
- if(ndistance<distance)
- {
- distance = ndistance;
- id = i;
- }
- }
- }
- return id;
-}
-void create_line(int x1, int y1, int x2, int y2, int r, int c);
-void update_particles_i(pixel *vid, int start, int inc)
-{
- int i, j, x, y, t, nx, ny, r, a, cr,cg,cb, s, rt, fe, nt, lpv, nearp, pavg;
- float mv, dx, dy, ix, iy, lx, ly, d, pp;
- float pt = R_TEMP;
- float c_heat = 0.0f;
- int h_count = 0;
- int starti = (start*-1);
- for(i=start; i<(NPART-starti); i+=inc)
- if(parts[i].type)
- {
-
- lx = parts[i].x;
- ly = parts[i].y;
- t = parts[i].type;
-
- if(sys_pause&&!framerender)
- goto justdraw;
-
- if(parts[i].life && t!=PT_ACID && t!=PT_WOOD && t!=PT_NBLE && t!=PT_SWCH && t!=PT_STKM)
- {
- if(!(parts[i].life==10&&parts[i].type==PT_LCRY))
- parts[i].life--;
- if(parts[i].life<=0 && t!=PT_METL && t!=PT_WATR && t!=PT_RBDM && t!=PT_LRBD && t!=PT_SLTW && t!=PT_BRMT && t!=PT_PSCN && t!=PT_NSCN && t!=PT_NTCT && t!=PT_PTCT && t!=PT_BMTL && t!=PT_SPRK && t!=PT_LAVA && t!=PT_ETRD&&t!=PT_LCRY && t!=PT_INWR)
- {
- kill_part(i);
- continue;
- }
- if(parts[i].life<=0 && t==PT_SPRK)
- {
- t = parts[i].ctype;
- if(t!=PT_METL&&t!=PT_BMTL&&t!=PT_BRMT&&t!=PT_LRBD&&t!=PT_RBDM&&t!=PT_BTRY&&t!=PT_NBLE)
- parts[i].temp = R_TEMP;
- if(!t)
- t = PT_METL;
- parts[i].type = t;
- parts[i].life = 4;
- if(t == PT_WATR)
- parts[i].life = 64;
- if(t == PT_SLTW)
- parts[i].life = 54;
- }
- }
-
- if(t==PT_SPRK&&parts[i].ctype==PT_SPRK)
- {
- kill_part(i);
- continue;
- }
-
- x = (int)(parts[i].x+0.5f);
- y = (int)(parts[i].y+0.5f);
-
-
- if(x<0 || y<0 || x>=XRES || y>=YRES ||
- ((bmap[y/CELL][x/CELL]==1 ||
- bmap[y/CELL][x/CELL]==8 ||
- bmap[y/CELL][x/CELL]==9 ||
- (bmap[y/CELL][x/CELL]==2) ||
- (bmap[y/CELL][x/CELL]==3 && ptypes[t].falldown!=2) ||
- (bmap[y/CELL][x/CELL]==10 && ptypes[t].falldown!=1) ||
- (bmap[y/CELL][x/CELL]==6 && (t==PT_METL || t==PT_SPRK)) ||
- (bmap[y/CELL][x/CELL]==7 && !emap[y/CELL][x/CELL])) && (t!=PT_STKM)))
- {
- kill_part(i);
- continue;
- }
-
- vx[y/CELL][x/CELL] *= ptypes[t].airloss;
- vy[y/CELL][x/CELL] *= ptypes[t].airloss;
- vx[y/CELL][x/CELL] += ptypes[t].airdrag*parts[i].vx;
- vy[y/CELL][x/CELL] += ptypes[t].airdrag*parts[i].vy;
- if(t==PT_GASS||t==PT_NBLE)
- {
- if(pv[y/CELL][x/CELL]<3.5f)
- pv[y/CELL][x/CELL] += ptypes[t].hotair*(3.5f-pv[y/CELL][x/CELL]);
- if(y+CELL<YRES && pv[y/CELL+1][x/CELL]<3.5f)
- pv[y/CELL+1][x/CELL] += ptypes[t].hotair*(3.5f-pv[y/CELL+1][x/CELL]);
- if(x+CELL<XRES)
- {
- pv[y/CELL][x/CELL+1] += ptypes[t].hotair*(3.5f-pv[y/CELL][x/CELL+1]);
- if(y+CELL<YRES)
- pv[y/CELL+1][x/CELL+1] += ptypes[t].hotair*(3.5f-pv[y/CELL+1][x/CELL+1]);
- }
- }
- else
- {
- pv[y/CELL][x/CELL] += ptypes[t].hotair;
- if(y+CELL<YRES)
- pv[y/CELL+1][x/CELL] += ptypes[t].hotair;
- if(x+CELL<XRES)
- {
- pv[y/CELL][x/CELL+1] += ptypes[t].hotair;
- if(y+CELL<YRES)
- pv[y/CELL+1][x/CELL+1] += ptypes[t].hotair;
- }
- }
-
- if((ptypes[t].explosive&2) && pv[y/CELL][x/CELL]>2.5f)
- {
- parts[i].life = rand()%80+180;
- rt = parts[i].type = PT_FIRE;
- parts[i].temp = ptypes[PT_FIRE].heat + (ptypes[rt].flammable/2);
- pv[y/CELL][x/CELL] += 0.25f * CFDS;
- t = PT_FIRE;
- }
-
- parts[i].vx *= ptypes[t].loss;
- parts[i].vy *= ptypes[t].loss;
-
- if(t==PT_DFRM && !parts[i].life)
- {
- if(pv[y/CELL][x/CELL]>1.0f)
- {
- parts[i].vx += ptypes[t].advection*vx[y/CELL][x/CELL];
- parts[i].vy += ptypes[t].advection*vy[y/CELL][x/CELL];
- parts[i].life = rand()%80+300;
- }
- }
- else
- {
- if(t==PT_PLAS && pv[y/CELL][x/CELL]>25.0f)
- {
- parts[i].vx += ptypes[t].advection*vx[y/CELL][x/CELL];
- parts[i].vy += ptypes[t].advection*vy[y/CELL][x/CELL];
- } 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)
- {
- parts[i].vx += ptypes[t].diffusion*(rand()/(0.5f*RAND_MAX)-1.0f);
- parts[i].vy += ptypes[t].diffusion*(rand()/(0.5f*RAND_MAX)-1.0f);
- }
-
- // interpolator
-#ifdef WIN32
- mv = max(fabsf(parts[i].vx), fabsf(parts[i].vy));
-#else
- mv = fmaxf(fabsf(parts[i].vx), fabsf(parts[i].vy));
-#endif
- if(mv < ISTP)
- {
- parts[i].x += parts[i].vx;
- parts[i].y += parts[i].vy;
- ix = parts[i].x;
- iy = parts[i].y;
- }
- else
- {
- dx = parts[i].vx*ISTP/mv;
- dy = parts[i].vy*ISTP/mv;
- ix = parts[i].x;
- iy = parts[i].y;
- while(1)
- {
- mv -= ISTP;
- if(mv <= 0.0f)
- {
- // nothing found
- parts[i].x += parts[i].vx;
- parts[i].y += parts[i].vy;
- ix = parts[i].x;
- iy = parts[i].y;
- break;
- }
- ix += dx;
- iy += dy;
- nx = (int)(ix+0.5f);
- ny = (int)(iy+0.5f);
- if(nx<0 || ny<0 || nx>=XRES || ny>=YRES || pmap[ny][nx] || (bmap[ny/CELL][nx/CELL] && bmap[ny/CELL][nx/CELL]!=5))
- {
- parts[i].x = ix;
- parts[i].y = iy;
- break;
- }
- }
- }
-
- a = nt = 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 &&
- (!bmap[(y+ny)/CELL][(x+nx)/CELL] || bmap[(y+ny)/CELL][(x+nx)/CELL]==5))
- {
- if(!pmap[y+ny][x+nx])
- a = 1;
- if((pmap[y+ny][x+nx]&0xFF)!=t)
- nt = 1;
- }
- if(legacy_enable)
- {
- if(t==PT_WTRV && pv[y/CELL][x/CELL]>4.0f)
- t = parts[i].type = PT_DSTW;
- if(t==PT_DESL && pv[y/CELL][x/CELL]<-6.0f)
- t = parts[i].type = PT_GASS;
- if(t==PT_GASS && pv[y/CELL][x/CELL]>6.0f)
- t = parts[i].type = PT_DESL;
- if(t==PT_DESL && pv[y/CELL][x/CELL]>12.0f)
- t = parts[i].type = PT_FIRE;
- }
- if(t==PT_DESL && pv[y/CELL][x/CELL]<-20.0f)
- t = parts[i].type = PT_GASS;
- if(t==PT_DESL && pv[y/CELL][x/CELL]>50.0f) // Only way I know to make it
- t = parts[i].type = PT_FIRE; // combust under pressure.
- if(t==PT_GASS && pv[y/CELL][x/CELL]>20.0f)
- t = parts[i].type = PT_DESL;
- if(t==PT_BMTL && pv[y/CELL][x/CELL]>2.5f)
- t = parts[i].type = PT_BRMT;
- //if(t==PT_GLAS && pv[y/CELL][x/CELL]>4.0f)
- // t = parts[i].type = PT_BGLA;
- if(t==PT_GLAS)
- {
- parts[i].pavg[0] = parts[i].pavg[1];
- parts[i].pavg[1] = pv[y/CELL][x/CELL];
- if(parts[i].pavg[1]-parts[i].pavg[0] > 0.05f || parts[i].pavg[1]-parts[i].pavg[0] < -0.05f)
- {
- parts[i].type = PT_BGLA;
- }
- }
- if(t==PT_ICEI && pv[y/CELL][x/CELL]>0.8f)
- t = parts[i].type = PT_SNOW;
- if(t==PT_PLUT && 1>rand()%100 && ((int)(5.0f*pv[y/CELL][x/CELL]))>(rand()%1000))
- {
- t = PT_NEUT;
- create_part(i, x, y, t);
- }
-
- if(t==PT_SPRK&&parts[i].ctype==PT_ETRD&&parts[i].life==1)
- {
- nearp = nearest_part(i, PT_ETRD);
- if(nearp!=-1)
- {
- create_line((int)parts[i].x, (int)parts[i].y, (int)parts[nearp].x, (int)parts[nearp].y, 0, PT_PLSM);
- t = parts[i].type = PT_ETRD;
- parts[i].ctype = PT_NONE;
- parts[i].life = 20;
- parts[nearp].type = PT_SPRK;
- parts[nearp].life = 9;
- parts[nearp].ctype = PT_ETRD;
- }
- }
-
- if(!legacy_enable)
- {
- int ctemp = pv[y/CELL][x/CELL]*2;
- c_heat = 0.0f;
- h_count = 0;
- if(ptypes[t].hconduct>(rand()%250))
- {
- 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_NONE&&parts[i].type!=PT_NONE&&ptypes[parts[r>>8].type].hconduct>0)
- {
- h_count++;
- c_heat += parts[r>>8].temp;
- }
- }
- }
- }
- pt = parts[i].temp = (c_heat+parts[i].temp)/(h_count+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 || !r)
- continue;
- if(parts[r>>8].type!=PT_NONE&&parts[i].type!=PT_NONE&&ptypes[parts[r>>8].type].hconduct>0)
- {
- parts[r>>8].temp = parts[i].temp;
- }
- }
- }
- }
- if(pt>=pstates[t].btemp&&pstates[t].burn)
- {
- t = parts[i].type = pstates[t].burn;
- if(t==PT_FIRE||t==PT_PLSM)
- parts[i].life = rand()%50+120;
- }
- else if((pt<=pstates[t].stemp||(t==PT_LAVA&&(pt<=pstates[parts[i].ctype].ltemp)))&&pstates[t].solid)
- {
- if(t==PT_LAVA&&parts[i].ctype)
- {
- parts[i].life = 0;
- t = parts[i].type = parts[i].ctype;
- parts[i].ctype = PT_NONE;
- }
- else if(pstates[t].solid==PT_ICEI&&pt<=pstates[t].stemp)
- {
- parts[i].ctype = parts[i].type;
- t = parts[i].type = PT_ICEI;
- }
- else
- {
- parts[i].life = 0;
- t = parts[i].type = pstates[t].solid;
- }
- }
- else if((pt>=pstates[t].ltemp&&(pt<=pstates[t].gtemp||!pstates[t].gas)&&pstates[t].state==ST_SOLID&&pstates[t].liquid)||(t==PT_ICEI&&pt>pstates[parts[i].ctype].stemp))
- {
- if(pstates[t].liquid==PT_LAVA)
- {
- parts[i].life = rand()%120+240;
- parts[i].ctype = (parts[i].type==PT_BRMT)?PT_BMTL:parts[i].type;
- parts[i].ctype = (parts[i].ctype==PT_SAND)?PT_GLAS:parts[i].ctype;
- parts[i].ctype = (parts[i].ctype==PT_BGLA)?PT_GLAS:parts[i].ctype;
- t = parts[i].type = pstates[t].liquid;
- }
- else if(t==PT_ICEI&&parts[i].ctype)
- {
- t = parts[i].type = parts[i].ctype;
- parts[i].ctype = PT_NONE;
- }
- else
- {
- t = parts[i].type = pstates[t].liquid;
- }
- }
- else if(pt-ctemp<=pstates[t].ltemp&&pstates[t].liquid&&pstates[t].state==ST_GAS)
- {
- t = parts[i].type = pstates[t].liquid;
- }
- else if(pt-ctemp>=pstates[t].gtemp&&(pstates[t].gas||parts[i].type==PT_LNTG)&&(pstates[t].state==ST_LIQUID||pstates[t].state==ST_SOLID))
- {
- if(t==PT_SLTW&&1>rand()%6)
- {
- t = parts[i].type = PT_SALT;
- }
- 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_URAN && pv[y/CELL][x/CELL]>0.0f)
- {
- float atemp = parts[i].temp + (-MIN_TEMP);
- pt = parts[i].temp = (atemp*(1+(pv[y/CELL][x/CELL]/2000)))+MIN_TEMP;
- }
- if(t==PT_LAVA)
- {
- parts[i].life = restrict_flt((pt-700)/7, 0.0f, 400.0f);
- }
- pt = parts[i].temp = restrict_flt(parts[i].temp, MIN_TEMP, MAX_TEMP);
- }
- }
- if(t==PT_PTCT&&parts[i].temp>24.0f)
- {
- pt = parts[i].temp -= 2.5f;
- }
- if(t==PT_NTCT&&parts[i].temp>24.0f)
- {
- pt = parts[i].temp -= 2.5f;
- }
-
- if(t==PT_WATR || t==PT_ETRD || t==PT_SLTW || t==PT_METL || t==PT_RBDM || t==PT_LRBD || t==PT_BRMT || t==PT_PSCN || t==PT_NSCN || t==PT_NTCT || t==PT_PTCT || t==PT_BMTL || t==PT_SPRK|| t == PT_NBLE || t==PT_INWR)
- {
- nx = x % CELL;
- if(nx == 0)
- nx = x/CELL - 1;
- else if(nx == CELL-1)
- nx = x/CELL + 1;
- else
- nx = x/CELL;
- ny = y % CELL;
- if(ny == 0)
- ny = y/CELL - 1;
- else if(ny == CELL-1)
- ny = y/CELL + 1;
- else
- ny = y/CELL;
- if(nx>=0 && ny>=0 && nx<XRES/CELL && ny<YRES/CELL)
- {
- if(t==PT_WATR || t==PT_ETRD || t==PT_SLTW || t==PT_METL || t==PT_RBDM || t==PT_LRBD || t==PT_NSCN || t==PT_NTCT || t==PT_PTCT || t==PT_PSCN || t==PT_BRMT || t==PT_BMTL||t==PT_NBLE || t==PT_INWR)
- {
- if(emap[ny][nx]==12 && !parts[i].life)
- {
- parts[i].type = PT_SPRK;
- parts[i].life = 4;
- parts[i].ctype = t;
- t = PT_SPRK;
- }
- }
- else if(bmap[ny][nx]==6 || bmap[ny][nx]==7 || bmap[ny][nx]==3 || bmap[ny][nx]==8 || bmap[ny][nx]==11 || bmap[ny][nx]==12)
- set_emap(nx, ny);
- }
- }
-
- nx = x/CELL;
- ny = y/CELL;
- if(bmap[ny][nx]==6 && emap[ny][nx]<8)
- set_emap(nx, ny);
-
- fe = 0;
- if(t==PT_THDR)
- {
- for(nx=-2; nx<3; nx++)
- for(ny=-2; ny<3; ny++)
- if(x+nx>=0 && y+ny>0 &&
- x+nx<XRES && y+ny<YRES && (nx || ny))
- {
- r = pmap[y+ny][x+nx];
- if((r>>8)>=NPART || !r)
- continue;
- if(((r&0xFF)==PT_METL || (r&0xFF)==PT_ETRD || (r&0xFF)==PT_PSCN || (r&0xFF)==PT_NSCN || (r&0xFF)==PT_NTCT || (r&0xFF)==PT_PTCT || (r&0xFF)==PT_BMTL || (r&0xFF)==PT_RBDM || (r&0xFF)==PT_LRBD || (r&0xFF)==PT_BRMT||(r&0xFF)==PT_NBLE) || (r&0xFF)==PT_INWR && parts[r>>8].ctype!=PT_SPRK )
- {
- t = parts[i].type = PT_NONE;
- parts[r>>8].ctype = parts[r>>8].type;
- parts[r>>8].type = PT_SPRK;
- parts[r>>8].life = 4;
- }
- else if((r&0xFF)!=PT_CLNE&&(r&0xFF)!=PT_THDR&&(r&0xFF)!=PT_SPRK&&(r&0xFF)!=PT_DMND&&(r&0xFF)!=PT_FIRE&&(r&0xFF)!=PT_NEUT&&(r&0xFF)!=PT_PHOT&&(r&0xFF))
- {
- pv[y/CELL][x/CELL] += 100.0f;
- if(legacy_enable&&1>(rand()%200))
- {
- parts[i].life = rand()%50+120;
- t = parts[i].type = PT_FIRE;
- }
- else
- {
- t = parts[i].type = PT_NONE;
- }
- }
- }
- }
- else if(t==PT_ICEI || t==PT_SNOW)
- {
- for(nx=-2; nx<3; nx++)
- for(ny=-2; ny<3; ny++)
- if(x+nx>=0 && y+ny>0 &&
- x+nx<XRES && y+ny<YRES && (nx || ny))
- {
- r = pmap[y+ny][x+nx];
- if((r>>8)>=NPART || !r)
- continue;
- if(((r&0xFF)==PT_SALT || (r&0xFF)==PT_SLTW) && 1>(rand()%1000))
- {
- t = parts[i].type = PT_SLTW;
- parts[r>>8].type = PT_SLTW;
- }
- if(legacy_enable)
- {
- if(((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 1>(rand()%1000))
- {
- t = parts[i].type = PT_ICEI;
- parts[r>>8].type = PT_ICEI;
- }
- if(t==PT_SNOW && ((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 15>(rand()%1000))
- t = parts[i].type = PT_WATR;
- }
- }
- }
- else if(t==PT_NTCT||t==PT_PTCT||t==PT_INWR)
- {
- for(nx=-2; nx<3; nx++)
- for(ny=-2; ny<3; ny++)
- if(x+nx>=0 && y+ny>0 &&
- x+nx<XRES && y+ny<YRES && (nx || ny))
- {
- r = pmap[y+ny][x+nx];
- if((r>>8)>=NPART || !r)
- continue;
- if((r&0xFF)==PT_SPRK && parts[r>>8].ctype==PT_METL)
- {
- parts[i].temp = 200.0f;
- }
- }
- }
- //PLANT
- else if(t==PT_PLNT)
- {
- for(nx=-2; nx<3; nx++)
- for(ny=-2; ny<3; ny++)
- if(x+nx>=0 && y+ny>0 &&
- x+nx<XRES && y+ny<YRES && (nx || ny))
- {
- r = pmap[y+ny][x+nx];
- if((r>>8)>=NPART || !r)
- continue;
- if((r&0xFF)==PT_WATR && 1>(rand()%250))
- {
- t = parts[i].type = PT_PLNT;
- parts[r>>8].type = PT_PLNT;
- }
- else if((r&0xFF)==PT_LAVA && 1>(rand()%250))
- {
- parts[i].life = 4;
- t = parts[i].type = PT_FIRE;
- }
- //if(t==PT_SNOW && (r&0xFF)==PT_WATR && 15>(rand()%1000))
- //t = parts[i].type = PT_WATR;
- }
- }
- else if(t==PT_WATR||t==PT_DSTW)
- {
- for(nx=-2; nx<3; nx++)
- for(ny=-2; ny<3; ny++)
- if(x+nx>=0 && y+ny>0 &&
- x+nx<XRES && y+ny<YRES && (nx || ny))
- {
- r = pmap[y+ny][x+nx];
- if((r>>8)>=NPART || !r)
- continue;
- if(((r&0xFF)==PT_FIRE || (r&0xFF)==PT_LAVA) && 1>(rand()%10) && legacy_enable)
- {
- t = parts[i].type = PT_WTRV;
- }
- else if((r&0xFF)==PT_SALT && 1>(rand()%250))
- {
- t = parts[i].type = PT_SLTW;
- parts[r>>8].type = PT_SLTW;
- }
- if((((r&0xFF)==PT_WATR||(r&0xFF)==PT_SLTW)&&t==PT_DSTW) && 1>(rand()%500))
- {
- t = parts[i].type = PT_WATR;
- }
- if(((r&0xFF)==PT_SLTW&&t==PT_DSTW) && 1>(rand()%500))
- {
- t = parts[i].type = PT_SLTW;
- }
- if(((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && (legacy_enable||pt>12.0f) && 1>(rand()%500))
- {
- parts[i].life = 4;
- t = parts[i].type = PT_FIRE;
-
- }
- }
- }
- else if(t==PT_SLTW)
- {
- for(nx=-2; nx<3; nx++)
- for(ny=-2; ny<3; ny++)
- if(x+nx>=0 && y+ny>0 &&
- x+nx<XRES && y+ny<YRES && (nx || ny))
- {
- r = pmap[y+ny][x+nx];
- if((r>>8)>=NPART || !r)
- continue;
- if(((r&0xFF)==PT_FIRE || (r&0xFF)==PT_LAVA) && 1>(rand()%10) && legacy_enable)
- {
- t = parts[i].type = PT_SALT;
- parts[r>>8].type = PT_WTRV;
- }
- else if((r&0xFF)==PT_SALT && 1>(rand()%10000))
- {
- parts[r>>8].type = PT_SLTW;
- }
- if(((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && pt>12.0f && 1>(rand()%500))
- {
- parts[i].life = 4;
- t = parts[i].type = PT_FIRE;
-
- }
- }
- }
- else if(t==PT_WTRV)
- {
- for(nx=-2; nx<3; nx++)
- for(ny=-2; ny<3; ny++)
- if(x+nx>=0 && y+ny>0 &&
- x+nx<XRES && y+ny<YRES && (nx || ny))
- {
- r = pmap[y+ny][x+nx];
- if((r>>8)>=NPART || !r)
- continue;
- if(((r&0xFF)==PT_WATR||(r&0xFF)==PT_DSTW||(r&0xFF)==PT_SLTW) && 1>(rand()%1000) && legacy_enable)
- {
- t = parts[i].type = PT_WATR;
- parts[r>>8].type = PT_WATR;
- }
-
- if(((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && pt>12.0f && 1>(rand()%500))
- {
- parts[i].life = 4;
- t = parts[i].type = PT_FIRE;
-
- }
- if(((r&0xFF)==PT_ICEI || (r&0xFF)==PT_SNOW) && 1>(rand()%1000) && legacy_enable)
- {
- t = parts[i].type = PT_WATR;
- if(1>(rand()%1000))
- parts[r>>8].type = PT_WATR;
- }
- }
- }
- else if(t==PT_YEST)
- {
- for(nx=-2; nx<3; nx++)
- for(ny=-2; ny<3; ny++)
- if(x+nx>=0 && y+ny>0 &&
- x+nx<XRES && y+ny<YRES && (nx || ny))
- {
- r = pmap[y+ny][x+nx];
- if((r>>8)>=NPART || !r)
- continue;
- if((r&0xFF)==PT_DYST && 1>(rand()%30) && !legacy_enable)
- {
- t = parts[i].type = PT_DYST;
- }
- }
- }
- else if(t==PT_ACID)
- {
- for(nx=-2; nx<3; nx++)
- for(ny=-2; ny<3; ny++)
- if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
- {
- r = pmap[y+ny][x+nx];
- if((r>>8)>=NPART || !r)
- continue;
- if((r&0xFF)!=PT_ACID)
- {
- if ((r&0xFF)==PT_PLEX || (r&0xFF)==PT_NITR || (r&0xFF)==PT_GUNP || (r&0xFF)==PT_RBDM || (r&0xFF)==PT_LRBD)
- {
- t = parts[i].type = PT_FIRE;
- parts[i].life = 4;
- parts[r>>8].type = PT_FIRE;
- parts[r>>8].life = 4;
- }
- else if(((r&0xFF)!=PT_CLNE && ptypes[parts[r>>8].type].hardness>(rand()%1000))&&parts[i].life>=50)
- {
- parts[i].life--;
- parts[r>>8].type = PT_NONE;
- }
- else if (parts[i].life==50)
- {
- parts[i].life = 0;
- t = parts[i].type = PT_NONE;
- }
- }
- }
- }
- else if(t==PT_NEUT)
- {
- rt = 3 + (int)pv[y/CELL][x/CELL];
- 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_WATR || (r&0xFF)==PT_ICEI || (r&0xFF)==PT_SNOW)
- {
- parts[i].vx *= 0.995;
- parts[i].vy *= 0.995;
- }
- if((r&0xFF)==PT_PLUT && rt>(rand()%1000))
- {
- if(33>rand()%100)
- {
- create_part(r>>8, x+nx, y+ny, rand()%2 ? PT_LAVA : PT_URAN);
- }
- else
- {
- 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;
- }
- pv[y/CELL][x/CELL] += 10.00f * CFDS; //Used to be 2, some people said nukes weren't powerful enough
- fe ++;
- }
- if((r&0xFF)==PT_GUNP && 15>(rand()%1000))
- parts[r>>8].type = PT_DUST;
- if((r&0xFF)==PT_DYST && 15>(rand()%1000))
- parts[r>>8].type = PT_YEST;
- if((r&0xFF)==PT_YEST){
- if(15>(rand()%100000)&&isplayer==0)
- parts[r>>8].type = PT_STKM;
- else
- parts[r>>8].type = PT_DYST;
- }
-
- if((r&0xFF)==PT_WATR && 15>(rand()%100))
- parts[r>>8].type = PT_DSTW;
- if((r&0xFF)==PT_PLEX && 15>(rand()%1000))
- parts[r>>8].type = PT_DFRM;
- if((r&0xFF)==PT_NITR && 15>(rand()%1000))
- parts[r>>8].type = PT_DESL;
- if((r&0xFF)==PT_OILL && 5>(rand()%1000))
- parts[r>>8].type = PT_PLAS;
- if((r&0xFF)==PT_PLNT && 5>(rand()%100))
- parts[r>>8].type = PT_WOOD;
- if((r&0xFF)==PT_PLAS && 5>(rand()%1000))
- parts[r>>8].type = PT_OILL;
- if((r&0xFF)==PT_DESL && 15>(rand()%1000))
- parts[r>>8].type = PT_GASS;
- if((r&0xFF)==PT_COAL && 5>(rand()%100))
- parts[r>>8].type = PT_WOOD;
- }
- }
- else if(t==PT_PHOT)
- {
- rt = 3 + (int)pv[y/CELL][x/CELL];
- for(nx=0; nx<1; nx++)
- for(ny=0; ny<1; 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_WATR || (r&0xFF)==PT_ICEI || (r&0xFF)==PT_SNOW)
- {
- parts[i].vx *= 0.995;
- parts[i].vy *= 0.995;
- }
- }
- }
- else if(t==PT_LCRY)
- {
- for(nx=-1; nx<2; nx++)
- for(ny=-1; ny<2; ny++)
- if(x+nx>=0 && y+ny>0 &&
- x+nx<XRES && y+ny<YRES && (nx || ny))
- {
- r = pmap[y+ny][x+nx];
- if((r>>8)>=NPART || !r)
- continue;
- rt = parts[r>>8].type;
- if(rt==PT_SPRK)
- {
- if(parts[r>>8].ctype==PT_PSCN)
- {
- parts[i].life = 10;
- }
- else if(parts[r>>8].ctype==PT_NSCN)
- {
- parts[i].life = 9;
- }
- }
- if(rt==PT_LCRY)
- {
- if(parts[i].life==10&&parts[r>>8].life<10&&parts[r>>8].life>0)
- {
- parts[i].life = 9;
- }
- else if(parts[i].life==0&&parts[r>>8].life==10)
- {
- parts[i].life = 10;
- }
- }
- }
- }
- else if(t==PT_BTRY)
- {
- rt = 3 + (int)pv[y/CELL][x/CELL];
- for(nx=-2; nx<3; nx++)
- for(ny=-2; ny<3; ny++)
- if(x+nx>=0 && y+ny>0 &&
- x+nx<XRES && y+ny<YRES && (nx || ny))
- {
- r = pmap[y+ny][x+nx];
- if((r>>8)>=NPART || !r)
- continue;
- rt = parts[r>>8].type;
- if(parts_avg(i,r>>8) != PT_INSL)
- {
- if((rt==PT_METL||rt==PT_ETRD||rt==PT_BMTL||rt==PT_BRMT||rt==PT_LRBD||rt==PT_RBDM||rt==PT_PSCN||rt==PT_NSCN||rt==PT_NBLE)&&parts[r>>8].life==0 && abs(nx)+abs(ny) < 4)
- {
- parts[r>>8].life = 4;
- parts[r>>8].ctype = rt;
- parts[r>>8].type = PT_SPRK;
- }
- }
- }
- }else if(t==PT_SWCH)
- {
- rt = 3 + (int)pv[y/CELL][x/CELL];
- for(nx=-2; nx<3; nx++)
- for(ny=-2; ny<3; ny++)
- if(x+nx>=0 && y+ny>0 &&
- x+nx<XRES && y+ny<YRES && (nx || ny))
- {
- r = pmap[y+ny][x+nx];
- if((r>>8)>=NPART || !r)
- continue;
- rt = parts[r>>8].type;
- if(parts[r>>8].type == PT_SWCH&&parts_avg(i,r>>8)!=PT_INSL)
- {
- if(parts[i].life==10&&parts[r>>8].life<10&&parts[r>>8].life>0)
- {
- parts[i].life = 9;
- }
- else if(parts[i].life==0&&parts[r>>8].life==10)
- {
- parts[i].life = 10;
- }
- }
- }
- }
- if(t==PT_SWCH)
- if((parts[i].life>0&&parts[i].life<10)|| parts[i].life == 11)
- {
- parts[i].life--;
- }
- if(t==PT_FIRE || t==PT_PLSM || t==PT_LAVA || t==PT_SPRK || fe || (t==PT_PHOT&&(1>rand()%10)))
- {
- for(nx=-2; nx<3; nx++)
- for(ny=-2; ny<3; ny++)
- if(x+nx>=0 && y+ny>0 &&
- x+nx<XRES && y+ny<YRES && (nx || ny))
- {
- r = pmap[y+ny][x+nx];
- if((r>>8)>=NPART || !r)
- continue;
- if(bmap[(y+ny)/CELL][(x+nx)/CELL] && bmap[(y+ny)/CELL][(x+nx)/CELL]!=5)
- continue;
- rt = parts[r>>8].type;
- if((a || ptypes[rt].explosive) && ((rt!=PT_RBDM && rt!=PT_LRBD && rt!=PT_INSL && rt!=PT_SWCH) || t!=PT_SPRK) &&
- (t!=PT_LAVA || parts[i].life>0 || (rt!=PT_STNE && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_METL && rt!=PT_ETRD && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SWCH && rt!=PT_INWR)) &&
- ptypes[rt].flammable && (ptypes[rt].flammable + (int)(pv[(y+ny)/CELL][(x+nx)/CELL]*10.0f))>(rand()%1000))
- {
- parts[r>>8].type = PT_FIRE;
- parts[r>>8].temp = ptypes[PT_FIRE].heat + (ptypes[rt].flammable/2);
- parts[r>>8].life = rand()%80+180;
- if(ptypes[rt].explosive)
- pv[y/CELL][x/CELL] += 0.25f * CFDS;
- continue;
- }
- lpv = (int)pv[(y+ny)/CELL][(x+nx)/CELL];
- if(lpv < 1) lpv = 1;
- if(legacy_enable)
- {
- if(t!=PT_SPRK && ptypes[rt].meltable && ((rt!=PT_RBDM && rt!=PT_LRBD) || t!=PT_SPRK) && ((t!=PT_FIRE&&t!=PT_PLSM) || (rt!=PT_METL && rt!=PT_ETRD && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SALT && rt!=PT_INWR)) &&
- ptypes[rt].meltable*lpv>(rand()%1000))
- {
- if(t!=PT_LAVA || parts[i].life>0)
- {
- parts[r>>8].ctype = (parts[r>>8].type==PT_BRMT)?PT_BMTL:parts[r>>8].type;
- parts[r>>8].ctype = (parts[r>>8].ctype==PT_SAND)?PT_GLAS:parts[r>>8].ctype;
- parts[r>>8].type = PT_LAVA;
- parts[r>>8].life = rand()%120+240;
- }
- else
- {
- parts[i].life = 0;
- t = parts[i].type = (parts[i].ctype)?parts[i].ctype:PT_STNE;
- parts[i].ctype = PT_NONE;//rt;
- goto killed;
- }
- }
- if(t!=PT_SPRK && (rt==PT_ICEI || rt==PT_SNOW))
- {
- parts[r>>8].type = PT_WATR;
- if(t==PT_FIRE)
- {
- parts[i].x = lx;
- parts[i].y = ly;
- kill_part(i);
- goto killed;
- }
- if(t==PT_LAVA)
- {
- parts[i].life = 0;
- t = parts[i].type = PT_STNE;
- goto killed;
- }
- }
- if(t!=PT_SPRK && (rt==PT_WATR || rt==PT_DSTW || rt==PT_SLTW))
- {
- kill_part(r>>8);
- if(t==PT_FIRE)
- {
- parts[i].x = lx;
- parts[i].y = ly;
- kill_part(i);
- goto killed;
- }
- if(t==PT_LAVA)
- {
- parts[i].life = 0;
- t = parts[i].type = (parts[i].ctype)?parts[i].ctype:PT_STNE;
- parts[i].ctype = PT_NONE;
- goto killed;
- }
- }
- }
- pavg = parts_avg(i, r>>8);
- if(rt==PT_SWCH && t==PT_SPRK)
- {
- pavg = parts_avg(r>>8, i);
- if(parts[i].ctype == PT_PSCN&&pavg != PT_INSL)
- parts[r>>8].life = 10;
- if(parts[i].ctype == PT_NSCN&&pavg != PT_INSL)
- parts[r>>8].life = 9;
- if(!(parts[i].ctype == PT_PSCN||parts[i].ctype == PT_NSCN)&&parts[r>>8].life == 10&&pavg != PT_INSL)
- {
- parts[r>>8].type = PT_SPRK;
- parts[r>>8].ctype = PT_SWCH;
- parts[r>>8].life = 4;
- }
- }
- pavg = parts_avg(i, r>>8);
- if(pavg != PT_INSL)
- {
- if(t==PT_SPRK && (rt==PT_METL||rt==PT_ETRD||rt==PT_BMTL||rt==PT_BRMT||rt==PT_LRBD||rt==PT_RBDM||rt==PT_PSCN||rt==PT_NSCN||rt==PT_NBLE) && parts[r>>8].life==0 &&
- (parts[i].life<3 || ((r>>8)<i && parts[i].life<4)) && abs(nx)+abs(ny)<4)
- {
- if(!(rt==PT_PSCN&&parts[i].ctype==PT_NSCN)&&!(rt!=PT_PSCN&&!(rt==PT_NSCN&&parts[i].temp>=100.0f)&&parts[i].ctype==PT_NTCT)&&!(rt!=PT_PSCN&&!(rt==PT_NSCN&&parts[i].temp<=100.0f)&&parts[i].ctype==PT_PTCT)&&!(rt!=PT_PSCN&&!(rt==PT_NSCN)&&parts[i].ctype==PT_INWR) && pavg != PT_INSL &&!(parts[i].ctype==PT_SWCH&&(rt==PT_PSCN||rt==PT_NSCN)) )
- {
- parts[r>>8].type = PT_SPRK;
- parts[r>>8].life = 4;
- parts[r>>8].ctype = rt;
- if(parts[r>>8].temp+10.0f<400.0f&&!legacy_enable&&!(rt==PT_LRBD||rt==PT_RBDM||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR))
- parts[r>>8].temp = parts[r>>8].temp+10.0f;
- }
- }
- if(t==PT_SPRK && rt==PT_NTCT && parts[r>>8].life==0 &&
- (parts[i].life<3 || ((r>>8)<i && parts[i].life<4)) && abs(nx)+abs(ny)<4)
- {
- if((parts[i].ctype==PT_NSCN||parts[i].ctype==PT_NTCT||(parts[i].ctype==PT_PSCN&&parts[r>>8].temp>100.0f))&&pavg != PT_INSL)
- {
- parts[r>>8].type = PT_SPRK;
- parts[r>>8].life = 4;
- parts[r>>8].ctype = rt;
- }
- }
- if(t==PT_SPRK && rt==PT_PTCT && parts[r>>8].life==0 &&
- (parts[i].life<3 || ((r>>8)<i && parts[i].life<4)) && abs(nx)+abs(ny)<4)
- {
- if((parts[i].ctype==PT_NSCN||parts[i].ctype==PT_PTCT||(parts[i].ctype==PT_PSCN&&parts[r>>8].temp<100.0f))&&pavg != PT_INSL)
- {
- parts[r>>8].type = PT_SPRK;
- parts[r>>8].life = 4;
- parts[r>>8].ctype = rt;
- }
- }
- if(t==PT_SPRK && rt==PT_INWR && parts[r>>8].life==0 &&
- (parts[i].life<3 || ((r>>8)<i && parts[i].life<4)) && abs(nx)+abs(ny)<4)
- {
- if((parts[i].ctype==PT_NSCN||parts[i].ctype==PT_INWR||parts[i].ctype==PT_PSCN)&&pavg != PT_INSL)
- {
- parts[r>>8].type = PT_SPRK;
- parts[r>>8].life = 4;
- parts[r>>8].ctype = rt;
- }
- }
- if(t==PT_SPRK && rt==PT_WATR && parts[r>>8].life==0 &&
- (parts[i].life<2 || ((r>>8)<i && parts[i].life<3)) && abs(nx)+abs(ny)<4)
- {
- parts[r>>8].type = PT_SPRK;
- parts[r>>8].life = 6;
- parts[r>>8].ctype = rt;
- }
- if(t==PT_SPRK && rt==PT_SLTW && parts[r>>8].life==0 &&
- (parts[i].life<2 || ((r>>8)<i && parts[i].life<3)) && abs(nx)+abs(ny)<4)
- {
- parts[r>>8].type = PT_SPRK;
- parts[r>>8].life = 5;
- parts[r>>8].ctype = rt;
- }
- if(t==PT_SPRK&&parts[i].ctype==PT_ETRD&&parts[i].life==5)
- {
- if(rt==PT_METL||rt==PT_ETRD||rt==PT_BMTL||rt==PT_BRMT||rt==PT_LRBD||rt==PT_RBDM||rt==PT_PSCN||rt==PT_NSCN)
- {
- t = parts[i].type = PT_ETRD;
- parts[i].ctype = PT_NONE;
- parts[i].life = 20;
- parts[r>>8].type = PT_SPRK;
- parts[r>>8].life = 4;
- parts[r>>8].ctype = rt;
- }
- }
-
- if(t==PT_SPRK&&parts[i].ctype==PT_NBLE&&parts[i].life<=1)
- {
- parts[i].life = rand()%150+50;
- parts[i].type = PT_PLSM;
- parts[i].ctype = PT_NBLE;
- parts[i].temp = 3500;
- pv[y/CELL][x/CELL] += 1;
- }
- if(t==PT_SPRK&&parts[i].ctype==PT_SWCH&&parts[i].life<=1)
- {
- parts[i].type = PT_SWCH;
- parts[i].life = 11;
- }
- }
- }
-killed:
- if(parts[i].type == PT_NONE)
- continue;
- }
- if(t==PT_STKM)
- {
- //Tempirature handling
- if(parts[i].temp<-30)
- parts[i].life -= 0.2;
- if((parts[i].temp<36.6f) && (parts[i].temp>=-30))
- parts[i].temp += 1;
-
- //Death
- if(parts[i].life<0 && (death == 1)) //If his HP is less that 0 or there is very big wind...
- {
- for(r=-2; r<=1; r++)
- {
- create_part(-1, x+r, y-2, player[2]);
- create_part(-1, x+r+1, y+2, player[2]);
- create_part(-1, x-2, y+r+1, player[2]);
- create_part(-1, x+2, y+r, player[2]);
- }
- kill_part(i); //Kill him
- goto killed;
- }
-
- //Verlet integration
- pp = 2*player[3]-player[5];
- player[5] = player[3];
- player[3] = pp;
- pp = 2*player[4]-player[6];
- player[6] = player[4];
- player[4] = pp;
-
- pp = 2*player[7]-player[9];
- player[9] = player[7];
- player[7] = pp;
- pp = 2*player[8]-player[10]+1;
- player[10] = player[8];
- player[8] = pp;
-
- pp = 2*player[11]-player[13];
- player[13] = player[11];
- player[11] = pp;
- pp = 2*player[12]-player[14];
- player[14] = player[12];
- player[12] = pp;
-
- pp = 2*player[15]-player[17];
- player[17] = player[15];
- player[15] = pp;
- pp = 2*player[16]-player[18]+1;
- player[18] = player[16];
- player[16] = pp;
-
- //Go left
- if (((int)(player[0])&0x01) == 0x01)
- {
- if (pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_LIQUID
- && (pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF) != PT_LNTG)
- {
- if (pmap[(int)(player[8]-1)][(int)(player[7])])
- {
- player[9] += 3;
- player[10] += 2;
- player[5] += 2;
- }
-
- if (pmap[(int)(player[16]-1)][(int)(player[15])])
- {
- player[17] += 3;
- player[18] += 2;
- player[13] +=2;
- }
- }
- else
- {
- if (pmap[(int)(player[8]-1)][(int)(player[7])]) //It should move another way in liquids
- {
- player[9] += 1;
- player[10] += 1;
- player[5] += 1;
- }
-
- if (pmap[(int)(player[16]-1)][(int)(player[15])])
- {
- player[17] += 1;
- player[18] += 1;
- player[13] +=1;
- }
- }
- }
-
- //Go right
- if (((int)(player[0])&0x02) == 0x02)
- {
- if (pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_LIQUID
- && (pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF) != PT_LNTG)
- {
- if (pmap[(int)(player[8]-1)][(int)(player[7])])
- {
- player[9] -= 3;
- player[10] += 2;
- player[5] -= 2;
- }
-
- if (pmap[(int)(player[16]-1)][(int)(player[15])])
- {
- player[17] -= 3;
- player[18] += 2;
- player[13] -= 2;
- }
- }
- else
- {
- if (pmap[(int)(player[8]-1)][(int)(player[7])])
- {
- player[9] -= 1;
- player[10] += 1;
- player[5] -= 1;
- }
-
- if (pmap[(int)(player[16]-1)][(int)(player[15])])
- {
- player[17] -= 1;
- player[18] += 1;
- player[13] -= 1;
- }
-
- }
- }
-
- //Charge detector wall if foot inside
- if(bmap[(int)(player[8]+0.5)/CELL][(int)(player[7]+0.5)/CELL]==6)
- set_emap((int)player[7]/CELL, (int)player[8]/CELL);
- if(bmap[(int)(player[16]+0.5)/CELL][(int)(player[15]+0.5)/CELL]==6)
- set_emap((int)(player[15]+0.5)/CELL, (int)(player[16]+0.5)/CELL);
-
- //Searching for particles near head
- for(nx = -2; nx <= 2; nx++)
- for(ny = 0; ny>=-2; ny--)
- {
- if(!pmap[ny+y][nx+x] || (pmap[ny+y][nx+x]>>8)>=NPART)
- continue;
- if((pstates[pmap[ny+y][nx+x]&0xFF].state != ST_SOLID && (pmap[ny+y][nx+x]&0xFF)!=PT_STKM
- && (pmap[ny+y][nx+x]&0xFF)!=PT_WHOL && (pmap[ny+y][nx+x]&0xFF)!=PT_BHOL)
- || (pmap[ny+y][nx+x]&0xFF) == PT_LNTG)
- {
- player[2] = pmap[ny+y][nx+x]&0xFF; //Current element
- }
- if((pmap[ny+y][nx+x]&0xFF) == PT_PLNT && parts[i].life<100) //Plant gives him 5 HP
- {
- if(parts[i].life<=95)
- parts[i].life += 5;
- else
- parts[i].life = 100;
- kill_part(pmap[ny+y][nx+x]>>8);
- }
-
- if((pmap[ny+y][nx+x]&0xFF) == PT_NEUT)
- {
- parts[i].life -= (102-parts[i].life)/2;
- kill_part(pmap[ny+y][nx+x]>>8);
- }
- }
-
- //Head position
- nx = x + 3*((((int)player[1])&0x02) == 0x02) - 3*((((int)player[1])&0x01) == 0x01);
- ny = y - 3*(player[1] == 0);
-
- //Spawn
- if(((int)(player[0])&0x08) == 0x08)
- {
- ny -= 2*(rand()%2)+1;
- r = pmap[ny][nx];
- if(!((r>>8)>=NPART))
- {
- if(pstates[r&0xFF].state == ST_SOLID)
- {
- create_part(-1, nx, ny, PT_SPRK);
- }
- else
- {
- create_part(-1, nx, ny, player[2]);
- r = pmap[ny][nx];
- if( ((r>>8) < NPART) && (r>>8)>=0 && player[2]!=PT_PHOT)
- parts[r>>8].vx = parts[r>>8].vx + 5*((((int)player[1])&0x02) == 0x02) - 5*(((int)(player[1])&0x01) == 0x01);
- if(((r>>8) < NPART) && (r>>8)>=0 && player[2] == PT_PHOT)
- {
- int random = abs(rand()%3-1)*3;
- if (random==0)
- {
- parts[r>>8].life = 0;
- parts[r>>8].type = PT_NONE;
- }
- else
- {
- parts[r>>8].vy = 0;
- parts[r>>8].vx = (((((int)player[1])&0x02) == 0x02) - (((int)(player[1])&0x01) == 0x01))*random;
- }
- }
-
- }
- }
- }
-
- //Jump
- if (((int)(player[0])&0x04) == 0x04)
- {
- if (pmap[(int)(player[8]-0.5)][(int)(player[7])] || pmap[(int)(player[16]-0.5)][(int)(player[15])])
- {
- parts[i].vy = -5;
- player[10] += 1;
- player[18] += 1;
- }
-
- }
-
- //Simulation of joints
- d = 25/(pow((player[3]-player[7]), 2) + pow((player[4]-player[8]), 2)+25) - 0.5; //Fast distance
- player[7] -= (player[3]-player[7])*d;
- player[8] -= (player[4]-player[8])*d;
- player[3] += (player[3]-player[7])*d;
- player[4] += (player[4]-player[8])*d;
-
- d = 25/(pow((player[11]-player[15]), 2) + pow((player[12]-player[16]), 2)+25) - 0.5;
- player[15] -= (player[11]-player[15])*d;
- player[16] -= (player[12]-player[16])*d;
- player[11] += (player[11]-player[15])*d;
- player[12] += (player[12]-player[16])*d;
-
- d = 36/(pow((player[3]-parts[i].x), 2) + pow((player[4]-parts[i].y), 2)+36) - 0.5;
- parts[i].vx -= (player[3]-parts[i].x)*d;
- parts[i].vy -= (player[4]-parts[i].y)*d;
- player[3] += (player[3]-parts[i].x)*d;
- player[4] += (player[4]-parts[i].y)*d;
-
- d = 36/(pow((player[11]-parts[i].x), 2) + pow((player[12]-parts[i].y), 2)+36) - 0.5;
- parts[i].vx -= (player[11]-parts[i].x)*d;
- parts[i].vy -= (player[12]-parts[i].y)*d;
- player[11] += (player[11]-parts[i].x)*d;
- player[12] += (player[12]-parts[i].y)*d;
-
- //Side collisions checking
- for(nx = -3; nx <= 3; nx++)
- {
- if(pmap[(int)(player[16]-2)][(int)(player[15]+nx)])
- player[15] -= nx;
-
- if(pmap[(int)(player[8]-2)][(int)(player[7]+nx)])
- player[7] -= nx;
- }
-
- //Collision checks
- for(ny = -2-(int)parts[i].vy; ny<=0; ny++)
- {
- r = pmap[(int)(player[8]+ny)][(int)(player[7]+0.5)]; //This is to make coding more pleasant :-)
-
- //For left leg
- if (r && (r&0xFF)!=PT_STKM)
- {
- if(pstates[r&0xFF].state == ST_LIQUID || pstates[r&0xFF].state == ST_GAS || (r&0xFF)==PT_LNTG) //Liquid checks
- {
- if(parts[i].y<(player[8]-10))
- parts[i].vy = 1;
- else
- parts[i].vy = 0;
- if(abs(parts[i].vx)>1)
- parts[i].vx *= 0.5;
- }
- else
- {
- player[8] += ny-1;
- parts[i].vy -= 0.5*parts[i].vy;
- }
- player[9] = player[7];
- }
-
- r = pmap[(int)(player[16]+ny)][(int)(player[15]+0.5)];
-
- //For right leg
- if (r && (r&0xFF)!=PT_STKM)
- {
- if(pstates[r&0xFF].state == ST_LIQUID || pstates[r&0xFF].state == ST_GAS || (r&0xFF)==PT_LNTG)
- {
- if(parts[i].y<(player[16]-10))
- parts[i].vy = 1;
- else
- parts[i].vy = 0;
- if(abs(parts[i].vx)>1)
- parts[i].vx *= 0.5;
- }
- else
- {
- player[16] += ny-1;
- parts[i].vy -= 0.5*parts[i].vy;
- }
- player[17] = player[15];
- }
-
- //If it falls too fast
- if (parts[i].vy>=30)
- {
- parts[i].y -= 10+ny;
- parts[i].vy = -10;
- }
-
- }
-
- //Keeping legs distance
- if (pow((player[7] - player[15]), 2)<16 && pow((player[8]-player[16]), 2)<1)
- {
- player[7] += 0.2;
- player[15] -= 0.2;
- }
-
- if (pow((player[3] - player[11]), 2)<16 && pow((player[4]-player[12]), 2)<1)
- {
- player[3] += 0.2;
- player[11] -= 0.2;
- }
-
- //If legs touch something
- r = pmap[(int)(player[8]+0.5)][(int)(player[7]+0.5)];
- if((r&0xFF)==PT_SPRK && r && (r>>8)<NPART) //If on charge
- {
- parts[i].life -= (int)(rand()/1000)+38;
- }
-
- if (r>0 && (r>>8)<NPART) //If hot or cold
- {
- if(parts[r>>8].temp>=50 || parts[r>>8].temp<=-30)
- {
- parts[i].life -= 2;
- player[16] -= 1;
- }
- }
-
- if ((r&0xFF)==PT_ACID) //If on acid
- parts[i].life -= 5;
- if ((r&0xFF)==PT_PLUT) //If on plut
- parts[i].life -= 1;
- r = pmap[(int)(player[16]+0.5)][(int)(player[15]+0.5)];
- if((r&0xFF)==PT_SPRK && r && (r>>8)<NPART) //If on charge
- {
- parts[i].life -= (int)(rand()/1000)+38;
- }
-
- if(r>0 && (r>>8)<NPART) //If hot or cold
- {
- if(parts[r>>8].temp>=50 || parts[r>>8].temp<=-30)
- {
- parts[i].life -= 2;
- player[8] -= 1;
- }
- }
-
- if ((r&0xFF)==PT_ACID) //If on acid
- parts[i].life -= 5;
-
- if ((r&0xFF)==PT_PLUT) //If on plut
- parts[i].life -= 1;
-
- isplayer = 1;
- }
- if(t==PT_CLNE)
- {
- if(!parts[i].ctype)
- {
- for(nx=-1; nx<2; nx++)
- for(ny=-1; ny<2; ny++)
- if(x+nx>=0 && y+ny>0 &&
- x+nx<XRES && y+ny<YRES &&
- pmap[y+ny][x+nx] &&
- (pmap[y+ny][x+nx]&0xFF)!=PT_CLNE &&
- (pmap[y+ny][x+nx]&0xFF)!=PT_STKM &&
- (pmap[y+ny][x+nx]&0xFF)!=0xFF)
- parts[i].ctype = pmap[y+ny][x+nx]&0xFF;
- }
- else
- create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype);
- }
- if(t==PT_YEST)
- {
- if(parts[i].temp>30&&parts[i].temp<44){
- create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_YEST);
- }
- }
- if(t==PT_PLSM&&parts[i].ctype == PT_NBLE&&parts[i].life <=1)
- {
- parts[i].type = PT_NBLE;
- parts[i].life = 0;
- }
- if (t==PT_FIRE && parts[i].life <=1)
- {
- t = parts[i].type = PT_SMKE;
- parts[i].life = rand()%20+250;
- }
-
- nx = (int)(parts[i].x+0.5f);
- ny = (int)(parts[i].y+0.5f);
-
- if(nx<CELL || nx>=XRES-CELL ||
- ny<CELL || ny>=YRES-CELL)
- {
- parts[i].x = lx;
- parts[i].y = ly;
- kill_part(i);
- continue;
- }
-
- rt = parts[i].flags & FLAG_STAGNANT;
- parts[i].flags &= ~FLAG_STAGNANT;
- if(!try_move(i, x, y, nx, ny))
- {
- parts[i].x = lx;
- parts[i].y = ly;
- if(ptypes[t].falldown)
- {
- if(nx!=x && try_move(i, x, y, nx, y))
- {
- parts[i].x = ix;
- parts[i].vx *= ptypes[t].collision;
- parts[i].vy *= ptypes[t].collision;
- }
- else if(ny!=y && try_move(i, x, y, x, ny))
- {
- parts[i].y = iy;
- parts[i].vx *= ptypes[t].collision;
- parts[i].vy *= ptypes[t].collision;
- }
- else
- {
- r = (rand()%2)*2-1;
- if(ny!=y && try_move(i, x, y, x+r, ny))
- {
- parts[i].x += r;
- parts[i].y = iy;
- parts[i].vx *= ptypes[t].collision;
- parts[i].vy *= ptypes[t].collision;
- }
- else if(ny!=y && try_move(i, x, y, x-r, ny))
- {
- parts[i].x -= r;
- parts[i].y = iy;
- parts[i].vx *= ptypes[t].collision;
- parts[i].vy *= ptypes[t].collision;
- }
- else if(nx!=x && try_move(i, x, y, nx, y+r))
- {
- parts[i].x = ix;
- parts[i].y += r;
- parts[i].vx *= ptypes[t].collision;
- parts[i].vy *= ptypes[t].collision;
- }
- else if(nx!=x && try_move(i, x, y, nx, y-r))
- {
- parts[i].x = ix;
- parts[i].y -= r;
- parts[i].vx *= ptypes[t].collision;
- parts[i].vy *= ptypes[t].collision;
- }
- else if(ptypes[t].falldown>1 && parts[i].vy>fabs(parts[i].vx))
- {
- s = 0;
- if(!rt || nt)
- rt = 50;
- else
- rt = 10;
- for(j=x+r; j>=0 && j>=x-rt && j<x+rt && j<XRES; j+=r)
- {
- if(try_move(i, x, y, j, ny))
- {
- parts[i].x += j-x;
- parts[i].y += ny-y;
- x = j;
- y = ny;
- s = 1;
- break;
- }
- if(try_move(i, x, y, j, y))
- {
- parts[i].x += j-x;
- x = j;
- s = 1;
- break;
- }
- if((pmap[y][j]&255)!=t || (bmap[y/CELL][j/CELL] && bmap[y/CELL][j/CELL]!=5))
- break;
- }
- if(parts[i].vy>0)
- r = 1;
- else
- r = -1;
- if(s)
- for(j=y+r; j>=0 && j<YRES && j>=y-rt && j<x+rt; j+=r)
- {
- if(try_move(i, x, y, x, j))
- {
- parts[i].y += j-y;
- break;
- }
- if((pmap[j][x]&255)!=t || (bmap[j/CELL][x/CELL] && bmap[j/CELL][x/CELL]!=5))
- {
- s = 0;
- break;
- }
- }
- parts[i].vx *= ptypes[t].collision;
- parts[i].vy *= ptypes[t].collision;
- if(!s)
- parts[i].flags |= FLAG_STAGNANT;
- }
- else
- {
- parts[i].flags |= FLAG_STAGNANT;
- parts[i].vx *= ptypes[t].collision;
- parts[i].vy *= ptypes[t].collision;
- }
- }
- }
- else
- {
- parts[i].flags |= FLAG_STAGNANT;
- if(nx>x+ISTP) nx=x+ISTP;
- if(nx<x-ISTP) nx=x-ISTP;
- if(ny>y+ISTP) ny=y+ISTP;
- if(ny<y-ISTP) ny=y-ISTP;
- if(t==PT_NEUT && 100>(rand()%1000))
- {
- kill_part(i);
- continue;
- }
- else if(try_move(i, x, y, 2*x-nx, ny))
- {
- parts[i].x = (float)(2*x-nx);
- parts[i].y = (float)iy;
- parts[i].vx *= ptypes[t].collision;
- }
- else if(try_move(i, x, y, nx, 2*y-ny))
- {
- parts[i].x = (float)ix;
- parts[i].y = (float)(2*y-ny);
- parts[i].vy *= ptypes[t].collision;
- }
- else
- {
- parts[i].vx *= ptypes[t].collision;
- parts[i].vy *= ptypes[t].collision;
- }
- }
- }
-
-justdraw:
-
- nx = (int)(parts[i].x+0.5f);
- ny = (int)(parts[i].y+0.5f);
-
- if(nx<CELL || nx>=XRES-CELL ||
- ny<CELL || ny>=YRES-CELL)
- {
- kill_part(i);
- continue;
- }
- if(cmode!=CM_HEAT)
- {
- if(t==PT_STKM) //Just draw head here
- {
- char buff[10]; //Buffer for HP
-
- if(mousex>(nx-3) && mousex<(nx+3) && mousey<(ny+3) && mousey>(ny-3)) //If mous is in the head
- {
- sprintf(buff, "%3d", (int)parts[i].life); //Show HP
- drawtext(vid, mousex-8-2*(parts[i].life<100)-2*(parts[i].life<10), mousey-12, buff, 255, 255, 255, 255);
- }
-
- for(r=-2; r<=1; r++) //Here I use r variable not as I should, but I think you will excuse me :-p
- {
- s = XRES+BARSIZE;
- vid[(ny-2)*s+nx+r] = ptypes[(int)player[2]].pcolors;
- vid[(ny+2)*s+nx+r+1] = ptypes[(int)player[2]].pcolors;
- vid[(ny+r+1)*s+nx-2] = ptypes[(int)player[2]].pcolors;
- vid[(ny+r)*s+nx+2] = ptypes[(int)player[2]].pcolors;
- }
- draw_line(vid , nx, ny+3, player[3], player[4], 255, 255, 255, s);
- draw_line(vid , player[3], player[4], player[7], player[8], 255, 255, 255, s);
- draw_line(vid , nx, ny+3, player[11], player[12], 255, 255, 255, s);
- draw_line(vid , player[11], player[12], player[15], player[16], 255, 255, 255, s);
-
- isplayer = 1; //It's a secret. Tssss...
- }
- if(t==PT_MWAX&&cmode == 6)
- {
- for(x=-1; x<=1; x++)
- {
- for(y=-1; y<=1; y++)
- {
- if ((abs(x) == 0) && (abs(y) == 0))
- blendpixel(vid,x+nx,y+ny,224,224,170,255);
- else if (abs(y) != 0 && abs(x) != 0)
- blendpixel(vid,x+nx,y+ny,224,224,170,20);
- else
- blendpixel(vid,x+nx,y+ny,224,224,170,40);
- }
- }
-
- }
- else if(t==PT_ACID)
- {
- if(parts[i].life>255) parts[i].life = 255;
- if(parts[i].life<47) parts[i].life = 48;
- s = (255/((parts[i].life-46)*28));
- if(s==0) s = 1;
- cr = PIXR(ptypes[t].pcolors)/s;
- cg = PIXG(ptypes[t].pcolors)/s;
- cb = PIXB(ptypes[t].pcolors)/s;
- if(cmode==6){
- for(x=-1; x<=1; x++)
- {
- for(y=-1; y<=1; y++)
- {
- if ((abs(x) == 0) && (abs(y) == 0))
- blendpixel(vid,x+nx,y+ny,cr,cg,cb,100);
- else if (abs(y) != 0 || abs(x) != 0)
- blendpixel(vid,x+nx,y+ny,cr,cg,cb,40);
- }
- }
- } else {
- blendpixel(vid, nx, ny, cr, cg, cb, 255);
- }
-
- if(cmode==4)
- {
- blendpixel(vid, nx+1, ny, cr, cg, cb, 223);
- blendpixel(vid, nx-1, ny, cr, cg, cb, 223);
- blendpixel(vid, nx, ny+1, cr, cg, cb, 223);
- blendpixel(vid, nx, ny-1, cr, cg, cb, 223);
-
- blendpixel(vid, nx+1, ny-1, cr, cg, cb, 112);
- blendpixel(vid, nx-1, ny-1, cr, cg, cb, 112);
- blendpixel(vid, nx+1, ny+1, cr, cg, cb, 112);
- blendpixel(vid, nx-1, ny+1, cr, cg, cb, 112);
- }
- }
- else if(t==PT_OILL&&cmode == 6)
- {
- for(x=-1; x<=1; x++)
- {
- for(y=-1; y<=1; y++)
- {
- if ((abs(x) == 0) && (abs(y) == 0))
- blendpixel(vid,x+nx,y+ny,64,64,16,100);
- else if (abs(y) != 0 || abs(x) != 0)
- blendpixel(vid,x+nx,y+ny,64,64,16,40);
- }
- }
- }
- else if(t==PT_NEUT)
- {
- if(cmode == 3||cmode==4 || cmode==6)
- {
- vid[ny*(XRES+BARSIZE)+nx] = ptypes[t].pcolors;
- cg = 8;
- cb = 12;
- x = nx/CELL;
- y = ny/CELL;
- cg += fire_g[y][x];
- if(cg > 255) cg = 255;
- fire_g[y][x] = cg;
- cb += fire_b[y][x];
- if(cb > 255) cb = 255;
- fire_b[y][x] = cb;
- }
- else
- {
- cr = 0x20;
- cg = 0xE0;
- cb = 0xFF;
- blendpixel(vid, nx, ny, cr, cg, cb, 192);
- blendpixel(vid, nx+1, ny, cr, cg, cb, 96);
- blendpixel(vid, nx-1, ny, cr, cg, cb, 96);
- blendpixel(vid, nx, ny+1, cr, cg, cb, 96);
- blendpixel(vid, nx, ny-1, cr, cg, cb, 96);
- blendpixel(vid, nx+1, ny-1, cr, cg, cb, 32);
- blendpixel(vid, nx-1, ny+1, cr, cg, cb, 32);
- blendpixel(vid, nx+1, ny+1, cr, cg, cb, 32);
- blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32);
- }
- } else if(t==PT_PLUT&&cmode == 6)
- {
- int tempx;
- int tempy;
- cr = 0x40;
- cg = 0x70;
- cb = 0x20;
- blendpixel(vid, nx, ny, cr, cg, cb, 192);
- blendpixel(vid, nx+1, ny, cr, cg, cb, 96);
- blendpixel(vid, nx-1, ny, cr, cg, cb, 96);
- blendpixel(vid, nx, ny+1, cr, cg, cb, 96);
- blendpixel(vid, nx, ny-1, cr, cg, cb, 96);
- for(tempx = 2; tempx < 10; tempx++) {
- for(tempy = 2; tempy < 10; tempy++) {
- blendpixel(vid, nx+tempx, ny-tempy, cr, cg, cb, 5);
- blendpixel(vid, nx-tempx, ny+tempy, cr, cg, cb, 5);
- blendpixel(vid, nx+tempx, ny+tempy, cr, cg, cb, 5);
- blendpixel(vid, nx-tempx, ny-tempy, cr, cg, cb, 5);
- }
- }
- } else if(t==PT_URAN&&cmode == 6)
- {
- int tempx;
- int tempy;
- cr = 0x70;
- cg = 0x70;
- cb = 0x20;
- blendpixel(vid, nx, ny, cr, cg, cb, 192);
- blendpixel(vid, nx+1, ny, cr, cg, cb, 96);
- blendpixel(vid, nx-1, ny, cr, cg, cb, 96);
- blendpixel(vid, nx, ny+1, cr, cg, cb, 96);
- blendpixel(vid, nx, ny-1, cr, cg, cb, 96);
- for(tempx = 2; tempx < 10; tempx++) {
- for(tempy = 2; tempy < 10; tempy++) {
- blendpixel(vid, nx+tempx, ny-tempy, cr, cg, cb, 5);
- blendpixel(vid, nx-tempx, ny+tempy, cr, cg, cb, 5);
- blendpixel(vid, nx+tempx, ny+tempy, cr, cg, cb, 5);
- blendpixel(vid, nx-tempx, ny-tempy, cr, cg, cb, 5);
- }
- }
- } else if(t==PT_SLTW&&cmode == 6)
- {
- for(x=-1; x<=1; x++)
- {
- for(y=-1; y<=1; y++)
- {
- if ((abs(x) == 0) && (abs(y) == 0))
- blendpixel(vid,x+nx,y+ny,64,80,240,100);
- else if (abs(y) != 0 || abs(x) != 0)
- blendpixel(vid,x+nx,y+ny,64,80,240,50);
- }
- }
- }
- else if(t==PT_PHOT)
- {
- if(cmode == 3||cmode==4 || cmode==6)
- {
- vid[ny*(XRES+BARSIZE)+nx] = ptypes[t].pcolors;
- cg = 12;
- cb = 12;
- cr = 12;
- x = nx/CELL;
- y = ny/CELL;
- cg += fire_g[y][x];
- if(cg > 255) cg = 255;
- fire_g[y][x] = cg;
- cb += fire_b[y][x];
- if(cb > 255) cb = 255;
- fire_b[y][x] = cb;
- cr += fire_r[y][x];
- if(cr > 255) cr = 255;
- fire_r[y][x] = cr;
- }
- else
- {
- cr = 0xFF;
- cg = 0xFF;
- cb = 0xFF;
- blendpixel(vid, nx, ny, cr, cg, cb, 192);
- blendpixel(vid, nx+1, ny, cr, cg, cb, 96);
- blendpixel(vid, nx-1, ny, cr, cg, cb, 96);
- blendpixel(vid, nx, ny+1, cr, cg, cb, 96);
- blendpixel(vid, nx, ny-1, cr, cg, cb, 96);
- blendpixel(vid, nx+1, ny-1, cr, cg, cb, 32);
- blendpixel(vid, nx-1, ny+1, cr, cg, cb, 32);
- blendpixel(vid, nx+1, ny+1, cr, cg, cb, 32);
- blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32);
- }
- }
- else if(t==PT_SWCH && parts[i].life == 10)
- {
- x = nx;
- y = ny;
- blendpixel(vid,x,y,17,217,24,255);
- }
- else if(t==PT_LNTG&&cmode == 6)
- {
- for(x=-1; x<=1; x++)
- {
- for(y=-1; y<=1; y++)
- {
- if ((abs(x) == 0) && (abs(y) == 0))
- blendpixel(vid,x+nx,y+ny,128,160,223,100);
- else if (abs(y) != 0 || abs(x) != 0)
- blendpixel(vid,x+nx,y+ny,128,160,223,50);
- }
- }
- }
- else if(t==PT_SMKE)
- {
- if(cmode == 3||cmode==4 || cmode==6)
- {
- x = nx/CELL;
- y = ny/CELL;
- cg = 10;
- cb = 10;
- cr = 10;
- cg += fire_g[y][x];
- if(cg > 50) cg = 50;
- fire_g[y][x] = cg;
- cb += fire_b[y][x];
- if(cb > 50) cb = 50;
- fire_b[y][x] = cb;
- cr += fire_r[y][x];
- if(cr > 50) cr = 50;
- fire_r[y][x] = cr;
- }
- else
- {
- for(x=-3; x<4; x++)
- {
- for(y=-3; y<4; y++)
- {
- if (abs(x)+abs(y) <2 && !(abs(x)==2||abs(y)==2))
- blendpixel(vid,x+nx,y+ny,100,100,100,30);
- if(abs(x)+abs(y) <=3 && abs(x)+abs(y))
- blendpixel(vid,x+nx,y+ny,100,100,100,10);
- if (abs(x)+abs(y) == 2)
- blendpixel(vid,x+nx,y+ny,100,100,100,20);
- }
- }
- }
- }
- else if(t==PT_WATR&&cmode == 6)
- {
- for(x=-1; x<=1; x++)
- {
- for(y=-1; y<=1; y++)
- {
- if ((abs(x) == 0) && (abs(y) == 0))
- blendpixel(vid,x+nx,y+ny,32,48,208,100);
- else if (abs(y) != 0 || abs(x) != 0)
- blendpixel(vid,x+nx,y+ny,32,48,208,50);
- }
- }
-
- } else if(t==PT_DSTW&&cmode == 6)
- {
- for(x=-1; x<=1; x++)
- {
- for(y=-1; y<=1; y++)
- {
- if ((abs(x) == 0) && (abs(y) == 0))
- blendpixel(vid,x+nx,y+ny,32,48,208,100);
- else if (abs(y) != 0 || abs(x) != 0)
- blendpixel(vid,x+nx,y+ny,32,48,208,50);
- }
- }
- }
- else if(t==PT_NITR&&cmode == 6)
- {
- for(x=-1; x<=1; x++)
- {
- for(y=-1; y<=1; y++)
- {
- if ((abs(x) == 0) && (abs(y) == 0))
- blendpixel(vid,x+nx,y+ny,32,224,16,100);
- else if (abs(y) != 0 || abs(x) != 0)
- blendpixel(vid,x+nx,y+ny,32,224,16,50);
- }
- }
-
- }
- else if(t==PT_LRBD&&cmode == 6)
- {
- for(x=-1; x<=1; x++)
- {
- for(y=-1; y<=1; y++)
- {
- if ((abs(x) == 0) && (abs(y) == 0))
- blendpixel(vid,x+nx,y+ny,170,170,170,100);
- else if (abs(y) != 0 || abs(x) != 0)
- blendpixel(vid,x+nx,y+ny,170,170,170,50);
- }
- }
-
- }
-
- else if(t==PT_NBLE&&cmode == 6)
- {
- for(x=-1; x<=1; x++)
- {
- for(y=-1; y<=1; y++)
- {
- if ((abs(x) == 0) && (abs(y) == 0))
- blendpixel(vid,x+nx,y+ny,235,73,23,100);
- else if (abs(y) != 0 && abs(x) != 0)
- blendpixel(vid,x+nx,y+ny,235,73,23,30);
- else
- blendpixel(vid,x+nx,y+ny,235,73,23,50);
- }
- }
-
- }
- else if(t==PT_GASS&&cmode == 6)
- {
- for(x=-1; x<=1; x++)
- {
- for(y=-1; y<=1; y++)
- {
- if ((abs(x) == 0) && (abs(y) == 0))
- blendpixel(vid,x+nx,y+ny,255,255,0,180);
- else if (abs(y) != 0 && abs(x) != 0)
- blendpixel(vid,x+nx,y+ny,255,255,0,50);
- else
- blendpixel(vid,x+nx,y+ny,255,255,0,80);
- }
- }
-
- }
- else if(t==PT_WTRV)
- {
- if(cmode == 3||cmode==4 || cmode==6)
- {
- x = nx/CELL;
- y = ny/CELL;
- cg = PIXG(ptypes[t].pcolors)/3;
- cb = PIXB(ptypes[t].pcolors)/3;
- cr = PIXR(ptypes[t].pcolors)/3;
- cg += fire_g[y][x];
- if(cg > PIXG(ptypes[t].pcolors)/2) cg = PIXG(ptypes[t].pcolors)/2;
- fire_g[y][x] = cg;
- cb += fire_b[y][x];
- if(cb > PIXB(ptypes[t].pcolors)/2) cb = PIXB(ptypes[t].pcolors)/2;
- fire_b[y][x] = cb;
- cr += fire_r[y][x];
- if(cr > PIXR(ptypes[t].pcolors)/2) cr = PIXR(ptypes[t].pcolors)/2;
- fire_r[y][x] = cr;
- }
- else
- {
- for(x=-3; x<4; x++)
- {
- for(y=-3; y<4; y++)
- {
- if (abs(x)+abs(y) <2 && !(abs(x)==2||abs(y)==2))
- blendpixel(vid,x+nx,y+ny, PIXR(ptypes[t].pcolors)/1.6, PIXG(ptypes[t].pcolors)/1.6, PIXB(ptypes[t].pcolors)/1.6, 30);
- if(abs(x)+abs(y) <=3 && abs(x)+abs(y))
- blendpixel(vid,x+nx,y+ny, PIXR(ptypes[t].pcolors)/1.6, PIXG(ptypes[t].pcolors)/1.6, PIXB(ptypes[t].pcolors)/1.6, 10);
- if (abs(x)+abs(y) == 2)
- blendpixel(vid,x+nx,y+ny, PIXR(ptypes[t].pcolors)/1.6, PIXG(ptypes[t].pcolors)/1.6, PIXB(ptypes[t].pcolors)/1.6, 20);
- }
- }
- }
- }
- else if(t==PT_THDR)
- {
- if(cmode == 3||cmode==4 || cmode==6)
- {
- vid[ny*(XRES+BARSIZE)+nx] = ptypes[t].pcolors;
- cg = 16;
- cb = 20;
- cr = 12;
- x = nx/CELL;
- y = ny/CELL;
- cg += fire_g[y][x];
- if(cg > 255) cg = 255;
- fire_g[y][x] = cg;
- cb += fire_b[y][x];
- if(cb > 255) cb = 255;
- fire_b[y][x] = cb;
- cr += fire_r[y][x];
- if(cr > 255) cr = 255;
- fire_r[y][x] = cr;
- }
- else
- {
- cr = 0xFF;
- cg = 0xFF;
- cb = 0xA0;
- blendpixel(vid, nx, ny, cr, cg, cb, 192);
- blendpixel(vid, nx+1, ny, cr, cg, cb, 96);
- blendpixel(vid, nx-1, ny, cr, cg, cb, 96);
- blendpixel(vid, nx, ny+1, cr, cg, cb, 96);
- blendpixel(vid, nx, ny-1, cr, cg, cb, 96);
- blendpixel(vid, nx+1, ny-1, cr, cg, cb, 32);
- blendpixel(vid, nx-1, ny+1, cr, cg, cb, 32);
- blendpixel(vid, nx+1, ny+1, cr, cg, cb, 32);
- blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32);
- }
- }
- else if(t==PT_LCRY)
- {
- if(cmode == 3||cmode==4 || cmode==6)
- {
- //cr = R/8;
- //cg = G/8;
- //cb = B/8;
- vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(0x50+(parts[i].life*10), 0x50+(parts[i].life*10), 0x50+(parts[i].life*10));
- //x = nx/CELL;
- //y = ny/CELL;
- //cg += fire_g[y][x]; if(cg > 255) cg = 255; fire_g[y][x] = cg;
- //cb += fire_b[y][x]; if(cb > 255) cb = 255; fire_b[y][x] = cb;
- //cr += fire_r[y][x]; if(cr > 255) cr = 255; fire_r[y][x] = cr;
- }
- else
- {
- cr = 0x50+(parts[i].life*10);
- cg = 0x50+(parts[i].life*10);
- cb = 0x50+(parts[i].life*10);
- blendpixel(vid, nx, ny, cr, cg, cb, 192);
- blendpixel(vid, nx+1, ny, cr, cg, cb, 96);
- blendpixel(vid, nx-1, ny, cr, cg, cb, 96);
- blendpixel(vid, nx, ny+1, cr, cg, cb, 96);
- blendpixel(vid, nx, ny-1, cr, cg, cb, 96);
- blendpixel(vid, nx+1, ny-1, cr, cg, cb, 32);
- blendpixel(vid, nx-1, ny+1, cr, cg, cb, 32);
- blendpixel(vid, nx+1, ny+1, cr, cg, cb, 32);
- blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32);
- }
- } else if(t==PT_PLSM)
- {
- float ttemp = parts[i].life;
- int caddress = restrict_flt(restrict_flt(ttemp, 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3);
- uint8 R = plasma_data[caddress];
- uint8 G = plasma_data[caddress+1];
- uint8 B = plasma_data[caddress+2];
- if(cmode == 3||cmode==4 || cmode==6)
- {
- cr = R/8;
- cg = G/8;
- cb = B/8;
- x = nx/CELL;
- y = ny/CELL;
- cg += fire_g[y][x];
- if(cg > 255) cg = 255;
- fire_g[y][x] = cg;
- cb += fire_b[y][x];
- if(cb > 255) cb = 255;
- fire_b[y][x] = cb;
- cr += fire_r[y][x];
- if(cr > 255) cr = 255;
- fire_r[y][x] = cr;
- }
- else
- {
- cr = R;
- cg = G;
- cb = B;
- blendpixel(vid, nx, ny, cr, cg, cb, 192);
- blendpixel(vid, nx+1, ny, cr, cg, cb, 96);
- blendpixel(vid, nx-1, ny, cr, cg, cb, 96);
- blendpixel(vid, nx, ny+1, cr, cg, cb, 96);
- blendpixel(vid, nx, ny-1, cr, cg, cb, 96);
- blendpixel(vid, nx+1, ny-1, cr, cg, cb, 32);
- blendpixel(vid, nx-1, ny+1, cr, cg, cb, 32);
- blendpixel(vid, nx+1, ny+1, cr, cg, cb, 32);
- blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32);
- }
- }
- else if(t==PT_FIRE && parts[i].life)
- {
- if(cmode == 3||cmode==4 || cmode==6)
- {
- cr = parts[i].life / 4;
- cg = parts[i].life / 16;
- cb = parts[i].life / 32;
- if(cr>255) cr = 255;
- if(cg>192) cg = 212;
- if(cb>128) cb = 192;
- x = nx/CELL;
- y = ny/CELL;
- cr += fire_r[y][x];
- if(cr > 255) cr = 255;
- fire_r[y][x] = cr;
- cg += fire_g[y][x];
- if(cg > 255) cg = 255;
- fire_g[y][x] = cg;
- cb += fire_b[y][x];
- if(cb > 255) cb = 255;
- fire_b[y][x] = cb;
- }
- else
- {
- cr = parts[i].life * 8;
- cg = parts[i].life * 2;
- cb = parts[i].life;
- if(cr>255) cr = 255;
- if(cg>192) cg = 212;
- if(cb>128) cb = 192;
- blendpixel(vid, nx, ny, cr, cg, cb, 255);
- blendpixel(vid, nx+1, ny, cr, cg, cb, 96);
- blendpixel(vid, nx-1, ny, cr, cg, cb, 96);
- blendpixel(vid, nx, ny+1, cr, cg, cb, 96);
- blendpixel(vid, nx, ny-1, cr, cg, cb, 96);
- blendpixel(vid, nx+1, ny-1, cr, cg, cb, 32);
- blendpixel(vid, nx-1, ny+1, cr, cg, cb, 32);
- blendpixel(vid, nx+1, ny+1, cr, cg, cb, 32);
- blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32);
- }
- }
- else if(t==PT_LAVA && parts[i].life)
- {
- cr = parts[i].life * 2 + 0xE0;
- cg = parts[i].life * 1 + 0x50;
- cb = parts[i].life/2 + 0x10;
- if(cr>255) cr = 255;
- if(cg>192) cg = 192;
- if(cb>128) cb = 128;
- blendpixel(vid, nx, ny, cr, cg, cb, 255);
- blendpixel(vid, nx+1, ny, cr, cg, cb, 64);
- blendpixel(vid, nx-1, ny, cr, cg, cb, 64);
- blendpixel(vid, nx, ny+1, cr, cg, cb, 64);
- blendpixel(vid, nx, ny-1, cr, cg, cb, 64);
- if(cmode == 3||cmode==4 || cmode==6)
- {
- cr /= 32;
- cg /= 32;
- cb /= 32;
- x = nx/CELL;
- y = ny/CELL;
- cr += fire_r[y][x];
- if(cr > 255) cr = 255;
- fire_r[y][x] = cr;
- cg += fire_g[y][x];
- if(cg > 255) cg = 255;
- fire_g[y][x] = cg;
- cb += fire_b[y][x];
- if(cb > 255) cb = 255;
- fire_b[y][x] = cb;
- }
- }
- else if(t==PT_LAVA || t==PT_SPRK)
- {
- vid[ny*(XRES+BARSIZE)+nx] = ptypes[t].pcolors;
- if(cmode == 3 || cmode==4 || cmode==6)
- {
- if(t == PT_LAVA)
- {
- cr = 3;
- cg = i%2;
- cb = 0;
- }
- else
- {
- cr = 8;
- cg = 12;
- cb = 16;
- }
- x = nx/CELL;
- y = ny/CELL;
- cr += fire_r[y][x];
- if(cr > 255) cr = 255;
- fire_r[y][x] = cr;
- cg += fire_g[y][x];
- if(cg > 255) cg = 255;
- fire_g[y][x] = cg;
- cb += fire_b[y][x];
- if(cb > 255) cb = 255;
- fire_b[y][x] = cb;
- }
- }
- else
- vid[ny*(XRES+BARSIZE)+nx] = ptypes[t].pcolors;
- }
- else
- {
- float ttemp = parts[i].temp+(-MIN_TEMP);
- int caddress = restrict_flt((int)( restrict_flt(ttemp, 0.0f, MAX_TEMP+(-MIN_TEMP)) / ((MAX_TEMP+(-MIN_TEMP))/512) ) *3, 0.0f, (512.0f*3)-3);
- uint8 R = color_data[caddress];
- uint8 G = color_data[caddress+1];
- uint8 B = color_data[caddress+2];
-
- if(t==PT_STKM) //Stick man should be visible in heat mode
- {
- char buff[10]; //Buffer for HP
-
- if(mousex>(nx-3) && mousex<(nx+3) && mousey<(ny+3) && mousey>(ny-3)) //If mous is in the head
- {
- sprintf(buff, "%3d", (int)parts[i].life); //Show HP
- drawtext(vid, mousex-8-2*(parts[i].life<100)-2*(parts[i].life<10), mousey-12, buff, 255, 255, 255, 255);
- }
-
- for(r=-2; r<=1; r++)
- {
- s = XRES+BARSIZE;
- vid[(ny-2)*s+nx+r] = PIXRGB (R, G, B);
- vid[(ny+2)*s+nx+r+1] = PIXRGB (R, G, B);
- vid[(ny+r+1)*s+nx-2] = PIXRGB (R, G, B);
- vid[(ny+r)*s+nx+2] = PIXRGB (R, G, B);
- }
- draw_line(vid , nx, ny+3, player[3], player[4], R, G, B, s);
- draw_line(vid , player[3], player[4], player[7], player[8], R, G, B, s);
- draw_line(vid , nx, ny+3, player[11], player[12], R, G, B, s);
- draw_line(vid , player[11], player[12], player[15], player[16], R, G, B, s);
- }
- else
- {
- vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(R, G, B);
- //blendpixel(vid, nx+1, ny, R, G, B, 255);
- }
- }
- if(cmode == 4&&t!=PT_FIRE&&t!=PT_PLSM&&t!=PT_NONE&&t!=PT_ACID)
- {
- uint8 R = PIXR(ptypes[t].pcolors);
- uint8 G = PIXG(ptypes[t].pcolors);
- uint8 B = PIXB(ptypes[t].pcolors);
-
- //if(vid[(ny-1)*YRES+(nx-1)]!=0){
- // blendpixel(vid, nx, ny-1, R, G, B, 46);
- //}
-
- blendpixel(vid, nx+1, ny, R, G, B, 223);
- blendpixel(vid, nx-1, ny, R, G, B, 223);
- blendpixel(vid, nx, ny+1, R, G, B, 223);
- blendpixel(vid, nx, ny-1, R, G, B, 223);
-
- blendpixel(vid, nx+1, ny-1, R, G, B, 112);
- blendpixel(vid, nx-1, ny-1, R, G, B, 112);
- blendpixel(vid, nx+1, ny+1, R, G, B, 112);
- blendpixel(vid, nx-1, ny+1, R, G, B, 112);
- }
- }
- if(framerender){
- framerender = 0;
- sys_pause = 1;
- }
-}
-
-void update_particles_i_th(void *arg)
-{
- upstruc *newup = (upstruc*)arg;
- update_particles_i(newup[0].vid, newup[0].start, newup[0].inc);
- return;
-}
-
-void update_particles(pixel *vid)
-{
- int i, j, x, y, t, nx, ny, r, cr,cg,cb, l = -1;
- float lx, ly;
-#ifdef MT
- int pt = 0, pc = 0;
- pthread_t *InterThreads;
-#endif
-
- isplayer = 0; //Needed for player spawning
- memset(pmap, 0, sizeof(pmap));
- r = rand()%2;
- for(j=0; j<NPART; j++)
- {
- i = r ? (NPART-1-j) : j;
- if(parts[i].type)
- {
- t = parts[i].type;
- x = (int)(parts[i].x+0.5f);
- y = (int)(parts[i].y+0.5f);
- if(x>=0 && y>=0 && x<XRES && y<YRES)
- pmap[y][x] = t|(i<<8);
- }
- else
- {
- parts[i].life = l;
- l = i;
- }
- }
- pfree=l;
- if(cmode==4)
- {
- for(y=0; y<YRES/CELL; y++)
- {
- for(x=0; x<XRES/CELL; x++)
- {
- if(bmap[y][x]==1)
- for(j=0; j<CELL; j++)
- for(i=0; i<CELL; i++)
- {
- pmap[y*CELL+j][x*CELL+i] = 0x7FFFFFFF;
- vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
- drawblob(vid, (x*CELL+i), (y*CELL+j), 0x80, 0x80, 0x80);
-
- }
- if(bmap[y][x]==2)
- for(j=0; j<CELL; j+=2)
- for(i=(j>>1)&1; i<CELL; i+=2)
- {
- vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
- drawblob(vid, (x*CELL+i), (y*CELL+j), 0x80, 0x80, 0x80);
- }
- if(bmap[y][x]==3)
- {
- for(j=0; j<CELL; j++)
- for(i=0; i<CELL; i++)
- if(!((y*CELL+j)%2) && !((x*CELL+i)%2))
- {
- vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0xC0C0C0);
- drawblob(vid, (x*CELL+i), (y*CELL+j), 0xC0, 0xC0, 0xC0);
- }
- if(emap[y][x])
- {
- cr = cg = cb = 16;
- cr += fire_r[y][x];
- if(cr > 255) cr = 255;
- fire_r[y][x] = cr;
- cg += fire_g[y][x];
- if(cg > 255) cg = 255;
- fire_g[y][x] = cg;
- cb += fire_b[y][x];
- if(cb > 255) cb = 255;
- fire_b[y][x] = cb;
- }
- }
- if(bmap[y][x]==4)
- for(j=0; j<CELL; j+=2)
- for(i=(j>>1)&1; i<CELL; i+=2)
- {
- vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x8080FF);
- drawblob(vid, (x*CELL+i), (y*CELL+j), 0x80, 0x80, 0xFF);
- }
- if(bmap[y][x]==6)
- {
- for(j=0; j<CELL; j+=2)
- for(i=(j>>1)&1; i<CELL; i+=2)
- {
- vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0xFF8080);
- drawblob(vid, (x*CELL+i), (y*CELL+j), 0xFF, 0x80, 0x80);
- }
- if(emap[y][x])
- {
- cr = 255;
- cg = 32;
- cb = 8;
- cr += fire_r[y][x];
- if(cr > 255) cr = 255;
- fire_r[y][x] = cr;
- cg += fire_g[y][x];
- if(cg > 255) cg = 255;
- fire_g[y][x] = cg;
- cb += fire_b[y][x];
- if(cb > 255) cb = 255;
- fire_b[y][x] = cb;
- }
- }
- if(bmap[y][x]==7)
- {
- if(emap[y][x])
- {
- cr = cg = cb = 128;
- cr += fire_r[y][x];
- if(cr > 255) cr = 255;
- fire_r[y][x] = cr;
- cg += fire_g[y][x];
- if(cg > 255) cg = 255;
- fire_g[y][x] = cg;
- cb += fire_b[y][x];
- if(cb > 255) cb = 255;
- fire_b[y][x] = cb;
- for(j=0; j<CELL; j++)
- for(i=0; i<CELL; i++)
- if(i&j&1)
- {
- vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
- drawblob(vid, (x*CELL+i), (y*CELL+j), 0x80, 0x80, 0x80);
- }
- }
- else
- {
- for(j=0; j<CELL; j++)
- for(i=0; i<CELL; i++)
- pmap[y*CELL+j][x*CELL+i] = 0x7FFFFFFF;
- for(j=0; j<CELL; j++)
- for(i=0; i<CELL; i++)
- if(!(i&j&1))
- {
- vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
- drawblob(vid, (x*CELL+i), (y*CELL+j), 0x80, 0x80, 0x80);
- }
- }
- }
- if(bmap[y][x]==8)
- {
- for(j=0; j<CELL; j++)
- for(i=0; i<CELL; i++)
- {
- pmap[y*CELL+j][x*CELL+i] = 0x7FFFFFFF;
- if(!((y*CELL+j)%2) && !((x*CELL+i)%2))
- {
- vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0xC0C0C0);
- drawblob(vid, (x*CELL+i), (y*CELL+j), 0xC0, 0xC0, 0xC0);
- }
- else
- {
- vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
- drawblob(vid, (x*CELL+i), (y*CELL+j), 0x80, 0x80, 0x80);
- }
- }
- if(emap[y][x])
- {
- cr = cg = cb = 16;
- cr += fire_r[y][x];
- if(cr > 255) cr = 255;
- fire_r[y][x] = cr;
- cg += fire_g[y][x];
- if(cg > 255) cg = 255;
- fire_g[y][x] = cg;
- cb += fire_b[y][x];
- if(cb > 255) cb = 255;
- fire_b[y][x] = cb;
- }
- }
- if(bmap[y][x]==11)
- {
- for(j=0; j<CELL; j++)
- for(i=0; i<CELL; i++)
- {
- //pmap[y*CELL+j][x*CELL+i] = 0x7FFFFFFF;
- if(!((y*CELL+j)%2) && !((x*CELL+i)%2))
- {
- vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0xFFFF22);
- drawblob(vid, (x*CELL+i), (y*CELL+j), 0xFF, 0xFF, 0x22);
- }
-
- }
- if(emap[y][x])
- {
- cr = cg = cb = 16;
- cr += fire_r[y][x];
- if(cr > 255) cr = 255;
- fire_r[y][x] = cr;
- cg += fire_g[y][x];
- if(cg > 255) cg = 255;
- fire_g[y][x] = cg;
- cb += fire_b[y][x];
- if(cb > 255) cb = 255;
- fire_b[y][x] = cb;
- }
- }
- if(bmap[y][x]==13)
- {
- for(j=0; j<CELL; j+=2)
- {
- for(i=(j>>1)&1; i<CELL; i+=2)
- {
- vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x579777);
- drawblob(vid, (x*CELL+i), (y*CELL+j), 0x57, 0x97, 0x77);
- }
- }
- }
- if(bmap[y][x]==9)
- {
- for(j=0; j<CELL; j+=2)
- {
- for(i=(j>>1)&1; i<CELL; i+=2)
- {
- vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x3C3C3C);
- drawblob(vid, (x*CELL+i), (y*CELL+j), 0x3C, 0x3C, 0x3C);
- }
- }
- }
- if(bmap[y][x]==10)
- {
- for(j=0; j<CELL; j+=2)
- {
- for(i=(j>>1)&1; i<CELL; i+=2)
- {
- vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x575757);
- drawblob(vid, (x*CELL+i), (y*CELL+j), 0x57, 0x57, 0x57);
- }
- }
- }
- if(bmap[y][x]==12)
- {
- if(emap[y][x])
- {
- for(j=0; j<CELL; j++)
- {
- for(i=(j)&1; i<CELL; i++)
- {
- vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x242424);
- drawblob(vid, (x*CELL+i), (y*CELL+j), 0x24, 0x24, 0x24);
- }
- }
- for(j=0; j<CELL; j+=2)
- {
- for(i=(j)&1; i<CELL; i+=2)
- {
- vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x000000);
- }
- }
- }
- else
- {
- for(j=0; j<CELL; j+=2)
- {
- for(i=(j)&1; i<CELL; i+=2)
- {
- vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x242424);
- drawblob(vid, (x*CELL+i), (y*CELL+j), 0x24, 0x24, 0x24);
- }
- }
- }
- if(emap[y][x])
- {
- cr = cg = cb = 16;
- cr += fire_r[y][x];
- if(cr > 255) cr = 255;
- fire_r[y][x] = cr;
- cg += fire_g[y][x];
- if(cg > 255) cg = 255;
- fire_g[y][x] = cg;
- cb += fire_b[y][x];
- if(cb > 255) cb = 255;
- fire_b[y][x] = cb;
- }
- }
- if(emap[y][x] && (!sys_pause||framerender))
- emap[y][x] --;
- }
- }
- }
- else
- {
- for(y=0; y<YRES/CELL; y++)
- {
- for(x=0; x<XRES/CELL; x++)
- {
- if(bmap[y][x]==1)
- for(j=0; j<CELL; j++)
- for(i=0; i<CELL; i++)
- {
- pmap[y*CELL+j][x*CELL+i] = 0x7FFFFFFF;
- vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
- }
- if(bmap[y][x]==2)
- for(j=0; j<CELL; j+=2)
- for(i=(j>>1)&1; i<CELL; i+=2)
- vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
- if(bmap[y][x]==3)
- {
- for(j=0; j<CELL; j++)
- for(i=0; i<CELL; i++)
- if(!((y*CELL+j)%2) && !((x*CELL+i)%2))
- vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0xC0C0C0);
- if(emap[y][x])
- {
- cr = cg = cb = 16;
- cr += fire_r[y][x];
- if(cr > 255) cr = 255;
- fire_r[y][x] = cr;
- cg += fire_g[y][x];
- if(cg > 255) cg = 255;
- fire_g[y][x] = cg;
- cb += fire_b[y][x];
- if(cb > 255) cb = 255;
- fire_b[y][x] = cb;
- }
- }
- if(bmap[y][x]==4)
- for(j=0; j<CELL; j+=2)
- for(i=(j>>1)&1; i<CELL; i+=2)
- vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x8080FF);
- if(bmap[y][x]==6)
- {
- for(j=0; j<CELL; j+=2)
- for(i=(j>>1)&1; i<CELL; i+=2)
- vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0xFF8080);
- if(emap[y][x])
- {
- cr = 255;
- cg = 32;
- cb = 8;
- cr += fire_r[y][x];
- if(cr > 255) cr = 255;
- fire_r[y][x] = cr;
- cg += fire_g[y][x];
- if(cg > 255) cg = 255;
- fire_g[y][x] = cg;
- cb += fire_b[y][x];
- if(cb > 255) cb = 255;
- fire_b[y][x] = cb;
- }
- }
- if(bmap[y][x]==7)
- {
- if(emap[y][x])
- {
- cr = cg = cb = 128;
- cr += fire_r[y][x];
- if(cr > 255) cr = 255;
- fire_r[y][x] = cr;
- cg += fire_g[y][x];
- if(cg > 255) cg = 255;
- fire_g[y][x] = cg;
- cb += fire_b[y][x];
- if(cb > 255) cb = 255;
- fire_b[y][x] = cb;
- for(j=0; j<CELL; j++)
- for(i=0; i<CELL; i++)
- if(i&j&1)
- vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
- }
- else
- {
- for(j=0; j<CELL; j++)
- for(i=0; i<CELL; i++)
- pmap[y*CELL+j][x*CELL+i] = 0x7FFFFFFF;
- for(j=0; j<CELL; j++)
- for(i=0; i<CELL; i++)
- if(!(i&j&1))
- vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
- }
- }
- if(bmap[y][x]==8)
- {
- for(j=0; j<CELL; j++)
- for(i=0; i<CELL; i++)
- {
- pmap[y*CELL+j][x*CELL+i] = 0x7FFFFFFF;
- if(!((y*CELL+j)%2) && !((x*CELL+i)%2))
- vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0xC0C0C0);
- else
- vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
- }
- if(emap[y][x])
- {
- cr = cg = cb = 16;
- cr += fire_r[y][x];
- if(cr > 255) cr = 255;
- fire_r[y][x] = cr;
- cg += fire_g[y][x];
- if(cg > 255) cg = 255;
- fire_g[y][x] = cg;
- cb += fire_b[y][x];
- if(cb > 255) cb = 255;
- fire_b[y][x] = cb;
- }
- }
- if(bmap[y][x]==11)
- {
- for(j=0; j<CELL; j++)
- for(i=0; i<CELL; i++)
- {
- //pmap[y*CELL+j][x*CELL+i] = 0x7FFFFFFF;
- if(!((y*CELL+j)%2) && !((x*CELL+i)%2))
- vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0xFFFF22);
-
- }
- if(emap[y][x])
- {
- cr = cg = cb = 16;
- cr += fire_r[y][x];
- if(cr > 255) cr = 255;
- fire_r[y][x] = cr;
- cg += fire_g[y][x];
- if(cg > 255) cg = 255;
- fire_g[y][x] = cg;
- cb += fire_b[y][x];
- if(cb > 255) cb = 255;
- fire_b[y][x] = cb;
- }
- }
- if(bmap[y][x]==9)
- {
- for(j=0; j<CELL; j+=2)
- {
- for(i=(j>>1)&1; i<CELL; i+=2)
- {
- vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x3C3C3C);
- }
- }
- }
- if(bmap[y][x]==13)
- {
- for(j=0; j<CELL; j+=2)
- {
- for(i=(j>>1)&1; i<CELL; i+=2)
- {
- vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x579777);
- }
- }
- }
- if(bmap[y][x]==10)
- {
- for(j=0; j<CELL; j+=2)
- {
- for(i=(j>>1)&1; i<CELL; i+=2)
- {
- vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x575757);
- }
- }
- }
- if(bmap[y][x]==12)
- {
- if(emap[y][x])
- {
- for(j=0; j<CELL; j++)
- {
- for(i=(j)&1; i<CELL; i++)
- {
- vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x242424);
- }
- }
- for(j=0; j<CELL; j+=2)
- {
- for(i=(j)&1; i<CELL; i+=2)
- {
- vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x000000);
- }
- }
- }
- else
- {
- for(j=0; j<CELL; j+=2)
- {
- for(i=(j)&1; i<CELL; i+=2)
- {
- vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x242424);
- }
- }
- }
- if(emap[y][x])
- {
- cr = cg = cb = 16;
- cr += fire_r[y][x];
- if(cr > 255) cr = 255;
- fire_r[y][x] = cr;
- cg += fire_g[y][x];
- if(cg > 255) cg = 255;
- fire_g[y][x] = cg;
- cb += fire_b[y][x];
- if(cb > 255) cb = 255;
- fire_b[y][x] = cb;
- }
- }
- if(emap[y][x] && (!sys_pause||framerender))
- emap[y][x] --;
- }
- }
- }
-
-#ifdef MT
- if(numCores > 1)
- {
- InterThreads = (pthread_t *)calloc(sizeof(pthread_t), numCores);
- for(pc = 0; pc<numCores-1; pc++)
- {
- upstruc *upargs = calloc(sizeof(upstruc), 1);
- upargs[0].vid = vid;
- upargs[0].start = pc;
- upargs[0].inc = numCores-1;
- pthread_create(&InterThreads[pc], NULL, update_particles_i_th, upargs);
- }
- for(pt = 0; pt<numCores-1; pt++)
- {
- pthread_join(InterThreads[pt],NULL);
- }
- }
- else
- {
- update_particles_i(vid, 0, 1);
- }
-#else
- update_particles_i(vid, 0, 1);
-#endif
- //update_particles_i(vid, 0);
- //update_particles_i(vid, 1);
-
- for(y=0; y<YRES/CELL; y++)
- for(x=0; x<XRES/CELL; x++)
- if(bmap[y][x]==5)
- {
- lx = x*CELL + CELL*0.5f;
- ly = y*CELL + CELL*0.5f;
- for(t=0; t<1024; t++)
- {
- nx = (int)(lx+0.5f);
- ny = (int)(ly+0.5f);
- if(nx<0 || nx>=XRES || ny<0 || ny>=YRES)
- break;
- addpixel(vid, nx, ny, 255, 255, 255, 64);
- i = nx/CELL;
- j = ny/CELL;
- lx += vx[j][i]*0.125f;
- ly += vy[j][i]*0.125f;
- if(bmap[j][i]==5 && i!=x && j!=y)
- break;
- }
- drawtext(vid, x*CELL, y*CELL-2, "\x8D", 255, 255, 255, 128);
- }
-
-}
-
-void update_particles_th(void *arg)
-{
- update_particles((pixel*)arg);
- return;
-}
/***********************************************************
* SDL OUTPUT *
@@ -8390,6 +5006,7 @@ int main(int argc, char *argv[])
memset(vid_buf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
}
update_particles(vid_buf);
+ draw_parts(vid_buf);
if(cmode==2)
{
@@ -9307,3 +5924,4 @@ int main(int argc, char *argv[])
http_done();
return 0;
}
+
diff --git a/powder.c b/powder.c
index e69de29..d6b71d9 100644
--- a/powder.c
+++ b/powder.c
@@ -0,0 +1,2547 @@
+#include <math.h>
+#include "defines.h"
+#include "powder.h"
+#include "air.h"
+#include "misc.h"
+
+int isplayer = 0;
+float player[20]; //[0] is a command cell, [3]-[18] are legs positions, [19] is index
+
+particle *parts;
+particle *cb_parts;
+
+unsigned char bmap[YRES/CELL][XRES/CELL];
+unsigned char emap[YRES/CELL][XRES/CELL];
+
+unsigned char cb_bmap[YRES/CELL][XRES/CELL];
+unsigned char cb_emap[YRES/CELL][XRES/CELL];
+
+int pfree;
+
+unsigned pmap[YRES][XRES];
+unsigned cb_pmap[YRES][XRES];
+
+int try_move(int i, int x, int y, int nx, int ny)
+{
+ unsigned r;
+
+
+ if(nx<0 || ny<0 || nx>=XRES || ny>=YRES)
+ return 0;
+ if(x==nx && y==ny)
+ return 1;
+ r = pmap[ny][nx];
+ if(r && (r>>8)<NPART)
+ r = (r&~0xFF) | parts[r>>8].type;
+
+ if(parts[i].type==PT_PHOT&&((r&0xFF)==PT_GLAS||(r&0xFF)==PT_PHOT||(r&0xFF)==PT_CLNE||((r&0xFF)==PT_LCRY&&parts[r>>8].life > 5)))
+ {
+ return 1;
+ }
+
+ if((r&0xFF)==PT_VOID)
+ {
+ parts[i].type=PT_NONE;
+ return 0;
+ }
+ if((r&0xFF)==PT_BHOL)
+ {
+ parts[i].type=PT_NONE;
+ if(!legacy_enable)
+ {
+ parts[r>>8].temp = restrict_flt(parts[r>>8].temp+parts[i].temp/2, MIN_TEMP, MAX_TEMP);//3.0f;
+ }
+ return 0;
+ }
+
+ if(parts[i].type==PT_STKM) //Stick man's head shouldn't collide
+ {
+ return 1;
+ }
+
+ if(bmap[ny/CELL][nx/CELL]==12 && !emap[y/CELL][x/CELL])
+ {
+ return 1;
+ }
+ if(bmap[ny/CELL][nx/CELL]==13 && ptypes[parts[i].type].falldown!=0 && parts[i].type!=PT_FIRE)
+ {
+ return 0;
+ }
+ if((bmap[y/CELL][x/CELL]==12 && !emap[y/CELL][x/CELL]) && (bmap[ny/CELL][nx/CELL]!=12 && !emap[ny/CELL][nx/CELL]))
+ {
+ return 0;
+ }
+
+ if(ptypes[parts[i].type].falldown!=2 && bmap[ny/CELL][nx/CELL]==3)
+ return 0;
+ if((parts[i].type==PT_NEUT ||parts[i].type==PT_PHOT) && bmap[ny/CELL][nx/CELL]==7 && !emap[ny/CELL][nx/CELL])
+ return 0;
+ if(r && (r>>8)<NPART && ptypes[r&0xFF].falldown!=2 && bmap[y/CELL][x/CELL]==3)
+ return 0;
+
+ if(bmap[ny/CELL][nx/CELL]==9)
+ return 0;
+
+ if(ptypes[parts[i].type].falldown!=1 && bmap[ny/CELL][nx/CELL]==10)
+ return 0;
+
+ if (r && ((r&0xFF) >= PT_NUM || !can_move[parts[i].type][(r&0xFF)]))
+ return 0;
+
+ if(parts[i].type==PT_CNCT && y<ny && (pmap[y+1][x]&0xFF)==PT_CNCT)
+ {
+ return 0;
+ }
+
+ pmap[ny][nx] = (i<<8)|parts[i].type;
+ pmap[y][x] = r;
+ if(r && (r>>8)<NPART)
+ {
+ r >>= 8;
+ parts[r].x += x-nx;
+ parts[r].y += y-ny;
+ }
+
+ return 1;
+}
+
+void kill_part(int i)
+{
+ int x, y;
+ parts[i].type = PT_NONE;
+
+ x = (int)(parts[i].x+0.5f);
+ y = (int)(parts[i].y+0.5f);
+
+ if(x>=0 && y>=0 && x<XRES && y<YRES)
+ pmap[y][x] = 0;
+
+ parts[i].life = pfree;
+ pfree = i;
+}
+
+#ifdef WIN32
+_inline int create_part(int p, int x, int y, int t)
+#else
+inline int create_part(int p, int x, int y, int t)
+#endif
+{
+ int i;
+
+ if(x<0 || y<0 || x>=XRES || y>=YRES)
+ return -1;
+
+ if(t==SPC_HEAT||t==SPC_COOL)
+ {
+ if((pmap[y][x]&0xFF)!=PT_NONE&&(pmap[y][x]&0xFF)<PT_NUM)
+ {
+ if(t==SPC_HEAT&&parts[pmap[y][x]>>8].temp<MAX_TEMP)
+ {
+ parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp + 4.0f, MIN_TEMP, MAX_TEMP);
+ }
+ if(t==SPC_COOL&&parts[pmap[y][x]>>8].temp>MIN_TEMP)
+ {
+ parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp - 4.0f, MIN_TEMP, MAX_TEMP);
+ }
+ return pmap[y][x]>>8;
+ }
+ else
+ {
+ return -1;
+ }
+ }
+ 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)
+ {
+ pv[y/CELL][x/CELL+1] += 0.03f;
+ if(y+CELL<YRES)
+ 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;
+ }
+ return -1;
+ }
+
+ if(t==PT_SPRK)
+ {
+ if((pmap[y][x]&0xFF)!=PT_METL &&
+ (pmap[y][x]&0xFF)!=PT_PSCN &&
+ (pmap[y][x]&0xFF)!=PT_NSCN &&
+ (pmap[y][x]&0xFF)!=PT_NTCT &&
+ (pmap[y][x]&0xFF)!=PT_PTCT &&
+ (pmap[y][x]&0xFF)!=PT_WATR &&
+ (pmap[y][x]&0xFF)!=PT_SLTW &&
+ (pmap[y][x]&0xFF)!=PT_BMTL &&
+ (pmap[y][x]&0xFF)!=PT_RBDM &&
+ (pmap[y][x]&0xFF)!=PT_LRBD &&
+ (pmap[y][x]&0xFF)!=PT_ETRD &&
+ (pmap[y][x]&0xFF)!=PT_BRMT &&
+ (pmap[y][x]&0xFF)!=PT_NBLE &&
+ (pmap[y][x]&0xFF)!=PT_INWR)
+ 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;
+ pmap[y][x] = (pmap[y][x]&~0xFF) | PT_SPRK;
+ return pmap[y][x]>>8;
+ }
+
+ if(p==-1)
+ {
+ if(pmap[y][x])
+ return -1;
+ if(pfree == -1)
+ return -1;
+ i = pfree;
+ pfree = parts[i].life;
+ }
+ else
+ i = p;
+
+ if(t==PT_GLAS)
+ {
+ parts[i].pavg[1] = pv[y/CELL][x/CELL];
+ }
+ if(t!=PT_STKM)
+ {
+ parts[i].x = (float)x;
+ parts[i].y = (float)y;
+ parts[i].type = t;
+ parts[i].vx = 0;
+ parts[i].vy = 0;
+ parts[i].life = 0;
+ parts[i].ctype = 0;
+ parts[i].temp = ptypes[t].heat;
+ }
+ if(t==PT_ACID)
+ {
+ parts[i].life = 75;
+ }
+ /*Testing
+ if(t==PT_WOOD){
+ parts[i].life = 150;
+ }
+ End Testing*/
+ if(t==PT_FIRE)
+ parts[i].life = rand()%50+120;
+ if(t==PT_PLSM)
+ parts[i].life = rand()%150+50;
+ if(t==PT_LAVA)
+ parts[i].life = rand()%120+240;
+ if(t==PT_NBLE)
+ parts[i].life = 0;
+ if(t==PT_NEUT)
+ {
+ float r = (rand()%128+128)/127.0f;
+ float a = (rand()%360)*3.14159f/180.0f;
+ parts[i].life = rand()%480+480;
+ parts[i].vx = r*cosf(a);
+ parts[i].vy = r*sinf(a);
+ }
+ if(t==PT_PHOT)
+ {
+ float r = (rand()%3-1)*3;
+ float a = (rand()%3-1)*3;
+ parts[i].life = 680;
+ if(a==0.0f&&r==0.0f)
+ {
+ parts[i].life = 0;
+ parts[i].type = PT_NONE;
+ return -1;
+ }
+ else
+ {
+ parts[i].vx = a;
+ parts[i].vy = r;
+ }
+ //} else {
+ // parts[i].life = 0;
+ // parts[i].type = PT_NONE;
+ //}/
+ }
+
+ if(t!=PT_STKM)
+ pmap[y][x] = t|(i<<8);
+ else
+ {
+ if(isplayer==0)
+ {
+ 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;
+
+
+
+ player[3] = x-1; //Setting legs positions
+ player[4] = y+6;
+ player[5] = x-1;
+ player[6] = y+6;
+
+ player[7] = x-3;
+ player[8] = y+12;
+ player[9] = x-3;
+ player[10] = y+12;
+
+ player[11] = x+1;
+ player[12] = y+6;
+ player[13] = x+1;
+ player[14] = y+6;
+
+ player[15] = x+3;
+ player[16] = y+12;
+ player[17] = x+3;
+ player[18] = y+12;
+
+ isplayer = 1;
+ }
+ }
+
+ return i;
+}
+
+#ifdef WIN32
+_inline void delete_part(int x, int y)
+#else
+inline void delete_part(int x, int y)
+#endif
+{
+ unsigned i;
+
+ if(x<0 || y<0 || x>=XRES || y>=YRES)
+ return;
+ i = pmap[y][x];
+ if(!i || (i>>8)>=NPART)
+ return;
+
+ kill_part(i>>8);
+ pmap[y][x] = 0; // just in case
+}
+
+#ifdef WIN32
+_inline int is_wire(int x, int y)
+#else
+inline int is_wire(int x, int y)
+#endif
+{
+ return bmap[y][x]==6 || bmap[y][x]==7 || bmap[y][x]==3 || bmap[y][x]==8 || bmap[y][x]==11 || bmap[y][x]==12;
+}
+
+#ifdef WIN32
+_inline int is_wire_off(int x, int y)
+#else
+inline int is_wire_off(int x, int y)
+#endif
+{
+ return (bmap[y][x]==6 || bmap[y][x]==7 || bmap[y][x]==3 || bmap[y][x]==8 || bmap[y][x]==11 || bmap[y][x]==12) && emap[y][x]<8;
+}
+
+void set_emap(int x, int y)
+{
+ int x1, x2;
+
+ if(!is_wire_off(x, y))
+ return;
+
+ // go left as far as possible
+ x1 = x2 = x;
+ while(x1>0)
+ {
+ if(!is_wire_off(x1-1, y))
+ break;
+ x1--;
+ }
+ while(x2<XRES/CELL-1)
+ {
+ if(!is_wire_off(x2+1, y))
+ break;
+ x2++;
+ }
+
+ // fill span
+ for(x=x1; x<=x2; x++)
+ emap[y][x] = 16;
+
+ // fill children
+
+ if(y>1 && x1==x2 &&
+ is_wire(x1-1, y-1) && is_wire(x1, y-1) && is_wire(x1+1, y-1) &&
+ !is_wire(x1-1, y-2) && is_wire(x1, y-2) && !is_wire(x1+1, y-2))
+ set_emap(x1, y-2);
+ else if(y>0)
+ for(x=x1; x<=x2; x++)
+ if(is_wire_off(x, y-1))
+ {
+ if(x==x1 || x==x2 || y>=YRES/CELL-1 ||
+ is_wire(x-1, y-1) || is_wire(x+1, y-1) ||
+ is_wire(x-1, y+1) || !is_wire(x, y+1) || is_wire(x+1, y+1))
+ set_emap(x, y-1);
+ }
+
+ if(y<YRES/CELL-2 && x1==x2 &&
+ is_wire(x1-1, y+1) && is_wire(x1, y+1) && is_wire(x1+1, y+1) &&
+ !is_wire(x1-1, y+2) && is_wire(x1, y+2) && !is_wire(x1+1, y+2))
+ set_emap(x1, y+2);
+ else if(y<YRES/CELL-1)
+ for(x=x1; x<=x2; x++)
+ if(is_wire_off(x, y+1))
+ {
+ if(x==x1 || x==x2 || y<0 ||
+ is_wire(x-1, y+1) || is_wire(x+1, y+1) ||
+ is_wire(x-1, y-1) || !is_wire(x, y-1) || is_wire(x+1, y-1))
+ set_emap(x, y+1);
+ }
+}
+
+#ifdef WIN32
+_inline int parts_avg(int ci, int ni)
+#else
+inline int parts_avg(int ci, int ni)
+#endif
+{
+ int pmr = pmap[(int)((parts[ci].y + parts[ni].y)/2)][(int)((parts[ci].x + parts[ni].x)/2)];
+ if((pmr>>8) < NPART && (pmr>>8) >= 0)
+ {
+ return parts[pmr>>8].type;
+ }
+ else
+ {
+ return PT_NONE;
+ }
+}
+
+int nearest_part(int ci, int t)
+{
+ int distance = sqrt(pow(XRES, 2)+pow(YRES, 2));
+ int ndistance = 0;
+ int id = -1;
+ int i = 0;
+ int cx = (int)parts[ci].x;
+ int cy = (int)parts[ci].y;
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type==t&&!parts[i].life&&i!=ci)
+ {
+ ndistance = abs((cx-parts[i].x)+(cy-parts[i].y));// Faster but less accurate Older: sqrt(pow(cx-parts[i].x, 2)+pow(cy-parts[i].y, 2));
+ if(ndistance<distance)
+ {
+ distance = ndistance;
+ id = i;
+ }
+ }
+ }
+ return id;
+}
+
+void update_particles_i(pixel *vid, int start, int inc)
+{
+ int i, j, x, y, t, nx, ny, r, a, cr,cg,cb, s, rt, fe, nt, lpv, nearp, pavg;
+ float mv, dx, dy, ix, iy, lx, ly, d, pp;
+ float pt = R_TEMP;
+ float c_heat = 0.0f;
+ int h_count = 0;
+ int starti = (start*-1);
+ for(i=start; i<(NPART-starti); i+=inc)
+ if(parts[i].type)
+ {
+
+ lx = parts[i].x;
+ ly = parts[i].y;
+ t = parts[i].type;
+
+ if(sys_pause&&!framerender)
+ return;
+
+ if(parts[i].life && t!=PT_ACID && t!=PT_WOOD && t!=PT_NBLE && t!=PT_SWCH && t!=PT_STKM)
+ {
+ if(!(parts[i].life==10&&parts[i].type==PT_LCRY))
+ parts[i].life--;
+ if(parts[i].life<=0 && t!=PT_METL && t!=PT_WATR && t!=PT_RBDM && t!=PT_LRBD && t!=PT_SLTW && t!=PT_BRMT && t!=PT_PSCN && t!=PT_NSCN && t!=PT_NTCT && t!=PT_PTCT && t!=PT_BMTL && t!=PT_SPRK && t!=PT_LAVA && t!=PT_ETRD&&t!=PT_LCRY && t!=PT_INWR)
+ {
+ kill_part(i);
+ continue;
+ }
+ if(parts[i].life<=0 && t==PT_SPRK)
+ {
+ t = parts[i].ctype;
+ if(t!=PT_METL&&t!=PT_BMTL&&t!=PT_BRMT&&t!=PT_LRBD&&t!=PT_RBDM&&t!=PT_BTRY&&t!=PT_NBLE)
+ parts[i].temp = R_TEMP;
+ if(!t)
+ t = PT_METL;
+ parts[i].type = t;
+ parts[i].life = 4;
+ if(t == PT_WATR)
+ parts[i].life = 64;
+ if(t == PT_SLTW)
+ parts[i].life = 54;
+ }
+ }
+
+ if(t==PT_SPRK&&parts[i].ctype==PT_SPRK)
+ {
+ kill_part(i);
+ continue;
+ }
+
+ x = (int)(parts[i].x+0.5f);
+ y = (int)(parts[i].y+0.5f);
+
+
+ if(x<0 || y<0 || x>=XRES || y>=YRES ||
+ ((bmap[y/CELL][x/CELL]==1 ||
+ bmap[y/CELL][x/CELL]==8 ||
+ bmap[y/CELL][x/CELL]==9 ||
+ (bmap[y/CELL][x/CELL]==2) ||
+ (bmap[y/CELL][x/CELL]==3 && ptypes[t].falldown!=2) ||
+ (bmap[y/CELL][x/CELL]==10 && ptypes[t].falldown!=1) ||
+ (bmap[y/CELL][x/CELL]==6 && (t==PT_METL || t==PT_SPRK)) ||
+ (bmap[y/CELL][x/CELL]==7 && !emap[y/CELL][x/CELL])) && (t!=PT_STKM)))
+ {
+ kill_part(i);
+ continue;
+ }
+
+ vx[y/CELL][x/CELL] *= ptypes[t].airloss;
+ vy[y/CELL][x/CELL] *= ptypes[t].airloss;
+ vx[y/CELL][x/CELL] += ptypes[t].airdrag*parts[i].vx;
+ vy[y/CELL][x/CELL] += ptypes[t].airdrag*parts[i].vy;
+ if(t==PT_GASS||t==PT_NBLE)
+ {
+ if(pv[y/CELL][x/CELL]<3.5f)
+ pv[y/CELL][x/CELL] += ptypes[t].hotair*(3.5f-pv[y/CELL][x/CELL]);
+ if(y+CELL<YRES && pv[y/CELL+1][x/CELL]<3.5f)
+ pv[y/CELL+1][x/CELL] += ptypes[t].hotair*(3.5f-pv[y/CELL+1][x/CELL]);
+ if(x+CELL<XRES)
+ {
+ pv[y/CELL][x/CELL+1] += ptypes[t].hotair*(3.5f-pv[y/CELL][x/CELL+1]);
+ if(y+CELL<YRES)
+ pv[y/CELL+1][x/CELL+1] += ptypes[t].hotair*(3.5f-pv[y/CELL+1][x/CELL+1]);
+ }
+ }
+ else
+ {
+ pv[y/CELL][x/CELL] += ptypes[t].hotair;
+ if(y+CELL<YRES)
+ pv[y/CELL+1][x/CELL] += ptypes[t].hotair;
+ if(x+CELL<XRES)
+ {
+ pv[y/CELL][x/CELL+1] += ptypes[t].hotair;
+ if(y+CELL<YRES)
+ pv[y/CELL+1][x/CELL+1] += ptypes[t].hotair;
+ }
+ }
+
+ if((ptypes[t].explosive&2) && pv[y/CELL][x/CELL]>2.5f)
+ {
+ parts[i].life = rand()%80+180;
+ rt = parts[i].type = PT_FIRE;
+ parts[i].temp = ptypes[PT_FIRE].heat + (ptypes[rt].flammable/2);
+ pv[y/CELL][x/CELL] += 0.25f * CFDS;
+ t = PT_FIRE;
+ }
+
+ parts[i].vx *= ptypes[t].loss;
+ parts[i].vy *= ptypes[t].loss;
+
+ if(t==PT_DFRM && !parts[i].life)
+ {
+ if(pv[y/CELL][x/CELL]>1.0f)
+ {
+ parts[i].vx += ptypes[t].advection*vx[y/CELL][x/CELL];
+ parts[i].vy += ptypes[t].advection*vy[y/CELL][x/CELL];
+ parts[i].life = rand()%80+300;
+ }
+ }
+ else
+ {
+ if(t==PT_PLAS && pv[y/CELL][x/CELL]>25.0f)
+ {
+ parts[i].vx += ptypes[t].advection*vx[y/CELL][x/CELL];
+ parts[i].vy += ptypes[t].advection*vy[y/CELL][x/CELL];
+ } 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)
+ {
+ parts[i].vx += ptypes[t].diffusion*(rand()/(0.5f*RAND_MAX)-1.0f);
+ parts[i].vy += ptypes[t].diffusion*(rand()/(0.5f*RAND_MAX)-1.0f);
+ }
+
+ // interpolator
+#ifdef WIN32
+ mv = max(fabsf(parts[i].vx), fabsf(parts[i].vy));
+#else
+ mv = fmaxf(fabsf(parts[i].vx), fabsf(parts[i].vy));
+#endif
+ if(mv < ISTP)
+ {
+ parts[i].x += parts[i].vx;
+ parts[i].y += parts[i].vy;
+ ix = parts[i].x;
+ iy = parts[i].y;
+ }
+ else
+ {
+ dx = parts[i].vx*ISTP/mv;
+ dy = parts[i].vy*ISTP/mv;
+ ix = parts[i].x;
+ iy = parts[i].y;
+ while(1)
+ {
+ mv -= ISTP;
+ if(mv <= 0.0f)
+ {
+ // nothing found
+ parts[i].x += parts[i].vx;
+ parts[i].y += parts[i].vy;
+ ix = parts[i].x;
+ iy = parts[i].y;
+ break;
+ }
+ ix += dx;
+ iy += dy;
+ nx = (int)(ix+0.5f);
+ ny = (int)(iy+0.5f);
+ if(nx<0 || ny<0 || nx>=XRES || ny>=YRES || pmap[ny][nx] || (bmap[ny/CELL][nx/CELL] && bmap[ny/CELL][nx/CELL]!=5))
+ {
+ parts[i].x = ix;
+ parts[i].y = iy;
+ break;
+ }
+ }
+ }
+
+ a = nt = 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 &&
+ (!bmap[(y+ny)/CELL][(x+nx)/CELL] || bmap[(y+ny)/CELL][(x+nx)/CELL]==5))
+ {
+ if(!pmap[y+ny][x+nx])
+ a = 1;
+ if((pmap[y+ny][x+nx]&0xFF)!=t)
+ nt = 1;
+ }
+ if(legacy_enable)
+ {
+ if(t==PT_WTRV && pv[y/CELL][x/CELL]>4.0f)
+ t = parts[i].type = PT_DSTW;
+ if(t==PT_DESL && pv[y/CELL][x/CELL]<-6.0f)
+ t = parts[i].type = PT_GASS;
+ if(t==PT_GASS && pv[y/CELL][x/CELL]>6.0f)
+ t = parts[i].type = PT_DESL;
+ if(t==PT_DESL && pv[y/CELL][x/CELL]>12.0f)
+ t = parts[i].type = PT_FIRE;
+ }
+ if(t==PT_DESL && pv[y/CELL][x/CELL]<-20.0f)
+ t = parts[i].type = PT_GASS;
+ if(t==PT_DESL && pv[y/CELL][x/CELL]>50.0f) // Only way I know to make it
+ t = parts[i].type = PT_FIRE; // combust under pressure.
+ if(t==PT_GASS && pv[y/CELL][x/CELL]>20.0f)
+ t = parts[i].type = PT_DESL;
+ if(t==PT_BMTL && pv[y/CELL][x/CELL]>2.5f)
+ t = parts[i].type = PT_BRMT;
+ //if(t==PT_GLAS && pv[y/CELL][x/CELL]>4.0f)
+ // t = parts[i].type = PT_BGLA;
+ if(t==PT_GLAS)
+ {
+ parts[i].pavg[0] = parts[i].pavg[1];
+ parts[i].pavg[1] = pv[y/CELL][x/CELL];
+ if(parts[i].pavg[1]-parts[i].pavg[0] > 0.05f || parts[i].pavg[1]-parts[i].pavg[0] < -0.05f)
+ {
+ parts[i].type = PT_BGLA;
+ }
+ }
+ if(t==PT_ICEI && pv[y/CELL][x/CELL]>0.8f)
+ t = parts[i].type = PT_SNOW;
+ if(t==PT_PLUT && 1>rand()%100 && ((int)(5.0f*pv[y/CELL][x/CELL]))>(rand()%1000))
+ {
+ t = PT_NEUT;
+ create_part(i, x, y, t);
+ }
+
+ if(t==PT_SPRK&&parts[i].ctype==PT_ETRD&&parts[i].life==1)
+ {
+ nearp = nearest_part(i, PT_ETRD);
+ if(nearp!=-1)
+ {
+ create_line((int)parts[i].x, (int)parts[i].y, (int)parts[nearp].x, (int)parts[nearp].y, 0, PT_PLSM);
+ t = parts[i].type = PT_ETRD;
+ parts[i].ctype = PT_NONE;
+ parts[i].life = 20;
+ parts[nearp].type = PT_SPRK;
+ parts[nearp].life = 9;
+ parts[nearp].ctype = PT_ETRD;
+ }
+ }
+
+ if(!legacy_enable)
+ {
+ int ctemp = pv[y/CELL][x/CELL]*2;
+ c_heat = 0.0f;
+ h_count = 0;
+ if(ptypes[t].hconduct>(rand()%250))
+ {
+ 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_NONE&&parts[i].type!=PT_NONE&&ptypes[parts[r>>8].type].hconduct>0)
+ {
+ h_count++;
+ c_heat += parts[r>>8].temp;
+ }
+ }
+ }
+ }
+ pt = parts[i].temp = (c_heat+parts[i].temp)/(h_count+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 || !r)
+ continue;
+ if(parts[r>>8].type!=PT_NONE&&parts[i].type!=PT_NONE&&ptypes[parts[r>>8].type].hconduct>0)
+ {
+ parts[r>>8].temp = parts[i].temp;
+ }
+ }
+ }
+ }
+ if(pt>=pstates[t].btemp&&pstates[t].burn)
+ {
+ t = parts[i].type = pstates[t].burn;
+ if(t==PT_FIRE||t==PT_PLSM)
+ parts[i].life = rand()%50+120;
+ }
+ else if((pt<=pstates[t].stemp||(t==PT_LAVA&&(pt<=pstates[parts[i].ctype].ltemp)))&&pstates[t].solid)
+ {
+ if(t==PT_LAVA&&parts[i].ctype)
+ {
+ parts[i].life = 0;
+ t = parts[i].type = parts[i].ctype;
+ parts[i].ctype = PT_NONE;
+ }
+ else if(pstates[t].solid==PT_ICEI&&pt<=pstates[t].stemp)
+ {
+ parts[i].ctype = parts[i].type;
+ t = parts[i].type = PT_ICEI;
+ }
+ else
+ {
+ parts[i].life = 0;
+ t = parts[i].type = pstates[t].solid;
+ }
+ }
+ else if((pt>=pstates[t].ltemp&&(pt<=pstates[t].gtemp||!pstates[t].gas)&&pstates[t].state==ST_SOLID&&pstates[t].liquid)||(t==PT_ICEI&&pt>pstates[parts[i].ctype].stemp))
+ {
+ if(pstates[t].liquid==PT_LAVA)
+ {
+ parts[i].life = rand()%120+240;
+ parts[i].ctype = (parts[i].type==PT_BRMT)?PT_BMTL:parts[i].type;
+ parts[i].ctype = (parts[i].ctype==PT_SAND)?PT_GLAS:parts[i].ctype;
+ parts[i].ctype = (parts[i].ctype==PT_BGLA)?PT_GLAS:parts[i].ctype;
+ t = parts[i].type = pstates[t].liquid;
+ }
+ else if(t==PT_ICEI&&parts[i].ctype)
+ {
+ t = parts[i].type = parts[i].ctype;
+ parts[i].ctype = PT_NONE;
+ }
+ else
+ {
+ t = parts[i].type = pstates[t].liquid;
+ }
+ }
+ else if(pt-ctemp<=pstates[t].ltemp&&pstates[t].liquid&&pstates[t].state==ST_GAS)
+ {
+ t = parts[i].type = pstates[t].liquid;
+ }
+ else if(pt-ctemp>=pstates[t].gtemp&&(pstates[t].gas||parts[i].type==PT_LNTG)&&(pstates[t].state==ST_LIQUID||pstates[t].state==ST_SOLID))
+ {
+ if(t==PT_SLTW&&1>rand()%6)
+ {
+ t = parts[i].type = PT_SALT;
+ }
+ 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_URAN && pv[y/CELL][x/CELL]>0.0f)
+ {
+ float atemp = parts[i].temp + (-MIN_TEMP);
+ pt = parts[i].temp = (atemp*(1+(pv[y/CELL][x/CELL]/2000)))+MIN_TEMP;
+ }
+ if(t==PT_LAVA)
+ {
+ parts[i].life = restrict_flt((pt-700)/7, 0.0f, 400.0f);
+ }
+ pt = parts[i].temp = restrict_flt(parts[i].temp, MIN_TEMP, MAX_TEMP);
+ }
+ }
+ if(t==PT_PTCT&&parts[i].temp>24.0f)
+ {
+ pt = parts[i].temp -= 2.5f;
+ }
+ if(t==PT_NTCT&&parts[i].temp>24.0f)
+ {
+ pt = parts[i].temp -= 2.5f;
+ }
+
+ if(t==PT_WATR || t==PT_ETRD || t==PT_SLTW || t==PT_METL || t==PT_RBDM || t==PT_LRBD || t==PT_BRMT || t==PT_PSCN || t==PT_NSCN || t==PT_NTCT || t==PT_PTCT || t==PT_BMTL || t==PT_SPRK|| t == PT_NBLE || t==PT_INWR)
+ {
+ nx = x % CELL;
+ if(nx == 0)
+ nx = x/CELL - 1;
+ else if(nx == CELL-1)
+ nx = x/CELL + 1;
+ else
+ nx = x/CELL;
+ ny = y % CELL;
+ if(ny == 0)
+ ny = y/CELL - 1;
+ else if(ny == CELL-1)
+ ny = y/CELL + 1;
+ else
+ ny = y/CELL;
+ if(nx>=0 && ny>=0 && nx<XRES/CELL && ny<YRES/CELL)
+ {
+ if(t==PT_WATR || t==PT_ETRD || t==PT_SLTW || t==PT_METL || t==PT_RBDM || t==PT_LRBD || t==PT_NSCN || t==PT_NTCT || t==PT_PTCT || t==PT_PSCN || t==PT_BRMT || t==PT_BMTL||t==PT_NBLE || t==PT_INWR)
+ {
+ if(emap[ny][nx]==12 && !parts[i].life)
+ {
+ parts[i].type = PT_SPRK;
+ parts[i].life = 4;
+ parts[i].ctype = t;
+ t = PT_SPRK;
+ }
+ }
+ else if(bmap[ny][nx]==6 || bmap[ny][nx]==7 || bmap[ny][nx]==3 || bmap[ny][nx]==8 || bmap[ny][nx]==11 || bmap[ny][nx]==12)
+ set_emap(nx, ny);
+ }
+ }
+
+ nx = x/CELL;
+ ny = y/CELL;
+ if(bmap[ny][nx]==6 && emap[ny][nx]<8)
+ set_emap(nx, ny);
+
+ fe = 0;
+ if(t==PT_THDR)
+ {
+ for(nx=-2; nx<3; nx++)
+ for(ny=-2; ny<3; ny++)
+ if(x+nx>=0 && y+ny>0 &&
+ x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART || !r)
+ continue;
+ if(((r&0xFF)==PT_METL || (r&0xFF)==PT_ETRD || (r&0xFF)==PT_PSCN || (r&0xFF)==PT_NSCN || (r&0xFF)==PT_NTCT || (r&0xFF)==PT_PTCT || (r&0xFF)==PT_BMTL || (r&0xFF)==PT_RBDM || (r&0xFF)==PT_LRBD || (r&0xFF)==PT_BRMT||(r&0xFF)==PT_NBLE) || (r&0xFF)==PT_INWR && parts[r>>8].ctype!=PT_SPRK )
+ {
+ t = parts[i].type = PT_NONE;
+ parts[r>>8].ctype = parts[r>>8].type;
+ parts[r>>8].type = PT_SPRK;
+ parts[r>>8].life = 4;
+ }
+ else if((r&0xFF)!=PT_CLNE&&(r&0xFF)!=PT_THDR&&(r&0xFF)!=PT_SPRK&&(r&0xFF)!=PT_DMND&&(r&0xFF)!=PT_FIRE&&(r&0xFF)!=PT_NEUT&&(r&0xFF)!=PT_PHOT&&(r&0xFF))
+ {
+ pv[y/CELL][x/CELL] += 100.0f;
+ if(legacy_enable&&1>(rand()%200))
+ {
+ parts[i].life = rand()%50+120;
+ t = parts[i].type = PT_FIRE;
+ }
+ else
+ {
+ t = parts[i].type = PT_NONE;
+ }
+ }
+ }
+ }
+ else if(t==PT_ICEI || t==PT_SNOW)
+ {
+ for(nx=-2; nx<3; nx++)
+ for(ny=-2; ny<3; ny++)
+ if(x+nx>=0 && y+ny>0 &&
+ x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART || !r)
+ continue;
+ if(((r&0xFF)==PT_SALT || (r&0xFF)==PT_SLTW) && 1>(rand()%1000))
+ {
+ t = parts[i].type = PT_SLTW;
+ parts[r>>8].type = PT_SLTW;
+ }
+ if(legacy_enable)
+ {
+ if(((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 1>(rand()%1000))
+ {
+ t = parts[i].type = PT_ICEI;
+ parts[r>>8].type = PT_ICEI;
+ }
+ if(t==PT_SNOW && ((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 15>(rand()%1000))
+ t = parts[i].type = PT_WATR;
+ }
+ }
+ }
+ else if(t==PT_NTCT||t==PT_PTCT||t==PT_INWR)
+ {
+ for(nx=-2; nx<3; nx++)
+ for(ny=-2; ny<3; ny++)
+ if(x+nx>=0 && y+ny>0 &&
+ x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART || !r)
+ continue;
+ if((r&0xFF)==PT_SPRK && parts[r>>8].ctype==PT_METL)
+ {
+ parts[i].temp = 200.0f;
+ }
+ }
+ }
+ //PLANT
+ else if(t==PT_PLNT)
+ {
+ for(nx=-2; nx<3; nx++)
+ for(ny=-2; ny<3; ny++)
+ if(x+nx>=0 && y+ny>0 &&
+ x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART || !r)
+ continue;
+ if((r&0xFF)==PT_WATR && 1>(rand()%250))
+ {
+ t = parts[i].type = PT_PLNT;
+ parts[r>>8].type = PT_PLNT;
+ }
+ else if((r&0xFF)==PT_LAVA && 1>(rand()%250))
+ {
+ parts[i].life = 4;
+ t = parts[i].type = PT_FIRE;
+ }
+ //if(t==PT_SNOW && (r&0xFF)==PT_WATR && 15>(rand()%1000))
+ //t = parts[i].type = PT_WATR;
+ }
+ }
+ else if(t==PT_WATR||t==PT_DSTW)
+ {
+ for(nx=-2; nx<3; nx++)
+ for(ny=-2; ny<3; ny++)
+ if(x+nx>=0 && y+ny>0 &&
+ x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART || !r)
+ continue;
+ if(((r&0xFF)==PT_FIRE || (r&0xFF)==PT_LAVA) && 1>(rand()%10) && legacy_enable)
+ {
+ t = parts[i].type = PT_WTRV;
+ }
+ else if((r&0xFF)==PT_SALT && 1>(rand()%250))
+ {
+ t = parts[i].type = PT_SLTW;
+ parts[r>>8].type = PT_SLTW;
+ }
+ if((((r&0xFF)==PT_WATR||(r&0xFF)==PT_SLTW)&&t==PT_DSTW) && 1>(rand()%500))
+ {
+ t = parts[i].type = PT_WATR;
+ }
+ if(((r&0xFF)==PT_SLTW&&t==PT_DSTW) && 1>(rand()%500))
+ {
+ t = parts[i].type = PT_SLTW;
+ }
+ if(((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && (legacy_enable||pt>12.0f) && 1>(rand()%500))
+ {
+ parts[i].life = 4;
+ t = parts[i].type = PT_FIRE;
+
+ }
+ }
+ }
+ else if(t==PT_SLTW)
+ {
+ for(nx=-2; nx<3; nx++)
+ for(ny=-2; ny<3; ny++)
+ if(x+nx>=0 && y+ny>0 &&
+ x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART || !r)
+ continue;
+ if(((r&0xFF)==PT_FIRE || (r&0xFF)==PT_LAVA) && 1>(rand()%10) && legacy_enable)
+ {
+ t = parts[i].type = PT_SALT;
+ parts[r>>8].type = PT_WTRV;
+ }
+ else if((r&0xFF)==PT_SALT && 1>(rand()%10000))
+ {
+ parts[r>>8].type = PT_SLTW;
+ }
+ if(((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && pt>12.0f && 1>(rand()%500))
+ {
+ parts[i].life = 4;
+ t = parts[i].type = PT_FIRE;
+
+ }
+ }
+ }
+ else if(t==PT_WTRV)
+ {
+ for(nx=-2; nx<3; nx++)
+ for(ny=-2; ny<3; ny++)
+ if(x+nx>=0 && y+ny>0 &&
+ x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART || !r)
+ continue;
+ if(((r&0xFF)==PT_WATR||(r&0xFF)==PT_DSTW||(r&0xFF)==PT_SLTW) && 1>(rand()%1000) && legacy_enable)
+ {
+ t = parts[i].type = PT_WATR;
+ parts[r>>8].type = PT_WATR;
+ }
+
+ if(((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && pt>12.0f && 1>(rand()%500))
+ {
+ parts[i].life = 4;
+ t = parts[i].type = PT_FIRE;
+
+ }
+ if(((r&0xFF)==PT_ICEI || (r&0xFF)==PT_SNOW) && 1>(rand()%1000) && legacy_enable)
+ {
+ t = parts[i].type = PT_WATR;
+ if(1>(rand()%1000))
+ parts[r>>8].type = PT_WATR;
+ }
+ }
+ }
+ else if(t==PT_YEST)
+ {
+ for(nx=-2; nx<3; nx++)
+ for(ny=-2; ny<3; ny++)
+ if(x+nx>=0 && y+ny>0 &&
+ x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART || !r)
+ continue;
+ if((r&0xFF)==PT_DYST && 1>(rand()%30) && !legacy_enable)
+ {
+ t = parts[i].type = PT_DYST;
+ }
+ }
+ }
+ else if(t==PT_ACID)
+ {
+ for(nx=-2; nx<3; nx++)
+ for(ny=-2; ny<3; ny++)
+ if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART || !r)
+ continue;
+ if((r&0xFF)!=PT_ACID)
+ {
+ if ((r&0xFF)==PT_PLEX || (r&0xFF)==PT_NITR || (r&0xFF)==PT_GUNP || (r&0xFF)==PT_RBDM || (r&0xFF)==PT_LRBD)
+ {
+ t = parts[i].type = PT_FIRE;
+ parts[i].life = 4;
+ parts[r>>8].type = PT_FIRE;
+ parts[r>>8].life = 4;
+ }
+ else if(((r&0xFF)!=PT_CLNE && ptypes[parts[r>>8].type].hardness>(rand()%1000))&&parts[i].life>=50)
+ {
+ parts[i].life--;
+ parts[r>>8].type = PT_NONE;
+ }
+ else if (parts[i].life==50)
+ {
+ parts[i].life = 0;
+ t = parts[i].type = PT_NONE;
+ }
+ }
+ }
+ }
+ else if(t==PT_NEUT)
+ {
+ rt = 3 + (int)pv[y/CELL][x/CELL];
+ 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_WATR || (r&0xFF)==PT_ICEI || (r&0xFF)==PT_SNOW)
+ {
+ parts[i].vx *= 0.995;
+ parts[i].vy *= 0.995;
+ }
+ if((r&0xFF)==PT_PLUT && rt>(rand()%1000))
+ {
+ if(33>rand()%100)
+ {
+ create_part(r>>8, x+nx, y+ny, rand()%2 ? PT_LAVA : PT_URAN);
+ }
+ else
+ {
+ 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;
+ }
+ pv[y/CELL][x/CELL] += 10.00f * CFDS; //Used to be 2, some people said nukes weren't powerful enough
+ fe ++;
+ }
+ if((r&0xFF)==PT_GUNP && 15>(rand()%1000))
+ parts[r>>8].type = PT_DUST;
+ if((r&0xFF)==PT_DYST && 15>(rand()%1000))
+ parts[r>>8].type = PT_YEST;
+ if((r&0xFF)==PT_YEST){
+ if(15>(rand()%100000)&&isplayer==0)
+ parts[r>>8].type = PT_STKM;
+ else
+ parts[r>>8].type = PT_DYST;
+ }
+
+ if((r&0xFF)==PT_WATR && 15>(rand()%100))
+ parts[r>>8].type = PT_DSTW;
+ if((r&0xFF)==PT_PLEX && 15>(rand()%1000))
+ parts[r>>8].type = PT_DFRM;
+ if((r&0xFF)==PT_NITR && 15>(rand()%1000))
+ parts[r>>8].type = PT_DESL;
+ if((r&0xFF)==PT_OILL && 5>(rand()%1000))
+ parts[r>>8].type = PT_PLAS;
+ if((r&0xFF)==PT_PLNT && 5>(rand()%100))
+ parts[r>>8].type = PT_WOOD;
+ if((r&0xFF)==PT_PLAS && 5>(rand()%1000))
+ parts[r>>8].type = PT_OILL;
+ if((r&0xFF)==PT_DESL && 15>(rand()%1000))
+ parts[r>>8].type = PT_GASS;
+ if((r&0xFF)==PT_COAL && 5>(rand()%100))
+ parts[r>>8].type = PT_WOOD;
+ }
+ }
+ else if(t==PT_PHOT)
+ {
+ rt = 3 + (int)pv[y/CELL][x/CELL];
+ for(nx=0; nx<1; nx++)
+ for(ny=0; ny<1; 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_WATR || (r&0xFF)==PT_ICEI || (r&0xFF)==PT_SNOW)
+ {
+ parts[i].vx *= 0.995;
+ parts[i].vy *= 0.995;
+ }
+ }
+ }
+ else if(t==PT_LCRY)
+ {
+ for(nx=-1; nx<2; nx++)
+ for(ny=-1; ny<2; ny++)
+ if(x+nx>=0 && y+ny>0 &&
+ x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART || !r)
+ continue;
+ rt = parts[r>>8].type;
+ if(rt==PT_SPRK)
+ {
+ if(parts[r>>8].ctype==PT_PSCN)
+ {
+ parts[i].life = 10;
+ }
+ else if(parts[r>>8].ctype==PT_NSCN)
+ {
+ parts[i].life = 9;
+ }
+ }
+ if(rt==PT_LCRY)
+ {
+ if(parts[i].life==10&&parts[r>>8].life<10&&parts[r>>8].life>0)
+ {
+ parts[i].life = 9;
+ }
+ else if(parts[i].life==0&&parts[r>>8].life==10)
+ {
+ parts[i].life = 10;
+ }
+ }
+ }
+ }
+ else if(t==PT_BTRY)
+ {
+ rt = 3 + (int)pv[y/CELL][x/CELL];
+ for(nx=-2; nx<3; nx++)
+ for(ny=-2; ny<3; ny++)
+ if(x+nx>=0 && y+ny>0 &&
+ x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART || !r)
+ continue;
+ rt = parts[r>>8].type;
+ if(parts_avg(i,r>>8) != PT_INSL)
+ {
+ if((rt==PT_METL||rt==PT_ETRD||rt==PT_BMTL||rt==PT_BRMT||rt==PT_LRBD||rt==PT_RBDM||rt==PT_PSCN||rt==PT_NSCN||rt==PT_NBLE)&&parts[r>>8].life==0 && abs(nx)+abs(ny) < 4)
+ {
+ parts[r>>8].life = 4;
+ parts[r>>8].ctype = rt;
+ parts[r>>8].type = PT_SPRK;
+ }
+ }
+ }
+ }else if(t==PT_SWCH)
+ {
+ rt = 3 + (int)pv[y/CELL][x/CELL];
+ for(nx=-2; nx<3; nx++)
+ for(ny=-2; ny<3; ny++)
+ if(x+nx>=0 && y+ny>0 &&
+ x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART || !r)
+ continue;
+ rt = parts[r>>8].type;
+ if(parts[r>>8].type == PT_SWCH&&parts_avg(i,r>>8)!=PT_INSL)
+ {
+ if(parts[i].life==10&&parts[r>>8].life<10&&parts[r>>8].life>0)
+ {
+ parts[i].life = 9;
+ }
+ else if(parts[i].life==0&&parts[r>>8].life==10)
+ {
+ parts[i].life = 10;
+ }
+ }
+ }
+ }
+ if(t==PT_SWCH)
+ if((parts[i].life>0&&parts[i].life<10)|| parts[i].life == 11)
+ {
+ parts[i].life--;
+ }
+ if(t==PT_FIRE || t==PT_PLSM || t==PT_LAVA || t==PT_SPRK || fe || (t==PT_PHOT&&(1>rand()%10)))
+ {
+ for(nx=-2; nx<3; nx++)
+ for(ny=-2; ny<3; ny++)
+ if(x+nx>=0 && y+ny>0 &&
+ x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ r = pmap[y+ny][x+nx];
+ if((r>>8)>=NPART || !r)
+ continue;
+ if(bmap[(y+ny)/CELL][(x+nx)/CELL] && bmap[(y+ny)/CELL][(x+nx)/CELL]!=5)
+ continue;
+ rt = parts[r>>8].type;
+ if((a || ptypes[rt].explosive) && ((rt!=PT_RBDM && rt!=PT_LRBD && rt!=PT_INSL && rt!=PT_SWCH) || t!=PT_SPRK) &&
+ (t!=PT_LAVA || parts[i].life>0 || (rt!=PT_STNE && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_METL && rt!=PT_ETRD && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SWCH && rt!=PT_INWR)) &&
+ ptypes[rt].flammable && (ptypes[rt].flammable + (int)(pv[(y+ny)/CELL][(x+nx)/CELL]*10.0f))>(rand()%1000))
+ {
+ parts[r>>8].type = PT_FIRE;
+ parts[r>>8].temp = ptypes[PT_FIRE].heat + (ptypes[rt].flammable/2);
+ parts[r>>8].life = rand()%80+180;
+ if(ptypes[rt].explosive)
+ pv[y/CELL][x/CELL] += 0.25f * CFDS;
+ continue;
+ }
+ lpv = (int)pv[(y+ny)/CELL][(x+nx)/CELL];
+ if(lpv < 1) lpv = 1;
+ if(legacy_enable)
+ {
+ if(t!=PT_SPRK && ptypes[rt].meltable && ((rt!=PT_RBDM && rt!=PT_LRBD) || t!=PT_SPRK) && ((t!=PT_FIRE&&t!=PT_PLSM) || (rt!=PT_METL && rt!=PT_ETRD && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SALT && rt!=PT_INWR)) &&
+ ptypes[rt].meltable*lpv>(rand()%1000))
+ {
+ if(t!=PT_LAVA || parts[i].life>0)
+ {
+ parts[r>>8].ctype = (parts[r>>8].type==PT_BRMT)?PT_BMTL:parts[r>>8].type;
+ parts[r>>8].ctype = (parts[r>>8].ctype==PT_SAND)?PT_GLAS:parts[r>>8].ctype;
+ parts[r>>8].type = PT_LAVA;
+ parts[r>>8].life = rand()%120+240;
+ }
+ else
+ {
+ parts[i].life = 0;
+ t = parts[i].type = (parts[i].ctype)?parts[i].ctype:PT_STNE;
+ parts[i].ctype = PT_NONE;//rt;
+ goto killed;
+ }
+ }
+ if(t!=PT_SPRK && (rt==PT_ICEI || rt==PT_SNOW))
+ {
+ parts[r>>8].type = PT_WATR;
+ if(t==PT_FIRE)
+ {
+ parts[i].x = lx;
+ parts[i].y = ly;
+ kill_part(i);
+ goto killed;
+ }
+ if(t==PT_LAVA)
+ {
+ parts[i].life = 0;
+ t = parts[i].type = PT_STNE;
+ goto killed;
+ }
+ }
+ if(t!=PT_SPRK && (rt==PT_WATR || rt==PT_DSTW || rt==PT_SLTW))
+ {
+ kill_part(r>>8);
+ if(t==PT_FIRE)
+ {
+ parts[i].x = lx;
+ parts[i].y = ly;
+ kill_part(i);
+ goto killed;
+ }
+ if(t==PT_LAVA)
+ {
+ parts[i].life = 0;
+ t = parts[i].type = (parts[i].ctype)?parts[i].ctype:PT_STNE;
+ parts[i].ctype = PT_NONE;
+ goto killed;
+ }
+ }
+ }
+ pavg = parts_avg(i, r>>8);
+ if(rt==PT_SWCH && t==PT_SPRK)
+ {
+ pavg = parts_avg(r>>8, i);
+ if(parts[i].ctype == PT_PSCN&&pavg != PT_INSL)
+ parts[r>>8].life = 10;
+ if(parts[i].ctype == PT_NSCN&&pavg != PT_INSL)
+ parts[r>>8].life = 9;
+ if(!(parts[i].ctype == PT_PSCN||parts[i].ctype == PT_NSCN)&&parts[r>>8].life == 10&&pavg != PT_INSL)
+ {
+ parts[r>>8].type = PT_SPRK;
+ parts[r>>8].ctype = PT_SWCH;
+ parts[r>>8].life = 4;
+ }
+ }
+ pavg = parts_avg(i, r>>8);
+ if(pavg != PT_INSL)
+ {
+ if(t==PT_SPRK && (rt==PT_METL||rt==PT_ETRD||rt==PT_BMTL||rt==PT_BRMT||rt==PT_LRBD||rt==PT_RBDM||rt==PT_PSCN||rt==PT_NSCN||rt==PT_NBLE) && parts[r>>8].life==0 &&
+ (parts[i].life<3 || ((r>>8)<i && parts[i].life<4)) && abs(nx)+abs(ny)<4)
+ {
+ if(!(rt==PT_PSCN&&parts[i].ctype==PT_NSCN)&&!(rt!=PT_PSCN&&!(rt==PT_NSCN&&parts[i].temp>=100.0f)&&parts[i].ctype==PT_NTCT)&&!(rt!=PT_PSCN&&!(rt==PT_NSCN&&parts[i].temp<=100.0f)&&parts[i].ctype==PT_PTCT)&&!(rt!=PT_PSCN&&!(rt==PT_NSCN)&&parts[i].ctype==PT_INWR) && pavg != PT_INSL &&!(parts[i].ctype==PT_SWCH&&(rt==PT_PSCN||rt==PT_NSCN)) )
+ {
+ parts[r>>8].type = PT_SPRK;
+ parts[r>>8].life = 4;
+ parts[r>>8].ctype = rt;
+ if(parts[r>>8].temp+10.0f<400.0f&&!legacy_enable&&!(rt==PT_LRBD||rt==PT_RBDM||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR))
+ parts[r>>8].temp = parts[r>>8].temp+10.0f;
+ }
+ }
+ if(t==PT_SPRK && rt==PT_NTCT && parts[r>>8].life==0 &&
+ (parts[i].life<3 || ((r>>8)<i && parts[i].life<4)) && abs(nx)+abs(ny)<4)
+ {
+ if((parts[i].ctype==PT_NSCN||parts[i].ctype==PT_NTCT||(parts[i].ctype==PT_PSCN&&parts[r>>8].temp>100.0f))&&pavg != PT_INSL)
+ {
+ parts[r>>8].type = PT_SPRK;
+ parts[r>>8].life = 4;
+ parts[r>>8].ctype = rt;
+ }
+ }
+ if(t==PT_SPRK && rt==PT_PTCT && parts[r>>8].life==0 &&
+ (parts[i].life<3 || ((r>>8)<i && parts[i].life<4)) && abs(nx)+abs(ny)<4)
+ {
+ if((parts[i].ctype==PT_NSCN||parts[i].ctype==PT_PTCT||(parts[i].ctype==PT_PSCN&&parts[r>>8].temp<100.0f))&&pavg != PT_INSL)
+ {
+ parts[r>>8].type = PT_SPRK;
+ parts[r>>8].life = 4;
+ parts[r>>8].ctype = rt;
+ }
+ }
+ if(t==PT_SPRK && rt==PT_INWR && parts[r>>8].life==0 &&
+ (parts[i].life<3 || ((r>>8)<i && parts[i].life<4)) && abs(nx)+abs(ny)<4)
+ {
+ if((parts[i].ctype==PT_NSCN||parts[i].ctype==PT_INWR||parts[i].ctype==PT_PSCN)&&pavg != PT_INSL)
+ {
+ parts[r>>8].type = PT_SPRK;
+ parts[r>>8].life = 4;
+ parts[r>>8].ctype = rt;
+ }
+ }
+ if(t==PT_SPRK && rt==PT_WATR && parts[r>>8].life==0 &&
+ (parts[i].life<2 || ((r>>8)<i && parts[i].life<3)) && abs(nx)+abs(ny)<4)
+ {
+ parts[r>>8].type = PT_SPRK;
+ parts[r>>8].life = 6;
+ parts[r>>8].ctype = rt;
+ }
+ if(t==PT_SPRK && rt==PT_SLTW && parts[r>>8].life==0 &&
+ (parts[i].life<2 || ((r>>8)<i && parts[i].life<3)) && abs(nx)+abs(ny)<4)
+ {
+ parts[r>>8].type = PT_SPRK;
+ parts[r>>8].life = 5;
+ parts[r>>8].ctype = rt;
+ }
+ if(t==PT_SPRK&&parts[i].ctype==PT_ETRD&&parts[i].life==5)
+ {
+ if(rt==PT_METL||rt==PT_ETRD||rt==PT_BMTL||rt==PT_BRMT||rt==PT_LRBD||rt==PT_RBDM||rt==PT_PSCN||rt==PT_NSCN)
+ {
+ t = parts[i].type = PT_ETRD;
+ parts[i].ctype = PT_NONE;
+ parts[i].life = 20;
+ parts[r>>8].type = PT_SPRK;
+ parts[r>>8].life = 4;
+ parts[r>>8].ctype = rt;
+ }
+ }
+
+ if(t==PT_SPRK&&parts[i].ctype==PT_NBLE&&parts[i].life<=1)
+ {
+ parts[i].life = rand()%150+50;
+ parts[i].type = PT_PLSM;
+ parts[i].ctype = PT_NBLE;
+ parts[i].temp = 3500;
+ pv[y/CELL][x/CELL] += 1;
+ }
+ if(t==PT_SPRK&&parts[i].ctype==PT_SWCH&&parts[i].life<=1)
+ {
+ parts[i].type = PT_SWCH;
+ parts[i].life = 11;
+ }
+ }
+ }
+killed:
+ if(parts[i].type == PT_NONE)
+ continue;
+ }
+ if(t==PT_STKM)
+ {
+ //Tempirature handling
+ if(parts[i].temp<-30)
+ parts[i].life -= 0.2;
+ if((parts[i].temp<36.6f) && (parts[i].temp>=-30))
+ parts[i].temp += 1;
+
+ //Death
+ if(parts[i].life<0 && (death == 1)) //If his HP is less that 0 or there is very big wind...
+ {
+ for(r=-2; r<=1; r++)
+ {
+ create_part(-1, x+r, y-2, player[2]);
+ create_part(-1, x+r+1, y+2, player[2]);
+ create_part(-1, x-2, y+r+1, player[2]);
+ create_part(-1, x+2, y+r, player[2]);
+ }
+ kill_part(i); //Kill him
+ goto killed;
+ }
+
+ //Verlet integration
+ pp = 2*player[3]-player[5];
+ player[5] = player[3];
+ player[3] = pp;
+ pp = 2*player[4]-player[6];
+ player[6] = player[4];
+ player[4] = pp;
+
+ pp = 2*player[7]-player[9];
+ player[9] = player[7];
+ player[7] = pp;
+ pp = 2*player[8]-player[10]+1;
+ player[10] = player[8];
+ player[8] = pp;
+
+ pp = 2*player[11]-player[13];
+ player[13] = player[11];
+ player[11] = pp;
+ pp = 2*player[12]-player[14];
+ player[14] = player[12];
+ player[12] = pp;
+
+ pp = 2*player[15]-player[17];
+ player[17] = player[15];
+ player[15] = pp;
+ pp = 2*player[16]-player[18]+1;
+ player[18] = player[16];
+ player[16] = pp;
+
+ //Go left
+ if (((int)(player[0])&0x01) == 0x01)
+ {
+ if (pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_LIQUID
+ && (pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF) != PT_LNTG)
+ {
+ if (pmap[(int)(player[8]-1)][(int)(player[7])])
+ {
+ player[9] += 3;
+ player[10] += 2;
+ player[5] += 2;
+ }
+
+ if (pmap[(int)(player[16]-1)][(int)(player[15])])
+ {
+ player[17] += 3;
+ player[18] += 2;
+ player[13] +=2;
+ }
+ }
+ else
+ {
+ if (pmap[(int)(player[8]-1)][(int)(player[7])]) //It should move another way in liquids
+ {
+ player[9] += 1;
+ player[10] += 1;
+ player[5] += 1;
+ }
+
+ if (pmap[(int)(player[16]-1)][(int)(player[15])])
+ {
+ player[17] += 1;
+ player[18] += 1;
+ player[13] +=1;
+ }
+ }
+ }
+
+ //Go right
+ if (((int)(player[0])&0x02) == 0x02)
+ {
+ if (pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_LIQUID
+ && (pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF) != PT_LNTG)
+ {
+ if (pmap[(int)(player[8]-1)][(int)(player[7])])
+ {
+ player[9] -= 3;
+ player[10] += 2;
+ player[5] -= 2;
+ }
+
+ if (pmap[(int)(player[16]-1)][(int)(player[15])])
+ {
+ player[17] -= 3;
+ player[18] += 2;
+ player[13] -= 2;
+ }
+ }
+ else
+ {
+ if (pmap[(int)(player[8]-1)][(int)(player[7])])
+ {
+ player[9] -= 1;
+ player[10] += 1;
+ player[5] -= 1;
+ }
+
+ if (pmap[(int)(player[16]-1)][(int)(player[15])])
+ {
+ player[17] -= 1;
+ player[18] += 1;
+ player[13] -= 1;
+ }
+
+ }
+ }
+
+ //Charge detector wall if foot inside
+ if(bmap[(int)(player[8]+0.5)/CELL][(int)(player[7]+0.5)/CELL]==6)
+ set_emap((int)player[7]/CELL, (int)player[8]/CELL);
+ if(bmap[(int)(player[16]+0.5)/CELL][(int)(player[15]+0.5)/CELL]==6)
+ set_emap((int)(player[15]+0.5)/CELL, (int)(player[16]+0.5)/CELL);
+
+ //Searching for particles near head
+ for(nx = -2; nx <= 2; nx++)
+ for(ny = 0; ny>=-2; ny--)
+ {
+ if(!pmap[ny+y][nx+x] || (pmap[ny+y][nx+x]>>8)>=NPART)
+ continue;
+ if((pstates[pmap[ny+y][nx+x]&0xFF].state != ST_SOLID && (pmap[ny+y][nx+x]&0xFF)!=PT_STKM
+ && (pmap[ny+y][nx+x]&0xFF)!=PT_WHOL && (pmap[ny+y][nx+x]&0xFF)!=PT_BHOL)
+ || (pmap[ny+y][nx+x]&0xFF) == PT_LNTG)
+ {
+ player[2] = pmap[ny+y][nx+x]&0xFF; //Current element
+ }
+ if((pmap[ny+y][nx+x]&0xFF) == PT_PLNT && parts[i].life<100) //Plant gives him 5 HP
+ {
+ if(parts[i].life<=95)
+ parts[i].life += 5;
+ else
+ parts[i].life = 100;
+ kill_part(pmap[ny+y][nx+x]>>8);
+ }
+
+ if((pmap[ny+y][nx+x]&0xFF) == PT_NEUT)
+ {
+ parts[i].life -= (102-parts[i].life)/2;
+ kill_part(pmap[ny+y][nx+x]>>8);
+ }
+ }
+
+ //Head position
+ nx = x + 3*((((int)player[1])&0x02) == 0x02) - 3*((((int)player[1])&0x01) == 0x01);
+ ny = y - 3*(player[1] == 0);
+
+ //Spawn
+ if(((int)(player[0])&0x08) == 0x08)
+ {
+ ny -= 2*(rand()%2)+1;
+ r = pmap[ny][nx];
+ if(!((r>>8)>=NPART))
+ {
+ if(pstates[r&0xFF].state == ST_SOLID)
+ {
+ create_part(-1, nx, ny, PT_SPRK);
+ }
+ else
+ {
+ create_part(-1, nx, ny, player[2]);
+ r = pmap[ny][nx];
+ if( ((r>>8) < NPART) && (r>>8)>=0 && player[2]!=PT_PHOT)
+ parts[r>>8].vx = parts[r>>8].vx + 5*((((int)player[1])&0x02) == 0x02) - 5*(((int)(player[1])&0x01) == 0x01);
+ if(((r>>8) < NPART) && (r>>8)>=0 && player[2] == PT_PHOT)
+ {
+ int random = abs(rand()%3-1)*3;
+ if (random==0)
+ {
+ parts[r>>8].life = 0;
+ parts[r>>8].type = PT_NONE;
+ }
+ else
+ {
+ parts[r>>8].vy = 0;
+ parts[r>>8].vx = (((((int)player[1])&0x02) == 0x02) - (((int)(player[1])&0x01) == 0x01))*random;
+ }
+ }
+
+ }
+ }
+ }
+
+ //Jump
+ if (((int)(player[0])&0x04) == 0x04)
+ {
+ if (pmap[(int)(player[8]-0.5)][(int)(player[7])] || pmap[(int)(player[16]-0.5)][(int)(player[15])])
+ {
+ parts[i].vy = -5;
+ player[10] += 1;
+ player[18] += 1;
+ }
+
+ }
+
+ //Simulation of joints
+ d = 25/(pow((player[3]-player[7]), 2) + pow((player[4]-player[8]), 2)+25) - 0.5; //Fast distance
+ player[7] -= (player[3]-player[7])*d;
+ player[8] -= (player[4]-player[8])*d;
+ player[3] += (player[3]-player[7])*d;
+ player[4] += (player[4]-player[8])*d;
+
+ d = 25/(pow((player[11]-player[15]), 2) + pow((player[12]-player[16]), 2)+25) - 0.5;
+ player[15] -= (player[11]-player[15])*d;
+ player[16] -= (player[12]-player[16])*d;
+ player[11] += (player[11]-player[15])*d;
+ player[12] += (player[12]-player[16])*d;
+
+ d = 36/(pow((player[3]-parts[i].x), 2) + pow((player[4]-parts[i].y), 2)+36) - 0.5;
+ parts[i].vx -= (player[3]-parts[i].x)*d;
+ parts[i].vy -= (player[4]-parts[i].y)*d;
+ player[3] += (player[3]-parts[i].x)*d;
+ player[4] += (player[4]-parts[i].y)*d;
+
+ d = 36/(pow((player[11]-parts[i].x), 2) + pow((player[12]-parts[i].y), 2)+36) - 0.5;
+ parts[i].vx -= (player[11]-parts[i].x)*d;
+ parts[i].vy -= (player[12]-parts[i].y)*d;
+ player[11] += (player[11]-parts[i].x)*d;
+ player[12] += (player[12]-parts[i].y)*d;
+
+ //Side collisions checking
+ for(nx = -3; nx <= 3; nx++)
+ {
+ if(pmap[(int)(player[16]-2)][(int)(player[15]+nx)])
+ player[15] -= nx;
+
+ if(pmap[(int)(player[8]-2)][(int)(player[7]+nx)])
+ player[7] -= nx;
+ }
+
+ //Collision checks
+ for(ny = -2-(int)parts[i].vy; ny<=0; ny++)
+ {
+ r = pmap[(int)(player[8]+ny)][(int)(player[7]+0.5)]; //This is to make coding more pleasant :-)
+
+ //For left leg
+ if (r && (r&0xFF)!=PT_STKM)
+ {
+ if(pstates[r&0xFF].state == ST_LIQUID || pstates[r&0xFF].state == ST_GAS || (r&0xFF)==PT_LNTG) //Liquid checks
+ {
+ if(parts[i].y<(player[8]-10))
+ parts[i].vy = 1;
+ else
+ parts[i].vy = 0;
+ if(abs(parts[i].vx)>1)
+ parts[i].vx *= 0.5;
+ }
+ else
+ {
+ player[8] += ny-1;
+ parts[i].vy -= 0.5*parts[i].vy;
+ }
+ player[9] = player[7];
+ }
+
+ r = pmap[(int)(player[16]+ny)][(int)(player[15]+0.5)];
+
+ //For right leg
+ if (r && (r&0xFF)!=PT_STKM)
+ {
+ if(pstates[r&0xFF].state == ST_LIQUID || pstates[r&0xFF].state == ST_GAS || (r&0xFF)==PT_LNTG)
+ {
+ if(parts[i].y<(player[16]-10))
+ parts[i].vy = 1;
+ else
+ parts[i].vy = 0;
+ if(abs(parts[i].vx)>1)
+ parts[i].vx *= 0.5;
+ }
+ else
+ {
+ player[16] += ny-1;
+ parts[i].vy -= 0.5*parts[i].vy;
+ }
+ player[17] = player[15];
+ }
+
+ //If it falls too fast
+ if (parts[i].vy>=30)
+ {
+ parts[i].y -= 10+ny;
+ parts[i].vy = -10;
+ }
+
+ }
+
+ //Keeping legs distance
+ if (pow((player[7] - player[15]), 2)<16 && pow((player[8]-player[16]), 2)<1)
+ {
+ player[7] += 0.2;
+ player[15] -= 0.2;
+ }
+
+ if (pow((player[3] - player[11]), 2)<16 && pow((player[4]-player[12]), 2)<1)
+ {
+ player[3] += 0.2;
+ player[11] -= 0.2;
+ }
+
+ //If legs touch something
+ r = pmap[(int)(player[8]+0.5)][(int)(player[7]+0.5)];
+ if((r&0xFF)==PT_SPRK && r && (r>>8)<NPART) //If on charge
+ {
+ parts[i].life -= (int)(rand()/1000)+38;
+ }
+
+ if (r>0 && (r>>8)<NPART) //If hot or cold
+ {
+ if(parts[r>>8].temp>=50 || parts[r>>8].temp<=-30)
+ {
+ parts[i].life -= 2;
+ player[16] -= 1;
+ }
+ }
+
+ if ((r&0xFF)==PT_ACID) //If on acid
+ parts[i].life -= 5;
+
+ if ((r&0xFF)==PT_PLUT) //If on plut
+ parts[i].life -= 1;
+
+ r = pmap[(int)(player[16]+0.5)][(int)(player[15]+0.5)];
+ if((r&0xFF)==PT_SPRK && r && (r>>8)<NPART) //If on charge
+ {
+ parts[i].life -= (int)(rand()/1000)+38;
+ }
+
+ if(r>0 && (r>>8)<NPART) //If hot or cold
+ {
+ if(parts[r>>8].temp>=50 || parts[r>>8].temp<=-30)
+ {
+ parts[i].life -= 2;
+ player[8] -= 1;
+ }
+ }
+
+ if ((r&0xFF)==PT_ACID) //If on acid
+ parts[i].life -= 5;
+
+ if ((r&0xFF)==PT_PLUT) //If on plut
+ parts[i].life -= 1;
+
+ isplayer = 1;
+ }
+ if(t==PT_CLNE)
+ {
+ if(!parts[i].ctype)
+ {
+ for(nx=-1; nx<2; nx++)
+ for(ny=-1; ny<2; ny++)
+ if(x+nx>=0 && y+ny>0 &&
+ x+nx<XRES && y+ny<YRES &&
+ pmap[y+ny][x+nx] &&
+ (pmap[y+ny][x+nx]&0xFF)!=PT_CLNE &&
+ (pmap[y+ny][x+nx]&0xFF)!=PT_STKM &&
+ (pmap[y+ny][x+nx]&0xFF)!=0xFF)
+ parts[i].ctype = pmap[y+ny][x+nx]&0xFF;
+ }
+ else
+ create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype);
+ }
+ if(t==PT_YEST)
+ {
+ if(parts[i].temp>30&&parts[i].temp<44){
+ create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_YEST);
+ }
+ }
+ if(t==PT_PLSM&&parts[i].ctype == PT_NBLE&&parts[i].life <=1)
+ {
+ parts[i].type = PT_NBLE;
+ parts[i].life = 0;
+ }
+ if (t==PT_FIRE && parts[i].life <=1)
+ {
+ t = parts[i].type = PT_SMKE;
+ parts[i].life = rand()%20+250;
+ }
+
+ nx = (int)(parts[i].x+0.5f);
+ ny = (int)(parts[i].y+0.5f);
+
+ if(nx<CELL || nx>=XRES-CELL ||
+ ny<CELL || ny>=YRES-CELL)
+ {
+ parts[i].x = lx;
+ parts[i].y = ly;
+ kill_part(i);
+ continue;
+ }
+
+ rt = parts[i].flags & FLAG_STAGNANT;
+ parts[i].flags &= ~FLAG_STAGNANT;
+ if(!try_move(i, x, y, nx, ny))
+ {
+ parts[i].x = lx;
+ parts[i].y = ly;
+ if(ptypes[t].falldown)
+ {
+ if(nx!=x && try_move(i, x, y, nx, y))
+ {
+ parts[i].x = ix;
+ parts[i].vx *= ptypes[t].collision;
+ parts[i].vy *= ptypes[t].collision;
+ }
+ else if(ny!=y && try_move(i, x, y, x, ny))
+ {
+ parts[i].y = iy;
+ parts[i].vx *= ptypes[t].collision;
+ parts[i].vy *= ptypes[t].collision;
+ }
+ else
+ {
+ r = (rand()%2)*2-1;
+ if(ny!=y && try_move(i, x, y, x+r, ny))
+ {
+ parts[i].x += r;
+ parts[i].y = iy;
+ parts[i].vx *= ptypes[t].collision;
+ parts[i].vy *= ptypes[t].collision;
+ }
+ else if(ny!=y && try_move(i, x, y, x-r, ny))
+ {
+ parts[i].x -= r;
+ parts[i].y = iy;
+ parts[i].vx *= ptypes[t].collision;
+ parts[i].vy *= ptypes[t].collision;
+ }
+ else if(nx!=x && try_move(i, x, y, nx, y+r))
+ {
+ parts[i].x = ix;
+ parts[i].y += r;
+ parts[i].vx *= ptypes[t].collision;
+ parts[i].vy *= ptypes[t].collision;
+ }
+ else if(nx!=x && try_move(i, x, y, nx, y-r))
+ {
+ parts[i].x = ix;
+ parts[i].y -= r;
+ parts[i].vx *= ptypes[t].collision;
+ parts[i].vy *= ptypes[t].collision;
+ }
+ else if(ptypes[t].falldown>1 && parts[i].vy>fabs(parts[i].vx))
+ {
+ s = 0;
+ if(!rt || nt)
+ rt = 50;
+ else
+ rt = 10;
+ for(j=x+r; j>=0 && j>=x-rt && j<x+rt && j<XRES; j+=r)
+ {
+ if(try_move(i, x, y, j, ny))
+ {
+ parts[i].x += j-x;
+ parts[i].y += ny-y;
+ x = j;
+ y = ny;
+ s = 1;
+ break;
+ }
+ if(try_move(i, x, y, j, y))
+ {
+ parts[i].x += j-x;
+ x = j;
+ s = 1;
+ break;
+ }
+ if((pmap[y][j]&255)!=t || (bmap[y/CELL][j/CELL] && bmap[y/CELL][j/CELL]!=5))
+ break;
+ }
+ if(parts[i].vy>0)
+ r = 1;
+ else
+ r = -1;
+ if(s)
+ for(j=y+r; j>=0 && j<YRES && j>=y-rt && j<x+rt; j+=r)
+ {
+ if(try_move(i, x, y, x, j))
+ {
+ parts[i].y += j-y;
+ break;
+ }
+ if((pmap[j][x]&255)!=t || (bmap[j/CELL][x/CELL] && bmap[j/CELL][x/CELL]!=5))
+ {
+ s = 0;
+ break;
+ }
+ }
+ parts[i].vx *= ptypes[t].collision;
+ parts[i].vy *= ptypes[t].collision;
+ if(!s)
+ parts[i].flags |= FLAG_STAGNANT;
+ }
+ else
+ {
+ parts[i].flags |= FLAG_STAGNANT;
+ parts[i].vx *= ptypes[t].collision;
+ parts[i].vy *= ptypes[t].collision;
+ }
+ }
+ }
+ else
+ {
+ parts[i].flags |= FLAG_STAGNANT;
+ if(nx>x+ISTP) nx=x+ISTP;
+ if(nx<x-ISTP) nx=x-ISTP;
+ if(ny>y+ISTP) ny=y+ISTP;
+ if(ny<y-ISTP) ny=y-ISTP;
+ if(t==PT_NEUT && 100>(rand()%1000))
+ {
+ kill_part(i);
+ continue;
+ }
+ else if(try_move(i, x, y, 2*x-nx, ny))
+ {
+ parts[i].x = (float)(2*x-nx);
+ parts[i].y = (float)iy;
+ parts[i].vx *= ptypes[t].collision;
+ }
+ else if(try_move(i, x, y, nx, 2*y-ny))
+ {
+ parts[i].x = (float)ix;
+ parts[i].y = (float)(2*y-ny);
+ parts[i].vy *= ptypes[t].collision;
+ }
+ else
+ {
+ parts[i].vx *= ptypes[t].collision;
+ parts[i].vy *= ptypes[t].collision;
+ }
+ }
+ }
+ if(nx<CELL || nx>=XRES-CELL || ny<CELL || ny>=YRES-CELL)
+ {
+ kill_part(i);
+ continue;
+ }
+ }
+ if(framerender){
+ framerender = 0;
+ sys_pause = 1;
+ }
+}
+
+void update_particles(pixel *vid)
+{
+ int i, j, x, y, t, nx, ny, r, cr,cg,cb, l = -1;
+ float lx, ly;
+#ifdef MT
+ int pt = 0, pc = 0;
+ pthread_t *InterThreads;
+#endif
+
+ isplayer = 0; //Needed for player spawning
+ memset(pmap, 0, sizeof(pmap));
+ r = rand()%2;
+ for(j=0; j<NPART; j++)
+ {
+ i = r ? (NPART-1-j) : j;
+ if(parts[i].type)
+ {
+ t = parts[i].type;
+ x = (int)(parts[i].x+0.5f);
+ y = (int)(parts[i].y+0.5f);
+ if(x>=0 && y>=0 && x<XRES && y<YRES)
+ pmap[y][x] = t|(i<<8);
+ }
+ else
+ {
+ parts[i].life = l;
+ l = i;
+ }
+ }
+ pfree=l;
+ if(cmode==4)
+ {
+ for(y=0; y<YRES/CELL; y++)
+ {
+ for(x=0; x<XRES/CELL; x++)
+ {
+ if(bmap[y][x]==1)
+ for(j=0; j<CELL; j++)
+ for(i=0; i<CELL; i++)
+ {
+ pmap[y*CELL+j][x*CELL+i] = 0x7FFFFFFF;
+ vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
+ drawblob(vid, (x*CELL+i), (y*CELL+j), 0x80, 0x80, 0x80);
+
+ }
+ if(bmap[y][x]==2)
+ for(j=0; j<CELL; j+=2)
+ for(i=(j>>1)&1; i<CELL; i+=2)
+ {
+ vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
+ drawblob(vid, (x*CELL+i), (y*CELL+j), 0x80, 0x80, 0x80);
+ }
+ if(bmap[y][x]==3)
+ {
+ for(j=0; j<CELL; j++)
+ for(i=0; i<CELL; i++)
+ if(!((y*CELL+j)%2) && !((x*CELL+i)%2))
+ {
+ vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0xC0C0C0);
+ drawblob(vid, (x*CELL+i), (y*CELL+j), 0xC0, 0xC0, 0xC0);
+ }
+ if(emap[y][x])
+ {
+ cr = cg = cb = 16;
+ cr += fire_r[y][x];
+ if(cr > 255) cr = 255;
+ fire_r[y][x] = cr;
+ cg += fire_g[y][x];
+ if(cg > 255) cg = 255;
+ fire_g[y][x] = cg;
+ cb += fire_b[y][x];
+ if(cb > 255) cb = 255;
+ fire_b[y][x] = cb;
+ }
+ }
+ if(bmap[y][x]==4)
+ for(j=0; j<CELL; j+=2)
+ for(i=(j>>1)&1; i<CELL; i+=2)
+ {
+ vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x8080FF);
+ drawblob(vid, (x*CELL+i), (y*CELL+j), 0x80, 0x80, 0xFF);
+ }
+ if(bmap[y][x]==6)
+ {
+ for(j=0; j<CELL; j+=2)
+ for(i=(j>>1)&1; i<CELL; i+=2)
+ {
+ vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0xFF8080);
+ drawblob(vid, (x*CELL+i), (y*CELL+j), 0xFF, 0x80, 0x80);
+ }
+ if(emap[y][x])
+ {
+ cr = 255;
+ cg = 32;
+ cb = 8;
+ cr += fire_r[y][x];
+ if(cr > 255) cr = 255;
+ fire_r[y][x] = cr;
+ cg += fire_g[y][x];
+ if(cg > 255) cg = 255;
+ fire_g[y][x] = cg;
+ cb += fire_b[y][x];
+ if(cb > 255) cb = 255;
+ fire_b[y][x] = cb;
+ }
+ }
+ if(bmap[y][x]==7)
+ {
+ if(emap[y][x])
+ {
+ cr = cg = cb = 128;
+ cr += fire_r[y][x];
+ if(cr > 255) cr = 255;
+ fire_r[y][x] = cr;
+ cg += fire_g[y][x];
+ if(cg > 255) cg = 255;
+ fire_g[y][x] = cg;
+ cb += fire_b[y][x];
+ if(cb > 255) cb = 255;
+ fire_b[y][x] = cb;
+ for(j=0; j<CELL; j++)
+ for(i=0; i<CELL; i++)
+ if(i&j&1)
+ {
+ vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
+ drawblob(vid, (x*CELL+i), (y*CELL+j), 0x80, 0x80, 0x80);
+ }
+ }
+ else
+ {
+ for(j=0; j<CELL; j++)
+ for(i=0; i<CELL; i++)
+ pmap[y*CELL+j][x*CELL+i] = 0x7FFFFFFF;
+ for(j=0; j<CELL; j++)
+ for(i=0; i<CELL; i++)
+ if(!(i&j&1))
+ {
+ vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
+ drawblob(vid, (x*CELL+i), (y*CELL+j), 0x80, 0x80, 0x80);
+ }
+ }
+ }
+ if(bmap[y][x]==8)
+ {
+ for(j=0; j<CELL; j++)
+ for(i=0; i<CELL; i++)
+ {
+ pmap[y*CELL+j][x*CELL+i] = 0x7FFFFFFF;
+ if(!((y*CELL+j)%2) && !((x*CELL+i)%2))
+ {
+ vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0xC0C0C0);
+ drawblob(vid, (x*CELL+i), (y*CELL+j), 0xC0, 0xC0, 0xC0);
+ }
+ else
+ {
+ vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
+ drawblob(vid, (x*CELL+i), (y*CELL+j), 0x80, 0x80, 0x80);
+ }
+ }
+ if(emap[y][x])
+ {
+ cr = cg = cb = 16;
+ cr += fire_r[y][x];
+ if(cr > 255) cr = 255;
+ fire_r[y][x] = cr;
+ cg += fire_g[y][x];
+ if(cg > 255) cg = 255;
+ fire_g[y][x] = cg;
+ cb += fire_b[y][x];
+ if(cb > 255) cb = 255;
+ fire_b[y][x] = cb;
+ }
+ }
+ if(bmap[y][x]==11)
+ {
+ for(j=0; j<CELL; j++)
+ for(i=0; i<CELL; i++)
+ {
+ //pmap[y*CELL+j][x*CELL+i] = 0x7FFFFFFF;
+ if(!((y*CELL+j)%2) && !((x*CELL+i)%2))
+ {
+ vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0xFFFF22);
+ drawblob(vid, (x*CELL+i), (y*CELL+j), 0xFF, 0xFF, 0x22);
+ }
+
+ }
+ if(emap[y][x])
+ {
+ cr = cg = cb = 16;
+ cr += fire_r[y][x];
+ if(cr > 255) cr = 255;
+ fire_r[y][x] = cr;
+ cg += fire_g[y][x];
+ if(cg > 255) cg = 255;
+ fire_g[y][x] = cg;
+ cb += fire_b[y][x];
+ if(cb > 255) cb = 255;
+ fire_b[y][x] = cb;
+ }
+ }
+ if(bmap[y][x]==13)
+ {
+ for(j=0; j<CELL; j+=2)
+ {
+ for(i=(j>>1)&1; i<CELL; i+=2)
+ {
+ vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x579777);
+ drawblob(vid, (x*CELL+i), (y*CELL+j), 0x57, 0x97, 0x77);
+ }
+ }
+ }
+ if(bmap[y][x]==9)
+ {
+ for(j=0; j<CELL; j+=2)
+ {
+ for(i=(j>>1)&1; i<CELL; i+=2)
+ {
+ vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x3C3C3C);
+ drawblob(vid, (x*CELL+i), (y*CELL+j), 0x3C, 0x3C, 0x3C);
+ }
+ }
+ }
+ if(bmap[y][x]==10)
+ {
+ for(j=0; j<CELL; j+=2)
+ {
+ for(i=(j>>1)&1; i<CELL; i+=2)
+ {
+ vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x575757);
+ drawblob(vid, (x*CELL+i), (y*CELL+j), 0x57, 0x57, 0x57);
+ }
+ }
+ }
+ if(bmap[y][x]==12)
+ {
+ if(emap[y][x])
+ {
+ for(j=0; j<CELL; j++)
+ {
+ for(i=(j)&1; i<CELL; i++)
+ {
+ vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x242424);
+ drawblob(vid, (x*CELL+i), (y*CELL+j), 0x24, 0x24, 0x24);
+ }
+ }
+ for(j=0; j<CELL; j+=2)
+ {
+ for(i=(j)&1; i<CELL; i+=2)
+ {
+ vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x000000);
+ }
+ }
+ }
+ else
+ {
+ for(j=0; j<CELL; j+=2)
+ {
+ for(i=(j)&1; i<CELL; i+=2)
+ {
+ vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x242424);
+ drawblob(vid, (x*CELL+i), (y*CELL+j), 0x24, 0x24, 0x24);
+ }
+ }
+ }
+ if(emap[y][x])
+ {
+ cr = cg = cb = 16;
+ cr += fire_r[y][x];
+ if(cr > 255) cr = 255;
+ fire_r[y][x] = cr;
+ cg += fire_g[y][x];
+ if(cg > 255) cg = 255;
+ fire_g[y][x] = cg;
+ cb += fire_b[y][x];
+ if(cb > 255) cb = 255;
+ fire_b[y][x] = cb;
+ }
+ }
+ if(emap[y][x] && (!sys_pause||framerender))
+ emap[y][x] --;
+ }
+ }
+ }
+ else
+ {
+ for(y=0; y<YRES/CELL; y++)
+ {
+ for(x=0; x<XRES/CELL; x++)
+ {
+ if(bmap[y][x]==1)
+ for(j=0; j<CELL; j++)
+ for(i=0; i<CELL; i++)
+ {
+ pmap[y*CELL+j][x*CELL+i] = 0x7FFFFFFF;
+ vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
+ }
+ if(bmap[y][x]==2)
+ for(j=0; j<CELL; j+=2)
+ for(i=(j>>1)&1; i<CELL; i+=2)
+ vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
+ if(bmap[y][x]==3)
+ {
+ for(j=0; j<CELL; j++)
+ for(i=0; i<CELL; i++)
+ if(!((y*CELL+j)%2) && !((x*CELL+i)%2))
+ vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0xC0C0C0);
+ if(emap[y][x])
+ {
+ cr = cg = cb = 16;
+ cr += fire_r[y][x];
+ if(cr > 255) cr = 255;
+ fire_r[y][x] = cr;
+ cg += fire_g[y][x];
+ if(cg > 255) cg = 255;
+ fire_g[y][x] = cg;
+ cb += fire_b[y][x];
+ if(cb > 255) cb = 255;
+ fire_b[y][x] = cb;
+ }
+ }
+ if(bmap[y][x]==4)
+ for(j=0; j<CELL; j+=2)
+ for(i=(j>>1)&1; i<CELL; i+=2)
+ vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x8080FF);
+ if(bmap[y][x]==6)
+ {
+ for(j=0; j<CELL; j+=2)
+ for(i=(j>>1)&1; i<CELL; i+=2)
+ vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0xFF8080);
+ if(emap[y][x])
+ {
+ cr = 255;
+ cg = 32;
+ cb = 8;
+ cr += fire_r[y][x];
+ if(cr > 255) cr = 255;
+ fire_r[y][x] = cr;
+ cg += fire_g[y][x];
+ if(cg > 255) cg = 255;
+ fire_g[y][x] = cg;
+ cb += fire_b[y][x];
+ if(cb > 255) cb = 255;
+ fire_b[y][x] = cb;
+ }
+ }
+ if(bmap[y][x]==7)
+ {
+ if(emap[y][x])
+ {
+ cr = cg = cb = 128;
+ cr += fire_r[y][x];
+ if(cr > 255) cr = 255;
+ fire_r[y][x] = cr;
+ cg += fire_g[y][x];
+ if(cg > 255) cg = 255;
+ fire_g[y][x] = cg;
+ cb += fire_b[y][x];
+ if(cb > 255) cb = 255;
+ fire_b[y][x] = cb;
+ for(j=0; j<CELL; j++)
+ for(i=0; i<CELL; i++)
+ if(i&j&1)
+ vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
+ }
+ else
+ {
+ for(j=0; j<CELL; j++)
+ for(i=0; i<CELL; i++)
+ pmap[y*CELL+j][x*CELL+i] = 0x7FFFFFFF;
+ for(j=0; j<CELL; j++)
+ for(i=0; i<CELL; i++)
+ if(!(i&j&1))
+ vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
+ }
+ }
+ if(bmap[y][x]==8)
+ {
+ for(j=0; j<CELL; j++)
+ for(i=0; i<CELL; i++)
+ {
+ pmap[y*CELL+j][x*CELL+i] = 0x7FFFFFFF;
+ if(!((y*CELL+j)%2) && !((x*CELL+i)%2))
+ vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0xC0C0C0);
+ else
+ vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
+ }
+ if(emap[y][x])
+ {
+ cr = cg = cb = 16;
+ cr += fire_r[y][x];
+ if(cr > 255) cr = 255;
+ fire_r[y][x] = cr;
+ cg += fire_g[y][x];
+ if(cg > 255) cg = 255;
+ fire_g[y][x] = cg;
+ cb += fire_b[y][x];
+ if(cb > 255) cb = 255;
+ fire_b[y][x] = cb;
+ }
+ }
+ if(bmap[y][x]==11)
+ {
+ for(j=0; j<CELL; j++)
+ for(i=0; i<CELL; i++)
+ {
+ //pmap[y*CELL+j][x*CELL+i] = 0x7FFFFFFF;
+ if(!((y*CELL+j)%2) && !((x*CELL+i)%2))
+ vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0xFFFF22);
+
+ }
+ if(emap[y][x])
+ {
+ cr = cg = cb = 16;
+ cr += fire_r[y][x];
+ if(cr > 255) cr = 255;
+ fire_r[y][x] = cr;
+ cg += fire_g[y][x];
+ if(cg > 255) cg = 255;
+ fire_g[y][x] = cg;
+ cb += fire_b[y][x];
+ if(cb > 255) cb = 255;
+ fire_b[y][x] = cb;
+ }
+ }
+ if(bmap[y][x]==9)
+ {
+ for(j=0; j<CELL; j+=2)
+ {
+ for(i=(j>>1)&1; i<CELL; i+=2)
+ {
+ vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x3C3C3C);
+ }
+ }
+ }
+ if(bmap[y][x]==13)
+ {
+ for(j=0; j<CELL; j+=2)
+ {
+ for(i=(j>>1)&1; i<CELL; i+=2)
+ {
+ vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x579777);
+ }
+ }
+ }
+ if(bmap[y][x]==10)
+ {
+ for(j=0; j<CELL; j+=2)
+ {
+ for(i=(j>>1)&1; i<CELL; i+=2)
+ {
+ vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x575757);
+ }
+ }
+ }
+ if(bmap[y][x]==12)
+ {
+ if(emap[y][x])
+ {
+ for(j=0; j<CELL; j++)
+ {
+ for(i=(j)&1; i<CELL; i++)
+ {
+ vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x242424);
+ }
+ }
+ for(j=0; j<CELL; j+=2)
+ {
+ for(i=(j)&1; i<CELL; i+=2)
+ {
+ vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x000000);
+ }
+ }
+ }
+ else
+ {
+ for(j=0; j<CELL; j+=2)
+ {
+ for(i=(j)&1; i<CELL; i+=2)
+ {
+ vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x242424);
+ }
+ }
+ }
+ if(emap[y][x])
+ {
+ cr = cg = cb = 16;
+ cr += fire_r[y][x];
+ if(cr > 255) cr = 255;
+ fire_r[y][x] = cr;
+ cg += fire_g[y][x];
+ if(cg > 255) cg = 255;
+ fire_g[y][x] = cg;
+ cb += fire_b[y][x];
+ if(cb > 255) cb = 255;
+ fire_b[y][x] = cb;
+ }
+ }
+ if(emap[y][x] && (!sys_pause||framerender))
+ emap[y][x] --;
+ }
+ }
+ }
+
+ update_particles_i(vid, 0, 1);
+
+ for(y=0; y<YRES/CELL; y++)
+ for(x=0; x<XRES/CELL; x++)
+ if(bmap[y][x]==5)
+ {
+ lx = x*CELL + CELL*0.5f;
+ ly = y*CELL + CELL*0.5f;
+ for(t=0; t<1024; t++)
+ {
+ nx = (int)(lx+0.5f);
+ ny = (int)(ly+0.5f);
+ if(nx<0 || nx>=XRES || ny<0 || ny>=YRES)
+ break;
+ addpixel(vid, nx, ny, 255, 255, 255, 64);
+ i = nx/CELL;
+ j = ny/CELL;
+ lx += vx[j][i]*0.125f;
+ ly += vy[j][i]*0.125f;
+ if(bmap[j][i]==5 && i!=x && j!=y)
+ break;
+ }
+ drawtext(vid, x*CELL, y*CELL-2, "\x8D", 255, 255, 255, 128);
+ }
+
+} \ No newline at end of file
diff --git a/powder.h b/powder.h
index 5f0ca71..9757d5a 100644
--- a/powder.h
+++ b/powder.h
@@ -397,4 +397,63 @@ static unsigned char can_move[PT_NUM][PT_NUM] =
/* e t r l e l a p r e s x m i e k w d t t t d d v t w t w d l t t n x n n u l l m d N d s n a r m d e E y y M H E s l l R T*/
};
+extern int isplayer;
+extern float player[20];
+
+extern particle *parts;
+extern particle *cb_parts;
+
+extern unsigned char bmap[YRES/CELL][XRES/CELL];
+extern unsigned char emap[YRES/CELL][XRES/CELL];
+
+extern unsigned char cb_bmap[YRES/CELL][XRES/CELL];
+extern unsigned char cb_emap[YRES/CELL][XRES/CELL];
+
+extern int pfree;
+
+extern unsigned pmap[YRES][XRES];
+unsigned cb_pmap[YRES][XRES];
+
+int try_move(int i, int x, int y, int nx, int ny);
+
+void kill_part(int i);
+
+#ifdef WIN32
+extern _inline int create_part(int p, int x, int y, int t);
+#else
+extern inline int create_part(int p, int x, int y, int t);
+#endif
+
+#ifdef WIN32
+extern _inline void delete_part(int x, int y);
+#else
+extern inline void delete_part(int x, int y);
+#endif
+
+#ifdef WIN32
+extern _inline int is_wire(int x, int y);
+#else
+extern inline int is_wire(int x, int y);
+#endif
+
+#ifdef WIN32
+extern _inline int is_wire_off(int x, int y);
+#else
+extern inline int is_wire_off(int x, int y);
+#endif
+
+void set_emap(int x, int y);
+
+#ifdef WIN32
+_inline int parts_avg(int ci, int ni);
+#else
+inline int parts_avg(int ci, int ni);
+#endif
+
+int nearest_part(int ci, int t);
+
+void update_particles_i(pixel *vid, int start, int inc);
+
+void update_particles(pixel *vid);
+
#endif \ No newline at end of file