From 081ad28435d9fb544d32f9ed20aca08223d09ba3 Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Wed, 29 Dec 2010 17:55:14 -0500 Subject: [PATCH 1/2] updated with simons small changes --- src/graphics.c | 2 +- src/interface.c | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/graphics.c b/src/graphics.c index adc0c18d7..9fcc71619 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -3386,7 +3386,7 @@ void sdl_open(void) SDL_WM_SetCaption("The Powder Toy", "Powder Toy"); sdl_seticon(); SDL_EnableUNICODE(1); - SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); + //SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); } #ifdef OpenGL diff --git a/src/interface.c b/src/interface.c index fef6445a3..b37c3e9f0 100644 --- a/src/interface.c +++ b/src/interface.c @@ -1853,20 +1853,36 @@ void set_cmode(int cm) strcpy(itc_msg, "Persistent Display"); } else if(cmode==CM_PRESS) + { strcpy(itc_msg, "Pressure Display"); + } else if(cmode==CM_NOTHING) + { strcpy(itc_msg, "Nothing Display"); + } else if(cmode==CM_CRACK) + { strcpy(itc_msg, "Alternate Velocity Display"); + } else if(cmode==CM_GRAD) + { strcpy(itc_msg, "Heat Gradient Display"); + } else if(cmode==CM_LIFE) - if(DEBUG_MODE) - strcpy(itc_msg, "Life Display"); - else - set_cmode(CM_CRACK); + { + if(DEBUG_MODE) + { + strcpy(itc_msg, "Life Display"); + } + else + { + set_cmode(CM_CRACK); + } + } else + { strcpy(itc_msg, "Velocity Display"); + } } char *download_ui(pixel *vid_buf, char *uri, int *len) From 2212d04fb035ec9e29d27ac8c0d818c83a5f3782 Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Thu, 30 Dec 2010 00:46:35 -0500 Subject: [PATCH 2/2] added SING, QRTZ and PQRT, see mod thread on forum. --- includes/powder.h | 13 +++- src/graphics.c | 11 ++++ src/main.c | 5 +- src/powder.c | 159 +++++++++++++++++++++++++++++++++++----------- 4 files changed, 148 insertions(+), 40 deletions(-) diff --git a/includes/powder.h b/includes/powder.h index 76ed40aba..f6755c02f 100644 --- a/includes/powder.h +++ b/includes/powder.h @@ -179,7 +179,10 @@ #define PT_STKM2 128 #define PT_BOMB 129 #define PT_C5 130 -#define PT_NUM 131 +#define PT_SING 131 +#define PT_QRTZ 132 +#define PT_PQRT 133 +#define PT_NUM 134 #define R_TEMP 22 #define MAX_TEMP 9999 @@ -403,6 +406,9 @@ static const part_type ptypes[PT_NUM] = {"STK2", PIXPACK(0x000000), 0.5f, 0.00f * CFDS, 0.2f, 1.0f, 0.0f, 0.0f, 0.0f, 0.00f * CFDS, 0, 0, 0, 0, 0, 1, 50, SC_SPECIAL, R_TEMP+14.6f+273.15f, 0, "Stickman. Don't kill him!", 0, NULL}, {"BOMB", PIXPACK(0xFFF288), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 20, 1, 30, SC_EXPLOSIVE, R_TEMP-2.0f +273.15f, 29, "Bomb.", TYPE_PART, NULL}, {"C-5", PIXPACK(0x2050E0), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 88, "Cold explosive", TYPE_SOLID | PROP_NEUTPENETRATE, NULL}, + {"SING", PIXPACK(0x242424), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, 0.0f, 0.12f, 0.00f, -0.001f * CFDS, 1, 0, 0, 0, 0, 1, 86, SC_NUCLEAR, R_TEMP+0.0f +273.15f, 70, "Singularity", TYPE_PART, NULL}, + {"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, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 3, "Quartz, breakable mineral. Conducts but becomes brittle at lower temperatures.", TYPE_SOLID| PROP_HOT_GLOW, NULL}, + {"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, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 3, "Broken quartz.", TYPE_PART| PROP_HOT_GLOW, NULL}, //Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Weights Section H Ins Description }; @@ -540,7 +546,10 @@ static part_state pstates[PT_NUM] = /* STKM2*/ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_FIRE, 620.0f}, /* BOMB */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, /* C-5 */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - + /* SING */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* QRTZ */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 2573.15f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* PQRT */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 2573.15f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + }; static int grule[NGOL][9] = { diff --git a/src/graphics.c b/src/graphics.c index 9fcc71619..bfc60b431 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1519,6 +1519,17 @@ void draw_parts(pixel *vid) } } + else if(t==PT_QRTZ || t==PT_PQRT) + { + int q = parts[i].tmp; + cr = q * 16 + PIXR(ptypes[t].pcolors); + cg = q * 16 + PIXG(ptypes[t].pcolors); + cb = q * 16 + PIXB(ptypes[t].pcolors); + cr = cr>255?255:cr; + cg = cg>255?255:cg; + cb = cb>255?255:cb; + blendpixel(vid, nx, ny, cr, cg, cb, 255); + } else if(t==PT_SPNG) { cr = PIXR(ptypes[t].pcolors) - parts[i].life*15; diff --git a/src/main.c b/src/main.c index 7acc85dce..21e8a4702 100644 --- a/src/main.c +++ b/src/main.c @@ -2077,7 +2077,10 @@ int main(int argc, char *argv[]) if(b & SDL_BUTTON_LMASK) set_cmode((cmode+1) % CM_COUNT); if(b & SDL_BUTTON_RMASK) - set_cmode((cmode+(CM_COUNT-1)) % CM_COUNT); + if((cmode+(CM_COUNT-1)) % CM_COUNT == CM_LIFE) + set_cmode(CM_GRAD); + else + set_cmode((cmode+(CM_COUNT-1)) % CM_COUNT); save_presets(0); } if(x>=(XRES+BARSIZE-(510-494)) && x<=(XRES+BARSIZE-(510-509)) && !bq) diff --git a/src/powder.c b/src/powder.c index 84d129bb5..356db7c55 100644 --- a/src/powder.c +++ b/src/powder.c @@ -78,7 +78,8 @@ static int eval_move(int pt, int nx, int ny, unsigned *rr) (r&0xFF)==PT_GLOW || (r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW || (r&0xFF)==PT_SLTW || (r&0xFF)==PT_ISOZ || (r&0xFF)==PT_ISZS || - (r&0xFF)==PT_FILT || (r&0xFF)==PT_INVIS || + (r&0xFF)==PT_FILT || (r&0xFF)==PT_INVIS || + (r&0xFF)==PT_QRTZ || (r&0xFF)==PT_PQRT || ((r&0xFF)==PT_LCRY&&parts[r>>8].life > 5))) return 2; @@ -552,6 +553,10 @@ inline int create_part(int p, int x, int y, int t) { parts[i].pavg[1] = pv[y/CELL][x/CELL]; } + if(t==PT_QRTZ) + { + parts[i].pavg[1] = pv[y/CELL][x/CELL]; + } if(t!=PT_STKM&&t!=PT_STKM2) { parts[i].x = (float)x; @@ -586,6 +591,12 @@ inline int create_part(int p, int x, int y, int t) parts[i].life = 30; if(t==PT_PUMP) parts[i].life= 10; + if(t==PT_SING) + parts[i].life = rand()%50+60; + if(t==PT_QRTZ) + parts[i].tmp = (rand()%11) -5; + if(t==PT_PQRT) + parts[i].tmp = (rand()%11) -5; if(t==PT_FSEP) parts[i].life = 50; if(t==PT_COAL) { @@ -1290,7 +1301,7 @@ void update_particles_i(pixel *vid, int start, int inc) { if(!(parts[i].life==10&&(parts[i].type==PT_LCRY||parts[i].type==PT_PCLN||parts[i].type==PT_HSWC||parts[i].type==PT_PUMP))) parts[i].life--; - if(parts[i].life<=0 && t!=PT_METL && t!=PT_ARAY && t!=PT_IRON && t!=PT_FIRW && t!=PT_PCLN && t!=PT_HSWC && t!=PT_PUMP && t!=PT_WATR && t!=PT_RBDM && t!=PT_LRBD && t!=PT_SLTW && t!=PT_BRMT && t!=PT_PSCN && t!=PT_NSCN && t!=PT_NTCT && t!=PT_PTCT && t!=PT_BMTL && t!=PT_SPRK && t!=PT_LAVA && t!=PT_ETRD&&t!=PT_LCRY && t!=PT_INWR && t!=PT_GLOW && t!= PT_FOG && t!=PT_PIPE && t!=PT_FRZW &&(t!=PT_ICEI&&parts[i].ctype!=PT_FRZW)&&t!=PT_INST && t!=PT_SHLD1&& t!=PT_SHLD2&& t!=PT_SHLD3&& t!=PT_SHLD4) + if(parts[i].life<=0 && t!=PT_METL && t!=PT_ARAY && t!=PT_IRON && t!=PT_FIRW && t!=PT_PCLN && t!=PT_HSWC && t!=PT_PUMP && t!=PT_WATR && t!=PT_RBDM && t!=PT_LRBD && t!=PT_SLTW && t!=PT_BRMT && t!=PT_PSCN && t!=PT_NSCN && t!=PT_NTCT && t!=PT_PTCT && t!=PT_BMTL && t!=PT_SPRK && t!=PT_LAVA && t!=PT_ETRD&&t!=PT_LCRY && t!=PT_INWR && t!=PT_QRTZ && t!=PT_GLOW && t!= PT_FOG && t!=PT_PIPE && t!=PT_FRZW &&(t!=PT_ICEI&&parts[i].ctype!=PT_FRZW)&&t!=PT_INST && t!=PT_SHLD1&& t!=PT_SHLD2&& t!=PT_SHLD3&& t!=PT_SHLD4) { kill_part(i); continue; @@ -1298,7 +1309,7 @@ void update_particles_i(pixel *vid, int start, int inc) if(parts[i].life<=0 && t==PT_SPRK) { t = parts[i].ctype; - if(t!=PT_METL&&t!=PT_IRON&&t!=PT_BMTL&&t!=PT_BRMT&&t!=PT_LRBD&&t!=PT_RBDM&&t!=PT_BTRY&&t!=PT_NBLE) + if(t!=PT_METL&&t!=PT_IRON&&t!=PT_BMTL&&t!=PT_BRMT&&t!=PT_LRBD&&t!=PT_RBDM&&t!=PT_BTRY&&t!=PT_NBLE&&t!=PT_QRTZ) parts[i].temp = R_TEMP + 273.15f; if(!t) t = PT_METL; @@ -1350,41 +1361,52 @@ void update_particles_i(pixel *vid, int start, int inc) vx[y/CELL][x/CELL] += ptypes[t].airdrag*parts[i].vx; vy[y/CELL][x/CELL] += ptypes[t].airdrag*parts[i].vy; } - if(t==PT_GAS||t==PT_NBLE||t==PT_PUMP) + if(t==PT_GAS||t==PT_NBLE) { - if(t==PT_PUMP && parts[i].life==10) - { - if(parts[i].temp>=256.0+273.15) - parts[i].temp=256.0+273.15; - if(parts[i].temp<= -256.0+273.15) - parts[i].temp = -256.0+273.15; - - if(pv[y/CELL][x/CELL]<(parts[i].temp-273.15)) - pv[y/CELL][x/CELL] += 0.1f*((parts[i].temp-273.15)-pv[y/CELL][x/CELL]); - if(y+CELL=256.0+273.15) + parts[i].temp=256.0+273.15; + if(parts[i].temp<= -256.0+273.15) + parts[i].temp = -256.0+273.15; + + if(pv[y/CELL][x/CELL]<(parts[i].temp-273.15)) + pv[y/CELL][x/CELL] += 0.1f*((parts[i].temp-273.15)-pv[y/CELL][x/CELL]); + if(y+CELL 0.05*(parts[i].temp/3) || parts[i].pavg[1]-parts[i].pavg[0] < -0.05*(parts[i].temp/3)) + { + parts[i].type = PT_PQRT; + } + } if(t==PT_ICEI && pv[y/CELL][x/CELL]>0.8f) t = parts[i].type = PT_SNOW; if(t==PT_PLUT && 1>rand()%100 && ((int)(5.0f*pv[y/CELL][x/CELL]))>(rand()%1000)) @@ -1682,6 +1713,7 @@ void update_particles_i(pixel *vid, int start, int inc) parts[i].ctype = (parts[i].type==PT_BRMT)?PT_BMTL:parts[i].type; parts[i].ctype = (parts[i].ctype==PT_SAND)?PT_GLAS:parts[i].ctype; parts[i].ctype = (parts[i].ctype==PT_BGLA)?PT_GLAS:parts[i].ctype; + parts[i].ctype = (parts[i].ctype==PT_PQRT)?PT_QRTZ:parts[i].ctype; t = parts[i].type = pstates[t].liquid; } else if(t==PT_ICEI&&parts[i].ctype) @@ -3560,6 +3592,49 @@ void update_particles_i(pixel *vid, int start, int inc) } } } + else if(t==PT_SING) + { + for(nx=-1; nx<2; nx++) + for(ny=-1; ny<2; ny++) + if(x+nx>=0 && y+ny>0 && + x+nx>8)>=NPART || !r) + continue; + if(parts[r>>8].type!=PT_DMND&&33>=rand()/(RAND_MAX/100)+1) + { + if(parts[r>>8].life >10) + { + if(parts[i].life+parts[r>>8].life > 255) + { + if(parts[r>>8].type!=PT_SING && 1>rand()%20000) + { + parts[r>>8].type = PT_SING; + parts[r>>8].life = rand()%50+60; + } + continue; + } + parts[i].life += parts[r>>8].life; + } + else + { + if(parts[i].life+1 > 255) + { + if(parts[r>>8].type!=PT_SING && 1>rand()%20000) + { + parts[r>>8].type = PT_SING; + parts[r>>8].life = rand()%50+60; + } + continue; + } + parts[i].life += 1; + } + parts[i].temp = restrict_flt(parts[r>>8].temp+parts[i].temp, MIN_TEMP, MAX_TEMP); + parts[r>>8].type=PT_NONE; + } + } + } else if(t==PT_FIRW) { if(parts[i].tmp==0) { for(nx=-1; nx<2; nx++) @@ -3694,7 +3769,7 @@ void update_particles_i(pixel *vid, int start, int inc) rt = parts[r>>8].type; if((a || ptypes[rt].explosive) && ((rt!=PT_RBDM && rt!=PT_LRBD && rt!=PT_INSL && rt!=PT_SWCH) || t!=PT_SPRK) && !(t==PT_PHOT && rt==PT_INSL) && - (t!=PT_LAVA || parts[i].life>0 || (rt!=PT_STNE && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_METL && rt!=PT_IRON && rt!=PT_ETRD && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SWCH && rt!=PT_INWR)) && !(rt==PT_SPNG && parts[r>>8].life>0) && + (t!=PT_LAVA || parts[i].life>0 || (rt!=PT_STNE && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_METL && rt!=PT_IRON && rt!=PT_ETRD && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SWCH && rt!=PT_INWR && rt!=PT_QRTZ)) && !(rt==PT_SPNG && parts[r>>8].life>0) && ptypes[rt].flammable && (ptypes[rt].flammable + (int)(pv[(y+ny)/CELL][(x+nx)/CELL]*10.0f))>(rand()%1000)) { parts[r>>8].type = PT_FIRE; @@ -3835,6 +3910,16 @@ void update_particles_i(pixel *vid, int start, int inc) parts[r>>8].ctype = rt; } } + if(t==PT_SPRK && rt==PT_QRTZ && parts[r>>8].life==0 && + (parts[i].life<3 || ((r>>8)>8].temp<173.15||pv[(y+ny)/CELL][(x+nx)/CELL]>8)) + { + parts[r>>8].type = PT_SPRK; + parts[r>>8].life = 4; + parts[r>>8].ctype = rt; + } + } if(t==PT_SPRK && rt==PT_WATR && parts[r>>8].life==0 && (parts[i].life<2 || ((r>>8)