From 2656bcec2bc9e14dca844195fab3d3c676fc7689 Mon Sep 17 00:00:00 2001 From: Jacob1 Date: Wed, 23 May 2012 18:54:25 -0400 Subject: [PATCH 01/20] fix compiling --- src/elements/gel.c | 5 +++-- src/main.c | 4 ++-- src/powder.c | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/elements/gel.c b/src/elements/gel.c index e55834294..c64591a02 100644 --- a/src/elements/gel.c +++ b/src/elements/gel.c @@ -17,6 +17,8 @@ int update_GEL(UPDATE_FUNC_ARGS) { int r, rx, ry; + float dx, dy; + char gel; if (parts[i].tmp>100) parts[i].tmp = 100; if (parts[i].tmp<0) parts[i].tmp = 0; for (rx=-2; rx<3; rx++) @@ -41,7 +43,7 @@ int update_GEL(UPDATE_FUNC_ARGS) { parts[i].tmp++; } - char gel = 0; + gel = 0; if ((r&0xFF)==PT_GEL) gel = 1; @@ -58,7 +60,6 @@ int update_GEL(UPDATE_FUNC_ARGS) { parts[i].tmp--; } - float dx, dy; dx = parts[i].x - parts[r>>8].x; dy = parts[i].y - parts[r>>8].y; diff --git a/src/main.c b/src/main.c index b61627321..b3ac8af89 100644 --- a/src/main.c +++ b/src/main.c @@ -770,6 +770,7 @@ int main(int argc, char *argv[]) unsigned int rgbSave = PIXRGB(127,0,0); SDL_AudioSpec fmt; int username_flash = 0, username_flash_t = 1; + int saveOpenError = 0; #ifdef PTW32_STATIC_LIB pthread_win32_process_attach_np(); pthread_win32_thread_attach_np(); @@ -779,7 +780,6 @@ int main(int argc, char *argv[]) part_vbuf = calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE); //Extra video buffer part_vbuf_store = part_vbuf; pers_bg = calloc((XRES+BARSIZE)*YRES, PIXELSIZE); - int saveOpenError = 0; gravity_init(); GSPEED = 1; @@ -902,12 +902,12 @@ int main(int argc, char *argv[]) } else if (!strncmp(argv[i], "ptsave", 7) && i+1 Date: Wed, 23 May 2012 19:45:16 -0400 Subject: [PATCH 02/20] fix emp flash, better live parts rendering in (render_ui &) deco editor --- includes/graphics.h | 4 ++ includes/powdergraphics.h | 1 - src/graphics.c | 100 +++++++++++++++++++++++++++++++++++++- src/interface.c | 72 +++++++-------------------- src/main.c | 95 +++++++----------------------------- src/powder.c | 28 +---------- 6 files changed, 137 insertions(+), 163 deletions(-) diff --git a/includes/graphics.h b/includes/graphics.h index 22986a5d3..986052262 100644 --- a/includes/graphics.h +++ b/includes/graphics.h @@ -195,6 +195,10 @@ void blend_line(pixel *vid, int x1, int y1, int x2, int y2, int r, int g, int b, void render_parts(pixel *vid); +void render_before(pixel *part_vbuf); + +void render_after(pixel *part_vbuf, pixel *vid_buf); + #ifdef OGLR void draw_parts_fbo(); #endif diff --git a/includes/powdergraphics.h b/includes/powdergraphics.h index 66286c6fa..0abe06c9e 100644 --- a/includes/powdergraphics.h +++ b/includes/powdergraphics.h @@ -65,6 +65,5 @@ #define DISPLAY_AIR 0x0000000F #define DISPLAY_WARP 0x00000010 #define DISPLAY_PERS 0x00000020 -#define DISPLAY_EFFE 0x00000040 #endif diff --git a/src/graphics.c b/src/graphics.c index 3916ffdf0..6d4853131 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1693,7 +1693,7 @@ void draw_other(pixel *vid) // EMP effect 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 (!(display_mode & DISPLAY_EFFE)) // no in nothing mode + if (!(render_mode & EFFECT)) // not in nothing mode return; if (emp_decor>0) { @@ -2869,10 +2869,82 @@ void draw_parts_fbo() } #endif +// draw the graphics that appear before update_particles is called +void render_before(pixel *part_vbuf) +{ +#ifdef OGLR + if (display_mode & DISPLAY_PERS)//save background for persistent, then clear + { + clearScreen(0.01f); + memset(part_vbuf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE); + } + else //clear screen every frame + { + clearScreen(1.0f); + memset(part_vbuf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE); + if (display_mode & DISPLAY_AIR)//air only gets drawn in these modes + { + draw_air(part_vbuf); + } + } +#else + if (display_mode & DISPLAY_AIR)//air only gets drawn in these modes + { + draw_air(part_vbuf); + } + else if (display_mode & DISPLAY_PERS)//save background for persistent, then clear + { + memcpy(part_vbuf, pers_bg, (XRES+BARSIZE)*YRES*PIXELSIZE); + memset(part_vbuf+((XRES+BARSIZE)*YRES), 0, ((XRES+BARSIZE)*YRES*PIXELSIZE)-((XRES+BARSIZE)*YRES*PIXELSIZE)); + } + else //clear screen every frame + { + memset(part_vbuf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE); + } +#endif + if(ngrav_enable && drawgrav_enable) + draw_grav(part_vbuf); + draw_walls(part_vbuf); +} + +int persist_counter = 0; +// draw the graphics that appear after update_particles is called +void render_after(pixel *part_vbuf, pixel *vid_buf) +{ + render_parts(part_vbuf); //draw particles + draw_other(part_vbuf); + //if(su == WL_GRAV+100) + // draw_grav_zones(part_vbuf); + if (vid_buf && (display_mode & DISPLAY_PERS)) + { + if (!persist_counter) + { + dim_copy_pers(pers_bg, vid_buf); + } + else + { + memcpy(pers_bg, vid_buf, (XRES+BARSIZE)*YRES*PIXELSIZE); + } + persist_counter = (persist_counter+1) % 3; + } +#ifndef OGLR + if (render_mode & FIREMODE) + render_fire(part_vbuf); +#endif + + render_signs(part_vbuf); + +#ifndef OGLR + if(vid_buf && ngrav_enable && (display_mode & DISPLAY_WARP)) + render_gravlensing(part_vbuf, vid_buf); +#endif +} + void draw_walls(pixel *vid) { - int x, y, i, j, cr, cg, cb; + int x, y, i, j, cr, cg, cb, nx, ny, t; unsigned char wt; + float lx, ly; pixel pc; pixel gc; for (y=0; y=XRES || ny<0 || ny>=YRES) + break; + addpixel(vid, nx, ny, 255, 255, 255, 64); + i = nx/CELL; + j = ny/CELL; + lx += vx[j][i]*0.125f; + ly += vy[j][i]*0.125f; + if (bmap[j][i]==WL_STREAM && i!=x && j!=y) + break; + } + drawtext(vid, x*CELL, y*CELL-2, "\x8D", 255, 255, 255, 128); + } } void create_decorations(int x, int y, int rx, int ry, int r, int g, int b, int click, int tool) diff --git a/src/interface.c b/src/interface.c index 0e31ffb56..9e8c6db86 100644 --- a/src/interface.c +++ b/src/interface.c @@ -5441,7 +5441,8 @@ unsigned int decorations_ui(pixel *vid_buf,int *bsx,int *bsy, unsigned int saved b = mouse_get_state(&mx, &my); memcpy(vid_buf,old_buf,(XRES+BARSIZE)*(YRES+MENUSIZE)*PIXELSIZE); - render_parts(vid_buf); + render_before(vid_buf); + render_after(vid_buf, NULL); ui_edit_process(mx, my, b, &box_R); ui_edit_process(mx, my, b, &box_G); ui_edit_process(mx, my, b, &box_B); @@ -6466,10 +6467,10 @@ void render_ui(pixel * vid_buf, int xcoord, int ycoord, int orientation) int render_optionicons[] = {0xE1, 0xDF, 0x9B, 0xC4, 0xBF, 0xDB}; char * render_desc[] = {"Effects", "Glow", "Fire", "Blur", "Blob", "Basic"}; - int display_optioncount = 7; - int display_options[] = {DISPLAY_AIRC, DISPLAY_AIRP, DISPLAY_AIRV, DISPLAY_AIRH, DISPLAY_WARP, DISPLAY_PERS, DISPLAY_EFFE}; - int display_optionicons[] = {0xD4, 0x99, 0x98, 0xBE, 0xDE, 0x9A, -1}; - char * display_desc[] = {"Air: Cracker", "Air: Pressure", "Air: Velocity", "Air: Heat", "Warp effect", "Persistent", "Effects"}; + int display_optioncount = 6; + int display_options[] = {DISPLAY_AIRC, DISPLAY_AIRP, DISPLAY_AIRV, DISPLAY_AIRH, DISPLAY_WARP, DISPLAY_PERS}; + int display_optionicons[] = {0xD4, 0x99, 0x98, 0xBE, 0xDE, 0x9A}; + char * display_desc[] = {"Air: Cracker", "Air: Pressure", "Air: Velocity", "Air: Heat", "Warp effect", "Persistent"}; int colour_optioncount = 4; int colour_options[] = {COLOUR_BASC, COLOUR_LIFE, COLOUR_HEAT, COLOUR_GRAD}; @@ -6558,63 +6559,24 @@ void render_ui(pixel * vid_buf, int xcoord, int ycoord, int orientation) b = mouse_get_state(&mx, &my); memcpy(vid_buf, o_vid_buf, ((YRES+MENUSIZE) * (XRES+BARSIZE)) * PIXELSIZE); - - if(ngrav_enable && display_mode & DISPLAY_WARP) +#ifdef OGLR + part_vbuf = vid_buf; +#else + if(ngrav_enable && (display_mode & DISPLAY_WARP)) { part_vbuf = part_vbuf_store; memset(vid_buf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE); } else { part_vbuf = vid_buf; } - -#ifdef OGLR - if (display_mode & DISPLAY_PERS)//save background for persistent, then clear - { - clearScreen(0.01f); - memset(part_vbuf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE); - } - else //clear screen every frame - { - clearScreen(1.0f); - memset(part_vbuf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE); - if (display_mode & DISPLAY_AIR)//air only gets drawn in these modes - { - draw_air(part_vbuf); - } - } -#else - if (display_mode & DISPLAY_AIR)//air only gets drawn in these modes - { - draw_air(part_vbuf); - } - else if (display_mode & DISPLAY_PERS)//save background for persistent, then clear - { - memcpy(part_vbuf, pers_bg, (XRES+BARSIZE)*YRES*PIXELSIZE); - memset(part_vbuf+((XRES+BARSIZE)*YRES), 0, ((XRES+BARSIZE)*YRES*PIXELSIZE)-((XRES+BARSIZE)*YRES*PIXELSIZE)); - } - else //clear screen every frame - { - memset(part_vbuf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE); - } -#endif - - if(ngrav_enable && drawgrav_enable) - draw_grav(vid_buf); - - draw_walls(part_vbuf); - - render_parts(part_vbuf); - draw_other(part_vbuf); -#ifndef OGLR - if (render_mode & FIREMODE) - render_fire(part_vbuf); -#endif - render_signs(part_vbuf); - -#ifndef OGLR - if(ngrav_enable && display_mode & DISPLAY_WARP) - render_gravlensing(part_vbuf, vid_buf); #endif + render_before(part_vbuf); + render_after(part_vbuf, vid_buf); + quickoptions_menu(vid_buf, b, bq, mx, my); + for (i=0; i1180) @@ -1067,10 +1025,19 @@ int main(int argc, char *argv[]) sandcolour_b = sandcolour_r = sandcolour_g = (int)(20.0f*sin((float)sandcolour_frame*(M_PI/180.0f))); sandcolour_frame++; sandcolour_frame%=360; - - if(ngrav_enable && drawgrav_enable) - draw_grav(vid_buf); - draw_walls(part_vbuf); + +#ifdef OGLR + part_vbuf = vid_buf; +#else + if(ngrav_enable && (display_mode & DISPLAY_WARP)) + { + part_vbuf = part_vbuf_store; + memset(vid_buf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE); + } else { + part_vbuf = vid_buf; + } +#endif + render_before(part_vbuf); if(debug_flags & (DEBUG_PERFORMANCE_CALC|DEBUG_PERFORMANCE_FRAME)) { @@ -1099,8 +1066,9 @@ int main(int argc, char *argv[]) #endif } - render_parts(part_vbuf); //draw particles - draw_other(part_vbuf); + render_after(part_vbuf, vid_buf); + if(su == WL_GRAV+100) + draw_grav_zones(part_vbuf); if(debug_flags & (DEBUG_PERFORMANCE_CALC|DEBUG_PERFORMANCE_FRAME)) { @@ -1118,9 +1086,6 @@ int main(int argc, char *argv[]) debug_perf_istart %= DEBUG_PERF_FRAMECOUNT; } - if(sl == WL_GRAV+100 || sr == WL_GRAV+100) - draw_grav_zones(part_vbuf); - gravity_update_async(); //Check for updated velocity maps from gravity thread if (!sys_pause||framerender) //Only update if not paused memset(gravmap, 0, (XRES/CELL)*(YRES/CELL)*sizeof(float)); //Clear the old gravmap @@ -1130,31 +1095,6 @@ int main(int argc, char *argv[]) sys_pause = 1; } - if (display_mode & DISPLAY_PERS) - { - if (!fire_fc)//fire_fc has nothing to do with fire... it is a counter for diminishing persistent view every 3 frames - { - dim_copy_pers(pers_bg, vid_buf); - } - else - { - memcpy(pers_bg, vid_buf, (XRES+BARSIZE)*YRES*PIXELSIZE); - } - fire_fc = (fire_fc+1) % 3; - } - -#ifndef OGLR - if (render_mode & FIREMODE) - render_fire(part_vbuf); -#endif - - render_signs(part_vbuf); - -#ifndef OGLR - if(ngrav_enable && display_mode & DISPLAY_WARP) - render_gravlensing(part_vbuf, vid_buf); -#endif - memset(vid_buf+((XRES+BARSIZE)*YRES), 0, (PIXELSIZE*(XRES+BARSIZE))*MENUSIZE);//clear menu areas clearrect(vid_buf, XRES-1, 0, BARSIZE+1, YRES); @@ -2822,7 +2762,6 @@ int main(int argc, char *argv[]) #endif } - //execute python step hook sdl_blit(0, 0, XRES+BARSIZE, YRES+MENUSIZE, vid_buf, XRES+BARSIZE); //Setting an element for the stick man diff --git a/src/powder.c b/src/powder.c index 798c562bc..da75ee2b2 100644 --- a/src/powder.c +++ b/src/powder.c @@ -2730,8 +2730,7 @@ movedone: int parts_lastActiveIndex = NPART-1; void update_particles(pixel *vid)//doesn't update the particles themselves, but some other things { - int i, j, x, y, t, nx, ny, r, cr,cg,cb, l = -1; - float lx, ly; + int i, x, y, t; int lastPartUsed = 0; int lastPartUnused = -1; #ifdef MT @@ -2792,31 +2791,6 @@ void update_particles(pixel *vid)//doesn't update the particles themselves, but } update_particles_i(vid, 0, 1); - - // this should probably be elsewhere - for (y=0; y=XRES || ny<0 || ny>=YRES) - break; - addpixel(vid, nx, ny, 255, 255, 255, 64); - i = nx/CELL; - j = ny/CELL; - lx += vx[j][i]*0.125f; - ly += vy[j][i]*0.125f; - if (bmap[j][i]==WL_STREAM && i!=x && j!=y) - break; - } - drawtext(vid, x*CELL, y*CELL-2, "\x8D", 255, 255, 255, 128); - } - } void clear_area(int area_x, int area_y, int area_w, int area_h) From 1026963293716c8d340fcb857c0af092af92aa11 Mon Sep 17 00:00:00 2001 From: Jacob1 Date: Wed, 23 May 2012 19:53:50 -0400 Subject: [PATCH 03/20] fusion changes --- src/elements/elec.c | 2 +- src/elements/h2.c | 12 +++++------- src/elements/nble.c | 10 +++++----- src/elements/pyro.c | 2 +- src/elements/sprk.c | 4 ++-- src/graphics.c | 6 +++--- 6 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/elements/elec.c b/src/elements/elec.c index 667499ffb..9ee3876c3 100644 --- a/src/elements/elec.c +++ b/src/elements/elec.c @@ -94,7 +94,7 @@ int update_ELEC(UPDATE_FUNC_ARGS) { kill_part(i); return 1; } - if (ptypes[r&0xFF].properties & PROP_CONDUCTS && ((r&0xFF)!=PT_H2||parts[i].tmp!=1)) + if (ptypes[r&0xFF].properties & PROP_CONDUCTS && ((r&0xFF)!=PT_H2||parts[i].temp<2273.15)) { create_part(-1, x+rx, y+ry, PT_SPRK); kill_part(i); diff --git a/src/elements/h2.c b/src/elements/h2.c index 212e56eca..d03cd5062 100644 --- a/src/elements/h2.c +++ b/src/elements/h2.c @@ -35,7 +35,7 @@ int update_H2(UPDATE_FUNC_ARGS) } if (parts[r>>8].temp > 2273.15)// && pv[y/CELL][x/CELL] > 50.0f) continue; - if (parts[i].tmp != 1) + if (parts[i].temp < 2273.15) { if (rt==PT_FIRE) { @@ -54,20 +54,18 @@ int update_H2(UPDATE_FUNC_ARGS) } if (parts[i].temp > 2273.15 && pv[y/CELL][x/CELL] > 50.0f) { - parts[i].tmp = 1; if (rand()%5 < 1) { int j; float temp = parts[i].temp; part_change_type(i,x,y,PT_PLSM); parts[i].life = rand()%150+50; - create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NEUT); - create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_ELEC); + j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NEUT); if (j != -1) parts[j].temp = temp; + j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_ELEC); if (j != -1) parts[j].temp = temp; j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_PHOT); if (j != -1) { parts[j].ctype = 0xFFFF00; parts[j].temp = temp; } - j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NBLE); - if (j != -1) { parts[j].tmp = 1; parts[j].temp = temp; } + j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NBLE); if (j != -1) parts[j].temp = temp; if (rand()%2) { @@ -75,7 +73,7 @@ int update_H2(UPDATE_FUNC_ARGS) if (j != -1) { parts[j].tmp = 1; parts[j].temp = temp; } } - parts[i].temp += 6000; + parts[i].temp += 750+rand()%500; pv[y/CELL][x/CELL] += 30; } } diff --git a/src/elements/nble.c b/src/elements/nble.c index bca0291df..dea5787b6 100644 --- a/src/elements/nble.c +++ b/src/elements/nble.c @@ -25,16 +25,16 @@ int update_NBLE(UPDATE_FUNC_ARGS) float temp = parts[i].temp; part_change_type(i,x,y,PT_PLSM); parts[i].life = rand()%150+50; - j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NEUT); if (j != -1) - j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_ELEC); if (j != -1) + j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NEUT); if (j != -1) parts[j].temp = temp; + j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_ELEC); if (j != -1) parts[j].temp = temp; j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_PHOT); if (j != -1) { parts[j].ctype = 0xFF0000; parts[j].temp = temp; } j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_CO2); - if (j != -1) parts[j].temp = temp - 1000; + if (j != -1) parts[j].temp = temp; - parts[i].temp += 10000; - pv[y/CELL][x/CELL] += 30; + parts[i].temp += 1750+rand()%500; + pv[y/CELL][x/CELL] += 50; } } return 0; diff --git a/src/elements/pyro.c b/src/elements/pyro.c index 854e62d61..c09dd63ee 100644 --- a/src/elements/pyro.c +++ b/src/elements/pyro.c @@ -61,7 +61,7 @@ int update_PYRO(UPDATE_FUNC_ARGS) { (t!=PT_SPRK || (rt!=PT_RBDM && rt!=PT_LRBD && rt!=PT_INSL)) && (t!=PT_PHOT || rt!=PT_INSL) && (rt!=PT_SPNG || parts[r>>8].life==0) && - (rt!=PT_H2 || (parts[r>>8].temp < 2273.15 && pv[y/CELL][x/CELL] < 50.0f)) && + (rt!=PT_H2 || parts[r>>8].temp < 2273.15) && ptypes[rt].flammable && (ptypes[rt].flammable + (int)(pv[(y+ry)/CELL][(x+rx)/CELL]*10.0f))>(rand()%1000)) { part_change_type(r>>8,x+rx,y+ry,PT_FIRE); diff --git a/src/elements/sprk.c b/src/elements/sprk.c index d7ee0f0d8..f1c8c8e33 100644 --- a/src/elements/sprk.c +++ b/src/elements/sprk.c @@ -59,7 +59,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) { parts[nearp].ctype = PT_ETRD; } } - else if (ct==PT_NBLE&&parts[i].life<=1&&parts[i].tmp!=1) + else if (ct==PT_NBLE&&parts[i].life<=1&&parts[i].temp<5273.15) { parts[i].life = rand()%150+50; part_change_type(i,x,y,PT_PLSM); @@ -194,7 +194,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) { conduct_sprk = 0; if (rt==PT_INST&&ct!=PT_PSCN) conduct_sprk = 0; - if (rt == PT_NBLE && parts[r>>8].tmp == 1) + if (rt == PT_NBLE && parts[r>>8].temp > 5273.15) conduct_sprk = 0; if (conduct_sprk) { diff --git a/src/graphics.c b/src/graphics.c index 6d4853131..c47c44e55 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -2877,10 +2877,10 @@ void render_before(pixel *part_vbuf) { clearScreen(0.01f); memset(part_vbuf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE); - } + } else //clear screen every frame { - clearScreen(1.0f); + clearScreen(1.0f); memset(part_vbuf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE); if (display_mode & DISPLAY_AIR)//air only gets drawn in these modes { @@ -2896,7 +2896,7 @@ void render_before(pixel *part_vbuf) { memcpy(part_vbuf, pers_bg, (XRES+BARSIZE)*YRES*PIXELSIZE); memset(part_vbuf+((XRES+BARSIZE)*YRES), 0, ((XRES+BARSIZE)*YRES*PIXELSIZE)-((XRES+BARSIZE)*YRES*PIXELSIZE)); - } + } else //clear screen every frame { memset(part_vbuf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE); From b9439454360fa5f1b340459aca44597e24f21489 Mon Sep 17 00:00:00 2001 From: Jacob1 Date: Wed, 23 May 2012 20:02:34 -0400 Subject: [PATCH 04/20] will remove this later & finish tommorow --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index eb3ec8ba2..f22dc53ce 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,5 @@ src/python/stdlib/* *.srv *.bat *.o -*.me \ No newline at end of file +*.me +* \ No newline at end of file From be2fe943c049d479bec9c476e196037678e05b32 Mon Sep 17 00:00:00 2001 From: Jacob1 Date: Wed, 23 May 2012 20:08:53 -0400 Subject: [PATCH 05/20] Prevent accidental infinite loops in lua Also fix glitch when step_functions[0] is unregistered but others aren't --- .gitignore | 2 +- includes/defines.h | 1 + includes/luaconsole.h | 1 + src/interface.c | 1 + src/luaconsole.c | 35 +++++++++++++++++++++++++---------- 5 files changed, 29 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index f22dc53ce..27e78a6ec 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,4 @@ src/python/stdlib/* *.bat *.o *.me -* \ No newline at end of file +* diff --git a/includes/defines.h b/includes/defines.h index 28cdbd2b6..bb57b8e39 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -189,6 +189,7 @@ extern int ngrav_enable; int limitFPS; int water_equal_test; extern int quickoptions_tooltip_fade; +extern int loop_time; extern int debug_flags; #define DEBUG_PERF_FRAMECOUNT 256 diff --git a/includes/luaconsole.h b/includes/luaconsole.h index 83fa4054a..ce8f6b1c6 100644 --- a/includes/luaconsole.h +++ b/includes/luaconsole.h @@ -62,6 +62,7 @@ int luacon_particle_getproperty(char * key, int * format); int luacon_transition_getproperty(char * key, int * format); int luacon_element_getproperty(char * key, int * format, unsigned int * modified_stuff); int process_command_lua(pixel *vid_buf, char *console, char *console_error); +void lua_hook(lua_State *L, lua_Debug *ar); int getPartIndex_curIdx; diff --git a/src/interface.c b/src/interface.c index 9e8c6db86..f2f4b180a 100644 --- a/src/interface.c +++ b/src/interface.c @@ -2683,6 +2683,7 @@ int sdl_poll(void) { SDL_Event event; sdl_key=sdl_rkey=sdl_wheel=sdl_ascii=0; + loop_time = SDL_GetTicks(); while (SDL_PollEvent(&event)) { switch (event.type) diff --git a/src/luaconsole.c b/src/luaconsole.c index 759dd7522..92b58bb78 100644 --- a/src/luaconsole.c +++ b/src/luaconsole.c @@ -32,6 +32,7 @@ int tptProperties; //Table for some TPT properties int tptPropertiesVersion; int tptElements; //Table for TPT element names int tptParts, tptPartsMeta, tptElementTransitions, tptPartsCData, tptPartMeta, tptPart, cIndex; +int loop_time = 0; void luacon_open(){ int i = 0, j; char tmpname[12]; @@ -219,6 +220,7 @@ tpt.partsdata = nil"); { lua_el_mode[i] = 0; } + lua_sethook(l, &lua_hook, LUA_MASKCOUNT, 200); } #ifndef FFI int luacon_partread(lua_State* l){ @@ -733,26 +735,39 @@ int luacon_step(int mx, int my, int selectl, int selectr){ lua_setfield(l, tptProperties, "mousey"); lua_setfield(l, tptProperties, "selectedl"); lua_setfield(l, tptProperties, "selectedr"); - if(step_functions[0]){ - //Set mouse globals - for(i = 0; i<6; i++){ - if(step_functions[i]){ - lua_rawgeti(l, LUA_REGISTRYINDEX, step_functions[i]); - callret = lua_pcall(l, 0, 0, 0); - if (callret) + for(i = 0; i<6; i++){ + if(step_functions[i]){ + loop_time = SDL_GetTicks(); + lua_rawgeti(l, LUA_REGISTRYINDEX, step_functions[i]); + callret = lua_pcall(l, 0, 0, 0); + if (callret) + { + // failed, TODO: better error reporting + printf("%s\n",luacon_geterror()); + if (!strcmp(luacon_geterror(),"Error: Infinite loop")) { - // failed, TODO: better error reporting - printf("%s\n",luacon_geterror()); + lua_pushcfunction(l,&luatpt_unregister_step); + lua_rawgeti(l, LUA_REGISTRYINDEX, step_functions[i]); + lua_pcall(l, 1, 0, 0); } } } - return tempret; } return 0; } int luacon_eval(char *command){ + loop_time = SDL_GetTicks(); return luaL_dostring (l, command); } +void lua_hook(lua_State *L, lua_Debug *ar) +{ + if(ar->event == LUA_HOOKCOUNT && SDL_GetTicks()-loop_time > 3000) + { + if (confirm_ui(vid_buf,"Infinite Loop","The Lua code might have an infinite loop. Press OK to stop it","OK")) + luaL_error(l,"Error: Infinite loop"); + loop_time = SDL_GetTicks(); + } +} int luacon_part_update(int t, int i, int x, int y, int surround_space, int nt) { int retval = 0; From 1c7fdb0c26d8bca5a1cb13a790090b87c3d809aa Mon Sep 17 00:00:00 2001 From: Jacob1 Date: Wed, 28 Mar 2012 16:13:49 -0400 Subject: [PATCH 06/20] oxygen fusion, fix two small bugs --- src/elements/O2.c | 61 +++++++++++++++++++++++++++++---------------- src/elements/co2.c | 3 ++- src/elements/elec.c | 2 +- 3 files changed, 43 insertions(+), 23 deletions(-) diff --git a/src/elements/O2.c b/src/elements/O2.c index 8ca0f4694..82171ec8b 100644 --- a/src/elements/O2.c +++ b/src/elements/O2.c @@ -18,28 +18,47 @@ int update_O2(UPDATE_FUNC_ARGS) { 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].temp+=(rand()/(RAND_MAX/100)); - if(parts[r>>8].tmp&0x01) - parts[r>>8].temp=3473; - parts[r>>8].tmp |= 2; - } - if ((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM) - { - create_part(i,x,y,PT_FIRE); - parts[i].temp+=(rand()/(RAND_MAX/100)); - parts[i].tmp |= 2; - } + r = pmap[y+ry][x+rx]; + if (!r) + continue; - } + if ((r&0xFF)==PT_FIRE) + { + parts[r>>8].temp+=(rand()/(RAND_MAX/100)); + if(parts[r>>8].tmp&0x01) + parts[r>>8].temp=3473; + parts[r>>8].tmp |= 2; + } + if ((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM) + { + create_part(i,x,y,PT_FIRE); + parts[i].temp+=(rand()/(RAND_MAX/100)); + parts[i].tmp |= 2; + } + + } + } + else if (parts[i].temp > 9973.15 && pv[y/CELL][x/CELL] > 250.0f && abs(gravx[(((y/sdl_scale)/CELL)*(XRES/CELL))+((x/sdl_scale)/CELL)]) + abs(gravy[(((y/sdl_scale)/CELL)*(XRES/CELL))+((x/sdl_scale)/CELL)]) > 50) + { + if (rand()%5 < 1) + { + int j; + part_change_type(i,x,y,PT_PLSM); + parts[i].life = rand()%150+50; + j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NEUT); if (j != -1) parts[j].temp = 15000; + j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_PHOT); if (j != -1) parts[j].temp = 15000; + j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_BRMT); if (j != -1) parts[j].temp = 15000; + j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_SING); if (j != -1) { parts[j].temp = 15000; parts[i].life = rand()%25+50; } + + parts[i].temp += 15000; + pv[y/CELL][x/CELL] += 300; + } + } return 0; } diff --git a/src/elements/co2.c b/src/elements/co2.c index 77a92b026..3f7328825 100644 --- a/src/elements/co2.c +++ b/src/elements/co2.c @@ -51,10 +51,11 @@ int update_CO2(UPDATE_FUNC_ARGS) { j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NEUT); if (j != -1) parts[j].temp = 15000; j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_ELEC); if (j != -1) parts[j].temp = 15000; j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_O2); if (j != -1) parts[j].temp = 15000; - j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_SING); if (j != -1) { parts[j].temp = 15000; parts[i].life = rand()%100+450; } + if (rand()%1000 < 1) { j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_SING); if (j != -1) { parts[j].temp = 15000; parts[i].life = 3; } } parts[i].temp += 15000; pv[y/CELL][x/CELL] += 100; + return 1; } } return 0; diff --git a/src/elements/elec.c b/src/elements/elec.c index 9ee3876c3..919ee87c9 100644 --- a/src/elements/elec.c +++ b/src/elements/elec.c @@ -94,7 +94,7 @@ int update_ELEC(UPDATE_FUNC_ARGS) { kill_part(i); return 1; } - if (ptypes[r&0xFF].properties & PROP_CONDUCTS && ((r&0xFF)!=PT_H2||parts[i].temp<2273.15)) + if (ptypes[r&0xFF].properties & PROP_CONDUCTS && ((r&0xFF)!=PT_NBLE||parts[i].temp<2273.15)) { create_part(-1, x+rx, y+ry, PT_SPRK); kill_part(i); From 3959db4c38df2aa2f7fe32f14dbdc9b9a75b5f0e Mon Sep 17 00:00:00 2001 From: Jacob1 Date: Thu, 24 May 2012 10:51:21 -0400 Subject: [PATCH 07/20] console doesn't enable hud, fast heat for PUMP/GPMP/ANIM, GPMP activated at draw --- includes/defines.h | 8 -------- src/luaconsole.c | 3 +-- src/main.c | 5 +---- src/powder.c | 32 +++++++++++++++++--------------- 4 files changed, 19 insertions(+), 29 deletions(-) diff --git a/includes/defines.h b/includes/defines.h index bb57b8e39..300884196 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -199,14 +199,6 @@ extern long debug_perf_frametime[DEBUG_PERF_FRAMECOUNT]; extern long debug_perf_partitime[DEBUG_PERF_FRAMECOUNT]; extern long debug_perf_time; -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/luaconsole.c b/src/luaconsole.c index 92b58bb78..65320cefa 100644 --- a/src/luaconsole.c +++ b/src/luaconsole.c @@ -32,7 +32,6 @@ int tptProperties; //Table for some TPT properties int tptPropertiesVersion; int tptElements; //Table for TPT element names int tptParts, tptPartsMeta, tptElementTransitions, tptPartsCData, tptPartMeta, tptPart, cIndex; -int loop_time = 0; void luacon_open(){ int i = 0, j; char tmpname[12]; @@ -220,7 +219,7 @@ tpt.partsdata = nil"); { lua_el_mode[i] = 0; } - lua_sethook(l, &lua_hook, LUA_MASKCOUNT, 200); + lua_sethook(l, &lua_hook, LUA_MASKCOUNT, 4000000); } #ifndef FFI int luacon_partread(lua_State* l){ diff --git a/src/main.c b/src/main.c index 96f3822b5..c39655b56 100644 --- a/src/main.c +++ b/src/main.c @@ -221,6 +221,7 @@ int frameidx = 0; //int CGOL = 0; //int GSPEED = 1;//causes my .exe to crash.. int sound_enable = 0; +int loop_time = 0; int debug_flags = 0; int debug_perf_istart = 1; @@ -2743,8 +2744,6 @@ int main(int argc, char *argv[]) break; } free(console); - if (!console_mode) - hud_enable = 1; #else char *console; sys_pause = 1; @@ -2757,8 +2756,6 @@ int main(int argc, char *argv[]) break; } free(console); - if (!console_mode) - hud_enable = 1; #endif } diff --git a/src/powder.c b/src/powder.c index da75ee2b2..e3e8c182b 100644 --- a/src/powder.c +++ b/src/powder.c @@ -717,23 +717,25 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a { if (t==SPC_HEAT&&parts[pmap[y][x]>>8].temp>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp + 0.1f, MIN_TEMP, MAX_TEMP); - } else if ((sdl_mod & (KMOD_SHIFT)) && (sdl_mod & (KMOD_CTRL))) { - parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp + 50.0f, MIN_TEMP, MAX_TEMP); - } else { - parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp + 4.0f, MIN_TEMP, MAX_TEMP); - } + float heatchange; + int r = pmap[y][x], fast = ((sdl_mod & (KMOD_SHIFT)) && (sdl_mod & (KMOD_CTRL))); + if ((r&0xFF)==PT_PUMP || (r&0xFF)==PT_GPMP) + heatchange = fast?1.0f:.1f; + else + heatchange = fast?50.0f:4.0f; + + parts[r>>8].temp = restrict_flt(parts[r>>8].temp + heatchange, MIN_TEMP, MAX_TEMP); } if (t==SPC_COOL&&parts[pmap[y][x]>>8].temp>MIN_TEMP) { - if ((pmap[y][x]&0xFF)==PT_PUMP || (pmap[y][x]&0xFF)==PT_GPMP) { - parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp - 0.1f, MIN_TEMP, MAX_TEMP); - } else if ((sdl_mod & (KMOD_SHIFT)) && (sdl_mod & (KMOD_CTRL))) { - parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp - 50.0f, MIN_TEMP, MAX_TEMP); - } else { - parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp - 4.0f, MIN_TEMP, MAX_TEMP); - } + float heatchange; + int r = pmap[y][x], fast = ((sdl_mod & (KMOD_SHIFT)) && (sdl_mod & (KMOD_CTRL))); + if ((r&0xFF)==PT_PUMP || (r&0xFF)==PT_GPMP) + heatchange = fast?1.0f:.1f; + else + heatchange = fast?50.0f:4.0f; + + parts[r>>8].temp = restrict_flt(parts[r>>8].temp - heatchange, MIN_TEMP, MAX_TEMP); } return pmap[y][x]>>8; } @@ -963,7 +965,7 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a parts[i].tmp = 10; if (t==PT_BRAY) parts[i].life = 30; - if (t==PT_PUMP) + if (t==PT_PUMP || t==PT_GPMP) parts[i].life= 10; if (t==PT_SING) parts[i].life = rand()%50+60; From e79d18c58cb6a1cd5c744643fa10cadaea93a71d Mon Sep 17 00:00:00 2001 From: Jacob1 Date: Thu, 24 May 2012 11:01:30 -0400 Subject: [PATCH 08/20] small o2 fusion change, add my name to contibuters (it is ok for me to do that, right?) --- src/elements/O2.c | 2 +- src/main.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/elements/O2.c b/src/elements/O2.c index 82171ec8b..737b571ad 100644 --- a/src/elements/O2.c +++ b/src/elements/O2.c @@ -44,7 +44,7 @@ int update_O2(UPDATE_FUNC_ARGS) } } - else if (parts[i].temp > 9973.15 && pv[y/CELL][x/CELL] > 250.0f && abs(gravx[(((y/sdl_scale)/CELL)*(XRES/CELL))+((x/sdl_scale)/CELL)]) + abs(gravy[(((y/sdl_scale)/CELL)*(XRES/CELL))+((x/sdl_scale)/CELL)]) > 50) + else if (parts[i].temp > 9973.15 && pv[y/CELL][x/CELL] > 250.0f && abs(gravx[(((y/sdl_scale)/CELL)*(XRES/CELL))+((x/sdl_scale)/CELL)]) + abs(gravy[(((y/sdl_scale)/CELL)*(XRES/CELL))+((x/sdl_scale)/CELL)]) > 20) { if (rand()%5 < 1) { diff --git a/src/main.c b/src/main.c index c39655b56..1cb106b4e 100644 --- a/src/main.c +++ b/src/main.c @@ -151,7 +151,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 \"me4502\", MaksProg\n" + "\bgLieuwe Mosch, Anthony Boot, Matthew \"me4502\", MaksProg, jacob1\n" "\n" "\bgTo use online features such as saving, you need to register at: \brhttp://powdertoy.co.uk/Register.html\n" "\n" From e4686724ac4203568b82002bc849df55c9205f8c Mon Sep 17 00:00:00 2001 From: Jacob1 Date: Thu, 5 Apr 2012 19:31:52 -0400 Subject: [PATCH 09/20] limit amount of ELEC produced to prevent infinite reactions --- src/elements/O2.c | 2 +- src/elements/co2.c | 2 +- src/elements/h2.c | 2 +- src/elements/nble.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/elements/O2.c b/src/elements/O2.c index 737b571ad..515247867 100644 --- a/src/elements/O2.c +++ b/src/elements/O2.c @@ -18,7 +18,7 @@ int update_O2(UPDATE_FUNC_ARGS) { int r,rx,ry; - if (parts[i].temp < 9773.15) + if (parts[i].temp < 9273.15) { for (rx=-2; rx<3; rx++) for (ry=-2; ry<3; ry++) diff --git a/src/elements/co2.c b/src/elements/co2.c index 3f7328825..acdbc9919 100644 --- a/src/elements/co2.c +++ b/src/elements/co2.c @@ -49,7 +49,7 @@ int update_CO2(UPDATE_FUNC_ARGS) { int j; kill_part(i); j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NEUT); if (j != -1) parts[j].temp = 15000; - j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_ELEC); if (j != -1) parts[j].temp = 15000; + if (!(rand()%50)) { j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_ELEC); if (j != -1) parts[j].temp = 15000; } j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_O2); if (j != -1) parts[j].temp = 15000; if (rand()%1000 < 1) { j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_SING); if (j != -1) { parts[j].temp = 15000; parts[i].life = 3; } } diff --git a/src/elements/h2.c b/src/elements/h2.c index d03cd5062..86c3be3dc 100644 --- a/src/elements/h2.c +++ b/src/elements/h2.c @@ -61,7 +61,7 @@ int update_H2(UPDATE_FUNC_ARGS) part_change_type(i,x,y,PT_PLSM); parts[i].life = rand()%150+50; j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NEUT); if (j != -1) parts[j].temp = temp; - j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_ELEC); if (j != -1) parts[j].temp = temp; + if (!(rand()%10)) { j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_ELEC); if (j != -1) parts[j].temp = temp; } j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_PHOT); if (j != -1) { parts[j].ctype = 0xFFFF00; parts[j].temp = temp; } diff --git a/src/elements/nble.c b/src/elements/nble.c index dea5787b6..0c118ede2 100644 --- a/src/elements/nble.c +++ b/src/elements/nble.c @@ -26,7 +26,7 @@ int update_NBLE(UPDATE_FUNC_ARGS) part_change_type(i,x,y,PT_PLSM); parts[i].life = rand()%150+50; j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NEUT); if (j != -1) parts[j].temp = temp; - j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_ELEC); if (j != -1) parts[j].temp = temp; + if (!(rand()%25)) { j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_ELEC); if (j != -1) parts[j].temp = temp; } j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_PHOT); if (j != -1) { parts[j].ctype = 0xFF0000; parts[j].temp = temp; } From 40046aeab0d26a12398b4d3beabc984d7cffe7e3 Mon Sep 17 00:00:00 2001 From: Jacob1 Date: Thu, 24 May 2012 11:07:38 -0400 Subject: [PATCH 10/20] update README --- README | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/README b/README index 11d244a45..1afb250ff 100644 --- a/README +++ b/README @@ -102,7 +102,38 @@ scripts - enable scripts to be run from old console History: --------------------------------------------------------------------------- -* Version 74.1 + +* Version 78.0 Beta Build 162 + o Fixes for OPS save format + o Fixes when moving signs + o Line snapping in deco editor + o Make SING explosion area smaller + o Save soap bubbles + o GEL can only absorb 100 water particles + o FILT not heated by photons with ambient heat on + o Enable OPS save format +* Version 77.0 Build 159 + o tmp2 support for old console + o save tmp2 for TRON +* Version 76.0 Build 158 + o GEL won't try to move solids anymore +* Version 76.0 Build 157 + o Fixes for GEL and TRON + o Fix sponge bug +* Version 76.0 Beta Build 156 + o New element: TRON +* Version 75.0 Beta Build 155 + o New element: GEL +* Version 74.2 Build 154 + o Walls don't trigger automatic pipe pattern generation + o BCOL uses COAL's graphics function + o Report icon + o Fix unmeltable ice +* Version 74.1 Build 152 + o Fix ice with ctype of 0 +* Version 74.1 Build 151 + o BRAY glows in fancy display mode +* Version 74.1 Build 150 o Icon for Force Elements o Allow DEST to be used with clone elements. * Version 74.0 @@ -168,7 +199,7 @@ History: o Correct icons in render_ui o Add back portal effects * Version 68.5 - o fix decorations + o Fix decorations * Version 68.4 o Stamp browser fixes o Remove some stuff from HUD to make it fit From e95bcb6fcc74b46ca36f07b0c241511dfad6883e Mon Sep 17 00:00:00 2001 From: Jacob1 Date: Thu, 24 May 2012 11:13:10 -0400 Subject: [PATCH 11/20] fix alt select being off by one every time, turn on deco before entering the deco editor (not after) --- src/interface.c | 3 +++ src/main.c | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/interface.c b/src/interface.c index f2f4b180a..3d95b7365 100644 --- a/src/interface.c +++ b/src/interface.c @@ -5725,6 +5725,9 @@ unsigned int decorations_ui(pixel *vid_buf,int *bsx,int *bsy, unsigned int saved cb = PIXB(tempcolor); if (cr || cg || cb) { + if (cr) cr++; + if (cg) cg++; + if (cb) cb++; currR = cr; currG = cg; currB = cb; diff --git a/src/main.c b/src/main.c index 1cb106b4e..87778bbbb 100644 --- a/src/main.c +++ b/src/main.c @@ -1490,9 +1490,8 @@ int main(int argc, char *argv[]) } else { - rgbSave = decorations_ui(vid_buf,&bsx,&bsy,rgbSave);//decoration_mode = !decoration_mode; decorations_enable = 1; - sys_pause=1; + rgbSave = decorations_ui(vid_buf,&bsx,&bsy,rgbSave);//decoration_mode = !decoration_mode; } } if (sdl_key=='g') From 6f3d87ad04529f5367bbb35caee5ab17eec19059 Mon Sep 17 00:00:00 2001 From: Jacob1 Date: Thu, 24 May 2012 11:25:52 -0400 Subject: [PATCH 12/20] update README --- README | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/README b/README index 1afb250ff..3b6aeed4f 100644 --- a/README +++ b/README @@ -103,15 +103,37 @@ History: --------------------------------------------------------------------------- +* Version 79.2 Beta Build 167 + o Fix minor spelling errors + o Fix crash when using flood-fill or a lot of INST + o Fix an issue that made it impossible to change the Windows size from the options screen +* Version 79.1 Beta Build 166 + o Prevent changing of Window size if the screen is too small. + o Fix bug that caused pressure to leak from TTAN when pausing/framestepping + o Fix crash when opening display options +* Version 79.0 Beta Build 165 + o Fix Titanium only conducting once + o Better colour options preview. +* Version 79.0 Beta Build 164 + o Fix a problem with GPMP that caused gravity to depend on air pressure + o Fix TNT sometimes not exploding if multiple TNT particles are in the same place + o Fix PUMP not generating negative pressure if it is next to a wall + o New element: titanium (in the solids menu), which completely blocks air and absorbs some neutrons +* Version 78.1 Build 163 + o Fix bug that created "weaponised explosive GEL" + o Changes to License (GPLv2 to GPLv3) + o Fix bug that caused thumbnail caching to not work + o Remove unused debug output of thumbnail cache + o Plasma can now travel through portals and PIPE + o Fix file opening on Mac OS X * Version 78.0 Beta Build 162 - o Fixes for OPS save format o Fixes when moving signs - o Line snapping in deco editor - o Make SING explosion area smaller + o Line snapping in the decoration editor + o Changes to SING to prevent it from exploding through walls o Save soap bubbles - o GEL can only absorb 100 water particles + o Changes to GEL, will no longer absorb water when saturated o FILT not heated by photons with ambient heat on - o Enable OPS save format + o New save format: OPS, allows saving of almost all data within the simulation * Version 77.0 Build 159 o tmp2 support for old console o save tmp2 for TRON @@ -177,8 +199,6 @@ History: * Version 70.0 o New element: ignition cord o Stickmen and fighter fixes - o Fixed WIRE graphics - o New elements: ACEL and DCEL, accelerate nearby photons * Version 69.1 o New Lua API features, ability to edit particle properties from tpt.el... array, particles are exposed as an array now * Version 69.0 From 82b60ba5ca7f83b6da677975b21d05247ac79134 Mon Sep 17 00:00:00 2001 From: Jacob1 Date: Thu, 24 May 2012 11:26:25 -0400 Subject: [PATCH 13/20] fix lua console freeze/bugs --- src/luaconsole.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/luaconsole.c b/src/luaconsole.c index 65320cefa..5e6eebc4c 100644 --- a/src/luaconsole.c +++ b/src/luaconsole.c @@ -1476,9 +1476,9 @@ int luatpt_drawrect(lua_State* l) if (x<0 || y<0 || x>=XRES+BARSIZE || y>=YRES+MENUSIZE) return luaL_error(l, "Screen coordinates out of range (%d,%d)", x, y); if(x+w > XRES+BARSIZE) - w = XRES-x; + w = XRES+BARSIZE-x; if(y+h > YRES+MENUSIZE) - h = YRES-y; + h = YRES+MENUSIZE-y; if (r<0) r = 0; if (r>255) r = 255; if (g<0) g = 0; @@ -1510,9 +1510,9 @@ int luatpt_fillrect(lua_State* l) if (x<0 || y<0 || x>=XRES+BARSIZE || y>=YRES+MENUSIZE) return luaL_error(l, "Screen coordinates out of range (%d,%d)", x, y); if(x+w > XRES+BARSIZE) - w = XRES-x; + w = XRES+BARSIZE-x; if(y+h > YRES+MENUSIZE) - h = YRES-y; + h = YRES+MENUSIZE-y; if (r<0) r = 0; if (r>255) r = 255; if (g<0) g = 0; @@ -1907,6 +1907,8 @@ int luatpt_setdebug(lua_State* l) int luatpt_setfpscap(lua_State* l) { int fpscap = luaL_optint(l, 1, 0); + if (fpscap < 2) + return luaL_error(l, "fps cap too small"); limitFPS = fpscap; return 0; } From dcd3ffcb11f60fec2c480661f5c5c547bcc850ca Mon Sep 17 00:00:00 2001 From: Jacob1 Date: Thu, 24 May 2012 11:35:07 -0400 Subject: [PATCH 14/20] finish --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 27e78a6ec..eb2ce9214 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,3 @@ src/python/stdlib/* *.bat *.o *.me -* From 4368ded19707c4272a31210503da7c123db24b63 Mon Sep 17 00:00:00 2001 From: Jacob1 Date: Thu, 24 May 2012 11:57:05 -0400 Subject: [PATCH 15/20] Fix lua console compiling with visual studio (I thought this was fixed already) --- src/luaconsole.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/luaconsole.c b/src/luaconsole.c index 5e6eebc4c..6d545295e 100644 --- a/src/luaconsole.c +++ b/src/luaconsole.c @@ -249,11 +249,11 @@ int luacon_partread(lua_State* l){ switch(format) { case 0: - tempinteger = *((int*)(((void*)&parts[i])+offset)); + tempinteger = *((int*)(((char*)&parts[i])+offset)); lua_pushnumber(l, tempinteger); break; case 1: - tempfloat = *((float*)(((void*)&parts[i])+offset)); + tempfloat = *((float*)(((char*)&parts[i])+offset)); lua_pushnumber(l, tempfloat); break; } @@ -281,10 +281,10 @@ int luacon_partwrite(lua_State* l){ switch(format) { case 0: - *((int*)(((void*)&parts[i])+offset)) = luaL_optinteger(l, 3, 0); + *((int*)(((char*)&parts[i])+offset)) = luaL_optinteger(l, 3, 0); break; case 1: - *((float*)(((void*)&parts[i])+offset)) = luaL_optnumber(l, 3, 0); + *((float*)(((char*)&parts[i])+offset)) = luaL_optnumber(l, 3, 0); break; } return 1; @@ -411,11 +411,11 @@ int luacon_transitionread(lua_State* l){ switch(format) { case 0: - tempinteger = *((int*)(((void*)&ptransitions[i])+offset)); + tempinteger = *((int*)(((char*)&ptransitions[i])+offset)); lua_pushnumber(l, tempinteger); break; case 1: - tempfloat = *((float*)(((void*)&ptransitions[i])+offset)); + tempfloat = *((float*)(((char*)&ptransitions[i])+offset)); lua_pushnumber(l, tempfloat); break; } @@ -445,10 +445,10 @@ int luacon_transitionwrite(lua_State* l){ switch(format) { case 0: - *((int*)(((void*)&ptransitions[i])+offset)) = luaL_optinteger(l, 3, 0); + *((int*)(((char*)&ptransitions[i])+offset)) = luaL_optinteger(l, 3, 0); break; case 1: - *((float*)(((void*)&ptransitions[i])+offset)) = luaL_optnumber(l, 3, 0); + *((float*)(((char*)&ptransitions[i])+offset)) = luaL_optnumber(l, 3, 0); break; } return 0; @@ -598,19 +598,19 @@ int luacon_elementread(lua_State* l){ switch(format) { case 0: - tempinteger = *((int*)(((void*)&ptypes[i])+offset)); + tempinteger = *((int*)(((char*)&ptypes[i])+offset)); lua_pushnumber(l, tempinteger); break; case 1: - tempfloat = *((float*)(((void*)&ptypes[i])+offset)); + tempfloat = *((float*)(((char*)&ptypes[i])+offset)); lua_pushnumber(l, tempfloat); break; case 2: - tempstring = *((char**)(((void*)&ptypes[i])+offset)); + tempstring = *((char**)(((char*)&ptypes[i])+offset)); lua_pushstring(l, tempstring); break; case 3: - tempinteger = *((unsigned char*)(((void*)&ptypes[i])+offset)); + tempinteger = *((unsigned char*)(((char*)&ptypes[i])+offset)); lua_pushnumber(l, tempinteger); break; } @@ -642,10 +642,10 @@ int luacon_elementwrite(lua_State* l){ switch(format) { case 0: - *((int*)(((void*)&ptypes[i])+offset)) = luaL_optinteger(l, 3, 0); + *((int*)(((char*)&ptypes[i])+offset)) = luaL_optinteger(l, 3, 0); break; case 1: - *((float*)(((void*)&ptypes[i])+offset)) = luaL_optnumber(l, 3, 0); + *((float*)(((char*)&ptypes[i])+offset)) = luaL_optnumber(l, 3, 0); break; case 2: tempstring = mystrdup(luaL_optstring(l, 3, "")); @@ -668,11 +668,11 @@ int luacon_elementwrite(lua_State* l){ return luaL_error(l, "Name in use"); } } - *((char**)(((void*)&ptypes[i])+offset)) = tempstring; + *((char**)(((char*)&ptypes[i])+offset)) = tempstring; //Need some way of cleaning up previous values break; case 3: - *((unsigned char*)(((void*)&ptypes[i])+offset)) = luaL_optinteger(l, 3, 0); + *((unsigned char*)(((char*)&ptypes[i])+offset)) = luaL_optinteger(l, 3, 0); break; } if (modified_stuff) From f49f4ea2413464ebdfac6ee0be32c1b282839c63 Mon Sep 17 00:00:00 2001 From: Jacob1 Date: Thu, 24 May 2012 12:42:19 -0400 Subject: [PATCH 16/20] fix crash, spark reset set type without checking if it was a valid number. Also disable another way to create invalid elements --- src/luaconsole.c | 11 ++++++++--- src/main.c | 9 +++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/luaconsole.c b/src/luaconsole.c index 6d545295e..e0aab5f47 100644 --- a/src/luaconsole.c +++ b/src/luaconsole.c @@ -1089,8 +1089,13 @@ int luatpt_reset_spark(lua_State* l) { if (parts[i].type==PT_SPRK) { - parts[i].type = parts[i].ctype; - parts[i].life = 4; + if (parts[i].ctype >= 0 && parts[i].ctype < PT_NUM) + { + parts[i].type = parts[i].ctype; + parts[i].life = 0; + } + else + kill_part(i); } } return 0; @@ -1284,7 +1289,7 @@ int luatpt_set_property(lua_State* l) } else { t = luaL_optint(l, 2, 0); } - if (format == 3 && (t<0 || t>=PT_NUM)) + if (format == 3 && (t<0 || t>=PT_NUM || !ptypes[t].enabled)) return luaL_error(l, "Unrecognised element number '%d'", t); } else { name = luaL_optstring(l, 2, "dust"); diff --git a/src/main.c b/src/main.c index 87778bbbb..3a9776ea4 100644 --- a/src/main.c +++ b/src/main.c @@ -1526,8 +1526,13 @@ int main(int argc, char *argv[]) for (i=0; i= 0 && parts[i].ctype < PT_NUM) + { + parts[i].type = parts[i].ctype; + parts[i].life = 0; + } + else + kill_part(i); } } else From 5edd224344b427f75f0740217e10cb4e44313a5d Mon Sep 17 00:00:00 2001 From: Jacob1 Date: Thu, 24 May 2012 13:08:55 -0400 Subject: [PATCH 17/20] custom graphics functions with lua (not finished yet) --- includes/luaconsole.h | 4 +++- src/graphics.c | 12 ++++++++++++ src/luaconsole.c | 44 +++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 57 insertions(+), 3 deletions(-) diff --git a/includes/luaconsole.h b/includes/luaconsole.h index ce8f6b1c6..4494ddb97 100644 --- a/includes/luaconsole.h +++ b/includes/luaconsole.h @@ -40,7 +40,7 @@ #define LUACON_EL_MODIFIED_GRAPHICS 0x2 #define LUACON_EL_MODIFIED_MENUS 0x4 -int *lua_el_func, *lua_el_mode; +int *lua_el_func, *lua_el_mode, *lua_gr_func; void luacon_open(); int luacon_step(int mx, int my, int selectl, int selectr); @@ -48,6 +48,7 @@ int luacon_mouseevent(int mx, int my, int mb, int event); int luacon_keyevent(int key, int modifier, int event); int luacon_eval(char *command); int luacon_part_update(int t, int i, int x, int y, int surround_space, int nt); +int luacon_graphics_update(int t, int i); char *luacon_geterror(); void luacon_close(); int luacon_partsread(lua_State* l); @@ -70,6 +71,7 @@ int getPartIndex_curIdx; int luatpt_test(lua_State* l); int luatpt_getelement(lua_State *l); int luatpt_element_func(lua_State *l); +int luatpt_graphics_func(lua_State *l); int luatpt_drawtext(lua_State* l); int luatpt_create(lua_State* l); int luatpt_setpause(lua_State* l); diff --git a/src/graphics.c b/src/graphics.c index c47c44e55..60d23b071 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -47,6 +47,9 @@ #include #include #include "hmap.h" +#ifdef LUACONSOLE +#include +#endif #if defined(LIN32) || defined(LIN64) #include "icon.h" @@ -1854,8 +1857,17 @@ void render_parts(pixel *vid) } else if(!(colour_mode & COLOUR_BASC)) //Don't get special effects for BASIC colour mode { +#ifdef LUACONSOLE + if (lua_gr_func[t]) + { + colr = luacon_graphics_update(t,i); + } + else if (ptypes[t].graphics_func) + { +#else if (ptypes[t].graphics_func) { +#endif if ((*(ptypes[t].graphics_func))(&(parts[i]), nx, ny, &pixel_mode, &cola, &colr, &colg, &colb, &firea, &firer, &fireg, &fireb)) //That's a lot of args, a struct might be better { graphicscache[t].isready = 1; diff --git a/src/luaconsole.c b/src/luaconsole.c index e0aab5f47..46168af5a 100644 --- a/src/luaconsole.c +++ b/src/luaconsole.c @@ -96,6 +96,7 @@ void luacon_open(){ {"screenshot",&luatpt_screenshot}, {"element",&luatpt_getelement}, {"element_func",&luatpt_element_func}, + {"graphics_func",&luatpt_graphics_func}, {NULL,NULL} }; @@ -213,11 +214,13 @@ tpt.partsdata = nil"); } lua_setfield(l, tptProperties, "eltransition"); - lua_el_func = calloc(PT_NUM, sizeof(int)); - lua_el_mode = calloc(PT_NUM, sizeof(int)); + lua_el_func = (int*)calloc(PT_NUM, sizeof(int)); + lua_el_mode = (int*)calloc(PT_NUM, sizeof(int)); + lua_gr_func = (int*)calloc(PT_NUM, sizeof(int)); for(i = 0; i < PT_NUM; i++) { lua_el_mode[i] = 0; + lua_gr_func[i] = 0; } lua_sethook(l, &lua_hook, LUA_MASKCOUNT, 4000000); } @@ -785,6 +788,20 @@ int luacon_part_update(int t, int i, int x, int y, int surround_space, int nt) } return retval; } +int luacon_graphics_update(int t, int i) +{ + int retval = 0; + if(lua_gr_func[t]){ + lua_rawgeti(l, LUA_REGISTRYINDEX, lua_gr_func[t]); + lua_pushinteger(l, i); + lua_pcall(l, 1, 1, 0); + if(lua_isnumber(l, -1)){ + retval = (int)lua_tonumber(l, -1); + } + lua_pop(l, 1); + } + return retval; +} char *luacon_geterror(){ char *error = lua_tostring(l, -1); if(error==NULL || !error[0]){ @@ -869,6 +886,29 @@ int luatpt_element_func(lua_State *l) } return 0; } +int luatpt_graphics_func(lua_State *l) +{ + if(lua_isfunction(l, 1)) + { + int element = luaL_optint(l, 2, 0); + int function; + lua_pushvalue(l, 1); + function = luaL_ref(l, LUA_REGISTRYINDEX); + if(element > 0 && element < PT_NUM) + { + lua_gr_func[element] = function; + graphicscache[element].isready = 0; + return 0; + } + else + { + return luaL_error(l, "Invalid element"); + } + } + else + return luaL_error(l, "Not a function"); + return 0; +} int luatpt_error(lua_State* l) { char *error = ""; From bdc94208d22dd65d5796264b62d275114489b35e Mon Sep 17 00:00:00 2001 From: Jacob1 Date: Thu, 10 May 2012 17:44:43 -0400 Subject: [PATCH 18/20] finish custom lua graphics functions --- includes/luaconsole.h | 2 +- src/graphics.c | 14 +++++++++++++- src/luaconsole.c | 33 +++++++++++++++++++++------------ 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/includes/luaconsole.h b/includes/luaconsole.h index 4494ddb97..b4e313b72 100644 --- a/includes/luaconsole.h +++ b/includes/luaconsole.h @@ -48,7 +48,7 @@ int luacon_mouseevent(int mx, int my, int mb, int event); int luacon_keyevent(int key, int modifier, int event); int luacon_eval(char *command); int luacon_part_update(int t, int i, int x, int y, int surround_space, int nt); -int luacon_graphics_update(int t, int i); +int luacon_graphics_update(int t, int i, int *pixel_mode, int *cola, int *colr, int *colg, int *colb, int *firea, int *firer, int *fireg, int *fireb); char *luacon_geterror(); void luacon_close(); int luacon_partsread(lua_State* l); diff --git a/src/graphics.c b/src/graphics.c index 60d23b071..0c4c9653f 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1860,7 +1860,19 @@ void render_parts(pixel *vid) #ifdef LUACONSOLE if (lua_gr_func[t]) { - colr = luacon_graphics_update(t,i); + if (luacon_graphics_update(t,i, &pixel_mode, &cola, &colr, &colg, &colb, &firea, &firer, &fireg, &fireb)) + { + graphicscache[t].isready = 1; + graphicscache[t].pixel_mode = pixel_mode; + graphicscache[t].cola = cola; + graphicscache[t].colr = colr; + graphicscache[t].colg = colg; + graphicscache[t].colb = colb; + graphicscache[t].firea = firea; + graphicscache[t].firer = firer; + graphicscache[t].fireg = fireg; + graphicscache[t].fireb = fireb; + } } else if (ptypes[t].graphics_func) { diff --git a/src/luaconsole.c b/src/luaconsole.c index 46168af5a..d32147c3f 100644 --- a/src/luaconsole.c +++ b/src/luaconsole.c @@ -788,19 +788,28 @@ int luacon_part_update(int t, int i, int x, int y, int surround_space, int nt) } return retval; } -int luacon_graphics_update(int t, int i) +int luacon_graphics_update(int t, int i, int *pixel_mode, int *cola, int *colr, int *colg, int *colb, int *firea, int *firer, int *fireg, int *fireb) { - int retval = 0; - if(lua_gr_func[t]){ - lua_rawgeti(l, LUA_REGISTRYINDEX, lua_gr_func[t]); - lua_pushinteger(l, i); - lua_pcall(l, 1, 1, 0); - if(lua_isnumber(l, -1)){ - retval = (int)lua_tonumber(l, -1); - } - lua_pop(l, 1); - } - return retval; + int cache = 0; + lua_rawgeti(l, LUA_REGISTRYINDEX, lua_gr_func[t]); + lua_pushinteger(l, i); + lua_pushinteger(l, *colr); + lua_pushinteger(l, *colg); + lua_pushinteger(l, *colb); + lua_pcall(l, 4, 10, 0); + + cache = luaL_optint(l, 2, 0); + *pixel_mode = luaL_optint(l, 3, *pixel_mode); + *cola = luaL_optint(l, 4, *cola); + *colr = luaL_optint(l, 5, *colr); + *colg = luaL_optint(l, 6, *colg); + *colb = luaL_optint(l, 7, *colb); + *firea = luaL_optint(l, 8, *firea); + *firer = luaL_optint(l, 9, *firer); + *fireg = luaL_optint(l, 10, *fireg); + *fireb = luaL_optint(l, 11, *fireb); + lua_pop(l, 10); + return cache; } char *luacon_geterror(){ char *error = lua_tostring(l, -1); From 9a179651ee9826f4c0b7df6c57aa75d8101baf5e Mon Sep 17 00:00:00 2001 From: Jacob1 Date: Thu, 24 May 2012 13:13:28 -0400 Subject: [PATCH 19/20] energy type particles automatically go into photons, not pmap --- src/elementdata.c | 4 ++-- src/powder.c | 17 +++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/elementdata.c b/src/elementdata.c index 28211274b..6cf8096b8 100644 --- a/src/elementdata.c +++ b/src/elementdata.c @@ -79,8 +79,8 @@ part_type ptypes[PT_NUM] = {"GLAS", PIXPACK(0x404040), 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, 150, "Solid. Meltable. Shatters under pressure", ST_SOLID, TYPE_SOLID | PROP_NEUTPASS | PROP_HOT_GLOW | PROP_SPARKSETTLE, &update_GLAS, NULL}, {"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, NULL}, {"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, 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, &graphics_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, &graphics_PLSM}, + {"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_PART, &update_THDR, &graphics_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, &graphics_PLSM}, {"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, 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, 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, &update_NBLE, NULL}, diff --git a/src/powder.c b/src/powder.c index e3e8c182b..a1187b1a6 100644 --- a/src/powder.c +++ b/src/powder.c @@ -176,6 +176,7 @@ void init_can_move() //whol eats anar can_move[PT_ANAR][PT_WHOL] = 1; can_move[PT_ANAR][PT_NWHL] = 1; + can_move[PT_THDR][PT_THDR] = 2; } /* @@ -257,7 +258,7 @@ int try_move(int i, int x, int y, int nx, int ny) if (!e) //if no movement { - if (parts[i].type!=PT_NEUT && parts[i].type!=PT_PHOT && parts[i].type!=PT_ELEC) + if (!(ptypes[parts[i].type].properties & TYPE_ENERGY)) return 0; if (!legacy_enable && parts[i].type==PT_PHOT && r)//PHOT heat conduction { @@ -271,7 +272,7 @@ int try_move(int i, int x, int y, int nx, int ny) if (!parts[r>>8].ctype) parts[r>>8].ctype = parts[i].type; } - if ((r&0xFF)==PT_PRTI && (parts[i].type==PT_PHOT || parts[i].type==PT_NEUT || parts[i].type==PT_ELEC)) + if ((r&0xFF)==PT_PRTI && (ptypes[parts[i].type].properties & TYPE_ENERGY)) { int nnx, count; for (count=0; count<8; count++) @@ -427,7 +428,7 @@ int do_move(int i, int x, int y, float nxf, float nyf) kill_part(i); return -1; } - if (t==PT_PHOT||t==PT_NEUT||t==PT_ELEC) + if (ptypes[t].properties & TYPE_ENERGY) photons[ny][nx] = t|(i<<8); else if (t) pmap[ny][nx] = t|(i<<8); @@ -678,7 +679,7 @@ inline void part_change_type(int i, int x, int y, int t)//changes the type of pa } parts[i].type = t; - if (t==PT_PHOT || t==PT_NEUT || t==PT_ELEC) + if (ptypes[t].properties & TYPE_ENERGY) { photons[y][x] = t|(i<<8); if ((pmap[y][x]>>8)==i) @@ -845,7 +846,7 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a } return -1; } - if (photons[y][x] && (t==PT_PHOT||t==PT_NEUT||t==PT_ELEC)) + if (photons[y][x] && (ptypes[t].properties & TYPE_ENERGY)) return -1; if (pfree == -1) return -1; @@ -1106,7 +1107,7 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a if (t==PT_BIZR||t==PT_BIZRG||t==PT_BIZRS) parts[i].ctype = 0x47FFFF; //and finally set the pmap/photon maps to the newly created particle - if (t==PT_PHOT||t==PT_NEUT||t==PT_ELEC) + if (ptypes[t].properties & TYPE_ENERGY) photons[y][x] = t|(i<<8); else if (t!=PT_STKM && t!=PT_STKM2 && t!=PT_FIGH) pmap[y][x] = t|(i<<8); @@ -2351,7 +2352,7 @@ killed: stagnant = parts[i].flags & FLAG_STAGNANT; parts[i].flags &= ~FLAG_STAGNANT; - if ((t==PT_PHOT||t==PT_NEUT||t==PT_ELEC)) { + if (ptypes[t].properties & TYPE_ENERGY) { if (t == PT_PHOT) { if (parts[i].flags&FLAG_SKIPMOVE) { @@ -2752,7 +2753,7 @@ void update_particles(pixel *vid)//doesn't update the particles themselves, but y = (int)(parts[i].y+0.5f); if (x>=0 && y>=0 && x Date: Thu, 24 May 2012 14:07:31 -0400 Subject: [PATCH 20/20] VOID & PVOD can be set to only eat/not eat certain things --- src/powder.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/powder.c b/src/powder.c index a1187b1a6..700a6d5e0 100644 --- a/src/powder.c +++ b/src/powder.c @@ -344,7 +344,8 @@ int try_move(int i, int x, int y, int nx, int ny) } if ((r&0xFF)==PT_VOID || (r&0xFF)==PT_PVOD) //this is where void eats particles { - kill_part(i); + if(!parts[r>>8].ctype || (parts[r>>8].ctype==parts[i].type)!=(parts[r>>8].tmp&1)) + kill_part(i); return 0; } if ((r&0xFF)==PT_BHOL || (r&0xFF)==PT_NBHL) //this is where blackhole eats particles