From bf8258ee306a9649e0cfbf5344f8a533907175d8 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Mon, 10 Oct 2011 23:41:19 +0100 Subject: Elements, LIGH, TESC, EMP and DEST thanks to MaksProg diff --git a/includes/graphics.h b/includes/graphics.h index 90dd4a7..afa09b3 100644 --- a/includes/graphics.h +++ b/includes/graphics.h @@ -36,6 +36,8 @@ #endif #endif +extern int emp_decor; + extern unsigned cmode; extern SDL_Surface *sdl_scrn; extern int sdl_scale; @@ -53,6 +55,8 @@ extern unsigned int fire_alpha[CELL*3][CELL*3]; extern pixel *fire_bg; extern pixel *pers_bg; +void draw_other(pixel *vid); + void draw_rgba_image(pixel *vid, unsigned char *data, int x, int y, float a); void *ptif_pack(pixel *src, int w, int h, int *result_size); diff --git a/includes/powder.h b/includes/powder.h index a7cf5fd..1e0c425 100644 --- a/includes/powder.h +++ b/includes/powder.h @@ -145,6 +145,10 @@ #define PT_CONV 85 #define PT_CAUS 86 +#define PT_LIGH 87 +#define PT_TESC 88 +#define PT_DEST 89 + #define PT_SPNG 90 #define PT_RIME 91 #define PT_FOG 92 @@ -190,13 +194,9 @@ #define PT_QRTZ 132 #define PT_PQRT 133 -#define PT_SEED 134 -#define PT_MAZE 135 -#define PT_COAG 136 -#define PT_WALL 137 -#define PT_GNAR 138 -#define PT_REPL 139 -#define PT_MYST 140 +#define PT_EMP 134 +#define PT_BREC 135 + #define PT_BOYL 141 #define OLD_PT_WIND 147 @@ -334,6 +334,9 @@ int update_BIZR(UPDATE_FUNC_ARGS); int update_PVOD(UPDATE_FUNC_ARGS); int update_CONV(UPDATE_FUNC_ARGS); int update_CAUS(UPDATE_FUNC_ARGS); +int update_DEST(UPDATE_FUNC_ARGS); +int update_EMP(UPDATE_FUNC_ARGS); +int update_LIGH(UPDATE_FUNC_ARGS); int update_MISC(UPDATE_FUNC_ARGS); int update_legacy_PYRO(UPDATE_FUNC_ARGS); @@ -500,9 +503,9 @@ static const part_type ptypes[PT_NUM] = {"PVOD", PIXPACK(0x792020), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 100, SC_POWERED, R_TEMP+0.0f +273.15f, 251, "Solid. When activated, destroys entering particles", ST_NONE, TYPE_SOLID, &update_PVOD}, {"CONV", PIXPACK(0x0AAB0A), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 251, "Solid. Converts whatever touches it into its ctype.", ST_NONE, TYPE_SOLID, &update_CONV}, {"CAUS", PIXPACK(0x80FFA0), 2.0f, 0.00f * CFDS, 0.99f, 0.30f, -0.1f, 0.0f, 1.50f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 1, 1, SC_GAS, R_TEMP+0.0f +273.15f, 70, "Caustic Gas, acts like Acid", ST_GAS, TYPE_GAS, &update_CAUS}, - /*FREE*/{"34", PIXPACK(0x500050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "34! B34/S34)", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, - /*FREE*/{"LLIF", PIXPACK(0x505050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "Long Life! B345/S5", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, - /*FREE*/{"STAN", PIXPACK(0x5000FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "Stains! B3678/S235678", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"LIGH", PIXPACK(0xFFFFC0), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 0, "More realistic lighting. Set pen size for setting size of the lighting.", ST_SOLID, TYPE_SOLID, &update_LIGH, 0}, + {"TESC", PIXPACK(0x707040), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Tesla coil!!!", ST_SOLID, TYPE_SOLID|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_HOT_GLOW, NULL, 0}, + {"DEST", PIXPACK(0xFF3311), -0.05f, 0.00f * CFDS, 0.95f, 0.95f, -0.1f, 0.4f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 0, 1, 1, 101, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 150, "Makes big destruction.", ST_SOLID, TYPE_PART|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC, &update_DEST, 0}, {"SPNG", PIXPACK(0xFFBE30), 0.00f, 0.00f * CFDS, 0.00f, 1.00f, 0.00f, 0.0f, 0.00f, 0.000f * CFDS, 0, 20, 0, 1, 30, 1, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "A sponge, absorbs water.", ST_SOLID, TYPE_SOLID, &update_SPNG}, {"RIME", PIXPACK(0xCCCCCC), 0.00f, 0.00f * CFDS, 0.00f, 1.00f, 0.00f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 30, 1, 1, 100, SC_CRACKER2, 243.15f, 100, "Not quite Ice", ST_SOLID, TYPE_SOLID, &update_RIME}, {"FOG", PIXPACK(0xAAAAAA), 0.8f, 0.00f * CFDS, 0.4f, 0.70f, -0.1f, 0.0f, 0.99f, 0.000f * CFDS, 0, 0, 0, 0, 30, 1, 1, 1, SC_CRACKER2, 243.15f, 100, "Not quite Steam", ST_GAS, TYPE_GAS|PROP_LIFE_DEC, &update_FOG}, @@ -547,8 +550,8 @@ static const part_type ptypes[PT_NUM] = {"SING", PIXPACK(0x242424), 0.7f, 0.36f * CFDS, 0.96f, 0.80f, 0.1f, 0.12f, 0.00f, -0.001f * CFDS, 1, 0, 0, 0, 0, 1, 1, 86, SC_NUCLEAR, R_TEMP+0.0f +273.15f, 70, "Singularity", ST_SOLID, TYPE_PART|PROP_LIFE_DEC, &update_SING}, {"QRTZ", PIXPACK(0xAADDDD), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 3, "Quartz, breakable mineral. Conducts but becomes brittle at lower temperatures.", ST_SOLID, TYPE_SOLID|PROP_HOT_GLOW|PROP_LIFE_DEC, &update_QRTZ}, {"PQRT", PIXPACK(0x88BBBB), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.27f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 0, 1, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 3, "Broken quartz.", ST_SOLID, TYPE_PART| PROP_HOT_GLOW, &update_QRTZ}, - /*FREE*/{"SEED", PIXPACK(0xFBEC7D), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "B2/S", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, - /*FREE*/{"MAZE", PIXPACK(0xA8E4A0), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "B3/S12345", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"EMP", PIXPACK(0x66AAFF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.0f, 0.0f * CFDS, 0, 0, 0, 0, 3, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 121, "Breaks some working electronics if take spark. For total breaking use more EMP pixels.", ST_SOLID, TYPE_SOLID|PROP_LIFE_DEC, &update_EMP, 0}, + {"BREL", PIXPACK(0x707060), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.18f, 0.00f, 0.000f * CFDS, 1, 0, 0, 2, 2, 1, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 211, "Bronen electronic.", ST_SOLID, TYPE_PART|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_HOT_GLOW, NULL, 0}, /*FREE*/{"COAG", PIXPACK(0x9ACD32), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "B378/S235678", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, /*FREE*/{"WALL", PIXPACK(0x0047AB), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "B45678/S2345", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, /*FREE*/{"GNAR", PIXPACK(0xE5B73B), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "B1/S1", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, @@ -1028,7 +1031,7 @@ int parts_avg(int ci, int ni, int t); void create_arc(int sx, int sy, int dx, int dy, int midpoints, int variance, int type, int flags); -int nearest_part(int ci, int t); +int nearest_part(int ci, int t, int max_d); void update_particles_i(pixel *vid, int start, int inc); diff --git a/src/elements/dest.c b/src/elements/dest.c new file mode 100644 index 0000000..fb2a9d7 --- /dev/null +++ b/src/elements/dest.c @@ -0,0 +1,59 @@ +#include + +int update_DEST(UPDATE_FUNC_ARGS) { + int r,rx,ry; + rx=rand()%5-2; + ry=rand()%5-2; + + r = pmap[y+ry][x+rx]; + if ((r>>8)>=NPART || !r) + return 0; + if ((r&0xFF)!=PT_DEST && (r&0xFF)!=PT_DMND) + { + if (parts[i].life<=0 || parts[i].life>37) + { + parts[i].life=30+rand()%20; + parts[i].temp+=20000; + pv[y/CELL][x/CELL]+=60.0f; + } + parts[i].temp+=10000; + if ((r&0xFF)==PT_PLUT || (r&0xFF)==PT_DEUT) + { + pv[y/CELL][x/CELL]+=20.0f; + parts[i].temp+=18000; + if (rand()%2==0) + { + part_change_type(r>>8, x+rx, y+ry, PT_NEUT); + float rad = (rand()%128+128)/127.0f; + float a = (rand()%360)*M_PI/180.0f; + parts[r>>8].vx = rad*cosf(a); + parts[r>>8].vy = rad*sinf(a); + parts[r>>8].temp+=40000; + pv[y/CELL][x/CELL]+=10.0f; + parts[i].life-=4; + } + } + if ((r&0xFF)==PT_INSL) + { + create_part(r>>8, x+rx, y+ry, PT_FIRE); + parts[r>>8].temp=10000; + } + else if (rand()%3==0) + { + kill_part(r>>8); + parts[i].life-=4*(ptypes[r&0xFF].properties==TYPE_SOLID?3:1); + if (parts[i].life<=0) + parts[i].life=1; + parts[i].temp+=10000; + } + else + { + parts[r>>8].temp+=10000; + } + int topv=pv[y/CELL][x/CELL]/9+parts[r>>8].temp/900; + if (topv>40.0f) + topv=40.0f; + pv[y/CELL][x/CELL]+=40.0f+topv; + } + return 0; +} diff --git a/src/elements/emp.c b/src/elements/emp.c new file mode 100644 index 0000000..3017bc6 --- /dev/null +++ b/src/elements/emp.c @@ -0,0 +1,102 @@ +#include + +int update_EMP(UPDATE_FUNC_ARGS) { + int r,rx,ry,ok=0,t; + if (parts[i].life) + return 0; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((r&0xFF)==PT_SPRK) + { + ok=1; + break; + } + } + if (!ok) + return 0; + parts[i].life=220; + emp_decor+=7; + if (emp_decor>100) + emp_decor=100; + for (r=0; r<=parts_lastActiveIndex; r++) + { + t=parts[r].type; + rx=parts[r].x; + ry=parts[r].y; + if (t==PT_SPRK || (t==PT_SWCH && parts[r].life!=0 && parts[r].life!=10) || (t==PT_WIRE && parts[r].ctype>0)) + { + int is_elec=0; + if ((parts[r].ctype==PT_PSCN || parts[r].ctype==PT_NSCN || parts[r].ctype==PT_PTCT || + parts[r].ctype==PT_NTCT || parts[r].ctype==PT_INST || parts[r].ctype==PT_SWCH) || t==PT_WIRE || t==PT_SWCH) + { + is_elec=1; + if (rand()%100==0) + parts[r].temp+=3000; + if (rand()%80==0) + part_change_type(r, rx, ry, PT_BREC); + else if (rand()%120==0) + part_change_type(r, rx, ry, PT_NTCT); + } + int n,nx,ny; + for (nx=-2; nx<3; nx++) + for (ny=-2; ny<3; ny++) + if (rx+nx>=0 && ry+ny>0 && rx+nx>8)>=NPART || !n) + continue; + /*if ((n&0xFF)==PT_BTRY && rand()%60==0) + { + part_change_type(n>>8, rx+nx, ry+ny, PT_PLSM); + parts[n>>8].life=rand()%100+70; + parts[n>>8].temp+=3000; + }*/ + if (is_elec && ((n&0xFF)==PT_METL || (n&0xFF)==PT_BMTL) && rand()%280==0) + { + parts[n>>8].temp+=3000; + } + if (is_elec && (n&0xFF)==PT_BMTL && rand()%160==0) + { + part_change_type(n>>8, rx+nx, ry+ny, PT_BMTL); + parts[n>>8].temp+=1000; + } + if (is_elec && (n&0xFF)==PT_METL && rand()%300==0) + { + part_change_type(n>>8, rx+nx, ry+ny, PT_BMTL); + } + if ((t==PT_PSCN || t==PT_NSCN) && (n&0xFF)==PT_SWCH && rand()%100==0) + { + part_change_type(n>>8, rx+nx, ry+ny, PT_BREC); + } + if ((t==PT_PSCN || t==PT_NSCN) && (n&0xFF)==PT_SWCH && rand()%100==0) + { + parts[n>>8].temp+=2000; + } + if (is_elec && (n&0xFF)==PT_WIFI && rand()%8==0) + { + parts[n>>8].temp=rand()%10000; + } + if (is_elec && (n&0xFF)==PT_WIFI && rand()%16==0) + { + create_part(n>>8, rx+nx, ry+ny, PT_BREC); + parts[n>>8].temp+=1000; + } + if ((n&0xFF)==PT_ARAY && rand()%60==0) + { + create_part(n>>8, rx+nx, ry+ny, PT_BREC); + parts[n>>8].temp+=1000; + } + if (t==PT_DLAY && rand()%70==0) + { + parts[n>>8].temp+=2000; + } + } + } + } + return 0; +} diff --git a/src/elements/ligh.c b/src/elements/ligh.c new file mode 100644 index 0000000..7ce780a --- /dev/null +++ b/src/elements/ligh.c @@ -0,0 +1,260 @@ +#include + +int contact_part(int i, int tp) +{ + int x=parts[i].x, y=parts[i].y; + int r,rx,ry; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((r&0xFF)==tp) + return r>>8; + } + return -1; +} + +void create_line_par(int x1, int y1, int x2, int y2, int c, int temp, int life, int tmp, int tmp2) +{ + if (c==WL_EHOLE || c==WL_ALLOWGAS || c==WL_ALLOWALLELEC || c==WL_ALLOWSOLID || c==WL_ALLOWAIR || c==WL_WALL || c==WL_DESTROYALL || c==WL_ALLOWLIQUID || c==WL_FAN || c==WL_STREAM || c==WL_DETECT || c==WL_EWALL || c==WL_WALLELEC) + return; // this function only for particles, no walls + int cp=abs(y2-y1)>abs(x2-x1), x, y, dx, dy, sy; + float e, de; + if (cp) + { + y = x1; + x1 = y1; + y1 = y; + y = x2; + x2 = y2; + y2 = y; + } + if (x1 > x2) + { + y = x1; + x1 = x2; + x2 = y; + y = y1; + y1 = y2; + y2 = y; + } + dx = x2 - x1; + dy = abs(y2 - y1); + e = 0.0f; + if (dx) + de = dy/(float)dx; + else + de = 0.0f; + y = y1; + sy = (y1= 0.5f) + { + y += sy; + e -= 1.0f; + } + } +} + +int update_LIGH(UPDATE_FUNC_ARGS) +{ + /*tmp2: + -1 - part will be removed + 0 - + 1 - + 2 - + */ + int r,rx,ry, multipler, powderful=parts[i].temp*(1+parts[i].life/40)/2; + hv[y/CELL][x/CELL]+=powderful/40; + if (hv[y/CELL][x/CELL]>MAX_TEMP) + hv[y/CELL][x/CELL]=MAX_TEMP; + for (rx=-2; rx<3; rx++) // destruction + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((r&0xFF)!=PT_LIGH) + { + if (parts[i].tmp2==3) + { + if ((ptypes[r&0xFF].properties&PROP_CONDUCTS) && parts[r>>8].life==0 && parts[r>>8].ctype!=PT_SPRK) + { + parts[r>>8].ctype = parts[r>>8].type; + part_change_type(r>>8,x+rx,y+ry,PT_SPRK); + parts[r>>8].life = 4; + + pv[y/CELL][x/CELL] += powderful/1200; + parts[r>>8].temp+=powderful/20; + } + 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) + { + pv[y/CELL][x/CELL] += powderful/110; + parts[r>>8].temp+=powderful/1.5; + } + if ((r&0xFF)==PT_DEUT || (r&0xFF)==PT_PLUT) + { + parts[r>>8].temp+=powderful; + pv[y/CELL][x/CELL] +=powderful/35; + if (rand()%3==0) + { + part_change_type(r>>8,x+rx,y+ry,PT_NEUT); + parts[r>>8].vx=rand()%10-5; + parts[r>>8].vy=rand()%10-5; + } + } + } + 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) + parts[r>>8].temp+=powderful/16; + else + parts[r>>8].temp+=powderful/70; + } + } + if (parts[i].tmp2==3) + { + //if (rand()&1) + parts[i].tmp2=1; + /*else + parts[i].tmp2=0;*/ + return 1; + } + + if (parts[i].tmp2==-1) + { + kill_part(i); + return 0; + } + if (parts[i].tmp2<=0 || parts[i].life<=1) + { + /*if (parts[i].tmp2!=3 && rand()%3000<400/(parts[i].life+1)) + { + parts[i].tmp2=1; + return 1; + }*/ + if (parts[i].tmp2>0) + parts[i].tmp2=0; + parts[i].tmp2--; + return 1; + } + if (parts[i].tmp2<=-2) + { + killpart(i); + return 0; + } + + float angle, angle2=-1; + + int near=nearest_part(i, -1, parts[i].life*3.5); + if (near!=-1 && (parts[near].type==PT_LIGH || parts[near].type==PT_THDR || parts[near].type==PT_NEUT)) + near=-1; + if (near!=-1) + { + int t=parts[near].type; + + rx=parts[near].x-x; + ry=parts[near].y-y; + if (asin(ry-sqrt(rx*rx+ry*ry))rand()%2000) + { + part_change_type(near, x+rx, y+ry, PT_LIGH); + parts[near].tmp2=3; + parts[near].life=(int)(1.0*parts[i].life/2-1); + parts[near].tmp=parts[i].tmp-180; + parts[near].temp=parts[i].temp; + }*/ + if (t!=PT_TESC) + { + near=contact_part(near, PT_LIGH); + if (near!=-1) + { + parts[near].tmp2=3; + parts[near].life=(int)(1.0*parts[i].life/2-1); + parts[near].tmp=parts[i].tmp-180; + parts[near].temp=parts[i].temp; + } + } + } + else near=-1; + } + + //if (parts[i].tmp2==1/* || near!=-1*/) + angle=parts[i].tmp-30+rand()%60; + if (angle<0) + angle+=360; + if (angle>=360) + angle-=360; + if (parts[i].tmp2==2) + { + angle2=angle+100-rand()%200; + if (angle2<0) + angle2+=360; + if (angle2>=360) + angle-=360; + /*angle=parts[i].tmp-70+rand()%50; + if (angle<0) + angle+=360; + if (angle>=360) + angle-=360;*/ + } + + multipler=parts[i].life*1.5+rand()%((int)(parts[i].life+1)); + rx=cos(angle*M_PI/180)*multipler; + ry=-sin(angle*M_PI/180)*multipler; + create_line_par(x, y, x+rx, y+ry, PT_LIGH, parts[i].temp, parts[i].life, angle, 0); + + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r)) + { + parts[r>>8].tmp2=1+(rand()%200>parts[i].tmp2*parts[i].tmp2/10+60); + parts[r>>8].life=(int)(1.0*parts[i].life/1.5-rand()%2); + parts[r>>8].tmp=angle; + parts[r>>8].temp=parts[i].temp; + } + } + + if (angle2!=-1) + { + multipler=parts[i].life*1.5+rand()%((int)(parts[i].life+1)); + rx=cos(angle2*M_PI/180)*multipler; + ry=-sin(angle2*M_PI/180)*multipler; + create_line_par(x, y, x+rx, y+ry, PT_LIGH, parts[i].temp, parts[i].life, angle2, 0); + + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r)) + { + parts[r>>8].tmp2=1+(rand()%200>parts[i].tmp2*parts[i].tmp2/10+40); + parts[r>>8].life=(int)(1.0*parts[i].life/1.5-rand()%2); + parts[r>>8].tmp=angle; + parts[r>>8].temp=parts[i].temp; + } + } + } + + parts[i].tmp2=-1; + return 1; +} diff --git a/src/elements/sprk.c b/src/elements/sprk.c index bae66e8..45b9acb 100644 --- a/src/elements/sprk.c +++ b/src/elements/sprk.c @@ -32,7 +32,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) { } else if (ct==PT_ETRD&&parts[i].life==1) { - nearp = nearest_part(i, PT_ETRD); + nearp = nearest_part(i, PT_ETRD, -1); if (nearp!=-1&&parts_avg(i, nearp, PT_INSL)!=PT_INSL) { create_line(x, y, (int)(parts[nearp].x+0.5f), (int)(parts[nearp].y+0.5f), 0, 0, PT_PLSM, 0); @@ -52,6 +52,40 @@ int update_SPRK(UPDATE_FUNC_ARGS) { parts[i].temp = 3500; pv[y/CELL][x/CELL] += 1; } + else if (ct==PT_TESC) // tesla coil code + { + if (parts[i].tmp>300) + parts[i].tmp=300; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || r) + continue; + if (rand()%(parts[i].tmp*parts[i].tmp/20+6)==0) + { + int p=create_part(-1, x+rx*2, y+ry*2, PT_LIGH); + if (p!=-1) + { + parts[p].life=rand()%(2+parts[i].tmp/15)+4+parts[i].tmp/7; + if (parts[i].life>60) + parts[i].life=60; + parts[p].temp=parts[p].life*parts[i].tmp/2.5; + parts[p].tmp2=1; + parts[p].tmp=acos(1.0*rx/sqrt(rx*rx+ry*ry))/M_PI*360; + parts[i].temp-=parts[i].tmp*2+parts[i].temp/5; // slight self-cooling + if (fabs(pv[y/CELL][x/CELL])!=0.0f) + { + if (fabs(pv[y/CELL][x/CELL])<=0.5f) + pv[y/CELL][x/CELL]=0; + else + pv[y/CELL][x/CELL]-=(pv[y/CELL][x/CELL]>0)?0.5:-0.5; + } + } + } + } + } else if (ct==PT_IRON) { for (rx=-1; rx<2; rx++) for (ry=-1; ry<2; ry++) diff --git a/src/graphics.c b/src/graphics.c index c038f10..83c9a5a 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -25,6 +25,8 @@ unsigned cmode = CM_FIRE; SDL_Surface *sdl_scrn; int sdl_scale = 1; +int emp_decor = 0; + int sandcolour_r = 0; int sandcolour_g = 0; int sandcolour_b = 0; @@ -1724,6 +1726,26 @@ void xor_rect(pixel *vid, int x, int y, int w, int h) } } +void draw_other(pixel *vid) // EMP effect +{ + int i, j; + if (emp_decor>0 && !sys_pause) emp_decor-=emp_decor/50+1; + if (emp_decor>100) emp_decor=100; + if (cmode==CM_NOTHING) // no in nothing mode + return; + if (emp_decor) + for (j=0; j255) r=255; + if (g>255) g=255; + if (b>255) g=255; + drawpixel(vid, i, j, r, g, b, a*255); + } +} + //the main function for drawing the particles void draw_parts(pixel *vid) { @@ -3329,6 +3351,103 @@ void draw_parts(pixel *vid) } } + else if (t==PT_LIGH) + { + uint8 R = 235; + uint8 G = 245; + uint8 B = 255; + float a=0.8*parts[i].life/40; + if (a>0.8) a=0.8; + blendpixel(vid, nx, ny, R, G, B, 255); + if (cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) + { + cr = a*R; + cg = a*G; + cb = a*B; + 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; + + if (a>0.3) + { + int rx, ry; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx 255) cg = 255; + fire_g[y+ry][x+rx] = cg; + cb += fire_b[y+ry][x+rx]; + if (cb > 255) cb = 255; + fire_b[y+ry][x+rx] = cb; + cr += fire_r[y+ry][x+rx]; + if (cr > 255) cr = 255; + fire_r[y+ry][x+rx] = cr; + } + } + } + } + else if (t==PT_DEST) + { + cr = PIXR(ptypes[t].pcolors); + cg = PIXG(ptypes[t].pcolors); + cb = PIXB(ptypes[t].pcolors); + if (cmode != CM_CRACK) { + int newx = 0; + float flicker = rand()%30; + float gradv = flicker+(parts[i].life==0?20:1)+parts[i].life*8; + blendpixel(vid, nx, ny, cr, cg, cb, (gradv*4)>255?255:(gradv*4) ); + blendpixel(vid, nx+1, ny, cr, cg, cb, (gradv*2)>255?255:(gradv*2) ); + blendpixel(vid, nx-1, ny, cr, cg, cb, (gradv*2)>255?255:(gradv*2) ); + blendpixel(vid, nx, ny+1, cr, cg, cb, (gradv*2)>255?255:(gradv*2) ); + blendpixel(vid, nx, ny-1, cr, cg, cb, (gradv*2)>255?255:(gradv*2) ); + if (gradv>255) gradv=255; + blendpixel(vid, nx+1, ny-1, cr, cg, cb, gradv); + blendpixel(vid, nx-1, ny-1, cr, cg, cb, gradv); + blendpixel(vid, nx+1, ny+1, cr, cg, cb, gradv); + blendpixel(vid, nx-1, ny+1, cr, cg, cb, gradv); + for (newx = 1; gradv>0.5; newx++) { + addpixel(vid, nx+newx, ny, cr, cg, cb, gradv); + addpixel(vid, nx-newx, ny, cr, cg, cb, gradv); + + addpixel(vid, nx, ny+newx, cr, cg, cb, gradv); + addpixel(vid, nx, ny-newx, cr, cg, cb, gradv); + float div_n=1.2f-0.006*parts[i].life; + if (div_n<1.01f) + div_n=1.01f; + gradv = gradv/div_n; + } + } else { + blendpixel(vid, nx, ny, cr, cg, cb, 255); + } + } + else if (t==PT_EMP && parts[i].life) + { + cr = parts[i].life*1.5; + cg = parts[i].life*1.5; + cb = 200-parts[i].life; + if (cr>255) + cr = 255; + if (cg>255) + cg = 255; + if (cb>255) + cb = 255; + if (cb<=0) + cb = 0; + blendpixel(vid, nx, ny, cr, cg, cb, 255); + } else if (t==PT_GBMB) { if (parts[i].life<=0) {//not yet detonated diff --git a/src/main.c b/src/main.c index f3d655f..a83ba3e 100644 --- a/src/main.c +++ b/src/main.c @@ -1815,6 +1815,7 @@ int main(int argc, char *argv[]) draw_walls(part_vbuf); update_particles(part_vbuf); //update everything draw_parts(part_vbuf); //draw particles + draw_other(part_vbuf); if(sl == WL_GRAV+100 || sr == WL_GRAV+100) draw_grav_zones(part_vbuf); diff --git a/src/powder.c b/src/powder.c index 077a242..100ea96 100644 --- a/src/powder.c +++ b/src/powder.c @@ -1258,9 +1258,9 @@ inline int parts_avg(int ci, int ni,int t) } -int nearest_part(int ci, int t) +int nearest_part(int ci, int t, int max_d) { - int distance = MAX_DISTANCE; + int distance = (max_d!=-1)?max_d:MAX_DISTANCE; int ndistance = 0; int id = -1; int i = 0; @@ -1268,7 +1268,7 @@ int nearest_part(int ci, int t) int cy = (int)parts[ci].y; for (i=0; i<=parts_lastActiveIndex; i++) { - if (parts[i].type==t&&!parts[i].life&&i!=ci) + if ((parts[i].type==t||t==-1)&&!parts[i].life&&i!=ci) { ndistance = abs(cx-parts[i].x)+abs(cy-parts[i].y);// Faster but less accurate Older: sqrt(pow(cx-parts[i].x, 2)+pow(cy-parts[i].y, 2)); if (ndistance Date: Mon, 10 Oct 2011 23:55:42 +0100 Subject: More functionality for LIGH, better english on element descriptions diff --git a/includes/powder.h b/includes/powder.h index 1e0c425..9b1e0e7 100644 --- a/includes/powder.h +++ b/includes/powder.h @@ -504,8 +504,8 @@ static const part_type ptypes[PT_NUM] = {"CONV", PIXPACK(0x0AAB0A), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 251, "Solid. Converts whatever touches it into its ctype.", ST_NONE, TYPE_SOLID, &update_CONV}, {"CAUS", PIXPACK(0x80FFA0), 2.0f, 0.00f * CFDS, 0.99f, 0.30f, -0.1f, 0.0f, 1.50f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 1, 1, SC_GAS, R_TEMP+0.0f +273.15f, 70, "Caustic Gas, acts like Acid", ST_GAS, TYPE_GAS, &update_CAUS}, {"LIGH", PIXPACK(0xFFFFC0), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 0, "More realistic lighting. Set pen size for setting size of the lighting.", ST_SOLID, TYPE_SOLID, &update_LIGH, 0}, - {"TESC", PIXPACK(0x707040), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Tesla coil!!!", ST_SOLID, TYPE_SOLID|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_HOT_GLOW, NULL, 0}, - {"DEST", PIXPACK(0xFF3311), -0.05f, 0.00f * CFDS, 0.95f, 0.95f, -0.1f, 0.4f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 0, 1, 1, 101, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 150, "Makes big destruction.", ST_SOLID, TYPE_PART|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC, &update_DEST, 0}, + {"TESC", PIXPACK(0x707040), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Tesla coil!", ST_SOLID, TYPE_SOLID|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_HOT_GLOW, NULL, 0}, + {"DEST", PIXPACK(0xFF3311), -0.05f, 0.00f * CFDS, 0.95f, 0.95f, -0.1f, 0.4f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 0, 1, 1, 101, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 150, "More destructive Bomb.", ST_SOLID, TYPE_PART|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC, &update_DEST, 0}, {"SPNG", PIXPACK(0xFFBE30), 0.00f, 0.00f * CFDS, 0.00f, 1.00f, 0.00f, 0.0f, 0.00f, 0.000f * CFDS, 0, 20, 0, 1, 30, 1, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "A sponge, absorbs water.", ST_SOLID, TYPE_SOLID, &update_SPNG}, {"RIME", PIXPACK(0xCCCCCC), 0.00f, 0.00f * CFDS, 0.00f, 1.00f, 0.00f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 30, 1, 1, 100, SC_CRACKER2, 243.15f, 100, "Not quite Ice", ST_SOLID, TYPE_SOLID, &update_RIME}, {"FOG", PIXPACK(0xAAAAAA), 0.8f, 0.00f * CFDS, 0.4f, 0.70f, -0.1f, 0.0f, 0.99f, 0.000f * CFDS, 0, 0, 0, 0, 30, 1, 1, 1, SC_CRACKER2, 243.15f, 100, "Not quite Steam", ST_GAS, TYPE_GAS|PROP_LIFE_DEC, &update_FOG}, @@ -550,8 +550,8 @@ static const part_type ptypes[PT_NUM] = {"SING", PIXPACK(0x242424), 0.7f, 0.36f * CFDS, 0.96f, 0.80f, 0.1f, 0.12f, 0.00f, -0.001f * CFDS, 1, 0, 0, 0, 0, 1, 1, 86, SC_NUCLEAR, R_TEMP+0.0f +273.15f, 70, "Singularity", ST_SOLID, TYPE_PART|PROP_LIFE_DEC, &update_SING}, {"QRTZ", PIXPACK(0xAADDDD), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 3, "Quartz, breakable mineral. Conducts but becomes brittle at lower temperatures.", ST_SOLID, TYPE_SOLID|PROP_HOT_GLOW|PROP_LIFE_DEC, &update_QRTZ}, {"PQRT", PIXPACK(0x88BBBB), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.27f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 0, 1, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 3, "Broken quartz.", ST_SOLID, TYPE_PART| PROP_HOT_GLOW, &update_QRTZ}, - {"EMP", PIXPACK(0x66AAFF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.0f, 0.0f * CFDS, 0, 0, 0, 0, 3, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 121, "Breaks some working electronics if take spark. For total breaking use more EMP pixels.", ST_SOLID, TYPE_SOLID|PROP_LIFE_DEC, &update_EMP, 0}, - {"BREL", PIXPACK(0x707060), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.18f, 0.00f, 0.000f * CFDS, 1, 0, 0, 2, 2, 1, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 211, "Bronen electronic.", ST_SOLID, TYPE_PART|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_HOT_GLOW, NULL, 0}, + {"EMP", PIXPACK(0x66AAFF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.0f, 0.0f * CFDS, 0, 0, 0, 0, 3, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 121, "Breaks activated electronics.", ST_SOLID, TYPE_SOLID|PROP_LIFE_DEC, &update_EMP, 0}, + {"BREL", PIXPACK(0x707060), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.18f, 0.00f, 0.000f * CFDS, 1, 0, 0, 2, 2, 1, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 211, "Broken electronics", ST_SOLID, TYPE_PART|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_HOT_GLOW, NULL, 0}, /*FREE*/{"COAG", PIXPACK(0x9ACD32), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "B378/S235678", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, /*FREE*/{"WALL", PIXPACK(0x0047AB), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "B45678/S2345", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, /*FREE*/{"GNAR", PIXPACK(0xE5B73B), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "B1/S1", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, diff --git a/src/elements/ligh.c b/src/elements/ligh.c index 7ce780a..8f9c80e 100644 --- a/src/elements/ligh.c +++ b/src/elements/ligh.c @@ -140,6 +140,7 @@ int update_LIGH(UPDATE_FUNC_ARGS) if (parts[i].tmp2==-1) { kill_part(i); + update_PYRO(UPDATE_FUNC_SUBCALL_ARGS); return 0; } if (parts[i].tmp2<=0 || parts[i].life<=1) diff --git a/src/powder.c b/src/powder.c index 100ea96..dad1f6e 100644 --- a/src/powder.c +++ b/src/powder.c @@ -9,6 +9,8 @@ int gravwl_timeout = 0; int wire_placed = 0; +int lighting_recreate = 0; + float player[28]; //[0] is a command cell, [3]-[18] are legs positions, [19]-[26] are accelerations, [27] shows if player was spawned float player2[28]; @@ -842,6 +844,12 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a parts[i].tmp = 0; parts[i].tmp2 = 0; } + if (t==PT_LIGH) + { + parts[i].tmp=270; + if (p=-2) + parts[i].tmp2=4; + } if (t==PT_SOAP) { parts[i].tmp = -1; @@ -1329,10 +1337,33 @@ void update_particles_i(pixel *vid, int start, int inc) int starti = (start*-1); int surround[8]; int surround_hconduct[8]; + int lighting_ok=1; float pGravX, pGravY, pGravD; + if (sys_pause&&lighting_recreate>0) + { + for (i=0; i<=parts_lastActiveIndex; i++) + { + if (parts[i].type==PT_LIGH && parts[i].tmp2>0) + { + lighting_ok=0; + break; + } + } + } + + if (lighting_ok) + lighting_recreate--; + + if (lighting_recreate<0) + lighting_recreate=1; + + if (lighting_recreate>21) + lighting_recreate=21; + if (sys_pause&&!framerender)//do nothing if paused return; + if (ISGRAV==1)//crappy grav color handling, i will change this someday { ISGRAV = 0; @@ -2807,6 +2838,24 @@ int create_parts(int x, int y, int rx, int ry, int c, int flags) { gravwl_timeout = 60; } + + if (c==PT_LIGH) + { + if (lighting_recreate>0 && rx+ry>0) + return 0; + int p=create_part(-2, x, y, c); + if (p!=-1) + { + parts[p].life=rx+ry; + if (parts[p].life>55) + parts[p].life=55; + parts[p].temp=parts[p].life*150; // temperatute of the lighting shows the power of the lighting + lighting_recreate+=parts[p].life/2+1; + return 1; + } + else return 0; + } + if (dw==1) { ry = ry/CELL; -- cgit v0.9.2-21-gd62e From 40457bf65218bd6d4aee0e377460d6cc6e61ee97 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Mon, 10 Oct 2011 23:58:50 +0100 Subject: Fix crash with LIGH diff --git a/src/elements/sprk.c b/src/elements/sprk.c index 45b9acb..ac86467 100644 --- a/src/elements/sprk.c +++ b/src/elements/sprk.c @@ -68,7 +68,9 @@ int update_SPRK(UPDATE_FUNC_ARGS) { int p=create_part(-1, x+rx*2, y+ry*2, PT_LIGH); if (p!=-1) { - parts[p].life=rand()%(2+parts[i].tmp/15)+4+parts[i].tmp/7; + if(!parts[i].tmp) //Prevent Arithmetic errors with zero values + continue; + parts[p].life=rand()%(2+parts[i].tmp/15)+4+parts[i].tmp/7; if (parts[i].life>60) parts[i].life=60; parts[p].temp=parts[p].life*parts[i].tmp/2.5; -- cgit v0.9.2-21-gd62e From aaf17208a2254708f5ddae39720e0fb93b0bbaa1 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Tue, 11 Oct 2011 00:02:29 +0100 Subject: Version Increment diff --git a/includes/defines.h b/includes/defines.h index 667ad69..9f69b60 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -8,7 +8,7 @@ #endif //VersionInfoStart -#define SAVE_VERSION 64 +#define SAVE_VERSION 65 #define MINOR_VERSION 0 //#define BETA #define BUILD_NUM 0 -- cgit v0.9.2-21-gd62e From e1cd3cc1809522294e1d0c50965b48898b161209 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Tue, 11 Oct 2011 00:25:43 +0100 Subject: Fix erronous assignment and add MaksProg to contributors list diff --git a/src/main.c b/src/main.c index a83ba3e..97f4d38 100644 --- a/src/main.c +++ b/src/main.c @@ -153,7 +153,7 @@ static const char *it_msg = "\n" "Contributors: \bgStanislaw K Skowronek (\brhttp://powder.unaligned.org\bg, \bbirc.unaligned.org #wtf\bg),\n" "\bgSimon Robertshaw, Skresanov Savely, cracker64, Catelite, Bryan Hoyle, Nathan Cousins, jacksonmj,\n" - "\bgLieuwe Mosch, Anthony Boot, Matthew Miller\n" + "\bgLieuwe Mosch, Anthony Boot, Matthew Miller, MaksProg\n" "\n" "\bgTo use online features such as saving, you need to register at: \brhttp://powdertoy.co.uk/Register.html" ; diff --git a/src/powder.c b/src/powder.c index dad1f6e..5547ddd 100644 --- a/src/powder.c +++ b/src/powder.c @@ -847,7 +847,7 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a if (t==PT_LIGH) { parts[i].tmp=270; - if (p=-2) + if (p==-2) parts[i].tmp2=4; } if (t==PT_SOAP) -- cgit v0.9.2-21-gd62e From 51aab692e98d19f6a5adf6f558c4ac8226a5f3fd Mon Sep 17 00:00:00 2001 From: "chaos.powdertoy.co.uk" Date: Mon, 10 Oct 2011 19:26:21 -0400 Subject: Version Increment diff --git a/includes/defines.h b/includes/defines.h index 9f69b60..2972c18 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -10,8 +10,8 @@ //VersionInfoStart #define SAVE_VERSION 65 #define MINOR_VERSION 0 -//#define BETA -#define BUILD_NUM 0 +#define BETA +#define BUILD_NUM 91 //VersionInfoEnd #define IDENT_VERSION "G" //Change this if you're not Simon! It should be a single letter. -- cgit v0.9.2-21-gd62e From 6178bb4605a24193a2049aa109f49b88a1a69ca5 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Tue, 11 Oct 2011 10:34:33 +0100 Subject: Fixes for LIGH and TESC, LIGH observes gravity setting diff --git a/src/elements/ligh.c b/src/elements/ligh.c index 8f9c80e..188ff97 100644 --- a/src/elements/ligh.c +++ b/src/elements/ligh.c @@ -1,5 +1,7 @@ #include +#define LIGHTING_POWER 0.65 + int contact_part(int i, int tp) { int x=parts[i].x, y=parts[i].y; @@ -75,13 +77,22 @@ void create_line_par(int x1, int y1, int x2, int y2, int c, int temp, int life, int update_LIGH(UPDATE_FUNC_ARGS) { - /*tmp2: - -1 - part will be removed - 0 - - 1 - - 2 - + /* + * + * tmp2: + * -1 - part will be removed + * 0 - "branches" of the lightning + * 1 - bending + * 2 - branching + * 3 - transfer spark or make destruction + * 4 - first pixel + * + * life - "thickness" of lighting (but anyway one pixel) + * + * tmp - angle of lighting + * */ - int r,rx,ry, multipler, powderful=parts[i].temp*(1+parts[i].life/40)/2; + int r,rx,ry, multipler, powderful=parts[i].temp*(1+parts[i].life/40)*LIGHTING_POWER; hv[y/CELL][x/CELL]+=powderful/40; if (hv[y/CELL][x/CELL]>MAX_TEMP) hv[y/CELL][x/CELL]=MAX_TEMP; @@ -92,7 +103,7 @@ int update_LIGH(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if ((r>>8)>=NPART || !r) continue; - if ((r&0xFF)!=PT_LIGH) + if ((r&0xFF)!=PT_LIGH && (r&0xFF)!=PT_TESC) { if (parts[i].tmp2==3) { @@ -140,7 +151,6 @@ int update_LIGH(UPDATE_FUNC_ARGS) if (parts[i].tmp2==-1) { kill_part(i); - update_PYRO(UPDATE_FUNC_SUBCALL_ARGS); return 0; } if (parts[i].tmp2<=0 || parts[i].life<=1) @@ -157,7 +167,7 @@ int update_LIGH(UPDATE_FUNC_ARGS) } if (parts[i].tmp2<=-2) { - killpart(i); + kill_part(i); return 0; } @@ -200,7 +210,19 @@ int update_LIGH(UPDATE_FUNC_ARGS) } //if (parts[i].tmp2==1/* || near!=-1*/) - angle=parts[i].tmp-30+rand()%60; + switch (gravityMode) + { + default: + case 0: + angle = parts[i].tmp-30+rand()%60; + break; + case 1: + angle = rand()%360; + break; + case 2: + angle = atan2(x-XCNTR, y-YCNTR)*(180.0f/M_PI)+90; + } + //angle=0;//parts[i].tmp-30+rand()%60; if (angle<0) angle+=360; if (angle>=360) @@ -227,7 +249,9 @@ int update_LIGH(UPDATE_FUNC_ARGS) if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r)) + /*if ((r&0xFF)!=PT_LIGH && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_UDMT && (r&0xFF)!=PT_TESC) + part_change_type(r>>8, x+rx, y+ry, PT_LIGH);*/ + if ((r&0xFF)==PT_LIGH && !((r>>8)>=NPART || !r)) { parts[r>>8].tmp2=1+(rand()%200>parts[i].tmp2*parts[i].tmp2/10+60); parts[r>>8].life=(int)(1.0*parts[i].life/1.5-rand()%2); @@ -246,7 +270,9 @@ int update_LIGH(UPDATE_FUNC_ARGS) if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r)) + /*if ((r&0xFF)!=PT_LIGH && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_UDMT && (r&0xFF)!=PT_TESC) + part_change_type(r>>8, x+rx, y+ry, PT_LIGH);*/ + if ((r&0xFF)==PT_LIGH && !((r>>8)>=NPART || !r)) { parts[r>>8].tmp2=1+(rand()%200>parts[i].tmp2*parts[i].tmp2/10+40); parts[r>>8].life=(int)(1.0*parts[i].life/1.5-rand()%2); diff --git a/src/elements/sprk.c b/src/elements/sprk.c index ac86467..2633a65 100644 --- a/src/elements/sprk.c +++ b/src/elements/sprk.c @@ -68,7 +68,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) { int p=create_part(-1, x+rx*2, y+ry*2, PT_LIGH); if (p!=-1) { - if(!parts[i].tmp) //Prevent Arithmetic errors with zero values + if(parts[i].tmp<=4) //Prevent Arithmetic errors with zero values continue; parts[p].life=rand()%(2+parts[i].tmp/15)+4+parts[i].tmp/7; if (parts[i].life>60) diff --git a/src/main.c b/src/main.c index 97f4d38..dacda26 100644 --- a/src/main.c +++ b/src/main.c @@ -2627,13 +2627,13 @@ int main(int argc, char *argv[]) } if (DEBUG_MODE) { - sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C, Life: %d", nametext, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life); + sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C, Life: %d, Tmp:%d", nametext, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life, parts[cr>>8].tmp); sprintf(coordtext, "#%d, X:%d Y:%d", cr>>8, x/sdl_scale, y/sdl_scale); } else { #ifdef BETA - sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C, Life: %d", nametext, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life); + sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C, Life: %d, Tmp:%d", nametext, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life, parts[cr>>8].tmp); #else sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C", nametext, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f); #endif diff --git a/src/powder.c b/src/powder.c index 5547ddd..3fe4ef5 100644 --- a/src/powder.c +++ b/src/powder.c @@ -846,9 +846,9 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a } if (t==PT_LIGH) { - parts[i].tmp=270; + parts[i].tmp = 270; if (p==-2) - parts[i].tmp2=4; + parts[i].tmp2 = 4; } if (t==PT_SOAP) { @@ -2806,7 +2806,7 @@ int flood_water(int x, int y, int i, int originaly, int check) //this creates particles from a brush, don't use if you want to create one particle int create_parts(int x, int y, int rx, int ry, int c, int flags) { - int i, j, r, f = 0, u, v, oy, ox, b = 0, dw = 0, stemp = 0;//n; + int i, j, r, f = 0, u, v, oy, ox, b = 0, dw = 0, stemp = 0, p;//n; int wall = c - 100; if (c==SPC_WIND){ @@ -2838,7 +2838,6 @@ int create_parts(int x, int y, int rx, int ry, int c, int flags) { gravwl_timeout = 60; } - if (c==PT_LIGH) { if (lighting_recreate>0 && rx+ry>0) @@ -2994,6 +2993,31 @@ int create_parts(int x, int y, int rx, int ry, int c, int flags) } //else, no special modes, draw element like normal. + if(c==PT_TESC) + { + if (rx==0&&ry==0)//workaround for 1pixel brush/floodfill crashing. todo: find a better fix later. + { + if (create_part(-2, x, y, c)==-1) + f = 1; + } + else + for (j=-ry; j<=ry; j++) + for (i=-rx; i<=rx; i++) + if (InCurrentBrush(i ,j ,rx ,ry)) + { + p = create_part(-2, x+i, y+j, c); + if (p==-1) + { + f = 1; + } else { + parts[p].tmp=rx*4+ry*4+7; + if (parts[p].tmp>300) + parts[p].tmp=300; + } + } + return !f; + } + if (rx==0&&ry==0)//workaround for 1pixel brush/floodfill crashing. todo: find a better fix later. { if (create_part(-2, x, y, c)==-1) -- cgit v0.9.2-21-gd62e From 265ce68e8146cf9b328b5fbc8c6b522b83311353 Mon Sep 17 00:00:00 2001 From: "chaos.powdertoy.co.uk" Date: Tue, 11 Oct 2011 05:35:37 -0400 Subject: Version Increment diff --git a/includes/defines.h b/includes/defines.h index 2972c18..d44834f 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -9,9 +9,9 @@ //VersionInfoStart #define SAVE_VERSION 65 -#define MINOR_VERSION 0 +#define MINOR_VERSION 1 #define BETA -#define BUILD_NUM 91 +#define BUILD_NUM 92 //VersionInfoEnd #define IDENT_VERSION "G" //Change this if you're not Simon! It should be a single letter. -- cgit v0.9.2-21-gd62e From 107e77a1a13f3dbdbc9703247f52f41716cd8115 Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Tue, 11 Oct 2011 21:51:45 +0800 Subject: Prevent extra particles at the end of 1px lines diff --git a/src/powder.c b/src/powder.c index 3fe4ef5..be22ca6 100644 --- a/src/powder.c +++ b/src/powder.c @@ -3103,7 +3103,8 @@ void create_line(int x1, int y1, int x2, int y2, int rx, int ry, int c, int flag if (e >= 0.5f) { y += sy; - if (c==WL_EHOLE+100 || c==WL_ALLOWGAS+100 || c==WL_ALLOWENERGY+100 || c==WL_ALLOWALLELEC+100 || c==WL_ALLOWSOLID+100 || c==WL_ALLOWAIR+100 || c==WL_WALL+100 || c==WL_DESTROYALL+100 || c==WL_ALLOWLIQUID+100 || c==WL_FAN+100 || c==WL_STREAM+100 || c==WL_DETECT+100 || c==WL_EWALL+100 || c==WL_WALLELEC+100 || !(rx+ry)) + if ((c==WL_EHOLE+100 || c==WL_ALLOWGAS+100 || c==WL_ALLOWENERGY+100 || c==WL_ALLOWALLELEC+100 || c==WL_ALLOWSOLID+100 || c==WL_ALLOWAIR+100 || c==WL_WALL+100 || c==WL_DESTROYALL+100 || c==WL_ALLOWLIQUID+100 || c==WL_FAN+100 || c==WL_STREAM+100 || c==WL_DETECT+100 || c==WL_EWALL+100 || c==WL_WALLELEC+100 || !(rx+ry)) + && ((y1=y2))) { if (cp) create_parts(y, x, rx, ry, c, flags); -- cgit v0.9.2-21-gd62e From 2f46dca7c1d0016957dfd88831f453f06e080fef Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Wed, 12 Oct 2011 00:11:20 +0800 Subject: Some work on DEST, EMP, LIGH Change indentation to tabs, respect temperature limit (if a hotter reaction is required, should raise temp limit instead of ignoring it). DEST: fix TYPE_SOLID check, and prevent it displacing DMND EMP: randomise DLAY delay instead of heating it (since DLAY does not melt and does not transfer heat) Fix nearest_part so that t=-1 does not include dead particles diff --git a/includes/powder.h b/includes/powder.h index 9b1e0e7..b281954 100644 --- a/includes/powder.h +++ b/includes/powder.h @@ -465,7 +465,7 @@ static const part_type ptypes[PT_NUM] = {"PTCT", PIXPACK(0x405050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Semi-conductor. Only conducts electricity when cold (Less than 100C)", ST_SOLID, TYPE_SOLID|PROP_CONDUCTS|PROP_LIFE_DEC, &update_NPTCT}, {"BGLA", PIXPACK(0x606060), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 5, 2, 1, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 150, "Broken Glass, Heavy particles. Meltable. Bagels.", ST_SOLID, TYPE_PART | PROP_HOT_GLOW, NULL}, {"THDR", PIXPACK(0xFFFFA0), 0.0f, 0.00f * CFDS, 1.0f, 0.30f, -0.99f, 0.6f, 0.62f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 1, 1, SC_EXPLOSIVE, 9000.0f +273.15f, 1, "Lightning! Very hot, inflicts damage upon most materials, transfers current to metals.", ST_NONE, TYPE_ENERGY, &update_THDR}, - {"PLSM", PIXPACK(0xBB99FF), 0.9f, 0.04f * CFDS, 0.97f, 0.20f, 0.0f, -0.1f, 0.30f, 0.001f * CFDS, 0, 0, 0, 0, 0, 1, 1, 1, SC_GAS, 10000.0f +273.15f, 5, "Plasma, extremely hot.", ST_NONE, TYPE_GAS|PROP_LIFE_DEC|PROP_LIFE_KILL, &update_PYRO}, + {"PLSM", PIXPACK(0xBB99FF), 0.9f, 0.04f * CFDS, 0.97f, 0.20f, 0.0f, -0.1f, 0.30f, 0.001f * CFDS, 0, 0, 0, 0, 0, 1, 1, 1, SC_GAS, 9999.0f, 5, "Plasma, extremely hot.", ST_NONE, TYPE_GAS|PROP_LIFE_DEC|PROP_LIFE_KILL, &update_PYRO}, {"ETRD", PIXPACK(0x404040), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Electrode. Creates a surface that allows Plasma arcs. (Use sparingly)", ST_NONE, TYPE_SOLID|PROP_CONDUCTS|PROP_LIFE_DEC, NULL}, {"NICE", PIXPACK(0xC0E0FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, -0.0005f* CFDS, 0, 0, 0, 0, 20, 1, 1, 100, SC_SOLIDS, 35.0f, 46, "Nitrogen Ice.", ST_SOLID, TYPE_SOLID, NULL}, {"NBLE", PIXPACK(0xEB4917), 1.0f, 0.01f * CFDS, 0.99f, 0.30f, -0.1f, 0.0f, 0.75f, 0.001f * CFDS, 0, 0, 0, 0, 1, 1, 1, 1, SC_GAS, R_TEMP+2.0f +273.15f, 106, "Noble Gas. Diffuses. Conductive. Ionizes into plasma when introduced to electricity", ST_GAS, TYPE_GAS|PROP_CONDUCTS|PROP_LIFE_DEC, NULL}, diff --git a/src/elements/dest.c b/src/elements/dest.c index fb2a9d7..a50dfaa 100644 --- a/src/elements/dest.c +++ b/src/elements/dest.c @@ -5,55 +5,50 @@ int update_DEST(UPDATE_FUNC_ARGS) { rx=rand()%5-2; ry=rand()%5-2; - r = pmap[y+ry][x+rx]; - if ((r>>8)>=NPART || !r) - return 0; - if ((r&0xFF)!=PT_DEST && (r&0xFF)!=PT_DMND) - { - if (parts[i].life<=0 || parts[i].life>37) - { - parts[i].life=30+rand()%20; - parts[i].temp+=20000; - pv[y/CELL][x/CELL]+=60.0f; - } - parts[i].temp+=10000; - if ((r&0xFF)==PT_PLUT || (r&0xFF)==PT_DEUT) - { - pv[y/CELL][x/CELL]+=20.0f; - parts[i].temp+=18000; - if (rand()%2==0) - { - part_change_type(r>>8, x+rx, y+ry, PT_NEUT); - float rad = (rand()%128+128)/127.0f; - float a = (rand()%360)*M_PI/180.0f; - parts[r>>8].vx = rad*cosf(a); - parts[r>>8].vy = rad*sinf(a); - parts[r>>8].temp+=40000; - pv[y/CELL][x/CELL]+=10.0f; - parts[i].life-=4; - } - } - if ((r&0xFF)==PT_INSL) - { - create_part(r>>8, x+rx, y+ry, PT_FIRE); - parts[r>>8].temp=10000; - } - else if (rand()%3==0) - { - kill_part(r>>8); - parts[i].life-=4*(ptypes[r&0xFF].properties==TYPE_SOLID?3:1); - if (parts[i].life<=0) - parts[i].life=1; - parts[i].temp+=10000; - } - else - { - parts[r>>8].temp+=10000; - } - int topv=pv[y/CELL][x/CELL]/9+parts[r>>8].temp/900; - if (topv>40.0f) - topv=40.0f; - pv[y/CELL][x/CELL]+=40.0f+topv; - } - return 0; + r = pmap[y+ry][x+rx]; + if (!r || (r&0xFF)==PT_DEST || (r&0xFF)==PT_DMND) + return 0; + + if (parts[i].life<=0 || parts[i].life>37) + { + parts[i].life=30+rand()%20; + parts[i].temp+=20000; + pv[y/CELL][x/CELL]+=60.0f; + } + parts[i].temp+=10000; + if ((r&0xFF)==PT_PLUT || (r&0xFF)==PT_DEUT) + { + pv[y/CELL][x/CELL]+=20.0f; + parts[i].temp+=18000; + if (rand()%2==0) + { + float orig_temp = parts[r>>8].temp; + create_part(r>>8, x+rx, y+ry, PT_NEUT); + parts[r>>8].temp = restrict_flt(orig_temp+40000.0f, MIN_TEMP, MAX_TEMP); + pv[y/CELL][x/CELL] += 10.0f; + parts[i].life-=4; + } + } + else if ((r&0xFF)==PT_INSL) + { + create_part(r>>8, x+rx, y+ry, PT_PLSM); + } + else if (rand()%3==0) + { + kill_part(r>>8); + parts[i].life -= 4*((ptypes[r&0xFF].properties&TYPE_SOLID)?3:1); + if (parts[i].life<=0) + parts[i].life=1; + parts[i].temp+=10000; + } + else + { + parts[r>>8].temp = restrict_flt(parts[r>>8].temp+10000.0f, MIN_TEMP, MAX_TEMP); + } + int topv=pv[y/CELL][x/CELL]/9+parts[r>>8].temp/900; + if (topv>40.0f) + topv=40.0f; + pv[y/CELL][x/CELL]+=40.0f+topv; + parts[i].temp = restrict_flt(parts[i].temp, MIN_TEMP, MAX_TEMP); + return 0; } diff --git a/src/elements/emp.c b/src/elements/emp.c index 3017bc6..96d1a6d 100644 --- a/src/elements/emp.c +++ b/src/elements/emp.c @@ -3,100 +3,108 @@ int update_EMP(UPDATE_FUNC_ARGS) { int r,rx,ry,ok=0,t; if (parts[i].life) - return 0; + return 0; for (rx=-2; rx<3; rx++) for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rx=0 && y+ry>=0 && x+rx>8)>=NPART || !r) + if (!r) continue; - if ((r&0xFF)==PT_SPRK) - { - ok=1; - break; - } + if ((r&0xFF)==PT_SPRK) + { + ok=1; + break; + } } - if (!ok) - return 0; - parts[i].life=220; - emp_decor+=7; - if (emp_decor>100) - emp_decor=100; + if (!ok) + return 0; + parts[i].life=220; + emp_decor+=7; + if (emp_decor>100) + emp_decor=100; for (r=0; r<=parts_lastActiveIndex; r++) { - t=parts[r].type; - rx=parts[r].x; - ry=parts[r].y; - if (t==PT_SPRK || (t==PT_SWCH && parts[r].life!=0 && parts[r].life!=10) || (t==PT_WIRE && parts[r].ctype>0)) - { - int is_elec=0; - if ((parts[r].ctype==PT_PSCN || parts[r].ctype==PT_NSCN || parts[r].ctype==PT_PTCT || - parts[r].ctype==PT_NTCT || parts[r].ctype==PT_INST || parts[r].ctype==PT_SWCH) || t==PT_WIRE || t==PT_SWCH) - { - is_elec=1; - if (rand()%100==0) - parts[r].temp+=3000; - if (rand()%80==0) - part_change_type(r, rx, ry, PT_BREC); - else if (rand()%120==0) - part_change_type(r, rx, ry, PT_NTCT); - } - int n,nx,ny; - for (nx=-2; nx<3; nx++) - for (ny=-2; ny<3; ny++) - if (rx+nx>=0 && ry+ny>0 && rx+nx>8)>=NPART || !n) - continue; - /*if ((n&0xFF)==PT_BTRY && rand()%60==0) - { - part_change_type(n>>8, rx+nx, ry+ny, PT_PLSM); - parts[n>>8].life=rand()%100+70; - parts[n>>8].temp+=3000; - }*/ - if (is_elec && ((n&0xFF)==PT_METL || (n&0xFF)==PT_BMTL) && rand()%280==0) - { - parts[n>>8].temp+=3000; - } - if (is_elec && (n&0xFF)==PT_BMTL && rand()%160==0) - { - part_change_type(n>>8, rx+nx, ry+ny, PT_BMTL); - parts[n>>8].temp+=1000; - } - if (is_elec && (n&0xFF)==PT_METL && rand()%300==0) - { - part_change_type(n>>8, rx+nx, ry+ny, PT_BMTL); - } - if ((t==PT_PSCN || t==PT_NSCN) && (n&0xFF)==PT_SWCH && rand()%100==0) - { - part_change_type(n>>8, rx+nx, ry+ny, PT_BREC); - } - if ((t==PT_PSCN || t==PT_NSCN) && (n&0xFF)==PT_SWCH && rand()%100==0) - { - parts[n>>8].temp+=2000; - } - if (is_elec && (n&0xFF)==PT_WIFI && rand()%8==0) - { - parts[n>>8].temp=rand()%10000; - } - if (is_elec && (n&0xFF)==PT_WIFI && rand()%16==0) - { - create_part(n>>8, rx+nx, ry+ny, PT_BREC); - parts[n>>8].temp+=1000; - } - if ((n&0xFF)==PT_ARAY && rand()%60==0) - { - create_part(n>>8, rx+nx, ry+ny, PT_BREC); - parts[n>>8].temp+=1000; - } - if (t==PT_DLAY && rand()%70==0) - { - parts[n>>8].temp+=2000; - } - } - } + t=parts[r].type; + rx=parts[r].x; + ry=parts[r].y; + if (t==PT_SPRK || (t==PT_SWCH && parts[r].life!=0 && parts[r].life!=10) || (t==PT_WIRE && parts[r].ctype>0)) + { + int is_elec=0; + if ((parts[r].ctype==PT_PSCN || parts[r].ctype==PT_NSCN || parts[r].ctype==PT_PTCT || + parts[r].ctype==PT_NTCT || parts[r].ctype==PT_INST || parts[r].ctype==PT_SWCH) || t==PT_WIRE || t==PT_SWCH) + { + is_elec=1; + if (rand()%100==0) + parts[r].temp = restrict_flt(parts[r].temp+3000.0f, MIN_TEMP, MAX_TEMP); + if (rand()%80==0) + part_change_type(r, rx, ry, PT_BREC); + else if (rand()%120==0) + part_change_type(r, rx, ry, PT_NTCT); + } + int n,nx,ny; + for (nx=-2; nx<3; nx++) + for (ny=-2; ny<3; ny++) + if (rx+nx>=0 && ry+ny>=0 && rx+nx>8, rx+nx, ry+ny, PT_PLSM); + parts[n>>8].life=rand()%100+70; + parts[n>>8].temp+=3000; + }*/ + + //Some elements should only be affected by wire/swch, or by a spark on inst/semiconductor + //So not affected by spark on metl, watr etc + if (is_elec) + { + if (((n&0xFF)==PT_METL || (n&0xFF)==PT_BMTL) && rand()%280==0) + { + parts[n>>8].temp = restrict_flt(parts[n>>8].temp+3000.0f, MIN_TEMP, MAX_TEMP); + } + if ((n&0xFF)==PT_BMTL && rand()%160==0) + { + part_change_type(n>>8, rx+nx, ry+ny, PT_BMTL);//TODO: Redundant, was this meant to be BRMT or something? + parts[n>>8].temp = restrict_flt(parts[n>>8].temp+1000.0f, MIN_TEMP, MAX_TEMP); + } + if ((n&0xFF)==PT_METL && rand()%300==0) + { + part_change_type(n>>8, rx+nx, ry+ny, PT_BMTL); + } + if ((n&0xFF)==PT_WIFI && rand()%8==0) + { + //Randomise channel + parts[n>>8].temp = rand()%MAX_TEMP; + } + if ((n&0xFF)==PT_WIFI && rand()%16==0) + { + create_part(n>>8, rx+nx, ry+ny, PT_BREC); + parts[n>>8].temp = restrict_flt(parts[n>>8].temp+1000.0f, MIN_TEMP, MAX_TEMP); + } + } + if ((n&0xFF)==PT_SWCH && rand()%100==0) + { + part_change_type(n>>8, rx+nx, ry+ny, PT_BREC); + } + if ((n&0xFF)==PT_SWCH && rand()%100==0) + { + parts[n>>8].temp = restrict_flt(parts[n>>8].temp+2000.0f, MIN_TEMP, MAX_TEMP); + } + if ((n&0xFF)==PT_ARAY && rand()%60==0) + { + create_part(n>>8, rx+nx, ry+ny, PT_BREC); + parts[n>>8].temp = restrict_flt(parts[n>>8].temp+1000.0f, MIN_TEMP, MAX_TEMP); + } + if (t==PT_DLAY && rand()%70==0) + { + //Randomise delay + parts[n>>8].temp = (rand()%256) + 273.15f; + } + } + } } return 0; } diff --git a/src/elements/ligh.c b/src/elements/ligh.c index 188ff97..f3eb316 100644 --- a/src/elements/ligh.c +++ b/src/elements/ligh.c @@ -4,26 +4,26 @@ int contact_part(int i, int tp) { - int x=parts[i].x, y=parts[i].y; - int r,rx,ry; - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rx=0 && y+ry>=0 && x+rx>8)>=NPART || !r) + if (!r) continue; - if ((r&0xFF)==tp) - return r>>8; + if ((r&0xFF)==tp) + return r>>8; } - return -1; + return -1; } void create_line_par(int x1, int y1, int x2, int y2, int c, int temp, int life, int tmp, int tmp2) { - if (c==WL_EHOLE || c==WL_ALLOWGAS || c==WL_ALLOWALLELEC || c==WL_ALLOWSOLID || c==WL_ALLOWAIR || c==WL_WALL || c==WL_DESTROYALL || c==WL_ALLOWLIQUID || c==WL_FAN || c==WL_STREAM || c==WL_DETECT || c==WL_EWALL || c==WL_WALLELEC) - return; // this function only for particles, no walls - int cp=abs(y2-y1)>abs(x2-x1), x, y, dx, dy, sy; + if (c==WL_EHOLE || c==WL_ALLOWGAS || c==WL_ALLOWALLELEC || c==WL_ALLOWSOLID || c==WL_ALLOWAIR || c==WL_WALL || c==WL_DESTROYALL || c==WL_ALLOWLIQUID || c==WL_FAN || c==WL_STREAM || c==WL_DETECT || c==WL_EWALL || c==WL_WALLELEC) + return; // this function only for particles, no walls + int cp=abs(y2-y1)>abs(x2-x1), x, y, dx, dy, sy; float e, de; if (cp) { @@ -54,18 +54,18 @@ void create_line_par(int x1, int y1, int x2, int y2, int c, int temp, int life, sy = (y1= 0.5f) { @@ -77,136 +77,137 @@ void create_line_par(int x1, int y1, int x2, int y2, int c, int temp, int life, int update_LIGH(UPDATE_FUNC_ARGS) { - /* - * - * tmp2: - * -1 - part will be removed - * 0 - "branches" of the lightning - * 1 - bending - * 2 - branching - * 3 - transfer spark or make destruction - * 4 - first pixel - * - * life - "thickness" of lighting (but anyway one pixel) - * - * tmp - angle of lighting - * - */ + /* + * + * tmp2: + * -1 - part will be removed + * 0 - "branches" of the lightning + * 1 - bending + * 2 - branching + * 3 - transfer spark or make destruction + * 4 - first pixel + * + * life - "thickness" of lighting (but anyway one pixel) + * + * tmp - angle of lighting + * + */ int r,rx,ry, multipler, powderful=parts[i].temp*(1+parts[i].life/40)*LIGHTING_POWER; hv[y/CELL][x/CELL]+=powderful/40; if (hv[y/CELL][x/CELL]>MAX_TEMP) - hv[y/CELL][x/CELL]=MAX_TEMP; - for (rx=-2; rx<3; rx++) // destruction - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rx=0 && y+ry>=0 && x+rx>8)>=NPART || !r) + if (!r) continue; - if ((r&0xFF)!=PT_LIGH && (r&0xFF)!=PT_TESC) + if ((r&0xFF)!=PT_LIGH && (r&0xFF)!=PT_TESC) { - if (parts[i].tmp2==3) - { - if ((ptypes[r&0xFF].properties&PROP_CONDUCTS) && parts[r>>8].life==0 && parts[r>>8].ctype!=PT_SPRK) - { - parts[r>>8].ctype = parts[r>>8].type; - part_change_type(r>>8,x+rx,y+ry,PT_SPRK); - parts[r>>8].life = 4; + if (parts[i].tmp2==3) + { + if ((ptypes[r&0xFF].properties&PROP_CONDUCTS) && parts[r>>8].life==0) + { + parts[r>>8].ctype = parts[r>>8].type; + create_part(r>>8,x+rx,y+ry,PT_SPRK); + parts[r>>8].life = 4; - pv[y/CELL][x/CELL] += powderful/1200; - parts[r>>8].temp+=powderful/20; - } - 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) - { - pv[y/CELL][x/CELL] += powderful/110; - parts[r>>8].temp+=powderful/1.5; - } - if ((r&0xFF)==PT_DEUT || (r&0xFF)==PT_PLUT) - { - parts[r>>8].temp+=powderful; - pv[y/CELL][x/CELL] +=powderful/35; - if (rand()%3==0) - { - part_change_type(r>>8,x+rx,y+ry,PT_NEUT); - parts[r>>8].vx=rand()%10-5; - parts[r>>8].vy=rand()%10-5; - } - } - } - 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) - parts[r>>8].temp+=powderful/16; - else - parts[r>>8].temp+=powderful/70; + pv[y/CELL][x/CELL] += powderful/1200; + parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful/20, MIN_TEMP, MAX_TEMP); + } + 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) + { + pv[y/CELL][x/CELL] += powderful/110; + parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful/1.5, MIN_TEMP, MAX_TEMP); + } + if ((r&0xFF)==PT_DEUT || (r&0xFF)==PT_PLUT) + { + parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful, MIN_TEMP, MAX_TEMP); + pv[y/CELL][x/CELL] +=powderful/35; + if (rand()%3==0) + { + part_change_type(r>>8,x+rx,y+ry,PT_NEUT); + parts[r>>8].life = rand()%480+480; + parts[r>>8].vx=rand()%10-5; + parts[r>>8].vy=rand()%10-5; + } + } + } + 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) + parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful/16, MIN_TEMP, MAX_TEMP); + else + parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful/70, MIN_TEMP, MAX_TEMP); } - } - if (parts[i].tmp2==3) - { - //if (rand()&1) - parts[i].tmp2=1; - /*else - parts[i].tmp2=0;*/ - return 1; - } + } + if (parts[i].tmp2==3) + { + //if (rand()&1) + parts[i].tmp2=1; + /*else + parts[i].tmp2=0;*/ + return 1; + } if (parts[i].tmp2==-1) { - kill_part(i); - return 0; + kill_part(i); + return 1; } if (parts[i].tmp2<=0 || parts[i].life<=1) { - /*if (parts[i].tmp2!=3 && rand()%3000<400/(parts[i].life+1)) - { - parts[i].tmp2=1; - return 1; - }*/ - if (parts[i].tmp2>0) - parts[i].tmp2=0; - parts[i].tmp2--; - return 1; + /*if (parts[i].tmp2!=3 && rand()%3000<400/(parts[i].life+1)) + { + parts[i].tmp2=1; + return 1; + }*/ + if (parts[i].tmp2>0) + parts[i].tmp2=0; + parts[i].tmp2--; + return 1; } if (parts[i].tmp2<=-2) { - kill_part(i); - return 0; + kill_part(i); + return 1; } float angle, angle2=-1; int near=nearest_part(i, -1, parts[i].life*3.5); if (near!=-1 && (parts[near].type==PT_LIGH || parts[near].type==PT_THDR || parts[near].type==PT_NEUT)) - near=-1; + near=-1; if (near!=-1) { - int t=parts[near].type; + int t=parts[near].type; - rx=parts[near].x-x; - ry=parts[near].y-y; - if (asin(ry-sqrt(rx*rx+ry*ry))rand()%2000) - { - part_change_type(near, x+rx, y+ry, PT_LIGH); - parts[near].tmp2=3; - parts[near].life=(int)(1.0*parts[i].life/2-1); - parts[near].tmp=parts[i].tmp-180; - parts[near].temp=parts[i].temp; - }*/ - if (t!=PT_TESC) - { - near=contact_part(near, PT_LIGH); - if (near!=-1) - { - parts[near].tmp2=3; - parts[near].life=(int)(1.0*parts[i].life/2-1); - parts[near].tmp=parts[i].tmp-180; - parts[near].temp=parts[i].temp; - } - } - } - else near=-1; + /*if (t!=PT_DMND && t!=PT_UDMT && t!=PT_TESC && parts[i].temp-300>rand()%2000) + { + part_change_type(near, x+rx, y+ry, PT_LIGH); + parts[near].tmp2=3; + parts[near].life=(int)(1.0*parts[i].life/2-1); + parts[near].tmp=parts[i].tmp-180; + parts[near].temp=parts[i].temp; + }*/ + if (t!=PT_TESC) + { + near=contact_part(near, PT_LIGH); + if (near!=-1) + { + parts[near].tmp2=3; + parts[near].life=(int)(1.0*parts[i].life/2-1); + parts[near].tmp=parts[i].tmp-180; + parts[near].temp=parts[i].temp; + } + } + } + else near=-1; } //if (parts[i].tmp2==1/* || near!=-1*/) @@ -222,66 +223,66 @@ int update_LIGH(UPDATE_FUNC_ARGS) case 2: angle = atan2(x-XCNTR, y-YCNTR)*(180.0f/M_PI)+90; } - //angle=0;//parts[i].tmp-30+rand()%60; - if (angle<0) - angle+=360; - if (angle>=360) - angle-=360; + //angle=0;//parts[i].tmp-30+rand()%60; + if (angle<0) + angle+=360; + if (angle>=360) + angle-=360; if (parts[i].tmp2==2) { - angle2=angle+100-rand()%200; - if (angle2<0) - angle2+=360; - if (angle2>=360) - angle-=360; - /*angle=parts[i].tmp-70+rand()%50; - if (angle<0) - angle+=360; - if (angle>=360) - angle-=360;*/ + angle2=angle+100-rand()%200; + if (angle2<0) + angle2+=360; + if (angle2>=360) + angle-=360; + /*angle=parts[i].tmp-70+rand()%50; + if (angle<0) + angle+=360; + if (angle>=360) + angle-=360;*/ } multipler=parts[i].life*1.5+rand()%((int)(parts[i].life+1)); - rx=cos(angle*M_PI/180)*multipler; - ry=-sin(angle*M_PI/180)*multipler; + rx=cos(angle*M_PI/180)*multipler; + ry=-sin(angle*M_PI/180)*multipler; create_line_par(x, y, x+rx, y+ry, PT_LIGH, parts[i].temp, parts[i].life, angle, 0); - if (x+rx>=0 && y+ry>0 && x+rx=0 && y+ry>=0 && x+rx>8, x+rx, y+ry, PT_LIGH);*/ - if ((r&0xFF)==PT_LIGH && !((r>>8)>=NPART || !r)) - { - parts[r>>8].tmp2=1+(rand()%200>parts[i].tmp2*parts[i].tmp2/10+60); - parts[r>>8].life=(int)(1.0*parts[i].life/1.5-rand()%2); - parts[r>>8].tmp=angle; - parts[r>>8].temp=parts[i].temp; - } + r = pmap[y+ry][x+rx]; + /*if ((r&0xFF)!=PT_LIGH && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_UDMT && (r&0xFF)!=PT_TESC) + part_change_type(r>>8, x+rx, y+ry, PT_LIGH);*/ + if ((r&0xFF)==PT_LIGH) + { + parts[r>>8].tmp2=1+(rand()%200>parts[i].tmp2*parts[i].tmp2/10+60); + parts[r>>8].life=(int)(1.0*parts[i].life/1.5-rand()%2); + parts[r>>8].tmp=angle; + parts[r>>8].temp=parts[i].temp; + } } if (angle2!=-1) { - multipler=parts[i].life*1.5+rand()%((int)(parts[i].life+1)); - rx=cos(angle2*M_PI/180)*multipler; - ry=-sin(angle2*M_PI/180)*multipler; - create_line_par(x, y, x+rx, y+ry, PT_LIGH, parts[i].temp, parts[i].life, angle2, 0); + multipler=parts[i].life*1.5+rand()%((int)(parts[i].life+1)); + rx=cos(angle2*M_PI/180)*multipler; + ry=-sin(angle2*M_PI/180)*multipler; + create_line_par(x, y, x+rx, y+ry, PT_LIGH, parts[i].temp, parts[i].life, angle2, 0); - if (x+rx>=0 && y+ry>0 && x+rx>8, x+rx, y+ry, PT_LIGH);*/ - if ((r&0xFF)==PT_LIGH && !((r>>8)>=NPART || !r)) - { - parts[r>>8].tmp2=1+(rand()%200>parts[i].tmp2*parts[i].tmp2/10+40); - parts[r>>8].life=(int)(1.0*parts[i].life/1.5-rand()%2); - parts[r>>8].tmp=angle; - parts[r>>8].temp=parts[i].temp; - } - } + if (x+rx>=0 && y+ry>0 && x+rx>8, x+rx, y+ry, PT_LIGH);*/ + if ((r&0xFF)==PT_LIGH && !((r>>8)>=NPART || !r)) + { + parts[r>>8].tmp2=1+(rand()%200>parts[i].tmp2*parts[i].tmp2/10+40); + parts[r>>8].life=(int)(1.0*parts[i].life/1.5-rand()%2); + parts[r>>8].tmp=angle; + parts[r>>8].temp=parts[i].temp; + } + } } - parts[i].tmp2=-1; + parts[i].tmp2=-1; return 1; } diff --git a/src/elements/sprk.c b/src/elements/sprk.c index 2633a65..f8f64f8 100644 --- a/src/elements/sprk.c +++ b/src/elements/sprk.c @@ -54,38 +54,38 @@ int update_SPRK(UPDATE_FUNC_ARGS) { } else if (ct==PT_TESC) // tesla coil code { - if (parts[i].tmp>300) - parts[i].tmp=300; - for (rx=-1; rx<2; rx++) + if (parts[i].tmp>300) + parts[i].tmp=300; + for (rx=-1; rx<2; rx++) for (ry=-1; ry<2; ry++) - if (x+rx>=0 && y+ry>0 && x+rx=0 && y+ry>0 && x+rx>8)>=NPART || r) continue; - if (rand()%(parts[i].tmp*parts[i].tmp/20+6)==0) - { - int p=create_part(-1, x+rx*2, y+ry*2, PT_LIGH); - if (p!=-1) - { + if (rand()%(parts[i].tmp*parts[i].tmp/20+6)==0) + { + int p=create_part(-1, x+rx*2, y+ry*2, PT_LIGH); + if (p!=-1) + { if(parts[i].tmp<=4) //Prevent Arithmetic errors with zero values continue; parts[p].life=rand()%(2+parts[i].tmp/15)+4+parts[i].tmp/7; - if (parts[i].life>60) - parts[i].life=60; - parts[p].temp=parts[p].life*parts[i].tmp/2.5; - parts[p].tmp2=1; - parts[p].tmp=acos(1.0*rx/sqrt(rx*rx+ry*ry))/M_PI*360; - parts[i].temp-=parts[i].tmp*2+parts[i].temp/5; // slight self-cooling - if (fabs(pv[y/CELL][x/CELL])!=0.0f) - { - if (fabs(pv[y/CELL][x/CELL])<=0.5f) - pv[y/CELL][x/CELL]=0; - else - pv[y/CELL][x/CELL]-=(pv[y/CELL][x/CELL]>0)?0.5:-0.5; - } - } - } + if (parts[i].life>60) + parts[i].life=60; + parts[p].temp=parts[p].life*parts[i].tmp/2.5; + parts[p].tmp2=1; + parts[p].tmp=acos(1.0*rx/sqrt(rx*rx+ry*ry))/M_PI*360; + parts[i].temp-=parts[i].tmp*2+parts[i].temp/5; // slight self-cooling + if (fabs(pv[y/CELL][x/CELL])!=0.0f) + { + if (fabs(pv[y/CELL][x/CELL])<=0.5f) + pv[y/CELL][x/CELL]=0; + else + pv[y/CELL][x/CELL]-=(pv[y/CELL][x/CELL]>0)?0.5:-0.5; + } + } + } } } else if (ct==PT_IRON) { diff --git a/src/powder.c b/src/powder.c index be22ca6..88d26a0 100644 --- a/src/powder.c +++ b/src/powder.c @@ -98,6 +98,7 @@ void init_can_move() can_move[t][rt] = 2; } } + can_move[PT_DEST][PT_DMND] = 0; can_move[PT_BIZR][PT_FILT] = 2; can_move[PT_BIZRG][PT_FILT] = 2; for (t=0;t Date: Wed, 12 Oct 2011 23:58:56 +0800 Subject: Don't heat elements which don't conduct heat diff --git a/src/elements/dest.c b/src/elements/dest.c index a50dfaa..17ea2fe 100644 --- a/src/elements/dest.c +++ b/src/elements/dest.c @@ -43,7 +43,7 @@ int update_DEST(UPDATE_FUNC_ARGS) { } else { - parts[r>>8].temp = restrict_flt(parts[r>>8].temp+10000.0f, MIN_TEMP, MAX_TEMP); + if (ptypes[r&0xFF].hconduct) parts[r>>8].temp = restrict_flt(parts[r>>8].temp+10000.0f, MIN_TEMP, MAX_TEMP); } int topv=pv[y/CELL][x/CELL]/9+parts[r>>8].temp/900; if (topv>40.0f) diff --git a/src/elements/emp.c b/src/elements/emp.c index 96d1a6d..b90fa86 100644 --- a/src/elements/emp.c +++ b/src/elements/emp.c @@ -35,7 +35,7 @@ int update_EMP(UPDATE_FUNC_ARGS) { parts[r].ctype==PT_NTCT || parts[r].ctype==PT_INST || parts[r].ctype==PT_SWCH) || t==PT_WIRE || t==PT_SWCH) { is_elec=1; - if (rand()%100==0) + if (ptypes[parts[r].type].hconduct && rand()%100==0) parts[r].temp = restrict_flt(parts[r].temp+3000.0f, MIN_TEMP, MAX_TEMP); if (rand()%80==0) part_change_type(r, rx, ry, PT_BREC); diff --git a/src/elements/ligh.c b/src/elements/ligh.c index f3eb316..1d38a6d 100644 --- a/src/elements/ligh.c +++ b/src/elements/ligh.c @@ -114,12 +114,12 @@ int update_LIGH(UPDATE_FUNC_ARGS) parts[r>>8].life = 4; pv[y/CELL][x/CELL] += powderful/1200; - parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful/20, MIN_TEMP, MAX_TEMP); + if (ptypes[r&0xFF].hconduct) parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful/20, MIN_TEMP, MAX_TEMP); } 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) { pv[y/CELL][x/CELL] += powderful/110; - parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful/1.5, MIN_TEMP, MAX_TEMP); + if (ptypes[r&0xFF].hconduct) parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful/1.5, MIN_TEMP, MAX_TEMP); } if ((r&0xFF)==PT_DEUT || (r&0xFF)==PT_PLUT) { @@ -134,10 +134,13 @@ int update_LIGH(UPDATE_FUNC_ARGS) } } } - 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) - parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful/16, MIN_TEMP, MAX_TEMP); - else - parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful/70, MIN_TEMP, MAX_TEMP); + if (ptypes[r&0xFF].hconduct) + { + 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) + parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful/16, MIN_TEMP, MAX_TEMP); + else + parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful/70, MIN_TEMP, MAX_TEMP); + } } } if (parts[i].tmp2==3) -- cgit v0.9.2-21-gd62e From 9dc154f1f1667bb7fc73aca6bd5d6fad7c381a0e Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Thu, 13 Oct 2011 01:04:02 +0800 Subject: Fix gravity occasionally not working diff --git a/src/main.c b/src/main.c index dacda26..7a08de7 100644 --- a/src/main.c +++ b/src/main.c @@ -1449,6 +1449,7 @@ void start_grav_async() { if(!ngrav_enable){ gravthread_done = 0; + grav_ready = 0; pthread_mutex_init (&gravmutex, NULL); pthread_cond_init(&gravcv, NULL); pthread_create(&gravthread, NULL, update_grav_async, NULL); //Start asynchronous gravity simulation -- cgit v0.9.2-21-gd62e From af21bcd353ae76a15364dfec3bd1c4c568845d39 Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Thu, 13 Oct 2011 22:32:23 +0800 Subject: Some changes to LIGH/EMP/TESC based on changes in MaksProg's mod v0.3 Weaker and shorter EMP flash. TESC has correct tmp value when created with replace mode. LIGH harms STKM. Gravity affects LIGH in create_part if p==-2, instead of in update_LIGH, so that TESC lightning is not affected by gravity. diff --git a/src/elements/emp.c b/src/elements/emp.c index b90fa86..a4c6067 100644 --- a/src/elements/emp.c +++ b/src/elements/emp.c @@ -20,9 +20,9 @@ int update_EMP(UPDATE_FUNC_ARGS) { if (!ok) return 0; parts[i].life=220; - emp_decor+=7; - if (emp_decor>100) - emp_decor=100; + emp_decor+=3; + if (emp_decor>40) + emp_decor=40; for (r=0; r<=parts_lastActiveIndex; r++) { t=parts[r].type; diff --git a/src/elements/ligh.c b/src/elements/ligh.c index 1d38a6d..f2b8a51 100644 --- a/src/elements/ligh.c +++ b/src/elements/ligh.c @@ -2,6 +2,29 @@ #define LIGHTING_POWER 0.65 +int LIGH_nearest_part(int ci, int max_d) +{ + int distance = (max_d!=-1)?max_d:MAX_DISTANCE; + 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<=parts_lastActiveIndex; i++) + { + if (parts[i].type && !parts[i].life && i!=ci && parts[i].type!=PT_LIGH && parts[i].type!=PT_THDR && parts[i].type!=PT_NEUT && parts[i].type!=PT_PHOT) + { + ndistance = abs(cx-parts[i].x)+abs(cy-parts[i].y);// Faster but less accurate Older: sqrt(pow(cx-parts[i].x, 2)+pow(cy-parts[i].y, 2)); + if (ndistanceMAX_TEMP) - hv[y/CELL][x/CELL]=MAX_TEMP; - for (rx=-2; rx<3; rx++) // destruction + update_PYRO(UPDATE_FUNC_SUBCALL_ARGS); + if (aheat_enable) + { + hv[y/CELL][x/CELL]+=powderful/50; + if (hv[y/CELL][x/CELL]>MAX_TEMP) + hv[y/CELL][x/CELL]=MAX_TEMP; + } + + for (rx=-2; rx<3; rx++) for (ry=-2; ry<3; ry++) if (x+rx>=0 && y+ry>=0 && x+rx>8].life==0) { - parts[r>>8].ctype = parts[r>>8].type; create_part(r>>8,x+rx,y+ry,PT_SPRK); - parts[r>>8].life = 4; - - pv[y/CELL][x/CELL] += powderful/1200; - if (ptypes[r&0xFF].hconduct) parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful/20, MIN_TEMP, MAX_TEMP); } - 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) + pv[y/CELL][x/CELL] += powderful/400; + if (ptypes[r&0xFF].hconduct) parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful/1.5, MIN_TEMP, MAX_TEMP); + } + if ((r&0xFF)==PT_DEUT || (r&0xFF)==PT_PLUT) // start nuclear reactions + { + parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful, MIN_TEMP, MAX_TEMP); + pv[y/CELL][x/CELL] +=powderful/35; + if (rand()%3==0) { - pv[y/CELL][x/CELL] += powderful/110; - if (ptypes[r&0xFF].hconduct) parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful/1.5, MIN_TEMP, MAX_TEMP); + part_change_type(r>>8,x+rx,y+ry,PT_NEUT); + parts[r>>8].life = rand()%480+480; + parts[r>>8].vx=rand()%10-5; + parts[r>>8].vy=rand()%10-5; } - if ((r&0xFF)==PT_DEUT || (r&0xFF)==PT_PLUT) - { - parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful, MIN_TEMP, MAX_TEMP); - pv[y/CELL][x/CELL] +=powderful/35; - if (rand()%3==0) - { - part_change_type(r>>8,x+rx,y+ry,PT_NEUT); - parts[r>>8].life = rand()%480+480; - parts[r>>8].vx=rand()%10-5; - parts[r>>8].vy=rand()%10-5; - } + } + if ((r&0xFF)==PT_COAL || (r&0xFF)==PT_BCOL) // ignite coal + { + if (parts[r>>8].life>100) { + parts[r>>8].life = 99; } } if (ptypes[r&0xFF].hconduct) + parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful/10, MIN_TEMP, MAX_TEMP); + if ((r&0xFF)==PT_STKM || (r&0xFF)==PT_STKM2) { - 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) - parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful/16, MIN_TEMP, MAX_TEMP); - else - parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful/70, MIN_TEMP, MAX_TEMP); + parts[r>>8].life-=powderful/100; } } } if (parts[i].tmp2==3) { - //if (rand()&1) - parts[i].tmp2=1; - /*else - parts[i].tmp2=0;*/ + parts[i].tmp2=0; return 1; } @@ -159,11 +181,6 @@ int update_LIGH(UPDATE_FUNC_ARGS) } if (parts[i].tmp2<=0 || parts[i].life<=1) { - /*if (parts[i].tmp2!=3 && rand()%3000<400/(parts[i].life+1)) - { - parts[i].tmp2=1; - return 1; - }*/ if (parts[i].tmp2>0) parts[i].tmp2=0; parts[i].tmp2--; @@ -177,27 +194,23 @@ int update_LIGH(UPDATE_FUNC_ARGS) float angle, angle2=-1; - int near=nearest_part(i, -1, parts[i].life*3.5); - if (near!=-1 && (parts[near].type==PT_LIGH || parts[near].type==PT_THDR || parts[near].type==PT_NEUT)) - near=-1; + int near = LIGH_nearest_part(i, parts[i].life*2.5); if (near!=-1) { int t=parts[near].type; - + float n_angle; // angle to nearest part rx=parts[near].x-x; ry=parts[near].y-y; - if (asin(ry-sqrt(rx*rx+ry*ry))rand()%2000) - { - part_change_type(near, x+rx, y+ry, PT_LIGH); - parts[near].tmp2=3; - parts[near].life=(int)(1.0*parts[i].life/2-1); - parts[near].tmp=parts[i].tmp-180; - parts[near].temp=parts[i].temp; - }*/ if (t!=PT_TESC) { near=contact_part(near, PT_LIGH); @@ -214,35 +227,19 @@ int update_LIGH(UPDATE_FUNC_ARGS) } //if (parts[i].tmp2==1/* || near!=-1*/) - switch (gravityMode) - { - default: - case 0: - angle = parts[i].tmp-30+rand()%60; - break; - case 1: - angle = rand()%360; - break; - case 2: - angle = atan2(x-XCNTR, y-YCNTR)*(180.0f/M_PI)+90; - } //angle=0;//parts[i].tmp-30+rand()%60; + angle = parts[i].tmp-30+rand()%60; if (angle<0) angle+=360; if (angle>=360) angle-=360; - if (parts[i].tmp2==2) + if (parts[i].tmp2==2 && near==-1) { angle2=angle+100-rand()%200; if (angle2<0) angle2+=360; if (angle2>=360) angle-=360; - /*angle=parts[i].tmp-70+rand()%50; - if (angle<0) - angle+=360; - if (angle>=360) - angle-=360;*/ } multipler=parts[i].life*1.5+rand()%((int)(parts[i].life+1)); @@ -253,8 +250,6 @@ int update_LIGH(UPDATE_FUNC_ARGS) if (x+rx>=0 && y+ry>=0 && x+rx>8, x+rx, y+ry, PT_LIGH);*/ if ((r&0xFF)==PT_LIGH) { parts[r>>8].tmp2=1+(rand()%200>parts[i].tmp2*parts[i].tmp2/10+60); @@ -274,9 +269,7 @@ int update_LIGH(UPDATE_FUNC_ARGS) if (x+rx>=0 && y+ry>0 && x+rx>8, x+rx, y+ry, PT_LIGH);*/ - if ((r&0xFF)==PT_LIGH && !((r>>8)>=NPART || !r)) + if ((r&0xFF)==PT_LIGH) { parts[r>>8].tmp2=1+(rand()%200>parts[i].tmp2*parts[i].tmp2/10+40); parts[r>>8].life=(int)(1.0*parts[i].life/1.5-rand()%2); diff --git a/src/elements/sprk.c b/src/elements/sprk.c index f8f64f8..efab62e 100644 --- a/src/elements/sprk.c +++ b/src/elements/sprk.c @@ -61,7 +61,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || r) + if (r) continue; if (rand()%(parts[i].tmp*parts[i].tmp/20+6)==0) { @@ -70,7 +70,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) { { if(parts[i].tmp<=4) //Prevent Arithmetic errors with zero values continue; - parts[p].life=rand()%(2+parts[i].tmp/15)+4+parts[i].tmp/7; + parts[p].life=rand()%(2+parts[i].tmp/15)+parts[i].tmp/7; if (parts[i].life>60) parts[i].life=60; parts[p].temp=parts[p].life*parts[i].tmp/2.5; diff --git a/src/graphics.c b/src/graphics.c index 83c9a5a..1f10b11 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1728,22 +1728,24 @@ void xor_rect(pixel *vid, int x, int y, int w, int h) void draw_other(pixel *vid) // EMP effect { - int i, j; - if (emp_decor>0 && !sys_pause) emp_decor-=emp_decor/50+1; - if (emp_decor>100) emp_decor=100; + int i, j; + if (emp_decor>0 && !sys_pause) emp_decor-=emp_decor/25+2; + if (emp_decor>40) emp_decor=40; if (cmode==CM_NOTHING) // no in nothing mode - return; - if (emp_decor) - for (j=0; j255) r=255; - if (g>255) g=255; - if (b>255) g=255; - drawpixel(vid, i, j, r, g, b, a*255); - } + return; + if (emp_decor) + { + int r=emp_decor*2.5, g=100+emp_decor*1.5, b=255; + int a=(1.0*emp_decor/110)*255; + if (r>255) r=255; + if (g>255) g=255; + if (b>255) g=255; + for (j=0; j0.8) a=0.8; + float a; + if (parts[i].tmp2!=3) + { + a=0.8*parts[i].life/40; + if (a>0.8) a=0.8; + } + else + { + a=1.0; + } blendpixel(vid, nx, ny, R, G, B, 255); if (cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) { @@ -3398,6 +3408,25 @@ void draw_parts(pixel *vid) } } } + else if (cmode!=CM_NOTHING) + { + blendpixel(vid, x, y, R, G, B, 255); + + blendpixel(vid, x, y-1, R, G, B, 150); + blendpixel(vid, x-1, y, R, G, B, 150); + blendpixel(vid, x+1, y, R, G, B, 150); + blendpixel(vid, x, y+1, R, G, B, 150); + + blendpixel(vid, x-1, y-1, R, G, B, 100); + blendpixel(vid, x+1, y-1, R, G, B, 100); + blendpixel(vid, x+1, y+1, R, G, B, 100); + blendpixel(vid, x-1, y+1, R, G, B, 100); + + blendpixel(vid, x, y-2, R, G, B, 50); + blendpixel(vid, x-2, y, R, G, B, 50); + blendpixel(vid, x+2, y, R, G, B, 50); + blendpixel(vid, x, y+2, R, G, B, 50); + } } else if (t==PT_DEST) { diff --git a/src/powder.c b/src/powder.c index 88d26a0..0633f75 100644 --- a/src/powder.c +++ b/src/powder.c @@ -845,11 +845,21 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a parts[i].tmp = 0; parts[i].tmp2 = 0; } - if (t==PT_LIGH) + if (t==PT_LIGH && p==-2) { - parts[i].tmp = 270; - if (p==-2) - parts[i].tmp2 = 4; + switch (gravityMode) + { + default: + case 0: + parts[i].tmp= 270+rand()%40-20; + break; + case 1: + parts[i].tmp = rand()%360; + break; + case 2: + parts[i].tmp = atan2(x-XCNTR, y-YCNTR)*(180.0f/M_PI)+90; + } + parts[i].tmp2 = 4; } if (t==PT_SOAP) { @@ -2804,6 +2814,19 @@ int flood_water(int x, int y, int i, int originaly, int check) return 1; } +//wrapper around create_part to create TESC with correct tmp value +int create_part_add_props(int p, int x, int y, int tv, int rx, int ry) +{ + p=create_part(p, x, y, tv); + if (tv==PT_TESC) + { + parts[p].tmp=rx*4+ry*4+7; + if (parts[p].tmp>300) + parts[p].tmp=300; + } + return p; +} + //this creates particles from a brush, don't use if you want to create one particle int create_parts(int x, int y, int rx, int ry, int c, int flags) { @@ -2843,13 +2866,13 @@ int create_parts(int x, int y, int rx, int ry, int c, int flags) { if (lighting_recreate>0 && rx+ry>0) return 0; - int p=create_part(-2, x, y, c); + p=create_part(-2, x, y, c); if (p!=-1) { parts[p].life=rx+ry; if (parts[p].life>55) parts[p].life=55; - parts[p].temp=parts[p].life*150; // temperatute of the lighting shows the power of the lighting + parts[p].temp=parts[p].life*150; // temperature of the lighting shows the power of the lighting lighting_recreate+=parts[p].life/2+1; return 1; } @@ -2970,7 +2993,7 @@ int create_parts(int x, int y, int rx, int ry, int c, int flags) { delete_part(x, y, 0); if (c!=0) - create_part(-2, x, y, c); + create_part_add_props(-2, x, y, c, rx, ry); } } } @@ -2987,48 +3010,23 @@ int create_parts(int x, int y, int rx, int ry, int c, int flags) { delete_part(x+i, y+j, 0); if (c!=0) - create_part(-2, x+i, y+j, c); + create_part_add_props(-2, x+i, y+j, c, rx, ry); } } return 1; } //else, no special modes, draw element like normal. - if(c==PT_TESC) - { - if (rx==0&&ry==0)//workaround for 1pixel brush/floodfill crashing. todo: find a better fix later. - { - if (create_part(-2, x, y, c)==-1) - f = 1; - } - else - for (j=-ry; j<=ry; j++) - for (i=-rx; i<=rx; i++) - if (InCurrentBrush(i ,j ,rx ,ry)) - { - p = create_part(-2, x+i, y+j, c); - if (p==-1) - { - f = 1; - } else { - parts[p].tmp=rx*4+ry*4+7; - if (parts[p].tmp>300) - parts[p].tmp=300; - } - } - return !f; - } - if (rx==0&&ry==0)//workaround for 1pixel brush/floodfill crashing. todo: find a better fix later. { - if (create_part(-2, x, y, c)==-1) + if (create_part_add_props(-2, x, y, c, rx, ry)==-1) f = 1; } else for (j=-ry; j<=ry; j++) for (i=-rx; i<=rx; i++) if (InCurrentBrush(i ,j ,rx ,ry)) - if (create_part(-2, x+i, y+j, c)==-1) + if (create_part_add_props(-2, x+i, y+j, c, rx, ry)==-1) f = 1; return !f; } -- cgit v0.9.2-21-gd62e From 83b4f7e1eca0ee29bf656fa7c714c835718bb192 Mon Sep 17 00:00:00 2001 From: "chaos.powdertoy.co.uk" Date: Fri, 14 Oct 2011 05:58:35 -0400 Subject: Version Increment diff --git a/includes/defines.h b/includes/defines.h index d44834f..824aced 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -9,9 +9,9 @@ //VersionInfoStart #define SAVE_VERSION 65 -#define MINOR_VERSION 1 +#define MINOR_VERSION 2 #define BETA -#define BUILD_NUM 92 +#define BUILD_NUM 93 //VersionInfoEnd #define IDENT_VERSION "G" //Change this if you're not Simon! It should be a single letter. -- cgit v0.9.2-21-gd62e From 56764a2309b98b5112613b59d1bd4e6e1a99e417 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Fri, 14 Oct 2011 12:11:09 +0100 Subject: Prevent integer overflow with emp_decor diff --git a/src/graphics.c b/src/graphics.c index 1f10b11..80d0a40 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1740,6 +1740,7 @@ void draw_other(pixel *vid) // EMP effect if (r>255) r=255; if (g>255) g=255; if (b>255) g=255; + if (a>255) a=255; for (j=0; j Date: Fri, 14 Oct 2011 12:12:27 +0100 Subject: Prevent integer overflow with emp_decor diff --git a/src/graphics.c b/src/graphics.c index 80d0a40..1751f8a 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1733,7 +1733,7 @@ void draw_other(pixel *vid) // EMP effect if (emp_decor>40) emp_decor=40; if (cmode==CM_NOTHING) // no in nothing mode return; - if (emp_decor) + if (emp_decor>0) { int r=emp_decor*2.5, g=100+emp_decor*1.5, b=255; int a=(1.0*emp_decor/110)*255; -- cgit v0.9.2-21-gd62e From 37e15bf3ad5a728e0394f40b9f4691de7464c6ea Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Fri, 14 Oct 2011 13:18:00 +0100 Subject: Replace use of gravy and gravf with gravxf and gravyf diff --git a/src/graphics.c b/src/graphics.c index 1751f8a..abe8421 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1527,15 +1527,15 @@ void draw_grav(pixel *vid) { for (x=0; xptransitions[t].phv&&ptransitions[t].pht>-1) { // particle type change due to high pressure if (ptransitions[t].pht!=PT_NUM) @@ -2354,8 +2354,8 @@ killed: pGravX = ptGrav * ((float)(nx - XCNTR) / pGravD); pGravY = ptGrav * ((float)(ny - YCNTR) / pGravD); } - pGravX += gravx[ny/CELL][nx/CELL]; - pGravY += gravy[ny/CELL][nx/CELL]; + pGravX += gravxf[(ny*XRES)+nx]; + pGravY += gravyf[(ny*XRES)+nx]; if (fabsf(pGravY)>fabsf(pGravX)) mv = fabsf(pGravY); else @@ -2413,8 +2413,8 @@ killed: pGravX = ptGrav * ((float)(nx - XCNTR) / pGravD); pGravY = ptGrav * ((float)(ny - YCNTR) / pGravD); } - pGravX += gravx[ny/CELL][nx/CELL]; - pGravY += gravy[ny/CELL][nx/CELL]; + pGravX += gravxf[(ny*XRES)+nx]; + pGravY += gravyf[(ny*XRES)+nx]; if (fabsf(pGravY)>fabsf(pGravX)) mv = fabsf(pGravY); else -- cgit v0.9.2-21-gd62e From b32663f667ba36a5e105b013f0aa3150e846db46 Mon Sep 17 00:00:00 2001 From: "chaos.powdertoy.co.uk" Date: Fri, 14 Oct 2011 12:55:29 -0400 Subject: Version Increment diff --git a/includes/defines.h b/includes/defines.h index 824aced..dfc2505 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -9,9 +9,9 @@ //VersionInfoStart #define SAVE_VERSION 65 -#define MINOR_VERSION 2 +#define MINOR_VERSION 3 #define BETA -#define BUILD_NUM 93 +#define BUILD_NUM 94 //VersionInfoEnd #define IDENT_VERSION "G" //Change this if you're not Simon! It should be a single letter. -- cgit v0.9.2-21-gd62e From 8e877594c9f661c668606e99f078055d6babfd67 Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Fri, 14 Oct 2011 02:37:20 +0800 Subject: Allow STKM to use lightning diff --git a/includes/powder.h b/includes/powder.h index b281954..e7f5b2c 100644 --- a/includes/powder.h +++ b/includes/powder.h @@ -974,8 +974,8 @@ extern int wire_placed; extern int gravwl_timeout; -extern float player[28]; -extern float player2[28]; +extern float player[29]; +extern float player2[29]; extern int gravityMode; extern int airMode; diff --git a/src/elements/ligh.c b/src/elements/ligh.c index f2b8a51..30ffad7 100644 --- a/src/elements/ligh.c +++ b/src/elements/ligh.c @@ -162,7 +162,7 @@ int update_LIGH(UPDATE_FUNC_ARGS) } if (ptypes[r&0xFF].hconduct) parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful/10, MIN_TEMP, MAX_TEMP); - if ((r&0xFF)==PT_STKM || (r&0xFF)==PT_STKM2) + if (((r&0xFF)==PT_STKM && player[2]!=PT_LIGH) || ((r&0xFF)==PT_STKM2 && player2[2]!=PT_LIGH)) { parts[r>>8].life-=powderful/100; } diff --git a/src/elements/stkm.c b/src/elements/stkm.c index a96de2a..85e6e4c 100644 --- a/src/elements/stkm.c +++ b/src/elements/stkm.c @@ -20,8 +20,9 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) { float gvx, gvy; float gx, gy, dl, dr; - if ((parts[i].ctype>0 && parts[i].ctype0) || parts[i].ctype==SPC_AIR || parts[i].ctype == PT_NEUT || parts[i].ctype == PT_PHOT) + if ((parts[i].ctype>0 && parts[i].ctype0) || parts[i].ctype==SPC_AIR || parts[i].ctype == PT_NEUT || parts[i].ctype == PT_PHOT || parts[i].ctype == PT_LIGH) playerp[2] = parts[i].ctype; + playerp[28]++; //Tempirature handling if (parts[i].temp<243) @@ -197,6 +198,8 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) { { playerp[2] = r&0xFF; //Current element } + if ((r&0xFF)==PT_TESC || (r&0xFF)==PT_LIGH) + playerp[2] = PT_LIGH; if ((r&0xFF) == PT_PLNT && parts[i].life<100) //Plant gives him 5 HP { if (parts[i].life<=95) @@ -229,24 +232,23 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) { { ry -= 2*(rand()%2)+1; r = pmap[ry][rx]; - if (ptypes[r&0xFF].state == ST_SOLID) - { - create_part(-1, rx, ry, PT_SPRK); - } + if (ptypes[r&0xFF].state == ST_SOLID) + { + create_part(-1, rx, ry, PT_SPRK); + playerp[28] = 0; + } + else + { + int np = -1; + if (playerp[2] == SPC_AIR) + create_parts(rx + 3*((((int)playerp[1])&0x02) == 0x02) - 3*((((int)playerp[1])&0x01) == 0x01), ry, 4, 4, SPC_AIR, 0); + else if (playerp[2]==PT_LIGH && playerp[28]<30)//limit lightning creation rate + np = -1; else + np = create_part(-1, rx, ry, playerp[2]); + if ( (np < NPART) && np>=0) { - int np = -1; - if (playerp[2] == SPC_AIR) - create_parts(rx + 3*((((int)playerp[1])&0x02) == 0x02) - 3*((((int)playerp[1])&0x01) == 0x01), ry, 4, 4, SPC_AIR, 0); - else - np = create_part(-1, rx, ry, playerp[2]); - if ( (np < NPART) && np>=0 && playerp[2] != PT_PHOT && playerp[2] != SPC_AIR) - { - parts[np].vx -= -gvy*(5*((((int)playerp[1])&0x02) == 0x02) - 5*(((int)(playerp[1])&0x01) == 0x01)); - parts[np].vy -= gvx*(5*((((int)playerp[1])&0x02) == 0x02) - 5*(((int)(playerp[1])&0x01) == 0x01)); - parts[i].vx -= (ptypes[(int)playerp[2]].weight*parts[np].vx)/1000; - } - if ((np < NPART) && np>=0 && playerp[2] == PT_PHOT) + if (playerp[2] == PT_PHOT) { int random = abs(rand()%3-1)*3; if (random==0) @@ -262,8 +264,35 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) { parts[np].vx = random; } } - + else if (playerp[2] == PT_LIGH) + { + float angle; + int power = 100; + if (gvx!=0 || gvy!=0) + angle = atan2(gvx, gvy)*180.0f/M_PI; + else + angle = rand()%360; + if (((int)playerp[1])&0x01) + angle += 180; + if (angle>360) + angle-=360; + if (angle<0) + angle+=360; + parts[np].tmp = angle; + parts[np].life=rand()%(2+power/15)+power/7; + parts[np].temp=parts[np].life*power/2.5; + parts[np].tmp2=1; + } + else if (playerp[2] != SPC_AIR) + { + parts[np].vx -= -gvy*(5*((((int)playerp[1])&0x02) == 0x02) - 5*(((int)(playerp[1])&0x01) == 0x01)); + parts[np].vy -= gvx*(5*((((int)playerp[1])&0x02) == 0x02) - 5*(((int)(playerp[1])&0x01) == 0x01)); + parts[i].vx -= (ptypes[(int)playerp[2]].weight*parts[np].vx)/1000; + } + playerp[28] = 0; } + + } } //Simulation of joints @@ -369,12 +398,12 @@ void STKM_interact(float* playerp, int i, int x, int y) r = pmap[y][x]; if (r) { - if ((r&0xFF)==PT_SPRK) //If on charge + if ((r&0xFF)==PT_SPRK && playerp[2]!=PT_LIGH) //If on charge { parts[i].life -= (int)(rand()*20/RAND_MAX)+32; } - if (ptypes[r&0xFF].hconduct && (parts[r>>8].temp>=323 || parts[r>>8].temp<=243)) + if (ptypes[r&0xFF].hconduct && ((playerp[2]!=PT_LIGH && parts[r>>8].temp>=323) || parts[r>>8].temp<=243)) { parts[i].life -= 2; playerp[22] -= 1; diff --git a/src/main.c b/src/main.c index 8f67b05..26e3c9c 100644 --- a/src/main.c +++ b/src/main.c @@ -1495,6 +1495,7 @@ int main(int argc, char *argv[]) prepare_alpha(4, 1.0f); player[2] = player2[2] = PT_DUST; + player[28] = player2[28] = 0; sprintf(ppmfilename, "%s.ppm", argv[2]); sprintf(ptifilename, "%s.pti", argv[2]); diff --git a/src/powder.c b/src/powder.c index b56426b..8da1bbf 100644 --- a/src/powder.c +++ b/src/powder.c @@ -11,8 +11,10 @@ int wire_placed = 0; int lighting_recreate = 0; -float player[28]; //[0] is a command cell, [3]-[18] are legs positions, [19]-[26] are accelerations, [27] shows if player was spawned -float player2[28]; +//[0] is a command cell, [3]-[18] are legs positions, [19]-[26] are accelerations, [27] shows if player was spawned +//[28] is frames since last particle spawn - used when spawning LIGH +float player[29]; +float player2[29]; particle *parts; particle *cb_parts; -- cgit v0.9.2-21-gd62e From 633c3da4016f2810ae5a8f98ee8ea0979a28d9ea Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Fri, 14 Oct 2011 06:54:50 +0800 Subject: Fix crash with abnormal ICE ctype diff --git a/src/powder.c b/src/powder.c index 8da1bbf..a427acc 100644 --- a/src/powder.c +++ b/src/powder.c @@ -1847,7 +1847,7 @@ void update_particles_i(pixel *vid, int start, int inc) if (ptransitions[t].tht!=PT_NUM) t = ptransitions[t].tht; else if (t==PT_ICEI) { - if (parts[i].ctype&&parts[i].ctype!=PT_ICEI) { + if (parts[i].ctype>0&&parts[i].ctype Date: Fri, 14 Oct 2011 21:20:26 +0800 Subject: Remove unused pixel buffer diff --git a/includes/graphics.h b/includes/graphics.h index afa09b3..66b2903 100644 --- a/includes/graphics.h +++ b/includes/graphics.h @@ -52,7 +52,6 @@ extern unsigned char fire_g[YRES/CELL][XRES/CELL]; extern unsigned char fire_b[YRES/CELL][XRES/CELL]; extern unsigned int fire_alpha[CELL*3][CELL*3]; -extern pixel *fire_bg; extern pixel *pers_bg; void draw_other(pixel *vid); diff --git a/src/graphics.c b/src/graphics.c index abe8421..7a1e483 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -37,7 +37,6 @@ unsigned char fire_g[YRES/CELL][XRES/CELL]; unsigned char fire_b[YRES/CELL][XRES/CELL]; unsigned int fire_alpha[CELL*3][CELL*3]; -pixel *fire_bg; pixel *pers_bg; void *ptif_pack(pixel *src, int w, int h, int *result_size){ diff --git a/src/interface.c b/src/interface.c index d098b3f..1afe53a 100644 --- a/src/interface.c +++ b/src/interface.c @@ -2604,7 +2604,6 @@ void set_cmode(int cm) // sets to given view mode } else if (cmode==CM_PERS) { - memset(fire_bg, 0, XRES*YRES*PIXELSIZE); memset(pers_bg, 0, (XRES+BARSIZE)*YRES*PIXELSIZE); strcpy(itc_msg, "Persistent Display"); } diff --git a/src/main.c b/src/main.c index 26e3c9c..51fc278 100644 --- a/src/main.c +++ b/src/main.c @@ -1112,7 +1112,6 @@ void clear_sim(void) player[27] = 0; player2[27] = 0; memset(pers_bg, 0, (XRES+BARSIZE)*YRES*PIXELSIZE); - memset(fire_bg, 0, XRES*YRES*PIXELSIZE); memset(fire_r, 0, sizeof(fire_r)); memset(fire_g, 0, sizeof(fire_g)); memset(fire_b, 0, sizeof(fire_b)); @@ -1491,7 +1490,6 @@ int main(int argc, char *argv[]) pfree = 0; pers_bg = calloc((XRES+BARSIZE)*YRES, PIXELSIZE); - fire_bg = calloc(XRES*YRES, PIXELSIZE); prepare_alpha(4, 1.0f); player[2] = player2[2] = PT_DUST; @@ -1633,7 +1631,6 @@ int main(int argc, char *argv[]) menu_count(); parts = calloc(sizeof(particle), NPART); cb_parts = calloc(sizeof(particle), NPART); - fire_bg=calloc(XRES*YRES, PIXELSIZE); init_can_move(); clear_sim(); @@ -3019,7 +3016,6 @@ int main(int argc, char *argv[]) if (x>=1 && x<=17) { search_ui(vid_buf); - memset(fire_bg, 0, XRES*YRES*PIXELSIZE); memset(pers_bg, 0, (XRES+BARSIZE)*YRES*PIXELSIZE); memset(fire_r, 0, sizeof(fire_r)); memset(fire_g, 0, sizeof(fire_g)); -- cgit v0.9.2-21-gd62e From f9883b31e0e9b9a3efeec67fcc3b62d1294e7b29 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Fri, 14 Oct 2011 18:08:06 +0100 Subject: Reset emp-decor if out of bounds diff --git a/src/graphics.c b/src/graphics.c index 7a1e483..a462a8b 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1730,6 +1730,7 @@ void draw_other(pixel *vid) // EMP effect int i, j; if (emp_decor>0 && !sys_pause) emp_decor-=emp_decor/25+2; if (emp_decor>40) emp_decor=40; + if (emp_decor<0) emp_decor = 0; if (cmode==CM_NOTHING) // no in nothing mode return; if (emp_decor>0) -- cgit v0.9.2-21-gd62e From cae9ad50d0765d9b9ce4a59fb7ac78ae1c59df6a Mon Sep 17 00:00:00 2001 From: "chaos.powdertoy.co.uk" Date: Fri, 14 Oct 2011 13:08:55 -0400 Subject: Version Increment diff --git a/includes/defines.h b/includes/defines.h index dfc2505..a619963 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -11,7 +11,7 @@ #define SAVE_VERSION 65 #define MINOR_VERSION 3 #define BETA -#define BUILD_NUM 94 +#define BUILD_NUM 95 //VersionInfoEnd #define IDENT_VERSION "G" //Change this if you're not Simon! It should be a single letter. -- cgit v0.9.2-21-gd62e From 7d9d504abfaaf132d831edd23bb225d346f619c8 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Mon, 17 Oct 2011 00:16:43 +0100 Subject: Debug performance/time graph diff --git a/includes/defines.h b/includes/defines.h index a619963..ad3d6a3 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -138,6 +138,8 @@ typedef unsigned int pixel; #define DEBUG_PARTS 0x0001 #define DEBUG_PARTCOUNT 0x0002 #define DEBUG_DRAWTOOL 0x0004 +#define DEBUG_PERFORMANCE_CALC 0x0008 +#define DEBUG_PERFORMANCE_FRAME 0x0010 typedef unsigned char uint8; @@ -161,11 +163,18 @@ extern int kiosk_enable; extern int aheat_enable; extern int decorations_enable; extern int hud_enable; -extern int debug_flags; extern int pretty_powder; int limitFPS; int water_equal_test; +extern int debug_flags; +#define DEBUG_PERF_FRAMECOUNT 256 +extern int debug_perf_istart; +extern int debug_perf_iend; +extern long debug_perf_frametime[DEBUG_PERF_FRAMECOUNT]; +extern long debug_perf_partitime[DEBUG_PERF_FRAMECOUNT]; +extern long debug_perf_time; + extern int active_menu; extern int sys_pause; diff --git a/src/graphics.c b/src/graphics.c index a462a8b..034df37 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -4954,6 +4954,59 @@ int sdl_open(void) int draw_debug_info(pixel* vid, int lm, int lx, int ly, int cx, int cy, int line_x, int line_y) { char infobuf[256]; + if(debug_flags & DEBUG_PERFORMANCE_FRAME || debug_flags & DEBUG_PERFORMANCE_CALC) + { + int t1, t2, x = 0, i = debug_perf_istart; + float partiavg = 0, frameavg = 0; + while(i != debug_perf_iend) + { + partiavg += abs(debug_perf_partitime[i]/100000); + frameavg += abs(debug_perf_frametime[i]/100000); + if(debug_flags & DEBUG_PERFORMANCE_CALC) + t1 = abs(debug_perf_partitime[i]/100000); + else + t1 = 0; + + if(debug_flags & DEBUG_PERFORMANCE_FRAME) + t2 = abs(debug_perf_frametime[i]/100000); + else + t2 = 0; + + if(t1 > YRES) + t1 = YRES; + if(t1+t2 > YRES) + t2 = YRES-t1; + + if(t1>0) + draw_line(vid, x, YRES, x, YRES-t1, 0, 255, 120, XRES+BARSIZE); + if(t2>0) + draw_line(vid, x, YRES-t1, x, YRES-(t1+t2), 255, 120, 0, XRES+BARSIZE); + + i++; + x++; + i %= DEBUG_PERF_FRAMECOUNT; + } + + if(debug_flags & DEBUG_PERFORMANCE_CALC) + t1 = abs(partiavg / x); + else + t1 = 0; + + if(debug_flags & DEBUG_PERFORMANCE_FRAME) + t2 = abs(frameavg / x); + else + t2 = 0; + + if(t1 > YRES) + t1 = YRES; + if(t1+t2 > YRES) + t2 = YRES-t1; + + if(t1>0) + fillrect(vid, x, YRES-t1-1, 5, t1+2, 0, 255, 0, 255); + if(t2>0) + fillrect(vid, x, (YRES-t1)-t2-1, 5, t2+1, 255, 0, 0, 255); + } if(debug_flags & DEBUG_DRAWTOOL) { if(lm == 1) //Line tool diff --git a/src/main.c b/src/main.c index 51fc278..9ac79cd 100644 --- a/src/main.c +++ b/src/main.c @@ -187,8 +187,13 @@ int frameidx = 0; //int CGOL = 0; //int GSPEED = 1;//causes my .exe to crash.. int sound_enable = 0; -int debug_flags = 0; +int debug_flags = 0; +int debug_perf_istart = 1; +int debug_perf_iend = 0; +long debug_perf_frametime[DEBUG_PERF_FRAMECOUNT]; +long debug_perf_partitime[DEBUG_PERF_FRAMECOUNT]; +long debug_perf_time = 0; sign signs[MAXSIGNS]; @@ -1812,9 +1817,53 @@ int main(int argc, char *argv[]) if(ngrav_enable && drawgrav_enable) draw_grav(vid_buf); draw_walls(part_vbuf); + + if(debug_flags & (DEBUG_PERFORMANCE_CALC|DEBUG_PERFORMANCE_FRAME)) + { + #ifdef WIN32 + #elif defined(MACOSX) + #else + struct timespec ts; + clock_gettime(CLOCK_REALTIME, &ts); + debug_perf_time = ts.tv_nsec; + #endif + } + update_particles(part_vbuf); //update everything + + if(debug_flags & (DEBUG_PERFORMANCE_CALC|DEBUG_PERFORMANCE_FRAME)) + { + #ifdef WIN32 + #elif defined(MACOSX) + #else + struct timespec ts; + clock_gettime(CLOCK_REALTIME, &ts); + + debug_perf_partitime[debug_perf_iend] = ts.tv_nsec - debug_perf_time; + + debug_perf_time = ts.tv_nsec; + #endif + } + draw_parts(part_vbuf); //draw particles draw_other(part_vbuf); + + if(debug_flags & (DEBUG_PERFORMANCE_CALC|DEBUG_PERFORMANCE_FRAME)) + { + #ifdef WIN32 + #elif defined(MACOSX) + #else + struct timespec ts; + clock_gettime(CLOCK_REALTIME, &ts); + + debug_perf_frametime[debug_perf_iend] = ts.tv_nsec - debug_perf_time; + #endif + debug_perf_iend++; + debug_perf_iend %= DEBUG_PERF_FRAMECOUNT; + debug_perf_istart++; + debug_perf_istart %= DEBUG_PERF_FRAMECOUNT; + } + if(sl == WL_GRAV+100 || sr == WL_GRAV+100) draw_grav_zones(part_vbuf); -- cgit v0.9.2-21-gd62e From 9fed467a28003c2e0a6055bc9db29d26d06fb5b3 Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Tue, 18 Oct 2011 22:10:25 +0800 Subject: Fix infinite temperatures May also need -fno-finite-math-only, but it works fine for me without it diff --git a/src/powder.c b/src/powder.c index a427acc..1851f45 100644 --- a/src/powder.c +++ b/src/powder.c @@ -1826,8 +1826,9 @@ void update_particles_i(pixel *vid, int start, int inc) pt = (c_heat+parts[i].temp*96.645/ptypes[t].hconduct*fabs(ptypes[t].weight))/(c_Cm+96.645/ptypes[t].hconduct*fabs(ptypes[t].weight)); #else - pt = parts[i].temp = (c_heat+parts[i].temp)/(h_count+1); + pt = (c_heat+parts[i].temp)/(h_count+1); #endif + pt = parts[i].temp = restrict_flt(pt, MIN_TEMP, MAX_TEMP); for (j=0; j<8; j++) { parts[surround_hconduct[j]].temp = pt; -- cgit v0.9.2-21-gd62e From 034cd4ed62d15ab8eedfb702ea6adcca04f51983 Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Wed, 19 Oct 2011 02:04:31 +0800 Subject: FILT subtracts photon colours when tmp=3 diff --git a/src/powder.c b/src/powder.c index 1851f45..bb91cd3 100644 --- a/src/powder.c +++ b/src/powder.c @@ -277,6 +277,8 @@ int try_move(int i, int x, int y, int nx, int ny) parts[i].ctype &= 0x1F << temp_bin; //Filter Colour } else if(parts[r>>8].tmp==2){ parts[i].ctype |= 0x1F << temp_bin; //Add Colour + } else if(parts[r>>8].tmp==3){ + parts[i].ctype &= ~(0x1F << temp_bin); //Subtract Colour } } if (parts[i].type == PT_NEUT && (r&0xFF)==PT_GLAS) { -- cgit v0.9.2-21-gd62e From 813f833cfcccb08f7f78b000d1394124dcf5b463 Mon Sep 17 00:00:00 2001 From: "chaos.powdertoy.co.uk" Date: Wed, 19 Oct 2011 05:48:09 -0400 Subject: Version Increment diff --git a/includes/defines.h b/includes/defines.h index ad3d6a3..a0c0a54 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -9,9 +9,8 @@ //VersionInfoStart #define SAVE_VERSION 65 -#define MINOR_VERSION 3 -#define BETA -#define BUILD_NUM 95 +#define MINOR_VERSION 4 +#define BUILD_NUM 96 //VersionInfoEnd #define IDENT_VERSION "G" //Change this if you're not Simon! It should be a single letter. -- cgit v0.9.2-21-gd62e From 447b8b9d2e21f95fb23970501c9c722ebd90d623 Mon Sep 17 00:00:00 2001 From: "chaos.powdertoy.co.uk" Date: Wed, 19 Oct 2011 06:03:06 -0400 Subject: Version Increment diff --git a/includes/defines.h b/includes/defines.h index a0c0a54..9aeed25 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -10,7 +10,7 @@ //VersionInfoStart #define SAVE_VERSION 65 #define MINOR_VERSION 4 -#define BUILD_NUM 96 +#define BUILD_NUM 97 //VersionInfoEnd #define IDENT_VERSION "G" //Change this if you're not Simon! It should be a single letter. -- cgit v0.9.2-21-gd62e From 29fa590f000aee805c74481fc52b6ebc30226341 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Wed, 19 Oct 2011 12:05:12 +0100 Subject: Update readme - slightly diff --git a/README b/README index 27a6f7a..523426c 100644 --- a/README +++ b/README @@ -1,6 +1,4 @@ -The Powder Toy - April 2011 - - +The Powder Toy - October 2011 Get latest version here: http://powdertoy.co.uk/Download.html @@ -20,7 +18,8 @@ Bryan Hoyle Nathan Cousins jacksonmj Lieuwe Mosch - +Anthony Boot +Matthew Miller Instructions: @@ -55,7 +54,8 @@ I Invert Pressure and Velocity map T Vine mode W Toggle gravity modes (+ Ctrl when STK2 is out) R Reset LIFE generation (when in Debug mode) -~ Python Console +N "Sand effect" for drawing powders +~ Console = Reset pressure and velocity map [ Decrase brush size ] Increase brush size @@ -74,9 +74,6 @@ Ctrl + Left Alt Select subject for Specific Element erase Ctrl + = Reset Electricity - - - Command Line: --------------------------------------------------------------------------- @@ -84,14 +81,24 @@ Command Line: scale:1 - Normal window resolution scale:2 - Doubled window resolution kiosk - Fullscreen mode -proxy:server:port (ie, proxy:wwwcache.lancs.ac.uk:8080) -open:file - Opens the file as a stamp or game save - +proxy:: (ie, proxy:wwwcache.lancs.ac.uk:8080) +open - Opens the file as a stamp or game save +ddir - Directory used for saving stamps and preferences History: --------------------------------------------------------------------------- +* Version 65.4 + o "Sand" effect for drawing powders, activate with "N" + o Elements from Maksprog's mod + o LIGH - Lightning + o DEST - Variation of BOMB + o TESC - Tesla coil, creates lightning + o EMP - Destroys electronic components + o Fix bug with infinite temperature + o Fix beta enrolling + o Add a new mode to filter, subtract (tmp of 3) * Version 47.3 o Enhanced visual effects for Portals o Glow now has more stimuli (Green: Pressure, Blue: Movement, Red: Heat) @@ -253,4 +260,4 @@ History: o Acid drastically changed, now dilutes itself when dissolving other particles * Version 28.0 o "Yellow wall" bug fix, doesn't absorb particles when placed above another wall type. - o New wall type added: E-Hole, absorbs particles when unpowered, released them when powered. \ No newline at end of file + o New wall type added: E-Hole, absorbs particles when unpowered, released them when powered. -- cgit v0.9.2-21-gd62e From c1eb40af61fc04a2db8971bbf233ddb0f9f4a2b5 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Fri, 21 Oct 2011 17:25:14 +0100 Subject: Fix gravity field drawing diff --git a/src/graphics.c b/src/graphics.c index 034df37..2ca21cc 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1519,22 +1519,23 @@ void draw_grav_zones(pixel * vid) void draw_grav(pixel *vid) { - int x, y, i; + int x, y, i, ca; float nx, ny, dist; for (y=0; y Date: Fri, 21 Oct 2011 17:37:26 +0100 Subject: Screenshot for lua diff --git a/includes/luaconsole.h b/includes/luaconsole.h index dc320ad..de33a04 100644 --- a/includes/luaconsole.h +++ b/includes/luaconsole.h @@ -77,4 +77,5 @@ int luatpt_setdebug(lua_State* l); int luatpt_setfpscap(lua_State* l); int luatpt_getscript(lua_State* l); int luatpt_setwindowsize(lua_State* l); +int luatpt_screenshot(lua_State* l); #endif diff --git a/src/luaconsole.c b/src/luaconsole.c index 5cc2bb3..c74155b 100644 --- a/src/luaconsole.c +++ b/src/luaconsole.c @@ -65,6 +65,7 @@ void luacon_open(){ {"getscript",&luatpt_getscript}, {"setwindowsize",&luatpt_setwindowsize}, {"watertest",&luatpt_togglewater}, + {"screenshot",&luatpt_screenshot}, {NULL,NULL} }; @@ -1123,9 +1124,9 @@ int luatpt_setdebug(lua_State* l) } int luatpt_setfpscap(lua_State* l) { -int fpscap = luaL_optint(l, 1, 0); -limitFPS = fpscap; -return 0; + int fpscap = luaL_optint(l, 1, 0); + limitFPS = fpscap; + return 0; } int luatpt_getscript(lua_State* l) { @@ -1225,4 +1226,22 @@ int luatpt_setwindowsize(lua_State* l) return 1; } +int luatpt_screenshot(lua_State* l) +{ + int captureUI = luaL_optint(l, 1, 0); + if(vid_buf) + { + if(captureUI) + { + dump_frame(vid_buf, XRES+BARSIZE, YRES+MENUSIZE, XRES+BARSIZE); + } + else + { + dump_frame(vid_buf, XRES, YRES, XRES+BARSIZE); + } + return 0; + } + return luaL_error(l, "Screen buffer does not exist"); +} + #endif -- cgit v0.9.2-21-gd62e From 9cf65de1c369e91ba9de1a9cbceab7ba9131c89d Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Fri, 21 Oct 2011 19:41:12 +0100 Subject: Quick options menu diff --git a/includes/defines.h b/includes/defines.h index 9aeed25..0f016f9 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -163,6 +163,7 @@ extern int aheat_enable; extern int decorations_enable; extern int hud_enable; extern int pretty_powder; +extern int drawgrav_enable; int limitFPS; int water_equal_test; diff --git a/includes/interface.h b/includes/interface.h index 5d59dcf..a8a511e 100644 --- a/includes/interface.h +++ b/includes/interface.h @@ -15,6 +15,17 @@ struct menu_section }; typedef struct menu_section menu_section; +#define QM_TOGGLE 1 + +struct quick_option +{ + char *icon; + const char *name; + int type; + int *variable; +}; +typedef struct quick_option quick_option; + struct menu_wall { pixel colour; @@ -58,6 +69,13 @@ static menu_section msections[] = //doshow does not do anything currently. {"\xC8", "Cracker!", 0, 0}, }; +static quick_option quickmenu[] = //doshow does not do anything currently. +{ + {"P", "Sand effect", QM_TOGGLE, &pretty_powder}, + {"G", "Draw gravity grid", QM_TOGGLE, &drawgrav_enable}, + {NULL} +}; + static menu_section colorsections[] = //doshow does not do anything currently. { {"\xC4", "Colors", 7, 1}, @@ -201,10 +219,10 @@ extern int zoom_en; extern int zoom_x, zoom_y; extern int zoom_wx, zoom_wy; -extern int drawgrav_enable; - void menu_count(void); +void quickoptions_menu(pixel *vid_buf, int b, int bq, int x, int y); + void prop_edit_ui(pixel *vid_buf, int x, int y); void get_sign_pos(int i, int *x0, int *y0, int *w, int *h); diff --git a/src/interface.c b/src/interface.c index 1afe53a..75e22ec 100644 --- a/src/interface.c +++ b/src/interface.c @@ -2416,6 +2416,51 @@ int color_menu_ui(pixel *vid_buf, int i, int *cr, int *cg, int *cb, int b, int b return 0; } +int quickoptions_tooltip_fade = 0; +char * quickoptions_tooltip; +int quickoptions_tooltip_y = 0; +void quickoptions_menu(pixel *vid_buf, int b, int bq, int x, int y) +{ + int i = 0; + if(quickoptions_tooltip_fade && quickoptions_tooltip) + { + drawtext_outline(vid_buf, (XRES - 5) - textwidth(quickoptions_tooltip), quickoptions_tooltip_y, quickoptions_tooltip, 255, 255, 255, quickoptions_tooltip_fade*20, 0, 0, 0, quickoptions_tooltip_fade*15); + quickoptions_tooltip_fade--; + } + while(quickmenu[i].icon!=NULL) + { + if(quickmenu[i].type == QM_TOGGLE) + { + drawrect(vid_buf, (XRES+BARSIZE)-16, (i*16)+1, 14, 14, 255, 255, 255, 255); + if(*(quickmenu[i].variable)) + { + fillrect(vid_buf, (XRES+BARSIZE)-16, (i*16)+1, 14, 14, 255, 255, 255, 255); + drawtext(vid_buf, (XRES+BARSIZE)-11, (i*16)+5, quickmenu[i].icon, 0, 0, 0, 255); + } + else + { + fillrect(vid_buf, (XRES+BARSIZE)-16, (i*16)+1, 14, 14, 0, 0, 0, 255); + drawtext(vid_buf, (XRES+BARSIZE)-11, (i*16)+5, quickmenu[i].icon, 255, 255, 255, 255); + } + if(x >= (XRES+BARSIZE)-16 && x <= (XRES+BARSIZE)-2 && y >= (i*16)+1 && y <= (i*16)+15) + { + quickoptions_tooltip_fade+=2; + quickoptions_tooltip = quickmenu[i].name; + quickoptions_tooltip_y = (i*16)+5; + if(b && !bq) + { + *(quickmenu[i].variable) = !(*(quickmenu[i].variable)); + } + } + } + i++; + } + if(quickoptions_tooltip_fade > 12) + quickoptions_tooltip_fade = 12; + if(quickoptions_tooltip_fade < 0) + quickoptions_tooltip_fade = 0; +} + int sdl_poll(void) { SDL_Event event; diff --git a/src/main.c b/src/main.c index 9ac79cd..9052730 100644 --- a/src/main.c +++ b/src/main.c @@ -2613,6 +2613,8 @@ int main(int argc, char *argv[]) luacon_step(x/sdl_scale, y/sdl_scale,sl,sr); #endif + quickoptions_menu(vid_buf, b, bq, x, y); + for (i=0; i Date: Sat, 22 Oct 2011 13:07:49 -0400 Subject: Version Increment diff --git a/includes/defines.h b/includes/defines.h index 0f016f9..f60272c 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -9,8 +9,8 @@ //VersionInfoStart #define SAVE_VERSION 65 -#define MINOR_VERSION 4 -#define BUILD_NUM 97 +#define MINOR_VERSION 5 +#define BUILD_NUM 98 //VersionInfoEnd #define IDENT_VERSION "G" //Change this if you're not Simon! It should be a single letter. -- cgit v0.9.2-21-gd62e From 84522d2594848ffeb539bc9af7eee5e6e775bb39 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Sat, 22 Oct 2011 19:39:24 +0100 Subject: Fix Options meny in scale:2 and make tooltip more readable diff --git a/includes/defines.h b/includes/defines.h index 0f016f9..9dc6db1 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -166,6 +166,7 @@ extern int pretty_powder; extern int drawgrav_enable; int limitFPS; int water_equal_test; +extern int quickoptions_tooltip_fade; extern int debug_flags; #define DEBUG_PERF_FRAMECOUNT 256 diff --git a/src/interface.c b/src/interface.c index 75e22ec..a41f2c2 100644 --- a/src/interface.c +++ b/src/interface.c @@ -2422,6 +2422,8 @@ int quickoptions_tooltip_y = 0; void quickoptions_menu(pixel *vid_buf, int b, int bq, int x, int y) { int i = 0; + x /= sdl_scale; + y /= sdl_scale; if(quickoptions_tooltip_fade && quickoptions_tooltip) { drawtext_outline(vid_buf, (XRES - 5) - textwidth(quickoptions_tooltip), quickoptions_tooltip_y, quickoptions_tooltip, 255, 255, 255, quickoptions_tooltip_fade*20, 0, 0, 0, quickoptions_tooltip_fade*15); diff --git a/src/main.c b/src/main.c index 9052730..e77e310 100644 --- a/src/main.c +++ b/src/main.c @@ -1585,7 +1585,7 @@ int main(int argc, char *argv[]) #endif int wavelength_gfx = 0; int x, y, line_x, line_y, b = 0, sl=1, sr=0, su=0, c, lb = 0, lx = 0, ly = 0, lm = 0;//, tx, ty; - int da = 0, dae = 0, db = 0, it = 2047, mx, my, bsx = 2, bsy = 2; + int da = 0, dae = 0, db = 0, it = 2047, mx, my, bsx = 2, bsy = 2, quickoptions_tooltip_fade_invert; float nfvx, nfvy; int load_mode=0, load_w=0, load_h=0, load_x=0, load_y=0, load_size=0; void *load_data=NULL; @@ -3479,29 +3479,29 @@ int main(int argc, char *argv[]) if (vs) strappend(uitext, " [FRAME CAPTURE]"); #endif - + quickoptions_tooltip_fade_invert = 255 - (quickoptions_tooltip_fade*20); if (sdl_zoom_trig||zoom_en) { if (zoom_x Date: Sat, 22 Oct 2011 14:40:23 -0400 Subject: Version Increment diff --git a/includes/defines.h b/includes/defines.h index f588d4a..70e1af8 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -10,7 +10,7 @@ //VersionInfoStart #define SAVE_VERSION 65 #define MINOR_VERSION 5 -#define BUILD_NUM 98 +#define BUILD_NUM 99 //VersionInfoEnd #define IDENT_VERSION "G" //Change this if you're not Simon! It should be a single letter. -- cgit v0.9.2-21-gd62e From 05eb16e14c679f92d766ace0b421e793f73faf69 Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Sat, 22 Oct 2011 19:27:32 +0800 Subject: Fix LIGH overwriting fire_alpha diff --git a/src/graphics.c b/src/graphics.c index 2ca21cc..b988213 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -3393,7 +3393,7 @@ void draw_parts(pixel *vid) int rx, ry; for (rx=-1; rx<2; rx++) for (ry=-1; ry<2; ry++) - if (x+rx>=0 && y+ry>0 && x+rx=0 && y+ry>=0 && x+rx Date: Sun, 23 Oct 2011 15:39:54 +0800 Subject: Fixed bug in compile process: Linker option '-lrt' was not set so ld complained about "undefined reference to 'clock_gettime'" diff --git a/Makefile b/Makefile index 399f6d6..071d5a5 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ PYCOMMAND := $(PY_BIN) getheader.py CFLAGS := -w -std=c99 -D_POSIX_C_SOURCE=200112L -DLUACONSOLE -DGRAVFFT -Iincludes/ -D_GNU_SOURCE OFLAGS := -O3 -ffast-math -ftree-vectorize -funsafe-math-optimizations -LFLAGS := -lpthread -lSDL -lfftw3f -lm -lbz2 -lX11 -llua5.1 #-lpython$(PY_VERSION) -L$(PY_LIBPATH) -I$(PY_INCPATH) $(PY_LDFLAGS) +LFLAGS := -lpthread -lSDL -lfftw3f -lm -lbz2 -lX11 -llua5.1 -lrt #-lpython$(PY_VERSION) -L$(PY_LIBPATH) -I$(PY_INCPATH) $(PY_LDFLAGS) LFLAGS_X := -lm -lbz2 -lSDLmain -I/Library/Frameworks/Python.framework/Versions/$(PY_VERSION)/include/python$(PY_VERSION) MFLAGS_SSE3 := -march=native -DX86 -DX86_SSE3 -msse3 MFLAGS_SSE2 := -march=native -DX86 -DX86_SSE2 -msse2 -- cgit v0.9.2-21-gd62e From aca5faed909663141625a3423efdb517479afed7 Mon Sep 17 00:00:00 2001 From: "chaos.powdertoy.co.uk" Date: Sun, 23 Oct 2011 12:06:11 -0400 Subject: Version Increment diff --git a/includes/defines.h b/includes/defines.h index 70e1af8..dfe24b2 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -10,7 +10,7 @@ //VersionInfoStart #define SAVE_VERSION 65 #define MINOR_VERSION 5 -#define BUILD_NUM 99 +#define BUILD_NUM 100 //VersionInfoEnd #define IDENT_VERSION "G" //Change this if you're not Simon! It should be a single letter. -- cgit v0.9.2-21-gd62e From b549688fddecbf98b79183bae0d4894f5b1ab154 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Sun, 23 Oct 2011 17:59:04 +0100 Subject: Compatibility with MSVC - devast8a diff --git a/src/elements/dest.c b/src/elements/dest.c index 17ea2fe..772065a 100644 --- a/src/elements/dest.c +++ b/src/elements/dest.c @@ -1,7 +1,7 @@ #include int update_DEST(UPDATE_FUNC_ARGS) { - int r,rx,ry; + int r,rx,ry,topv; rx=rand()%5-2; ry=rand()%5-2; @@ -45,7 +45,7 @@ int update_DEST(UPDATE_FUNC_ARGS) { { if (ptypes[r&0xFF].hconduct) parts[r>>8].temp = restrict_flt(parts[r>>8].temp+10000.0f, MIN_TEMP, MAX_TEMP); } - int topv=pv[y/CELL][x/CELL]/9+parts[r>>8].temp/900; + topv=pv[y/CELL][x/CELL]/9+parts[r>>8].temp/900; if (topv>40.0f) topv=40.0f; pv[y/CELL][x/CELL]+=40.0f+topv; diff --git a/src/elements/emp.c b/src/elements/emp.c index a4c6067..c47c902 100644 --- a/src/elements/emp.c +++ b/src/elements/emp.c @@ -1,7 +1,7 @@ #include int update_EMP(UPDATE_FUNC_ARGS) { - int r,rx,ry,ok=0,t; + int r,rx,ry,ok=0,t,n,nx,ny; if (parts[i].life) return 0; for (rx=-2; rx<3; rx++) @@ -42,7 +42,7 @@ int update_EMP(UPDATE_FUNC_ARGS) { else if (rand()%120==0) part_change_type(r, rx, ry, PT_NTCT); } - int n,nx,ny; + for (nx=-2; nx<3; nx++) for (ny=-2; ny<3; ny++) if (rx+nx>=0 && ry+ny>=0 && rx+nx>8; if(proptype==2){ - *((float*)(((void*)&parts[i])+propoffset)) = *((float*)propvalue); + *((float*)(((char*)&parts[i])+propoffset)) = *((float*)propvalue); } else if(proptype==0) { - *((int*)(((void*)&parts[i])+propoffset)) = *((int*)propvalue); + *((int*)(((char*)&parts[i])+propoffset)) = *((int*)propvalue); } else if(proptype==1) { - *((char*)(((void*)&parts[i])+propoffset)) = *((char*)propvalue); + *((char*)(((char*)&parts[i])+propoffset)) = *((char*)propvalue); } bitmap[(y*XRES)+x] = 1; } -- cgit v0.9.2-21-gd62e From b04c20e747a03a895cdef478a7356e7a79c40200 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Sun, 23 Oct 2011 18:24:51 +0100 Subject: More MSVC fixes diff --git a/includes/powder.h b/includes/powder.h index e7f5b2c..4e15dcc 100644 --- a/includes/powder.h +++ b/includes/powder.h @@ -503,9 +503,9 @@ static const part_type ptypes[PT_NUM] = {"PVOD", PIXPACK(0x792020), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 100, SC_POWERED, R_TEMP+0.0f +273.15f, 251, "Solid. When activated, destroys entering particles", ST_NONE, TYPE_SOLID, &update_PVOD}, {"CONV", PIXPACK(0x0AAB0A), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 251, "Solid. Converts whatever touches it into its ctype.", ST_NONE, TYPE_SOLID, &update_CONV}, {"CAUS", PIXPACK(0x80FFA0), 2.0f, 0.00f * CFDS, 0.99f, 0.30f, -0.1f, 0.0f, 1.50f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 1, 1, SC_GAS, R_TEMP+0.0f +273.15f, 70, "Caustic Gas, acts like Acid", ST_GAS, TYPE_GAS, &update_CAUS}, - {"LIGH", PIXPACK(0xFFFFC0), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 0, "More realistic lighting. Set pen size for setting size of the lighting.", ST_SOLID, TYPE_SOLID, &update_LIGH, 0}, - {"TESC", PIXPACK(0x707040), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Tesla coil!", ST_SOLID, TYPE_SOLID|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_HOT_GLOW, NULL, 0}, - {"DEST", PIXPACK(0xFF3311), -0.05f, 0.00f * CFDS, 0.95f, 0.95f, -0.1f, 0.4f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 0, 1, 1, 101, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 150, "More destructive Bomb.", ST_SOLID, TYPE_PART|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC, &update_DEST, 0}, + {"LIGH", PIXPACK(0xFFFFC0), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 0, "More realistic lighting. Set pen size for setting size of the lighting.", ST_SOLID, TYPE_SOLID, &update_LIGH}, + {"TESC", PIXPACK(0x707040), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Tesla coil!", ST_SOLID, TYPE_SOLID|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_HOT_GLOW, NULL}, + {"DEST", PIXPACK(0xFF3311), -0.05f, 0.00f * CFDS, 0.95f, 0.95f, -0.1f, 0.4f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 0, 1, 1, 101, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 150, "More destructive Bomb.", ST_SOLID, TYPE_PART|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC, &update_DEST}, {"SPNG", PIXPACK(0xFFBE30), 0.00f, 0.00f * CFDS, 0.00f, 1.00f, 0.00f, 0.0f, 0.00f, 0.000f * CFDS, 0, 20, 0, 1, 30, 1, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "A sponge, absorbs water.", ST_SOLID, TYPE_SOLID, &update_SPNG}, {"RIME", PIXPACK(0xCCCCCC), 0.00f, 0.00f * CFDS, 0.00f, 1.00f, 0.00f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 30, 1, 1, 100, SC_CRACKER2, 243.15f, 100, "Not quite Ice", ST_SOLID, TYPE_SOLID, &update_RIME}, {"FOG", PIXPACK(0xAAAAAA), 0.8f, 0.00f * CFDS, 0.4f, 0.70f, -0.1f, 0.0f, 0.99f, 0.000f * CFDS, 0, 0, 0, 0, 30, 1, 1, 1, SC_CRACKER2, 243.15f, 100, "Not quite Steam", ST_GAS, TYPE_GAS|PROP_LIFE_DEC, &update_FOG}, @@ -550,8 +550,8 @@ static const part_type ptypes[PT_NUM] = {"SING", PIXPACK(0x242424), 0.7f, 0.36f * CFDS, 0.96f, 0.80f, 0.1f, 0.12f, 0.00f, -0.001f * CFDS, 1, 0, 0, 0, 0, 1, 1, 86, SC_NUCLEAR, R_TEMP+0.0f +273.15f, 70, "Singularity", ST_SOLID, TYPE_PART|PROP_LIFE_DEC, &update_SING}, {"QRTZ", PIXPACK(0xAADDDD), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 3, "Quartz, breakable mineral. Conducts but becomes brittle at lower temperatures.", ST_SOLID, TYPE_SOLID|PROP_HOT_GLOW|PROP_LIFE_DEC, &update_QRTZ}, {"PQRT", PIXPACK(0x88BBBB), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.27f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 0, 1, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 3, "Broken quartz.", ST_SOLID, TYPE_PART| PROP_HOT_GLOW, &update_QRTZ}, - {"EMP", PIXPACK(0x66AAFF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.0f, 0.0f * CFDS, 0, 0, 0, 0, 3, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 121, "Breaks activated electronics.", ST_SOLID, TYPE_SOLID|PROP_LIFE_DEC, &update_EMP, 0}, - {"BREL", PIXPACK(0x707060), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.18f, 0.00f, 0.000f * CFDS, 1, 0, 0, 2, 2, 1, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 211, "Broken electronics", ST_SOLID, TYPE_PART|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_HOT_GLOW, NULL, 0}, + {"EMP", PIXPACK(0x66AAFF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.0f, 0.0f * CFDS, 0, 0, 0, 0, 3, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 121, "Breaks activated electronics.", ST_SOLID, TYPE_SOLID|PROP_LIFE_DEC, &update_EMP}, + {"BREL", PIXPACK(0x707060), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.18f, 0.00f, 0.000f * CFDS, 1, 0, 0, 2, 2, 1, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 211, "Broken electronics", ST_SOLID, TYPE_PART|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_HOT_GLOW, NULL}, /*FREE*/{"COAG", PIXPACK(0x9ACD32), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "B378/S235678", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, /*FREE*/{"WALL", PIXPACK(0x0047AB), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "B45678/S2345", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, /*FREE*/{"GNAR", PIXPACK(0xE5B73B), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "B1/S1", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, diff --git a/src/elements/ligh.c b/src/elements/ligh.c index 30ffad7..bfbcd0d 100644 --- a/src/elements/ligh.c +++ b/src/elements/ligh.c @@ -44,10 +44,10 @@ int contact_part(int i, int tp) void create_line_par(int x1, int y1, int x2, int y2, int c, int temp, int life, int tmp, int tmp2) { - if (c==WL_EHOLE || c==WL_ALLOWGAS || c==WL_ALLOWALLELEC || c==WL_ALLOWSOLID || c==WL_ALLOWAIR || c==WL_WALL || c==WL_DESTROYALL || c==WL_ALLOWLIQUID || c==WL_FAN || c==WL_STREAM || c==WL_DETECT || c==WL_EWALL || c==WL_WALLELEC) - return; // this function only for particles, no walls int cp=abs(y2-y1)>abs(x2-x1), x, y, dx, dy, sy; float e, de; + if (c==WL_EHOLE || c==WL_ALLOWGAS || c==WL_ALLOWALLELEC || c==WL_ALLOWSOLID || c==WL_ALLOWAIR || c==WL_WALL || c==WL_DESTROYALL || c==WL_ALLOWLIQUID || c==WL_FAN || c==WL_STREAM || c==WL_DETECT || c==WL_EWALL || c==WL_WALLELEC) + return; // this function only for particles, no walls if (cp) { y = x1; @@ -115,7 +115,10 @@ int update_LIGH(UPDATE_FUNC_ARGS) * tmp - angle of lighting * */ - int r,rx,ry, multipler, powderful=parts[i].temp*(1+parts[i].life/40)*LIGHTING_POWER; + int r,rx,ry, multipler, powderful; + float angle, angle2=-1; + int near; + powderful = powderful=parts[i].temp*(1+parts[i].life/40)*LIGHTING_POWER; update_PYRO(UPDATE_FUNC_SUBCALL_ARGS); if (aheat_enable) { @@ -192,9 +195,9 @@ int update_LIGH(UPDATE_FUNC_ARGS) return 1; } - float angle, angle2=-1; + angle2=-1; - int near = LIGH_nearest_part(i, parts[i].life*2.5); + near = LIGH_nearest_part(i, parts[i].life*2.5); if (near!=-1) { int t=parts[near].type; -- cgit v0.9.2-21-gd62e From 89fd306ba155d9674008b4fce444f8476d4369da Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Sun, 23 Oct 2011 18:37:25 +0100 Subject: Fix unitialised variable 'bc' in main.c diff --git a/src/main.c b/src/main.c index e77e310..c65394c 100644 --- a/src/main.c +++ b/src/main.c @@ -1579,7 +1579,7 @@ int main(int argc, char *argv[]) void *http_ver_check, *http_session_check = NULL; char *ver_data=NULL, *check_data=NULL, *tmp; //char console_error[255] = ""; - int result, i, j, bq, bc, fire_fc=0, do_check=0, do_s_check=0, old_version=0, http_ret=0,http_s_ret=0, major, minor, buildnum, is_beta = 0, old_ver_len, new_message_len=0; + int result, i, j, bq, bc = 0, fire_fc=0, do_check=0, do_s_check=0, old_version=0, http_ret=0,http_s_ret=0, major, minor, buildnum, is_beta = 0, old_ver_len, new_message_len=0; #ifdef INTERNAL int vs = 0; #endif -- cgit v0.9.2-21-gd62e From c3b9c698d23354a73d2cd2772eb31b67045f45c7 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Mon, 24 Oct 2011 18:43:45 +0100 Subject: Prevent UI text from overlapping intro message diff --git a/includes/defines.h b/includes/defines.h index dfe24b2..4849ce6 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -15,6 +15,9 @@ #define IDENT_VERSION "G" //Change this if you're not Simon! It should be a single letter. +#define MTOS_EXPAND(str) #str +#define MTOS(str) MTOS_EXPAND(str) + #define SERVER "powdertoy.co.uk" #define SCRIPTSERVER "powdertoy.co.uk" diff --git a/src/graphics.c b/src/graphics.c index 8413a73..fd6c2b2 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1057,6 +1057,10 @@ int drawtext(pixel *vid, int x, int y, const char *s, int r, int g, int b, int a r = 255; g = b = 0; break; + case 'l': + r = 255; + g = b = 75; + break; case 'b': r = g = 0; b = 255; @@ -1135,10 +1139,19 @@ int drawtextwrap(pixel *vid, int x, int y, int w, const char *s, int r, int g, i r = 255; g = b = 0; break; + case 'l': + r = 255; + g = b = 75; + break; case 'b': r = g = 0; b = 255; break; + case 't': + b = 255; + g = 170; + r = 32; + break; } s++; } diff --git a/src/main.c b/src/main.c index c65394c..39f7905 100644 --- a/src/main.c +++ b/src/main.c @@ -131,7 +131,7 @@ void play_sound(char *file) } static const char *it_msg = - "\brThe Powder Toy - http://powdertoy.co.uk, irc.freenode.net #powder\n" + "\blThe Powder Toy - Version " MTOS(SAVE_VERSION) "." MTOS(MINOR_VERSION) " - http://powdertoy.co.uk, irc.freenode.net #powder\n" "\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\n" "\n" "\bgControl+C/V/X are Copy, Paste and cut respectively.\n" @@ -1585,7 +1585,7 @@ int main(int argc, char *argv[]) #endif int wavelength_gfx = 0; int x, y, line_x, line_y, b = 0, sl=1, sr=0, su=0, c, lb = 0, lx = 0, ly = 0, lm = 0;//, tx, ty; - int da = 0, dae = 0, db = 0, it = 2047, mx, my, bsx = 2, bsy = 2, quickoptions_tooltip_fade_invert; + int da = 0, dae = 0, db = 0, it = 2047, mx, my, bsx = 2, bsy = 2, quickoptions_tooltip_fade_invert, it_invert = 0; float nfvx, nfvy; int load_mode=0, load_w=0, load_h=0, load_x=0, load_y=0, load_size=0; void *load_data=NULL; @@ -3480,6 +3480,11 @@ int main(int argc, char *argv[]) strappend(uitext, " [FRAME CAPTURE]"); #endif quickoptions_tooltip_fade_invert = 255 - (quickoptions_tooltip_fade*20); + it_invert = 50 - it; + if(it_invert < 0) + it_invert = 0; + if(it_invert > 50) + it_invert = 50; if (sdl_zoom_trig||zoom_en) { if (zoom_x Date: Mon, 24 Oct 2011 18:46:58 +0100 Subject: Draw version info with outline diff --git a/src/main.c b/src/main.c index 39f7905..75a3a95 100644 --- a/src/main.c +++ b/src/main.c @@ -3525,8 +3525,7 @@ int main(int argc, char *argv[]) draw_wavelengths(vid_buf,XRES-20-textwidth(heattext),11,2,wavelength_gfx); } wavelength_gfx = 0; - fillrect(vid_buf, 12, 12, textwidth(uitext)+8, 15, 0, 0, 0, it_invert * 3); - drawtext(vid_buf, 16, 16, uitext, 32, 216, 255, it_invert * 4); + drawtext_outline(vid_buf, 16, 16, uitext, 32, 216, 255, it_invert * 4, 0, 0, 0, it_invert * 4); } -- cgit v0.9.2-21-gd62e From f8d54e66dba5d8448d30f61f84883b4e7e6e1087 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Mon, 24 Oct 2011 19:05:03 +0100 Subject: F1 to bring up intro message diff --git a/src/main.c b/src/main.c index 75a3a95..4b6d413 100644 --- a/src/main.c +++ b/src/main.c @@ -2415,10 +2415,22 @@ int main(int argc, char *argv[]) if (sdl_key==SDLK_SPACE) sys_pause = !sys_pause; if (sdl_key=='u') - aheat_enable = !aheat_enable; - if (sdl_key=='h') + if (sdl_key=='h' && !(sdl_mod & KMOD_LCTRL)) + { hud_enable = !hud_enable; + } + if (sdl_key==SDLK_F1 || (sdl_key=='h' && (sdl_mod & KMOD_LCTRL))) + { + if(!it) + { + it = 8047; + } + else + { + it = 0; + } + } if (sdl_key=='n') pretty_powder = !pretty_powder; if (sdl_key=='p') -- cgit v0.9.2-21-gd62e