From 98446365932f1e1071b9c59c5760ca2e2c003be7 Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Sun, 6 Feb 2011 12:50:04 -0500 Subject: [PATCH 01/15] particle # shows up again --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 3358a333c..6d9dbfd7d 100644 --- a/src/main.c +++ b/src/main.c @@ -1830,7 +1830,7 @@ int main(int argc, char *argv[]) int tctype = parts[cr>>8].ctype; if (tctype>=PT_NUM) tctype = 0; - sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[tctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life); + sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d, #%d", ptypes[cr&0xFF].name, ptypes[tctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life, cr>>8); //sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[parts[cr>>8].ctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life); } else sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life); From 30d86813fcc642cdb2e68c59b5e1db2992a741bc Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Sun, 6 Feb 2011 13:29:37 -0500 Subject: [PATCH 02/15] hidden menu shows up correctly --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 6d9dbfd7d..4dc5a14a9 100644 --- a/src/main.c +++ b/src/main.c @@ -1563,7 +1563,7 @@ int main(int argc, char *argv[]) } } if ((sdl_mod & (KMOD_RCTRL) )&&( sdl_mod & (KMOD_RALT))) - active_menu = 11; + active_menu = 12; if (sdl_key==SDLK_INSERT)// || sdl_key==SDLK_BACKQUOTE) REPLACE_MODE = !REPLACE_MODE; if (sdl_key==SDLK_BACKQUOTE) From e882dfecf91bbad8480422418f163686e60b64b6 Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Thu, 10 Feb 2011 19:46:34 -0500 Subject: [PATCH 03/15] update with latest --- includes/defines.h | 6 +- includes/powder.h | 18 +-- src/air.c | 26 ++++ src/elements/prti.c | 2 + src/elements/prto.c | 2 + src/elements/wifi.c | 2 + src/graphics.c | 141 +++++++++++------- src/interface.c | 72 ++++------ src/main.c | 340 +++++++++++++++++++++++++++++--------------- src/misc.c | 27 ++-- src/powder.c | 99 +++++++------ 11 files changed, 458 insertions(+), 277 deletions(-) diff --git a/includes/defines.h b/includes/defines.h index 9fba0fb2e..f4a2a4dfa 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -8,9 +8,9 @@ #endif #define SAVE_VERSION 46 -#define MINOR_VERSION 0 +#define MINOR_VERSION 1 #define IDENT_VERSION "G" //Change this if you're not Simon! It should be a single letter. -//#define BETA +#define BETA #define SERVER "powdertoy.co.uk" @@ -99,7 +99,7 @@ int GRAV_G2; int GRAV_B2; extern int legacy_enable; - +extern int sound_enable; extern int kiosk_enable; extern int sys_pause; diff --git a/includes/powder.h b/includes/powder.h index b09ad5ead..f5fa948d5 100644 --- a/includes/powder.h +++ b/includes/powder.h @@ -441,22 +441,22 @@ static const part_type ptypes[PT_NUM] = {"FIRW", PIXPACK(0xFFA040), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, -0.99f, 0.1f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 30, 1, 55, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 70, "Fireworks!", ST_SOLID, TYPE_PART, &update_FIRW}, {"FUSE", PIXPACK(0x0A5706), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.0f, 0.0f * CFDS, 0, 0, 0, 0, 20, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 200, "Solid. Burns slowly. Ignites at somewhat high temperatures and electricity.", ST_SOLID, TYPE_SOLID, &update_FUSE}, {"FSEP", PIXPACK(0x63AD5F), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 30, 1, 70, SC_POWDERS, R_TEMP+0.0f +273.15f, 70, "Fuse Powder. See FUSE.", ST_SOLID, TYPE_PART, &update_FSEP}, - {"AMTR", PIXPACK(0x808080), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, 0.00f, 0.10f, 1.00f, 0.0000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_NUCLEAR, R_TEMP+0.0f +273.15f, 70, "Anti-Matter, Destroys a majority of particles", ST_NONE, TYPE_PART, NULL}, //Maybe TYPE_ENERGY? + {"AMTR", PIXPACK(0x808080), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, 0.00f, 0.10f, 1.00f, 0.0000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_NUCLEAR, R_TEMP+0.0f +273.15f, 70, "Anti-Matter, Destroys a majority of particles", ST_NONE, TYPE_PART, &update_AMTR}, //Maybe TYPE_ENERGY? {"BCOL", PIXPACK(0x333333), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 5, 2, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 150, "Broken Coal. Heavy particles. See COAL", ST_SOLID, TYPE_PART, &update_BCOL}, {"PCLN", PIXPACK(0x3B3B10), 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_ELEC, R_TEMP+0.0f +273.15f, 251, "Solid. When activated, duplicates any particles it touches.", ST_NONE, TYPE_SOLID, &update_PCLN}, {"HSWC", PIXPACK(0x3B1010), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Heat switch. Conducts Heat only when activated", ST_NONE, TYPE_SOLID, &update_HSWC}, {"IRON", PIXPACK(0x707070), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 50, 1, 100, SC_CRACKER2, R_TEMP+0.0f +273.15f, 251, "Rusts with salt, can be used for electrolysis of WATR", ST_SOLID, TYPE_SOLID|PROP_CONDUCTS, &update_IRON}, {"MORT", PIXPACK(0xE0E0E0), 0.0f, 0.00f * CFDS, 1.00f, 1.00f, -0.99f, 0.0f, 0.01f, 0.002f * CFDS, 0, 0, 0, 0, 0, 1, -1, SC_CRACKER2, R_TEMP+4.0f +273.15f, 60, "Steam Train.", ST_NONE, TYPE_PART, &update_MORT}, - {"GOL ", PIXPACK(0x0CAC00), 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_LIFE, 9000.0f, 40, "Game Of Life! B3/S23", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"GOL", PIXPACK(0x0CAC00), 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_LIFE, 9000.0f, 40, "Game Of Life! B3/S23", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, {"HLIF", PIXPACK(0xFF0000), 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_LIFE, 9000.0f, 40, "High Life! B36/S23", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, {"ASIM", PIXPACK(0x0000FF), 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_LIFE, 9000.0f, 40, "Assimilation! B345/S4567", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, - {"2x2 ", PIXPACK(0xFFFF00), 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_LIFE, 9000.0f, 40, "2x2! B36/S125", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"2x2", PIXPACK(0xFFFF00), 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_LIFE, 9000.0f, 40, "2x2! B36/S125", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, {"DANI", PIXPACK(0x00FFFF), 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_LIFE, 9000.0f, 40, "Day and Night! B3678/S34678", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, {"AMOE", PIXPACK(0xFF00FF), 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_LIFE, 9000.0f, 40, "Amoeba! B357/S1358", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, {"MOVE", PIXPACK(0xFFFFFF), 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_LIFE, 9000.0f, 40, "'Move' particles! Does not move things.. it is a life type B368/S245", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, {"PGOL", PIXPACK(0xE05010), 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_LIFE, 9000.0f, 40, "Pseudo Life! B357/S238", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, {"DMOE", PIXPACK(0x500000), 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_LIFE, 9000.0f, 40, "Diamoeba! B35678/S5678", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, - {"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, 1, 100, SC_LIFE, 9000.0f, 40, "34! B34/S34)", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"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, 1, 100, SC_LIFE, 9000.0f, 40, "34! B34/S34)", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, {"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, 1, 100, SC_LIFE, 9000.0f, 40, "Long Life! B345/S5", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, {"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, 1, 100, SC_LIFE, 9000.0f, 40, "Stains! B3678/S235678", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, {"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, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "A sponge, absorbs water.", ST_SOLID, TYPE_SOLID, &update_SPNG}, @@ -767,10 +767,11 @@ static int lolzrule[9][9] = {0,1,0,0,0,0,0,1,0}, {0,1,0,0,0,0,0,1,0}, }; -int portal[(int)(MAX_TEMP-73.15f)/100+2][8][80]; -float portaltemp[(int)(MAX_TEMP-73.15f)/100+2][8][80]; -int portalctype[(int)(MAX_TEMP-73.15f)/100+2][8][80]; -int wireless[(int)(MAX_TEMP-73.15f)/100+2][2]; +#define CHANNELS ((int)(MAX_TEMP-73.15f)/100+2) +int portal[CHANNELS][8][80]; +float portaltemp[CHANNELS][8][80]; +int portalctype[CHANNELS][8][80]; +int wireless[CHANNELS][2]; extern int isplayer; extern float player[27]; @@ -778,6 +779,7 @@ extern float player[27]; extern float player2[27]; extern int gravityMode; +extern int airMode; extern particle *parts; extern particle *cb_parts; diff --git a/src/air.c b/src/air.c index e9a8b9e93..aaf42d265 100644 --- a/src/air.c +++ b/src/air.c @@ -33,6 +33,9 @@ void update_air(void) { int x, y, i, j; float dp, dx, dy, f, tx, ty; + +if (airMode != 4) { + for (i=0; i 256.0f) dy = 256.0f; if (dy < -256.0f) dy = -256.0f; + + switch (airMode) + { + default: + case 0: //Default + break; + case 1: //0 Pressure + dp = 0.0f; + break; + case 2: //0 Velocity + dx = 0.0f; + dy = 0.0f; + break; + case 3: //0 Air + dx = 0.0f; + dy = 0.0f; + dp = 0.0f; + break; + case 4: //No Update + break; + } + ovx[y][x] = dx; ovy[y][x] = dy; opv[y][x] = dp; @@ -185,3 +210,4 @@ void update_air(void) memcpy(vy, ovy, sizeof(vy)); memcpy(pv, opv, sizeof(pv)); } +} diff --git a/src/elements/prti.c b/src/elements/prti.c index b25f7a3db..560ba8ca7 100644 --- a/src/elements/prti.c +++ b/src/elements/prti.c @@ -4,6 +4,8 @@ int update_PRTI(UPDATE_FUNC_ARGS) { int r, nnx, rx, ry; int count =0; parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1); + if (parts[i].tmp>=CHANNELS) parts[i].tmp = CHANNELS-1; + else if (parts[i].tmp<0) parts[i].tmp = 0; for (rx=-1; rx<2; rx++) for (ry=-1; ry<2; ry++) if (x+rx>=0 && y+ry>0 && x+rx=CHANNELS) parts[i].tmp = CHANNELS-1; + else if (parts[i].tmp<0) parts[i].tmp = 0; for (rx=-1; rx<2; rx++) for (ry=-1; ry<2; ry++) if (x+rx>=0 && y+ry>0 && x+rx=CHANNELS) parts[i].tmp = CHANNELS-1; + else if (parts[i].tmp<0) parts[i].tmp = 0; for (rx=-1; rx<2; rx++) for (ry=-1; ry<2; ry++) if (x+rx>=0 && y+ry>0 && x+rx=-1; s++) { - switch (s[1]) + if (*s == '\n') { - case 'w': - r = g = b = 255; - break; - case 'g': - r = g = b = 192; - break; - case 'o': - r = 255; - g = 216; - b = 32; - break; - case 'r': - r = 255; - g = b = 0; - break; - case 'b': - r = g = 0; - b = 255; - break; - } - s++; - } - else - { - if (x-cw>=w) { x = sx; rw = 0; - y+=FONT_H+2; - rh+=FONT_H+2; + y += FONT_H+2; + } + else if (*s == '\b') + { + switch (s[1]) + { + case 'w': + r = g = b = 255; + break; + case 'g': + r = g = b = 192; + break; + case 'o': + r = 255; + g = 216; + b = 32; + break; + case 'r': + r = 255; + g = b = 0; + break; + case 'b': + r = g = 0; + b = 255; + break; + } + s++; + } + else + { + + if (x-cw>=w) + { + x = sx; + rw = 0; + y+=FONT_H+2; + rh+=FONT_H+2; + } + x = drawchar(vid, x, y, *(unsigned char *)s, r, g, b, a); } - x = drawchar(vid, x, y, *(unsigned char *)s, r, g, b, a); } } #endif @@ -1009,18 +1025,29 @@ void textnpos(char *s, int n, int w, int *cx, int *cy) { int x = 0; int y = 0; - //TODO: Implement Textnheight for wrapped text - for (; *s; s++) + int wordlen, charspace; + while (*s&&n) { - if (!n) { - break; - } - x += font_data[font_ptrs[(int)(*(unsigned char *)s)]]; - if (x>=w) { + wordlen = strcspn(s," .,!?\n"); + charspace = textwidthx(s, w-x); + if (charspace=-1; s++) + { + if (!n) { + break; + } + x += font_data[font_ptrs[(int)(*(unsigned char *)s)]]; + if (x>=w) + { + x = 0; + y += FONT_H+2; + } + n--; + } } *cx = x-1; *cy = y; @@ -1041,18 +1068,28 @@ int textwidthx(char *s, int w) } int textposxy(char *s, int width, int w, int h) { - int x=0,y=0,n=0,cw; - for (; *s; s++) + int x=0,y=0,n=0,cw, wordlen, charspace; + while (*s) { - cw = font_data[font_ptrs[(int)(*(unsigned char *)s)]]; - if (x+(cw/2) >= w && y+6 >= h) - break; - x += cw; - if (x>=width) { + wordlen = strcspn(s," .,!?\n"); + charspace = textwidthx(s, width-x); + if (charspace=-1; s++) + { + cw = font_data[font_ptrs[(int)(*(unsigned char *)s)]]; + if ((x+(cw/2) >= w && y+6 >= h)||(y+6 >= h+FONT_H+2)) + return n++; + x += cw; + if (x>=width) { + x = 0; + y += FONT_H+2; + } + n++; + } } return n; } @@ -1483,7 +1520,9 @@ void draw_parts(pixel *vid) t!=PT_HFLM && t!=PT_SPRK && t!=PT_FIRW && t!=PT_DUST && t!=PT_FIRW && t!=PT_FWRK && t!=PT_NEUT && t!=PT_LAVA && t!=PT_BOMB && - t!=PT_PHOT && t!=PT_THDR && t!=PT_SMKE) + t!=PT_PHOT && t!=PT_THDR && t!=PT_SMKE && + t!=PT_LCRY && t!=PT_SWCH && t!=PT_PCLN && + t!=PT_PUMP && t!=PT_HSWC && t!=PT_FILT) { if (ptypes[parts[i].type].properties&TYPE_LIQUID) { @@ -2907,7 +2946,7 @@ void render_signs(pixel *vid_buf) sprintf(buff, "Temp: 0.00"); //...tempirature drawtext(vid_buf, x+3, y+3, buff, 255, 255, 255, 255); } - + if(sregexp(signs[i].text, "^{c:[0-9]*|.*}$")==0) { int sldr, startm; diff --git a/src/interface.c b/src/interface.c index 31d885a03..32c83a18b 100644 --- a/src/interface.c +++ b/src/interface.c @@ -96,7 +96,7 @@ void get_sign_pos(int i, int *x0, int *y0, int *w, int *h) memset(buff, 0, sizeof(buff)); for(sldr=3; signs[i].text[sldr-1] != '|'; sldr++) startm = sldr + 1; - + sldr = startm; while(signs[i].text[sldr] != '}') { @@ -105,7 +105,7 @@ void get_sign_pos(int i, int *x0, int *y0, int *w, int *h) } *w = textwidth(buff) + 5; } - + //Ususal width if (strcmp(signs[i].text, "{p}") && strcmp(signs[i].text, "{t}") && sregexp(signs[i].text, "^{c:[0-9]*|.*}$")) *w = textwidth(signs[i].text) + 5; @@ -867,26 +867,26 @@ void login_ui(pixel *vid_buf) if (res && !strncmp(res, "OK ", 3)) { char *s_id,*u_e,*nres; - printf("\n{%s}\n", res); + printf("{%s}\n", res); s_id = strchr(res+3, ' '); if (!s_id) goto fail; *(s_id++) = 0; - + u_e = strchr(s_id, ' '); - if (!u_e){ + if (!u_e) { u_e = malloc(1); memset(u_e, 0, 1); } else *(u_e++) = 0; - + strcpy(svf_user_id, res+3); strcpy(svf_session_id, s_id); nres = mystrdup(u_e); - - printf("\n{%s} {%s} {%s}\n", svf_user_id, svf_session_id, nres); - + + printf("{%s} {%s} {%s}\n", svf_user_id, svf_session_id, nres); + if (!strncmp(nres, "ADMIN", 5)) { svf_admin = 1; @@ -3862,22 +3862,22 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show mx /= sdl_scale; my /= sdl_scale; ed.focus = 1; - + clearrect(vid_buf, 0, 0, XRES+BARSIZE, 220);//anyway to make it transparent? draw_line(vid_buf, 1, 219, XRES, 219, 228, 228, 228, XRES+BARSIZE); drawtext(vid_buf, 100, 15, "Welcome to The Powder Toy console v.2 (by cracker64)\n" - "Current commands are quit, set, reset, load, create, file, kill, sound\n" - "You can set type, temp, ctype, life, x, y, vx, vy using this format ('set life particle# 9001')\n" - "You can also use 'all' instead of a particle number to do it to everything.\n" - "You can now use particle names (ex. set type all deut)\n" - "Reset works with pressure, velocity, sparks, temp (ex. 'reset pressure')\n" - "To load a save use load saveID (ex. load 1337)\n" - "Create particles with 'create deut x,y' where x and y are the coords\n" - "Run scripts from file 'file filename'\n" - "You can delete/kill a particle with 'kill x,y'" - "Play a sound with (sound blah.wav)" - ,255, 187, 187, 255); - + "Current commands are quit, set, reset, load, create, file, kill, sound\n" + "You can set type, temp, ctype, life, x, y, vx, vy using this format ('set life particle# 9001')\n" + "You can also use 'all' instead of a particle number to do it to everything.\n" + "You can now use particle names (ex. set type all deut)\n" + "Reset works with pressure, velocity, sparks, temp (ex. 'reset pressure')\n" + "To load a save use load saveID (ex. load 1337)\n" + "Create particles with 'create deut x,y' where x and y are the coords\n" + "Run scripts from file 'file filename'\n" + "You can delete/kill a particle with 'kill x,y'" + "Play a sound with (sound blah.wav)" + ,255, 187, 187, 255); + cc = 0; currentcommand = last_command; while(cc < 10) @@ -3957,19 +3957,7 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show int console_parse_type(char *txt, int *element, char *err) { - int i = atoi(txt); - char num[4]; - if (i>=0 && i=XRES) - { - strcpy(err,"Invalid coordinates"); - return 0; - } - if (ny<0 && ny>=YRES) + if (sscanf(txt,"%d,%d",&nx,&ny)!=2 || nx<0 || nx>=XRES || ny<0 || ny>=YRES) { strcpy(err,"Invalid coordinates"); return 0; @@ -4012,9 +3994,10 @@ int console_parse_coords(char *txt, int *x, int *y, char *err) } int console_parse_partref(char *txt, int *which, char *err) { + strcpy(err,""); // TODO: use regex? int i = -1, nx, ny; - if (console_parse_coords(txt, &nx, &ny, err)) + if (strchr(txt,',') && console_parse_coords(txt, &nx, &ny, err)) { i = pmap[ny][nx]; if (!i || (i>>8)>=NPART) @@ -4025,7 +4008,6 @@ int console_parse_partref(char *txt, int *which, char *err) else if (txt) { char *num = (char*)malloc(strlen(txt)+3); - strcpy(err,""); // suppress error message from failed coordinate parsing i = atoi(txt); sprintf(num,"%d",i); if (!txt || strcmp(txt,num)!=0) @@ -4038,6 +4020,6 @@ int console_parse_partref(char *txt, int *which, char *err) strcpy(err,""); return 1; } - strcpy(err,"Particle does not exist"); + if (strcmp(err,"")==0) strcpy(err,"Particle does not exist"); return 0; } diff --git a/src/main.c b/src/main.c index 4dc5a14a9..bb2747323 100644 --- a/src/main.c +++ b/src/main.c @@ -54,65 +54,67 @@ #define NUM_SOUNDS 2 struct sample { - Uint8 *data; - Uint32 dpos; - Uint32 dlen; + Uint8 *data; + Uint32 dpos; + Uint32 dlen; } sounds[NUM_SOUNDS]; void mixaudio(void *unused, Uint8 *stream, int len) { - int i; - Uint32 amount; + int i; + Uint32 amount; - for ( i=0; i len ) { - amount = len; - } - SDL_MixAudio(stream, &sounds[i].data[sounds[i].dpos], amount, SDL_MIX_MAXVOLUME); - sounds[i].dpos += amount; - } + for ( i=0; i len ) { + amount = len; + } + SDL_MixAudio(stream, &sounds[i].data[sounds[i].dpos], amount, SDL_MIX_MAXVOLUME); + sounds[i].dpos += amount; + } } void play_sound(char *file) { - int index; - SDL_AudioSpec wave; - Uint8 *data; - Uint32 dlen; - SDL_AudioCVT cvt; + int index; + SDL_AudioSpec wave; + Uint8 *data; + Uint32 dlen; + SDL_AudioCVT cvt; - /* Look for an empty (or finished) sound slot */ - for ( index=0; index2){ + //User is elevated + if (!strncmp(check_data+3, "ADMIN", 5)) + { + svf_admin = 1; + svf_mod = 0; + } + else if (!strncmp(check_data+3, "MOD", 3)) + { + svf_admin = 0; + svf_mod = 1; + } + } + save_presets(0); + } + else + { + //No idea, but log the user out anyway + strcpy(svf_user, ""); + strcpy(svf_pass, ""); + strcpy(svf_user_id, ""); + strcpy(svf_session_id, ""); + svf_login = 0; + svf_own = 0; + svf_admin = 0; + svf_mod = 0; + } + free(check_data); + } + http_session_check = NULL; + } + do_s_check = (do_s_check+1) & 15; + } if (sdl_key=='q' || sdl_key==SDLK_ESCAPE) { @@ -1563,7 +1642,7 @@ int main(int argc, char *argv[]) } } if ((sdl_mod & (KMOD_RCTRL) )&&( sdl_mod & (KMOD_RALT))) - active_menu = 12; + active_menu = 11; if (sdl_key==SDLK_INSERT)// || sdl_key==SDLK_BACKQUOTE) REPLACE_MODE = !REPLACE_MODE; if (sdl_key==SDLK_BACKQUOTE) @@ -1624,6 +1703,33 @@ int main(int argc, char *argv[]) } } + if (sdl_key=='y') + { + ++airMode; + itc = 52; + switch (airMode) + { + default: + airMode = 0; + case 0: + strcpy(itc_msg, "Air: On"); + break; + case 1: + strcpy(itc_msg, "Air: Pressure Off"); + break; + case 2: + strcpy(itc_msg, "Air: Velocity Off"); + break; + case 3: + strcpy(itc_msg, "Air: Off"); + break; + case 4: + strcpy(itc_msg, "Air: No Update"); + break; + } + } + + if (sdl_key=='t') VINE_MODE = !VINE_MODE; if (sdl_key==SDLK_SPACE) @@ -1841,7 +1947,6 @@ int main(int argc, char *argv[]) if (tctype>=PT_NUM) tctype = 0; sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d, #%d", ptypes[cr&0xFF].name, ptypes[tctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life ,cr>>8); - sprintf(coordtext, "X:%d Y:%d", x/sdl_scale, y/sdl_scale); //sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[parts[cr>>8].ctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life); } else { sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C", ptypes[cr&0xFF].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f); @@ -1850,10 +1955,10 @@ int main(int argc, char *argv[]) } else { - if (DEBUG_MODE) - sprintf(coordtext, "X:%d Y:%d", x/sdl_scale, y/sdl_scale); sprintf(heattext, "Empty, Pressure: %3.2f", pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL]); } + if (DEBUG_MODE) + sprintf(coordtext, "X:%d Y:%d", x/sdl_scale, y/sdl_scale); } mx = x; my = y; @@ -2173,6 +2278,7 @@ int main(int argc, char *argv[]) svf_tags[0] = 0; svf_description[0] = 0; gravityMode = 1; + airMode = 0; death = death2 = 0; isplayer2 = 0; isplayer = 0; @@ -2239,10 +2345,10 @@ int main(int argc, char *argv[]) else if (y=0 && y>=0 && x>8)==i) - pmap[y][x] = 0; - else if ((photons[y][x]>>8)==i) - photons[y][x] = 0; - } + x = (int)(parts[i].x+0.5f); + y = (int)(parts[i].y+0.5f); + if (parts[i].type == PT_STKM) + { + death = 1; + isplayer = 0; + } + if (parts[i].type == PT_STKM2) + { + death2 = 1; + isplayer2 = 0; + } + if (parts[i].type == PT_SPAWN) + { + ISSPAWN1 = 0; + } + if (parts[i].type == PT_SPAWN2) + { + ISSPAWN2 = 0; + } + if (x>=0 && y>=0 && x>8)==i) + pmap[y][x] = 0; + else if ((photons[y][x]>>8)==i) + photons[y][x] = 0; } parts[i].type = PT_NONE; @@ -458,10 +456,18 @@ inline void part_change_type(int i, int x, int y, int t) if (x<0 || y<0 || x>=XRES || y>=YRES || i>=NPART) return -1; parts[i].type = t; - if (t!=PT_STKM&&t!=PT_STKM2 && t!=PT_PHOT)// && t!=PT_NEUT) + if (t==PT_PHOT)// || t==PT_NEUT) + { + photons[y][x] = t|(i<<8); + if ((pmap[y][x]>>8)==i) + pmap[y][x] = 0; + } + else + { pmap[y][x] = t|(i<<8); - else if ((pmap[y][x]>>8)==i) - pmap[y][x] = 0; + if ((photons[y][x]>>8)==i) + photons[y][x] = 0; + } } #if defined(WIN32) && !defined(__GNUC__) @@ -500,6 +506,8 @@ inline int create_n_parts(int n, int x, int y, float vx, float vy, int t) parts[i].tmp = 0; if (t!=PT_STKM&&t!=PT_STKM2 && t!=PT_PHOT && !pmap[y][x])// && t!=PT_NEUT) pmap[y][x] = t|(i<<8); + else if (t==PT_PHOT && !photons[y][x]) + photons[y][x] = t|(i<<8); pv[y/CELL][x/CELL] += 6.0f * CFDS; } @@ -1341,15 +1349,13 @@ void update_particles_i(pixel *vid, int start, int inc) if(parts[r>>8].tmp==grule[golnum][9]-1) parts[r>>8].tmp --; } - if(parts[r>>8].tmp<=0) + if (r && parts[r>>8].tmp<=0) parts[r>>8].type = PT_NONE;//using kill_part makes it not work } - gol2[nx][ny][0] = 0; - for ( z = 1; z<=NGOL; z++) - gol2[nx][ny][z] = 0; } if (createdsomething) GENERATION ++; + memset(gol2, 0, sizeof(gol2)); } if (ISWIRE==1) { @@ -1525,10 +1531,10 @@ void update_particles_i(pixel *vid, int start, int inc) ctemph = ctempl = pt; // change boiling point with pressure if ((ptypes[t].state==ST_LIQUID && ptransitions[t].tht>-1 && ptransitions[t].tht-1 && ptransitions[t].tltptransitions[t].thv&&ptransitions[t].tht>-1) { @@ -2030,10 +2036,19 @@ killed: } nx = (int)(parts[i].x+0.5f); ny = (int)(parts[i].y+0.5f); - if (nx=XRES-CELL || ny=YRES-CELL) + if (ny!=y || nx!=x) { - kill_part(i); - continue; + if ((pmap[y][x]>>8)==i) pmap[y][x] = 0; + else if (t==PT_PHOT&&(photons[y][x]>>8)==i) photons[y][x] = 0; + if (nx=XRES-CELL || ny=YRES-CELL) + { + kill_part(i); + continue; + } + if (t==PT_PHOT) + photons[ny][nx] = t|(i<<8); + else + pmap[ny][nx] = t|(i<<8); } } if (framerender) { From b08c37342b4e1925776451d0ca7388cb5841d432 Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Mon, 14 Feb 2011 20:32:01 -0500 Subject: [PATCH 04/15] Commands in signs, some don't fit --- src/graphics.c | 16 +++++++++++++++- src/interface.c | 18 +++++++++++++++++- src/main.c | 22 ++++++++++++++++++++++ 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/src/graphics.c b/src/graphics.c index 78f1867fb..29aa3ebc1 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -2961,9 +2961,23 @@ void render_signs(pixel *vid_buf) } drawtext(vid_buf, x+3, y+3, buff, 0, 191, 255, 255); } + if(sregexp(signs[i].text, "^{e:.*|.*}$")==0) + { + int sldr, startm; + memset(buff, 0, sizeof(buff)); + for(sldr=3; signs[i].text[sldr-1] != '|'; sldr++) + startm = sldr + 1; + sldr = startm; + while(signs[i].text[sldr] != '}') + { + buff[sldr - startm] = signs[i].text[sldr]; + sldr++; + } + drawtext(vid_buf, x+3, y+3, buff, 0, 255, 215, 255); + } //Usual text - if(strcmp(signs[i].text, "{p}") && strcmp(signs[i].text, "{t}") && sregexp(signs[i].text, "^{c:[0-9]*|.*}$")) + if(strcmp(signs[i].text, "{p}") && strcmp(signs[i].text, "{t}") && sregexp(signs[i].text, "^{c:[0-9]*|.*}$") && sregexp(signs[i].text, "^{e:.*|.*}$")) drawtext(vid_buf, x+3, y+3, signs[i].text, 255, 255, 255, 255); x = signs[i].x; diff --git a/src/interface.c b/src/interface.c index 32c83a18b..07616926e 100644 --- a/src/interface.c +++ b/src/interface.c @@ -105,9 +105,25 @@ void get_sign_pos(int i, int *x0, int *y0, int *w, int *h) } *w = textwidth(buff) + 5; } + if(sregexp(signs[i].text, "^{e:.*|.*}$")==0)//character width limit in signs need to be incresed, as most commands don't fit.. + { + int sldr, startm; + char buff[256]; + memset(buff, 0, sizeof(buff)); + for(sldr=3; signs[i].text[sldr-1] != '|'; sldr++) + startm = sldr + 1; + + sldr = startm; + while(signs[i].text[sldr] != '}') + { + buff[sldr - startm] = signs[i].text[sldr]; + sldr++; + } + *w = textwidth(buff) + 5; + } //Ususal width - if (strcmp(signs[i].text, "{p}") && strcmp(signs[i].text, "{t}") && sregexp(signs[i].text, "^{c:[0-9]*|.*}$")) + if (strcmp(signs[i].text, "{p}") && strcmp(signs[i].text, "{t}") && sregexp(signs[i].text, "^{c:[0-9]*|.*}$") && sregexp(signs[i].text, "^{e:.*|.*}$")) *w = textwidth(signs[i].text) + 5; *h = 14; *x0 = (signs[i].ju == 2) ? signs[i].x - *w : diff --git a/src/main.c b/src/main.c index bb2747323..568b07002 100644 --- a/src/main.c +++ b/src/main.c @@ -2353,6 +2353,7 @@ int main(int argc, char *argv[]) { if(!bq) for(signi=0; signi=signx && x<=signx+signw && y>=signy && y<=signy+signh) + { + char buff[256]; + int sldr; + + memset(buff, 0, sizeof(buff)); + + for(sldr=3; signs[signi].text[sldr] != '|'; sldr++) + buff[sldr-3] = signs[signi].text[sldr]; + + char buff2[sldr-2]; //TODO: Fix this for Visual Studio + memset(buff2, 0, sizeof(buff2)); + memcpy(&buff2, &buff, sldr-3); + process_command(vid_buf, buff2,console_error); + } + } + } } if (c==WL_SIGN+100) From 89b19bcbeea3c90f3a30a409a113c165eb5edf39 Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Thu, 17 Feb 2011 19:03:14 -0500 Subject: [PATCH 05/15] NEUT fixed to dust and fwrk reaction. --- src/elements/neut.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/elements/neut.c b/src/elements/neut.c index aa3ddf0d5..a97701dc4 100644 --- a/src/elements/neut.c +++ b/src/elements/neut.c @@ -72,9 +72,9 @@ int update_NEUT(UPDATE_FUNC_ARGS) { else if ((r&0xFF)==PT_COAL && 5>(rand()%100)) create_part(r>>8, x+rx, y+ry, PT_WOOD); else if ((r&0xFF)==PT_DUST && 5>(rand()%100)) - create_part(r>>8, x+rx, y+ry, PT_FWRK); + part_change_type(r>>8, x+rx, y+ry, PT_FWRK); else if ((r&0xFF)==PT_FWRK && 5>(rand()%100)) - create_part(r>>8, x+rx, y+ry, PT_DUST); + parts[r>>8].ctype = PT_DUST; else if ((r&0xFF)==PT_ACID && 5>(rand()%100)) create_part(r>>8, x+rx, y+ry, PT_ISOZ); /*if(parts[r>>8].type>1 && parts[r>>8].type!=PT_NEUT && parts[r>>8].type-1!=PT_NEUT && parts[r>>8].type-1!=PT_STKM && From a8439f221e7bc4a8314aa84d4be60dfa68d16831 Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Tue, 22 Feb 2011 20:55:09 -0500 Subject: [PATCH 06/15] updating --- includes/defines.h | 8 +- includes/graphics.h | 1 + includes/interface.h | 5 +- includes/powder.h | 10 +- src/elements/bcln.c | 14 +- src/elements/goo.c | 14 +- src/graphics.c | 19 +-- src/interface.c | 73 ++++----- src/main.c | 346 ++++++++++++++++++++++--------------------- src/powder.c | 62 ++++---- 10 files changed, 269 insertions(+), 283 deletions(-) diff --git a/includes/defines.h b/includes/defines.h index f4a2a4dfa..01c281216 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -8,9 +8,9 @@ #endif #define SAVE_VERSION 46 -#define MINOR_VERSION 1 +#define MINOR_VERSION 3 #define IDENT_VERSION "G" //Change this if you're not Simon! It should be a single letter. -#define BETA +//#define BETA #define SERVER "powdertoy.co.uk" @@ -83,6 +83,10 @@ typedef unsigned int pixel; #define GLASS_IOR 1.9 #define GLASS_DISP 0.07 +#ifdef WIN32 +#define strcasecmp stricmp +#endif + typedef unsigned char uint8; extern int amd; diff --git a/includes/graphics.h b/includes/graphics.h index a5de71a25..4d4d438fb 100644 --- a/includes/graphics.h +++ b/includes/graphics.h @@ -46,6 +46,7 @@ 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; pixel *rescale_img(pixel *src, int sw, int sh, int *qw, int *qh, int f); diff --git a/includes/interface.h b/includes/interface.h index e1d7e6f22..ea1f9a5be 100644 --- a/includes/interface.h +++ b/includes/interface.h @@ -52,10 +52,9 @@ static menu_wall mwalls[] = #define SC_LIQUID 4 #define SC_NUCLEAR 7 #define SC_LIFE 9 -#define SC_LIFE2 10 #define SC_CRACKER 12 #define SC_CRACKER2 13 -#define SC_TOTAL 11 +#define SC_TOTAL 10 static menu_section msections[] = { @@ -154,8 +153,6 @@ extern char search_expr[256]; extern char *tag_names[TAG_MAX]; extern int tag_votes[TAG_MAX]; -extern int Z_keysym; - extern int zoom_en; extern int zoom_x, zoom_y; extern int zoom_wx, zoom_wy; diff --git a/includes/powder.h b/includes/powder.h index f5fa948d5..9964abadd 100644 --- a/includes/powder.h +++ b/includes/powder.h @@ -511,11 +511,11 @@ static const part_type ptypes[PT_NUM] = {"REPL", PIXPACK(0x259588), 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_LIFE, 9000.0f, 40, "B1357/S1357", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, {"MYST", PIXPACK(0x0C3C00), 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_LIFE, 9000.0f, 40, "B3458/S05678", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, {"BOYL", PIXPACK(0x0A3200), 1.0f, 0.01f * CFDS, 0.99f, 0.30f, -0.1f, 0.0f, 0.18f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, SC_GAS, R_TEMP+2.0f +273.15f, 42, "Boyle, variable pressure gas. Expands when heated.", ST_GAS, TYPE_GAS, &update_BOYL}, - {"LOTE", PIXPACK(0xFF0000), 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_LIFE2, 9000.0f, 40, "Behaves kinda like Living on the Edge S3458/B37/4", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, - {"FRG2", PIXPACK(0x00FF00), 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_LIFE2, 9000.0f, 40, "Like Frogs rule S124/B3/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, - {"STAR", PIXPACK(0x0000FF), 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_LIFE2, 9000.0f, 40, "Like Star Wars rule S3456/B278/6", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, - {"FROG", PIXPACK(0x00AA00), 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_LIFE2, 9000.0f, 40, "Frogs S12/B34/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, - {"BRAN", PIXPACK(0xCCCC00), 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_LIFE2, 9000.0f, 40, "Brian 6 S6/B246/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"LOTE", PIXPACK(0xFF0000), 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_LIFE, 9000.0f, 40, "Behaves kinda like Living on the Edge S3458/B37/4", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"FRG2", PIXPACK(0x00FF00), 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_LIFE, 9000.0f, 40, "Like Frogs rule S124/B3/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"STAR", PIXPACK(0x0000FF), 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_LIFE, 9000.0f, 40, "Like Star Wars rule S3456/B278/6", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"FROG", PIXPACK(0x00AA00), 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_LIFE, 9000.0f, 40, "Frogs S12/B34/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"BRAN", PIXPACK(0xCCCC00), 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_LIFE, 9000.0f, 40, "Brian 6 S6/B246/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, //Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Weights Section H Ins Description }; diff --git a/src/elements/bcln.c b/src/elements/bcln.c index 3581fc2d9..36ad347d0 100644 --- a/src/elements/bcln.c +++ b/src/elements/bcln.c @@ -1,15 +1,13 @@ #include int update_BCLN(UPDATE_FUNC_ARGS) { - if (!parts[i].life) + if (!parts[i].life && pv[y/CELL][x/CELL]>4.0f) + parts[i].life = rand()%40+80; + if (parts[i].life) { - if (pv[y/CELL][x/CELL]>4.0f) - { - float advection = 0.1f; - parts[i].vx += advection*vx[y/CELL][x/CELL]; - parts[i].vy += advection*vy[y/CELL][x/CELL]; - parts[i].life = rand()%40+80; - } + float advection = 0.1f; + parts[i].vx += advection*vx[y/CELL][x/CELL]; + parts[i].vy += advection*vy[y/CELL][x/CELL]; } if (!parts[i].ctype) { diff --git a/src/elements/goo.c b/src/elements/goo.c index 0818173db..a3176e1e5 100644 --- a/src/elements/goo.c +++ b/src/elements/goo.c @@ -1,15 +1,13 @@ #include int update_GOO(UPDATE_FUNC_ARGS) { - if (!parts[i].life) + if (!parts[i].life && pv[y/CELL][x/CELL]>1.0f) + parts[i].life = rand()%80+300; + if (parts[i].life) { - if (pv[y/CELL][x/CELL]>1.0f) - { - float advection = 0.1f; - parts[i].vx += advection*vx[y/CELL][x/CELL]; - parts[i].vy += advection*vy[y/CELL][x/CELL]; - parts[i].life = rand()%80+300; - } + float advection = 0.1f; + parts[i].vx += advection*vx[y/CELL][x/CELL]; + parts[i].vy += advection*vy[y/CELL][x/CELL]; } return 0; } diff --git a/src/graphics.c b/src/graphics.c index 29aa3ebc1..ea8d0d545 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -31,6 +31,7 @@ unsigned char fire_b[YRES/CELL][XRES/CELL]; unsigned int fire_alpha[CELL*3][CELL*3]; pixel *fire_bg; +pixel *pers_bg; pixel *rescale_img(pixel *src, int sw, int sh, int *qw, int *qh, int f) { @@ -447,6 +448,8 @@ void draw_tool(pixel *vid_buf, int b, int sl, int sr, unsigned pc, unsigned iswa int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc) { int i, j, c; + if (x > XRES-26 || x < 0) + return 26; if (b>=UI_WALLSTART) { b = b-100; @@ -2961,23 +2964,9 @@ void render_signs(pixel *vid_buf) } drawtext(vid_buf, x+3, y+3, buff, 0, 191, 255, 255); } - if(sregexp(signs[i].text, "^{e:.*|.*}$")==0) - { - int sldr, startm; - memset(buff, 0, sizeof(buff)); - for(sldr=3; signs[i].text[sldr-1] != '|'; sldr++) - startm = sldr + 1; - sldr = startm; - while(signs[i].text[sldr] != '}') - { - buff[sldr - startm] = signs[i].text[sldr]; - sldr++; - } - drawtext(vid_buf, x+3, y+3, buff, 0, 255, 215, 255); - } //Usual text - if(strcmp(signs[i].text, "{p}") && strcmp(signs[i].text, "{t}") && sregexp(signs[i].text, "^{c:[0-9]*|.*}$") && sregexp(signs[i].text, "^{e:.*|.*}$")) + if(strcmp(signs[i].text, "{p}") && strcmp(signs[i].text, "{t}") && sregexp(signs[i].text, "^{c:[0-9]*|.*}$")) drawtext(vid_buf, x+3, y+3, signs[i].text, 255, 255, 255, 255); x = signs[i].x; diff --git a/src/interface.c b/src/interface.c index 07616926e..a762b39d7 100644 --- a/src/interface.c +++ b/src/interface.c @@ -60,8 +60,6 @@ char search_expr[256] = ""; char *tag_names[TAG_MAX]; int tag_votes[TAG_MAX]; -int Z_keysym = 'z'; - int zoom_en = 0; int zoom_x=(XRES-ZSIZE_D)/2, zoom_y=(YRES-ZSIZE_D)/2; int zoom_wx=0, zoom_wy=0; @@ -105,25 +103,9 @@ void get_sign_pos(int i, int *x0, int *y0, int *w, int *h) } *w = textwidth(buff) + 5; } - if(sregexp(signs[i].text, "^{e:.*|.*}$")==0)//character width limit in signs need to be incresed, as most commands don't fit.. - { - int sldr, startm; - char buff[256]; - memset(buff, 0, sizeof(buff)); - for(sldr=3; signs[i].text[sldr-1] != '|'; sldr++) - startm = sldr + 1; - - sldr = startm; - while(signs[i].text[sldr] != '}') - { - buff[sldr - startm] = signs[i].text[sldr]; - sldr++; - } - *w = textwidth(buff) + 5; - } //Ususal width - if (strcmp(signs[i].text, "{p}") && strcmp(signs[i].text, "{t}") && sregexp(signs[i].text, "^{c:[0-9]*|.*}$") && sregexp(signs[i].text, "^{e:.*|.*}$")) + if (strcmp(signs[i].text, "{p}") && strcmp(signs[i].text, "{t}") && sregexp(signs[i].text, "^{c:[0-9]*|.*}$")) *w = textwidth(signs[i].text) + 5; *h = 14; *x0 = (signs[i].ju == 2) ? signs[i].x - *w : @@ -1549,13 +1531,14 @@ void menu_ui(pixel *vid_buf, int i, int *sl, int *sr) void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx, int my) { - int h,x,y,n=0,height,width,sy,rows=0; + int h,x,y,n=0,height,width,sy,rows=0,xoff=0,fwidth; SEC = SEC2; mx /= sdl_scale; my /= sdl_scale; rows = ceil((float)msections[i].itemcount/16.0f); height = (ceil((float)msections[i].itemcount/16.0f)*18); width = restrict_flt(msections[i].itemcount*31, 0, 16*31); + fwidth = msections[i].itemcount*31; h = -1; x = XRES-BARSIZE-18; y = YRES+1; @@ -1566,11 +1549,11 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx, { if (n!=SPC_AIR&&n!=SPC_HEAT&&n!=SPC_COOL&&n!=SPC_VACUUM) { - if (x-18<=2) + /*if (x-18<=2) { x = XRES-BARSIZE-18; y += 19; - } + }*/ x -= draw_tool_xy(vid_buf, x, y, n, mwalls[n-UI_WALLSTART].colour)+5; if (!bq && mx>=x+32 && mx=y && my< y+15) { @@ -1603,11 +1586,11 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx, { if (n==SPC_AIR||n==SPC_HEAT||n==SPC_COOL||n==SPC_VACUUM) { - if (x-18<=0) + /*if (x-18<=0) { x = XRES-BARSIZE-18; y += 19; - } + }*/ x -= draw_tool_xy(vid_buf, x, y, n, mwalls[n-UI_WALLSTART].colour)+5; if (!bq && mx>=x+32 && mx=y && my< y+15) { @@ -1637,11 +1620,11 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx, { if (ptypes[n].menusection==i&&ptypes[n].menu==1) { - if (x-18<=0) + /*if (x-18<=0) { x = XRES-BARSIZE-18; y += 19; - } + }*/ x -= draw_tool_xy(vid_buf, x, y, n, ptypes[n].pcolors)+5; if (!bq && mx>=x+32 && mx=y && my< y+15) { @@ -1670,37 +1653,36 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx, } else { + if (fwidth > XRES-BARSIZE){ + float overflow = fwidth-(XRES-BARSIZE), location = ((float)XRES-BARSIZE)/((float)(mx-(XRES-BARSIZE))); + xoff = (int)(overflow / location); + } for (n = 0; n=x+32-xoff && mx=y && my< y+15) { - x = XRES-BARSIZE-18; - y += 19; - } - x -= draw_tool_xy(vid_buf, x, y, n, ptypes[n].pcolors)+5; - if (!bq && mx>=x+32 && mx=y && my< y+15) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + drawrect(vid_buf, x+30-xoff, y-1, 29, 17, 255, 0, 0, 255); h = n; } - if (!bq && mx>=x+32 && mx=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))) + if (!bq && mx>=x+32-xoff && mx=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))) { - drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255); + drawrect(vid_buf, x+30-xoff, y-1, 29, 17, 0, 255, 255, 255); h = n; } else if (n==SLALT) { - drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255); + drawrect(vid_buf, x+30-xoff, y-1, 29, 17, 0, 255, 255, 255); } else if (n==*sl) { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + drawrect(vid_buf, x+30-xoff, y-1, 29, 17, 255, 0, 0, 255); } else if (n==*sr) { - drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255); + drawrect(vid_buf, x+30-xoff, y-1, 29, 17, 0, 0, 255, 255); } } } @@ -1779,10 +1761,9 @@ int sdl_poll(void) sdl_ascii=event.key.keysym.unicode; if (event.key.keysym.sym == SDLK_CAPSLOCK) sdl_caps = 1; - if (event.key.keysym.unicode=='z' || event.key.keysym.unicode=='Z') + if (event.key.keysym.sym=='z') { sdl_zoom_trig = 1; - Z_keysym = event.key.keysym.sym; } if ( event.key.keysym.sym == SDLK_PLUS) { @@ -1832,7 +1813,7 @@ int sdl_poll(void) case SDL_KEYUP: if (event.key.keysym.sym == SDLK_CAPSLOCK) sdl_caps = 0; - if (event.key.keysym.sym == Z_keysym) + if (event.key.keysym.sym == 'z') sdl_zoom_trig = 0; if (event.key.keysym.sym == SDLK_RIGHT || event.key.keysym.sym == SDLK_LEFT) { @@ -1908,6 +1889,7 @@ void set_cmode(int cm) 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"); } else if (cmode==CM_PRESS) @@ -1941,6 +1923,7 @@ void set_cmode(int cm) { strcpy(itc_msg, "Velocity Display"); } + save_presets(0); } char *download_ui(pixel *vid_buf, char *uri, int *len) @@ -3857,7 +3840,7 @@ struct command_history { typedef struct command_history command_history; command_history *last_command = NULL; char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show previous commands - int mx,my,b,bq,cc,ci = -1; + int mx,my,b,cc,ci = -1; command_history *currentcommand; ui_edit ed; ed.x = 15; @@ -3873,7 +3856,6 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show //fillrect(vid_buf, -1, -1, XRES, 220, 0, 0, 0, 190); while (!sdl_poll()) { - bq = b; b = SDL_GetMouseState(&mx, &my); mx /= sdl_scale; my /= sdl_scale; @@ -3968,6 +3950,7 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show } } } + console_mode = 0; return NULL; } @@ -4010,9 +3993,9 @@ int console_parse_coords(char *txt, int *x, int *y, char *err) } int console_parse_partref(char *txt, int *which, char *err) { + int i = -1, nx, ny; strcpy(err,""); // TODO: use regex? - int i = -1, nx, ny; if (strchr(txt,',') && console_parse_coords(txt, &nx, &ny, err)) { i = pmap[ny][nx]; diff --git a/src/main.c b/src/main.c index 568b07002..3fa2828f9 100644 --- a/src/main.c +++ b/src/main.c @@ -169,7 +169,8 @@ int FPSB = 0; int MSIGN =-1; //int CGOL = 0; //int GSPEED = 1;//causes my .exe to crash.. -int sound_enable; +int sound_enable = 0; +int file_script = 0; sign signs[MAXSIGNS]; @@ -440,11 +441,11 @@ void *build_save(int *size, int x0, int y0, int w, int h) //New file header uses PSv, replacing fuC. This is to detect if the client uses a new save format for temperatures //This creates a problem for old clients, that display and "corrupt" error instead of a "newer version" error - + c[0] = 0x50; //0x66; c[1] = 0x53; //0x75; c[2] = 0x76; //0x43; - c[3] = legacy_enable|((sys_pause<<1)&0x02); + c[3] = legacy_enable|((sys_pause<<1)&0x02)|((gravityMode<<2)&0x0C)|((airMode<<4)&0x70); c[4] = SAVE_VERSION; c[5] = CELL; c[6] = bw; @@ -500,6 +501,10 @@ int parse_save(void *save, int size, int replace, int x0, int y0) if (!sys_pause) { sys_pause = (c[3]>>1)&0x01; } + if(ver>=46 && replace) { + gravityMode = ((c[3]>>2)&0x03);// | ((c[3]>>2)&0x01); + airMode = ((c[3]>>4)&0x07);// | ((c[3]>>4)&0x02) | ((c[3]>>4)&0x01); + } } else { if (c[3]==1||c[3]==0) { legacy_enable = c[3]; @@ -545,8 +550,10 @@ int parse_save(void *save, int size, int replace, int x0, int y0) if (replace) { - gravityMode = 1; - airMode = 1; + if(ver<46){ + gravityMode = 0; + airMode = 0; + } memset(bmap, 0, sizeof(bmap)); memset(emap, 0, sizeof(emap)); memset(signs, 0, sizeof(signs)); @@ -1174,7 +1181,7 @@ int main(int argc, char *argv[]) #ifdef BETA int is_beta = 0; #endif - char uitext[255] = ""; + char uitext[512] = ""; char heattext[128] = ""; char coordtext[13] = ""; int currentTime = 0; @@ -1182,7 +1189,6 @@ int main(int argc, char *argv[]) int pastFPS = 0; int past = 0; pixel *vid_buf=calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE); - pixel *pers_bg=calloc((XRES+BARSIZE)*YRES, PIXELSIZE); void *http_ver_check; void *http_session_check = NULL; char *ver_data=NULL, *check_data=NULL, *tmp; @@ -1198,9 +1204,10 @@ int main(int argc, char *argv[]) void *load_data=NULL; pixel *load_img=NULL;//, *fbi_img=NULL; int save_mode=0, save_x=0, save_y=0, save_w=0, save_h=0, copy_mode=0; + SDL_AudioSpec fmt; + int username_flash = 0, username_flash_t = 1; GSPEED = 1; - SDL_AudioSpec fmt; /* Set 16-bit stereo audio at 22Khz */ fmt.freq = 22050; fmt.format = AUDIO_S16; @@ -1208,16 +1215,7 @@ int main(int argc, char *argv[]) fmt.samples = 512; fmt.callback = mixaudio; fmt.userdata = NULL; - /* Open the audio device and start playing sound! */ - if ( SDL_OpenAudio(&fmt, NULL) < 0 ) - { - fprintf(stderr, "Unable to open audio: %s\n", SDL_GetError()); - } - else - { - sound_enable = 1; - SDL_PauseAudio(0); - } + #ifdef MT numCores = core_count(); #endif @@ -1242,6 +1240,7 @@ int main(int argc, char *argv[]) parts[NPART-1].life = -1; pfree = 0; fire_bg=calloc(XRES*YRES, PIXELSIZE); + pers_bg=calloc((XRES+BARSIZE)*YRES, PIXELSIZE); memset(signs, 0, sizeof(signs)); //fbi_img = render_packed_rgb(fbi, FBI_W, FBI_H, FBI_CMP); @@ -1266,9 +1265,27 @@ int main(int argc, char *argv[]) else if (!strncmp(argv[i], "kiosk", 5)) { kiosk_enable = 1; - sdl_scale = 2; + //sdl_scale = 2; //Removed because some displays cannot handle the resolution hud_enable = 0; } + else if (!strncmp(argv[i], "sound", 5)) + { + /* Open the audio device and start playing sound! */ + if ( SDL_OpenAudio(&fmt, NULL) < 0 ) + { + fprintf(stderr, "Unable to open audio: %s\n", SDL_GetError()); + } + else + { + sound_enable = 1; + SDL_PauseAudio(0); + } + } + else if (!strncmp(argv[i], "scripts", 5)) + { + file_script = 1; + } + } save_presets(0); @@ -1385,7 +1402,6 @@ int main(int argc, char *argv[]) check_data = http_async_req_stop(http_session_check, &http_s_ret, NULL); if(http_ret==200 && check_data) { - printf("{%s}\n", check_data); if(!strncmp(check_data, "EXPIRED", 7)) { //Session expired @@ -1409,6 +1425,7 @@ int main(int argc, char *argv[]) svf_own = 0; svf_admin = 0; svf_mod = 0; + error_ui(vid_buf, "Unable to log in", "Your account has been suspended, consider reading the rules."); } else if(!strncmp(check_data, "OK", 2)) { @@ -1426,7 +1443,6 @@ int main(int argc, char *argv[]) svf_mod = 1; } } - save_presets(0); } else { @@ -1440,9 +1456,26 @@ int main(int argc, char *argv[]) svf_admin = 0; svf_mod = 0; } + save_presets(0); free(check_data); } http_session_check = NULL; + } else { + clearrect(vid_buf, XRES-125+BARSIZE/*385*/, YRES+(MENUSIZE-16), 91, 14); + drawrect(vid_buf, XRES-125+BARSIZE/*385*/, YRES+(MENUSIZE-16), 91, 14, 255, 255, 255, 255); + drawtext(vid_buf, XRES-122+BARSIZE/*388*/, YRES+(MENUSIZE-13), "\x84", 255, 255, 255, 255); + if(username_flash>30){ + username_flash_t = -1; + username_flash = 30; + } else if(username_flash<0) { + username_flash_t = 1; + username_flash = 0; + } + username_flash += username_flash_t; + if (svf_login) + drawtext(vid_buf, XRES-104+BARSIZE/*406*/, YRES+(MENUSIZE-12), svf_user, 255, 255, 255, 175-(username_flash*5)); + else + drawtext(vid_buf, XRES-104+BARSIZE/*406*/, YRES+(MENUSIZE-12), "[checking]", 255, 255, 255, 255); } do_s_check = (do_s_check+1) & 15; } @@ -1691,10 +1724,10 @@ int main(int argc, char *argv[]) default: gravityMode = 0; case 0: - strcpy(itc_msg, "Gravity: Off"); + strcpy(itc_msg, "Gravity: Vertical"); break; case 1: - strcpy(itc_msg, "Gravity: Vertical"); + strcpy(itc_msg, "Gravity: Off"); break; case 2: strcpy(itc_msg, "Gravity: Radial"); @@ -1702,33 +1735,32 @@ int main(int argc, char *argv[]) } } - - if (sdl_key=='y') - { - ++airMode; - itc = 52; - switch (airMode) - { - default: - airMode = 0; - case 0: - strcpy(itc_msg, "Air: On"); - break; - case 1: - strcpy(itc_msg, "Air: Pressure Off"); - break; - case 2: - strcpy(itc_msg, "Air: Velocity Off"); - break; - case 3: - strcpy(itc_msg, "Air: Off"); - break; - case 4: - strcpy(itc_msg, "Air: No Update"); - break; - } - } - + if (sdl_key=='y') + { + ++airMode; + itc = 52; + + switch (airMode) + { + default: + airMode = 0; + case 0: + strcpy(itc_msg, "Air: On"); + break; + case 1: + strcpy(itc_msg, "Air: Pressure Off"); + break; + case 2: + strcpy(itc_msg, "Air: Velocity Off"); + break; + case 3: + strcpy(itc_msg, "Air: Off"); + break; + case 4: + strcpy(itc_msg, "Air: No Update"); + break; + } + } if (sdl_key=='t') VINE_MODE = !VINE_MODE; @@ -1930,35 +1962,29 @@ int main(int argc, char *argv[]) } if (!((cr>>8)>=NPART || !cr)) { -#ifdef BETA if (DEBUG_MODE) { int tctype = parts[cr>>8].ctype; if (tctype>=PT_NUM) tctype = 0; - sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d, #%d", ptypes[cr&0xFF].name, ptypes[tctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life, cr>>8); - //sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[parts[cr>>8].ctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life); - } else + sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[tctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life); + sprintf(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", ptypes[cr&0xFF].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life); #else - if (DEBUG_MODE) - { - int tctype = parts[cr>>8].ctype; - if (tctype>=PT_NUM) - tctype = 0; - sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d, #%d", ptypes[cr&0xFF].name, ptypes[tctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life ,cr>>8); - //sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[parts[cr>>8].ctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life); - } else { sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C", ptypes[cr&0xFF].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f); - } #endif + } } else { sprintf(heattext, "Empty, Pressure: %3.2f", pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL]); + if (DEBUG_MODE) + { + sprintf(coordtext, "X:%d Y:%d", x/sdl_scale, y/sdl_scale); + } } - if (DEBUG_MODE) - sprintf(coordtext, "X:%d Y:%d", x/sdl_scale, y/sdl_scale); } mx = x; my = y; @@ -2109,7 +2135,7 @@ int main(int argc, char *argv[]) if (!sdl_zoom_trig && zoom_en==1) zoom_en = 0; - if (sdl_key==Z_keysym && zoom_en==2) + if (sdl_key=='z' && zoom_en==2) zoom_en = 1; if (load_mode) @@ -2277,7 +2303,7 @@ int main(int argc, char *argv[]) svf_name[0] = 0; svf_tags[0] = 0; svf_description[0] = 0; - gravityMode = 1; + gravityMode = 0; airMode = 0; death = death2 = 0; isplayer2 = 0; @@ -2286,6 +2312,7 @@ int main(int argc, char *argv[]) ISSPAWN2 = 0; 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)); memset(fire_b, 0, sizeof(fire_b)); @@ -2293,8 +2320,10 @@ int main(int argc, char *argv[]) if (x>=(XRES+BARSIZE-(510-385)) && x<=(XRES+BARSIZE-(510-476))) { login_ui(vid_buf); - if (svf_login) + if (svf_login){ save_presets(0); + http_session_check = NULL; + } } if (x>=37 && x<=187 && svf_login) { @@ -2314,6 +2343,7 @@ int main(int argc, char *argv[]) { 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)); memset(fire_b, 0, sizeof(fire_b)); @@ -2335,7 +2365,6 @@ int main(int argc, char *argv[]) set_cmode((cmode+(CM_COUNT-1)) % CM_COUNT); } } - save_presets(0); } if (x>=(XRES+BARSIZE-(510-494)) && x<=(XRES+BARSIZE-(510-509)) && !bq) sys_pause = !sys_pause; @@ -2353,7 +2382,6 @@ int main(int argc, char *argv[]) { if(!bq) for(signi=0; signi=signx && x<=signx+signw && y>=signy && y<=signy+signh) - { - char buff[256]; - int sldr; - - memset(buff, 0, sizeof(buff)); - - for(sldr=3; signs[signi].text[sldr] != '|'; sldr++) - buff[sldr-3] = signs[signi].text[sldr]; - - char buff2[sldr-2]; //TODO: Fix this for Visual Studio - memset(buff2, 0, sizeof(buff2)); - memcpy(&buff2, &buff, sldr-3); - process_command(vid_buf, buff2,console_error); - } - } - } } if (c==WL_SIGN+100) @@ -2676,10 +2681,10 @@ int main(int argc, char *argv[]) } #ifdef BETA - sprintf(uitext, "Version %d Beta %d FPS:%d Parts:%d Generation:%d", SAVE_VERSION, MINOR_VERSION, FPSB, NUM_PARTS,GENERATION); + sprintf(uitext, "Version %d Beta %d FPS:%d Parts:%d Generation:%d Gravity:%d Air:%d", SAVE_VERSION, MINOR_VERSION, FPSB, NUM_PARTS, GENERATION, gravityMode, airMode); #else if (DEBUG_MODE) - sprintf(uitext, "Version %d.%d FPS:%d Parts:%d Generation:%d", SAVE_VERSION, MINOR_VERSION, FPSB, NUM_PARTS,GENERATION); + sprintf(uitext, "Version %d.%d FPS:%d Parts:%d Generation:%d Gravity:%d Air:%d", SAVE_VERSION, MINOR_VERSION, FPSB, NUM_PARTS, GENERATION, gravityMode, airMode); else sprintf(uitext, "Version %d.%d FPS:%d", SAVE_VERSION, MINOR_VERSION, FPSB); #endif @@ -2772,84 +2777,93 @@ int process_command(pixel *vid_buf,char *console,char *console_error) { } else if(strcmp(console2, "file")==0 && console3) { - FILE *f=fopen(console3, "r"); - if(f) - { - nx = 0; - ny = 0; - j = 0; - m = 0; - if(console4) - console_parse_coords(console4, &nx , &ny, console_error); - char fileread[5000];//TODO: make this change with file size - char pch[5000]; - memset(pch,0,sizeof(pch)); - memset(fileread,0,sizeof(fileread)); - char tokens[10]; - int tokensize; - fread(fileread,1,5000,f); - for(i=0; i>8)==e) pmap[ny][nx] = 0; parts[e].x += x-nx; parts[e].y += y-ny; pmap[(int)(parts[e].y+0.5f)][(int)(parts[e].x+0.5f)] = (e<<8)|parts[e].type; @@ -453,8 +454,8 @@ _inline void part_change_type(int i, int x, int y, int t) inline void part_change_type(int i, int x, int y, int t) #endif { - if (x<0 || y<0 || x>=XRES || y>=YRES || i>=NPART) - return -1; + if (x<0 || y<0 || x>=XRES || y>=YRES || i>=NPART || t<0 || t>=PT_NUM) + return; parts[i].type = t; if (t==PT_PHOT)// || t==PT_NEUT) { @@ -484,7 +485,7 @@ inline int create_n_parts(int n, int x, int y, float vx, float vy, int t) if (n>680) { n = 680; } - if (x<0 || y<0 || x>=XRES || y>=YRES) + if (x<0 || y<0 || x>=XRES || y>=YRES || t<0 || t>=PT_NUM) return -1; for (c; c=XRES || y>=YRES) + if (x<0 || y<0 || x>=XRES || y>=YRES || ((t<0 || t>=PT_NUM)&&t!=SPC_HEAT&&t!=SPC_COOL&&t!=SPC_AIR&&t!=SPC_VACUUM)) return -1; if (t==SPC_HEAT||t==SPC_COOL) @@ -1134,7 +1135,7 @@ int nearest_part(int ci, int t) void update_particles_i(pixel *vid, int start, int inc) { - int i, j, x, y, t, nx, ny, r, surround_space, s, lt, rt, nt, nnx, nny, q, golnum, goldelete, z, neighbors; + int i, j, x, y, t, nx, ny, r, surround_space, s, lt, rt, nt, nnx, nny, q, golnum, goldelete, z, neighbors, createdsomething; float mv, dx, dy, ix, iy, lx, ly, nrx, nry, dp, ctemph, ctempl; int fin_x, fin_y, clear_x, clear_y; float fin_xf, fin_yf, clear_xf, clear_yf; @@ -1337,14 +1338,14 @@ void update_particles_i(pixel *vid, int start, int inc) if(neighbors==0 || !(ptypes[r&0xFF].properties&PROP_LIFE || !r&0xFF) || (r>>8)>=NPART) continue; for ( golnum = 1; golnum<=NGOL; golnum++) - for ( goldelete = 0; goldelete<9; goldelete++) { - if (neighbors==goldelete&&gol[nx][ny]==0&&grule[golnum][goldelete]>=2&&gol2[nx][ny][golnum]>=(goldelete%2)+goldelete/2) + goldelete = neighbors; + if (gol[nx][ny]==0&&grule[golnum][goldelete]>=2&&gol2[nx][ny][golnum]>=(goldelete%2)+goldelete/2) { if (create_part(-1,nx,ny,goltype[golnum-1])) createdsomething = 1; } - else if (neighbors-1==goldelete&&gol[nx][ny]==golnum&&(grule[golnum][goldelete]==0||grule[golnum][goldelete]==2))//subtract 1 because it counted itself + else if (gol[nx][ny]==golnum&&(grule[golnum][goldelete-1]==0||grule[golnum][goldelete-1]==2))//subtract 1 because it counted itself { if(parts[r>>8].tmp==grule[golnum][9]-1) parts[r>>8].tmp --; @@ -1442,21 +1443,18 @@ void update_particles_i(pixel *vid, int start, int inc) //Gravity mode by Moach switch (gravityMode) { - default: - case 0: - pGravX = pGravY = 0.0f; - break; - case 1: - pGravX = 0.0f; - pGravY = ptypes[t].gravity; - break; - case 2: - - pGravD = 0.01f - hypotf((x - XCNTR), (y - YCNTR)); - - pGravX = ptypes[t].gravity * ((float)(x - XCNTR) / pGravD); - pGravY = ptypes[t].gravity * ((float)(y - YCNTR) / pGravD); - + default: + case 0: + pGravX = 0.0f; + pGravY = ptypes[t].gravity; + break; + case 1: + pGravX = pGravY = 0.0f; + break; + case 2: + pGravD = 0.01f - hypotf((x - XCNTR), (y - YCNTR)); + pGravX = ptypes[t].gravity * ((float)(x - XCNTR) / pGravD); + pGravY = ptypes[t].gravity * ((float)(y - YCNTR) / pGravD); } parts[i].vx *= ptypes[t].loss; @@ -1782,6 +1780,9 @@ killed: } } + rt = parts[i].flags & FLAG_STAGNANT; + parts[i].flags &= ~FLAG_STAGNANT; + if ((t==PT_PHOT||t==PT_NEUT)) { if (t == PT_PHOT) { rt = pmap[fin_y][fin_x] & 0xFF; @@ -2010,24 +2011,25 @@ killed: break; } } - else if (clear_x!=x&&clear_y!=y && try_move(i, x, y, clear_x, clear_y)) { + else if ((clear_x!=x||clear_y!=y) && try_move(i, x, y, clear_x, clear_y)) { // if interpolation was done and haven't yet moved, try moving to last clear position parts[i].x = clear_xf; parts[i].y = clear_yf; } + else + parts[i].flags |= FLAG_STAGNANT; parts[i].vx *= ptypes[t].collision; parts[i].vy *= ptypes[t].collision; - if (!s) - parts[i].flags |= FLAG_STAGNANT; } else { - if (clear_x!=x&&clear_y!=y && try_move(i, x, y, clear_x, clear_y)) { + if ((clear_x!=x||clear_y!=y) && try_move(i, x, y, clear_x, clear_y)) { // if interpolation was done, try moving to last clear position parts[i].x = clear_xf; parts[i].y = clear_yf; } - parts[i].flags |= FLAG_STAGNANT; + else + parts[i].flags |= FLAG_STAGNANT; parts[i].vx *= ptypes[t].collision; parts[i].vy *= ptypes[t].collision; } @@ -2710,7 +2712,7 @@ void create_box(int x1, int y1, int x2, int y2, int c) } for (j=y1; j<=y2; j++) for (i=x1; i<=x2; i++) - create_parts(i, j, 1, 1, c); + create_parts(i, j, 0, 0, c); } int flood_parts(int x, int y, int c, int cm, int bm) From bdcc6e3fbaf4af4604c711652646552c34144b11 Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Tue, 22 Feb 2011 20:55:50 -0500 Subject: [PATCH 07/15] Reduce GoL lag --- src/powder.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/powder.c b/src/powder.c index b6aab3270..2cb8e24b8 100644 --- a/src/powder.c +++ b/src/powder.c @@ -1353,10 +1353,12 @@ void update_particles_i(pixel *vid, int start, int inc) if (r && parts[r>>8].tmp<=0) parts[r>>8].type = PT_NONE;//using kill_part makes it not work } + for( z = 0;z<=NGOL;z++) + gol2[nx][ny][z] = 0;//this improves performance A LOT compared to the memset, i was getting ~23 more fps with this. } if (createdsomething) GENERATION ++; - memset(gol2, 0, sizeof(gol2)); + //memset(gol2, 0, sizeof(gol2)); } if (ISWIRE==1) { From cf80586ddc0e49e8bde1326af69d22016e9aede3 Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Wed, 23 Feb 2011 13:33:36 -0500 Subject: [PATCH 08/15] Fix GoL to not set gol2 on other things --- src/powder.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/powder.c b/src/powder.c index 2cb8e24b8..605964095 100644 --- a/src/powder.c +++ b/src/powder.c @@ -1320,8 +1320,12 @@ void update_particles_i(pixel *vid, int start, int inc) for ( nnx=-1; nnx<2; nnx++) for ( nny=-1; nny<2; nny++)//it will count itself as its own neighbor, which is needed, but will have 1 extra for delete check { - gol2[((nx+nnx+XRES-3*CELL)%(XRES-2*CELL))+CELL][((ny+nny+YRES-3*CELL)%(YRES-2*CELL))+CELL][golnum] ++; - gol2[((nx+nnx+XRES-3*CELL)%(XRES-2*CELL))+CELL][((ny+nny+YRES-3*CELL)%(YRES-2*CELL))+CELL][0] ++; + rt = pmap[((ny+nny+YRES-3*CELL)%(YRES-2*CELL))+CELL][((nx+nnx+XRES-3*CELL)%(XRES-2*CELL))+CELL]; + if (!rt || ptypes[rt&0xFF].properties&PROP_LIFE) + { + gol2[((nx+nnx+XRES-3*CELL)%(XRES-2*CELL))+CELL][((ny+nny+YRES-3*CELL)%(YRES-2*CELL))+CELL][golnum] ++; + gol2[((nx+nnx+XRES-3*CELL)%(XRES-2*CELL))+CELL][((ny+nny+YRES-3*CELL)%(YRES-2*CELL))+CELL][0] ++; + } } } else { parts[r>>8].tmp --; From a53d956d8dea008f6719b3d537c0e1d204c476c0 Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Wed, 23 Feb 2011 21:55:33 -0500 Subject: [PATCH 09/15] transparent console.... --- src/interface.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/interface.c b/src/interface.c index a762b39d7..5e8eed45f 100644 --- a/src/interface.c +++ b/src/interface.c @@ -3841,6 +3841,7 @@ typedef struct command_history command_history; command_history *last_command = NULL; char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show previous commands int mx,my,b,cc,ci = -1; + pixel *old_buf=calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE); command_history *currentcommand; ui_edit ed; ed.x = 15; @@ -3853,7 +3854,9 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show ed.hide = 0; ed.multiline = 0; ed.cursor = 0; - //fillrect(vid_buf, -1, -1, XRES, 220, 0, 0, 0, 190); + memcpy(old_buf,vid_buf,(XRES+BARSIZE)*YRES*PIXELSIZE); + fillrect(old_buf, -1, -1, XRES, 220, 0, 0, 0, 190); + while (!sdl_poll()) { b = SDL_GetMouseState(&mx, &my); @@ -3861,19 +3864,11 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show my /= sdl_scale; ed.focus = 1; - clearrect(vid_buf, 0, 0, XRES+BARSIZE, 220);//anyway to make it transparent? + //clearrect(vid_buf, 0, 0, XRES+BARSIZE, 220);//anyway to make it transparent? + memcpy(vid_buf,old_buf,(XRES+BARSIZE)*YRES*PIXELSIZE); draw_line(vid_buf, 1, 219, XRES, 219, 228, 228, 228, XRES+BARSIZE); - drawtext(vid_buf, 100, 15, "Welcome to The Powder Toy console v.2 (by cracker64)\n" - "Current commands are quit, set, reset, load, create, file, kill, sound\n" - "You can set type, temp, ctype, life, x, y, vx, vy using this format ('set life particle# 9001')\n" - "You can also use 'all' instead of a particle number to do it to everything.\n" - "You can now use particle names (ex. set type all deut)\n" - "Reset works with pressure, velocity, sparks, temp (ex. 'reset pressure')\n" - "To load a save use load saveID (ex. load 1337)\n" - "Create particles with 'create deut x,y' where x and y are the coords\n" - "Run scripts from file 'file filename'\n" - "You can delete/kill a particle with 'kill x,y'" - "Play a sound with (sound blah.wav)" + drawtext(vid_buf, 100, 15, "Welcome to The Powder Toy console v.3 (by cracker64)\n" + "Current commands are quit, set, reset, load, create, file, kill, sound\n" //TODO: help command ,255, 187, 187, 255); cc = 0; @@ -3911,11 +3906,13 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show currentcommand->prev_command = last_command; currentcommand->command = mystrdup(ed.str); last_command = currentcommand; + free(old_buf); return currentcommand->command; } if (sdl_key==SDLK_ESCAPE || sdl_key==SDLK_BACKQUOTE) { console_mode = 0; + free(old_buf); return NULL; } if(sdl_key==SDLK_UP || sdl_key==SDLK_DOWN) @@ -3951,6 +3948,7 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show } } console_mode = 0; + free(old_buf); return NULL; } From 98a61e0e201d90157ca9c77b9e996663d12e9dff Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Thu, 24 Feb 2011 00:26:37 -0500 Subject: [PATCH 10/15] a drag tool! --- src/main.c | 17 ++++++++++++++--- src/powder.c | 2 ++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main.c b/src/main.c index 3fa2828f9..16e5ce31e 100644 --- a/src/main.c +++ b/src/main.c @@ -1183,7 +1183,7 @@ int main(int argc, char *argv[]) #endif char uitext[512] = ""; char heattext[128] = ""; - char coordtext[13] = ""; + char coordtext[128] = ""; int currentTime = 0; int FPS = 0; int pastFPS = 0; @@ -2436,7 +2436,18 @@ int main(int argc, char *argv[]) } else { - create_line(lx, ly, x, y, bsx, bsy, c); + if (c == PT_DRAG) + { + for (j=-bsy; j<=bsy; j++) + for (i=-bsx; i<=bsx; i++) + if ((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(bsx,2))+(pow(j,2))/(pow(bsy,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=bsy*bsx)) + { + vx[(y+j)/CELL][(x+i)/CELL] += (x-lx)*0.01f; + vy[(y+j)/CELL][(x+i)/CELL] += (y-ly)*0.01f; + } + } + else + create_line(lx, ly, x, y, bsx, bsy, c); lx = x; ly = y; } @@ -2461,7 +2472,7 @@ int main(int argc, char *argv[]) { if (sdl_mod & (KMOD_CAPS)) c = 0; - if (c!=WL_STREAM+100&&c!=SPC_AIR&&c!=SPC_HEAT&&c!=SPC_COOL&&c!=SPC_VACUUM&&!REPLACE_MODE) + if (c!=WL_STREAM+100&&c!=SPC_AIR&&c!=SPC_HEAT&&c!=SPC_COOL&&c!=SPC_VACUUM&&!REPLACE_MODE&&c!=PT_DRAG) flood_parts(x, y, c, -1, -1); if (c==SPC_HEAT || c==SPC_COOL) create_parts(x, y, bsx, bsy, c); diff --git a/src/powder.c b/src/powder.c index 605964095..8decfba98 100644 --- a/src/powder.c +++ b/src/powder.c @@ -2860,6 +2860,8 @@ int create_parts(int x, int y, int rx, int ry, int c) b = WL_FANHELPER; dw = 1; } + if (c == PT_DRAG) + return 1; if (dw==1) { rx = rx/CELL; From bf24a261397636d194748ba241620655b470a69e Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Thu, 24 Feb 2011 00:51:09 -0500 Subject: [PATCH 11/15] forgot powder.h, and renamed drag to wind --- includes/powder.h | 7 +++++-- src/main.c | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/includes/powder.h b/includes/powder.h index 9964abadd..a78d35f49 100644 --- a/includes/powder.h +++ b/includes/powder.h @@ -196,7 +196,8 @@ #define PT_STAR 144 #define PT_FROG 145 #define PT_BRAN 146 -#define PT_NUM 147 +#define PT_WIND 147 +#define PT_NUM 148 #define R_TEMP 22 #define MAX_TEMP 9999 @@ -516,7 +517,8 @@ static const part_type ptypes[PT_NUM] = {"STAR", PIXPACK(0x0000FF), 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_LIFE, 9000.0f, 40, "Like Star Wars rule S3456/B278/6", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, {"FROG", PIXPACK(0x00AA00), 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_LIFE, 9000.0f, 40, "Frogs S12/B34/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, {"BRAN", PIXPACK(0xCCCC00), 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_LIFE, 9000.0f, 40, "Brian 6 S6/B246/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, - //Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Weights Section H Ins Description + {"WIND", PIXPACK(0x000000), 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_SPECIAL, 0.0f, 40, "Drag tool", ST_NONE, ST_NONE, NULL}, +//Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Weights Section H Ins Description }; // temporarily define abbreviations for impossible p/t values @@ -678,6 +680,7 @@ static part_transition ptransitions[PT_NUM] = /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* WIND */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, }; #undef IPL #undef IPH diff --git a/src/main.c b/src/main.c index 16e5ce31e..178a38b13 100644 --- a/src/main.c +++ b/src/main.c @@ -2436,7 +2436,7 @@ int main(int argc, char *argv[]) } else { - if (c == PT_DRAG) + if (c == PT_WIND) { for (j=-bsy; j<=bsy; j++) for (i=-bsx; i<=bsx; i++) @@ -2472,7 +2472,7 @@ int main(int argc, char *argv[]) { if (sdl_mod & (KMOD_CAPS)) c = 0; - if (c!=WL_STREAM+100&&c!=SPC_AIR&&c!=SPC_HEAT&&c!=SPC_COOL&&c!=SPC_VACUUM&&!REPLACE_MODE&&c!=PT_DRAG) + if (c!=WL_STREAM+100&&c!=SPC_AIR&&c!=SPC_HEAT&&c!=SPC_COOL&&c!=SPC_VACUUM&&!REPLACE_MODE&&c!=PT_WIND) flood_parts(x, y, c, -1, -1); if (c==SPC_HEAT || c==SPC_COOL) create_parts(x, y, bsx, bsy, c); From 83d89ad4cd4c23b85a6581e5f44f101a64e2f119 Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Thu, 24 Feb 2011 00:52:37 -0500 Subject: [PATCH 12/15] rename drag to wind --- src/powder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/powder.c b/src/powder.c index 8decfba98..c8fc40b4d 100644 --- a/src/powder.c +++ b/src/powder.c @@ -2860,7 +2860,7 @@ int create_parts(int x, int y, int rx, int ry, int c) b = WL_FANHELPER; dw = 1; } - if (c == PT_DRAG) + if (c == PT_WIND) return 1; if (dw==1) { From 30ceffa46dfae19c2422077faf4be27f6c3ab2a0 Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Mon, 28 Feb 2011 19:48:53 -0500 Subject: [PATCH 13/15] INST works with caps lock/replace mode, and fix some replace mode out of screen crashes. --- src/powder.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/powder.c b/src/powder.c index c8fc40b4d..dcdda771f 100644 --- a/src/powder.c +++ b/src/powder.c @@ -2759,7 +2759,7 @@ int flood_parts(int x, int y, int c, int cm, int bm) bm = 0; } - if (((pmap[y][x]&0xFF)!=cm || bmap[y/CELL][x/CELL]!=bm )||( (sdl_mod & (KMOD_CAPS)) && cm!=SLALT)) + if (((pmap[y][x]&0xFF)!=cm || bmap[y/CELL][x/CELL]!=bm )||( (sdl_mod & (KMOD_CAPS)) && cm!=SLALT && !(cm==PT_INST&&co==PT_SPRK))) return 1; // go left as far as possible @@ -2784,7 +2784,12 @@ int flood_parts(int x, int y, int c, int cm, int bm) // fill span for (x=x1; x<=x2; x++) { - if (!create_parts(x, y, 0, 0, co)) + if(cm==PT_INST&&co==PT_SPRK) + { + if(create_part(-1,x, y, co)==-1) + return 0; + } + else if (!create_parts(x, y, 0, 0, co)) return 0; } // fill children @@ -2933,10 +2938,14 @@ int create_parts(int x, int y, int rx, int ry, int c) for (j=-ry; j<=ry; j++) for (i=-rx; i<=rx; i++) if ((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx)) + { + if( x+i<0 || y+j<0 || x+i>=XRES || y+j>=YRES) + continue; if (!REPLACE_MODE) create_part(-2, x+i, y+j, c); else if ((pmap[y+j][x+i]&0xFF)==SLALT&&SLALT!=0) create_part(-2, x+i, y+j, c); + } return 1; } @@ -2975,6 +2984,8 @@ int create_parts(int x, int y, int rx, int ry, int c) for (i=-rx; i<=rx; i++) if ((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx)) { + if( x+i<0 || y+j<0 || x+i>=XRES || y+j>=YRES) + continue; if ((pmap[y+j][x+i]&0xFF)!=SLALT&&SLALT!=0) continue; if ((pmap[y+j][x+i])) From 13e90886c1d4ae571707c8f31a7702fce7b2ec74 Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Tue, 1 Mar 2011 13:33:10 -0500 Subject: [PATCH 14/15] fix "water spark bounce" --- src/powder.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/powder.c b/src/powder.c index dcdda771f..af9180885 100644 --- a/src/powder.c +++ b/src/powder.c @@ -79,6 +79,9 @@ int eval_move(int pt, int nx, int ny, unsigned *rr) if ((r&0xFF)==PT_VOID || (r&0xFF)==PT_BHOL) return 1; + if(pt==PT_SPRK)//spark shouldn't move + return 0; + if (pt==PT_PHOT&&( (r&0xFF)==PT_GLAS || (r&0xFF)==PT_PHOT || (r&0xFF)==PT_CLNE || (r&0xFF)==PT_PCLN || From ca1cd0da065a1774dbeeba161139f580ab7f711a Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Mon, 7 Mar 2011 00:32:04 -0500 Subject: [PATCH 15/15] check bounds for wind, causes some funny glitches though. --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 178a38b13..6795f5148 100644 --- a/src/main.c +++ b/src/main.c @@ -2440,7 +2440,7 @@ int main(int argc, char *argv[]) { for (j=-bsy; j<=bsy; j++) for (i=-bsx; i<=bsx; i++) - if ((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(bsx,2))+(pow(j,2))/(pow(bsy,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=bsy*bsx)) + if (x+i>0 && y+j>0 && x+i