From 6a2f357efd2dac87a4a9f30206717500440d2a76 Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Sat, 28 May 2011 21:01:31 +0100 Subject: [PATCH] Revert "Pass decorations to saving functions (doesn't actually save yet)" This reverts commit 7fe99f32102429113c671615fc2c5cadb9c51e56. Conflicts: src/main.c --- includes/defines.h | 6 +++--- src/interface.c | 4 ++-- src/main.c | 23 +++++++++++------------ src/powder.c | 34 ++++++++++++++++------------------ 4 files changed, 32 insertions(+), 35 deletions(-) diff --git a/includes/defines.h b/includes/defines.h index 3e6a6b340..2194159a1 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -187,7 +187,7 @@ extern int sys_pause; extern int sys_shortcuts; extern int legacy_enable; //Used to disable new features such as heat, will be set by commandline or save. extern int death, death2, framerender; -extern pixel *vid_buf, *decorations; +extern pixel *vid_buf; extern unsigned char last_major, last_minor, update_flag; @@ -198,8 +198,8 @@ void thumb_cache_inval(char *id); void thumb_cache_add(char *id, void *thumb, int size); int thumb_cache_find(char *id, void **thumb, int *size); void *build_thumb(int *size, int bzip2); -void *build_save(int *size, int x0, int y0, int w, int h, unsigned char bmap[YRES/CELL][XRES/CELL], float fvx[YRES/CELL][XRES/CELL], float fvy[YRES/CELL][XRES/CELL], sign signs[MAXSIGNS], void* partsptr, pixel *decorations); -int parse_save(void *save, int size, int replace, int x0, int y0, unsigned char bmap[YRES/CELL][XRES/CELL], float fvx[YRES/CELL][XRES/CELL], float fvy[YRES/CELL][XRES/CELL], sign signs[MAXSIGNS], void* partsptr, unsigned pmap[YRES][XRES], pixel *decorations); +void *build_save(int *size, int x0, int y0, int w, int h, unsigned char bmap[YRES/CELL][XRES/CELL], float fvx[YRES/CELL][XRES/CELL], float fvy[YRES/CELL][XRES/CELL], sign signs[MAXSIGNS], void* partsptr); +int parse_save(void *save, int size, int replace, int x0, int y0, unsigned char bmap[YRES/CELL][XRES/CELL], float fvx[YRES/CELL][XRES/CELL], float fvy[YRES/CELL][XRES/CELL], sign signs[MAXSIGNS], void* partsptr, unsigned pmap[YRES][XRES]); void clear_sim(void); void del_stamp(int d); void sdl_seticon(void); diff --git a/src/interface.c b/src/interface.c index 65d80dcac..c501dddaf 100644 --- a/src/interface.c +++ b/src/interface.c @@ -3375,7 +3375,7 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date) if (queue_open) { if (info_ready && data_ready) { // Do Open! - status = parse_save(data, data_size, 1, 0, 0, bmap, fvx, fvy, signs, parts, pmap, decorations); + status = parse_save(data, data_size, 1, 0, 0, bmap, fvx, fvy, signs, parts, pmap); if (!status) { //if(svf_last) //free(svf_last); @@ -3896,7 +3896,7 @@ void execute_save(pixel *vid_buf) plens[0] = strlen(svf_name); uploadparts[1] = svf_description; plens[1] = strlen(svf_description); - uploadparts[2] = build_save(plens+2, 0, 0, XRES, YRES, bmap, fvx, fvy, signs, parts, decorations); + uploadparts[2] = build_save(plens+2, 0, 0, XRES, YRES, bmap, fvx, fvy, signs, parts); uploadparts[3] = build_thumb(plens+3, 1); uploadparts[4] = (svf_publish==1)?"Public":"Private"; plens[4] = strlen((svf_publish==1)?"Public":"Private"); diff --git a/src/main.c b/src/main.c index dcac7b142..446f1670b 100644 --- a/src/main.c +++ b/src/main.c @@ -59,7 +59,7 @@ #include "pyconsole.h" #endif -pixel *vid_buf, *decorations; +pixel *vid_buf; #define NUM_SOUNDS 2 struct sample { @@ -319,7 +319,7 @@ void *build_thumb(int *size, int bzip2) } //the saving function -void *build_save(int *size, int x0, int y0, int w, int h, unsigned char bmap[YRES/CELL][XRES/CELL], float fvx[YRES/CELL][XRES/CELL], float fvy[YRES/CELL][XRES/CELL], sign signs[MAXSIGNS], void* partsptr, pixel *decorations) +void *build_save(int *size, int x0, int y0, int w, int h, unsigned char bmap[YRES/CELL][XRES/CELL], float fvx[YRES/CELL][XRES/CELL], float fvy[YRES/CELL][XRES/CELL], sign signs[MAXSIGNS], void* partsptr) { unsigned char *d=calloc(1,3*(XRES/CELL)*(YRES/CELL)+(XRES*YRES)*15+MAXSIGNS*262), *c; int i,j,x,y,p=0,*m=calloc(XRES*YRES, sizeof(int)); @@ -524,7 +524,7 @@ void *build_save(int *size, int x0, int y0, int w, int h, unsigned char bmap[YRE return c; } -int parse_save(void *save, int size, int replace, int x0, int y0, unsigned char bmap[YRES/CELL][XRES/CELL], float fvx[YRES/CELL][XRES/CELL], float fvy[YRES/CELL][XRES/CELL], sign signs[MAXSIGNS], void* partsptr, unsigned pmap[YRES][XRES], pixel *decorations) +int parse_save(void *save, int size, int replace, int x0, int y0, unsigned char bmap[YRES/CELL][XRES/CELL], float fvx[YRES/CELL][XRES/CELL], float fvy[YRES/CELL][XRES/CELL], sign signs[MAXSIGNS], void* partsptr, unsigned pmap[YRES][XRES]) { unsigned char *d=NULL,*c=save; int q,i,j,k,x,y,p=0,*m=NULL, ver, pty, ty, legacy_beta=0, tempGrav = 0; @@ -615,7 +615,6 @@ int parse_save(void *save, int size, int replace, int x0, int y0, unsigned char } clear_sim(); } - clearrect(decorations, x0, y0, w, h); m = calloc(XRES*YRES, sizeof(int)); // make a catalog of free parts @@ -1162,7 +1161,7 @@ void stamp_save(int x, int y, int w, int h) FILE *f; int n; char fn[64], sn[16]; - void *s=build_save(&n, x, y, w, h, bmap, fvx, fvy, signs, parts, decorations); + void *s=build_save(&n, x, y, w, h, bmap, fvx, fvy, signs, parts); #ifdef WIN32 _mkdir("stamps"); @@ -1451,7 +1450,8 @@ int main(int argc, char *argv[]) if(load_data && load_size){ int parsestate = 0; - parsestate = parse_save(load_data, load_size, 1, 0, 0, bmap, fvx, fvy, signs, parts, pmap, decorations); + //parsestate = parse_save(load_data, load_size, 1, 0, 0); + parsestate = parse_save(load_data, load_size, 1, 0, 0, bmap, fvx, fvy, signs, parts, pmap); for(i=0; i<30; i++){ memset(vid_buf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE); @@ -1549,7 +1549,6 @@ int main(int argc, char *argv[]) pthread_win32_process_attach_np(); pthread_win32_thread_attach_np(); #endif - decorations = calloc((XRES+BARSIZE)*YRES, PIXELSIZE); vid_buf = calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE); pers_bg = calloc((XRES+BARSIZE)*YRES, PIXELSIZE); GSPEED = 1; @@ -1704,7 +1703,7 @@ int main(int argc, char *argv[]) if (file_data) { it=0; - parse_save(file_data, size, 0, 0, 0, bmap, fvx, fvy, signs, parts, pmap, decorations); + parse_save(file_data, size, 0, 0, 0, bmap, fvx, fvy, signs, parts, pmap); } } @@ -2690,7 +2689,7 @@ int main(int argc, char *argv[]) if (load_y<0) load_y=0; if (bq==1 && !b) { - parse_save(load_data, load_size, 0, load_x, load_y, bmap, fvx, fvy, signs, parts, pmap, decorations); + parse_save(load_data, load_size, 0, load_x, load_y, bmap, fvx, fvy, signs, parts, pmap); free(load_data); free(load_img); load_mode = 0; @@ -2732,14 +2731,14 @@ int main(int argc, char *argv[]) { if (copy_mode==1)//CTRL-C, copy { - clipboard_data=build_save(&clipboard_length, save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL, bmap, fvx, fvy, signs, parts, decorations); + clipboard_data=build_save(&clipboard_length, save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL, bmap, fvx, fvy, signs, parts); clipboard_ready = 1; save_mode = 0; copy_mode = 0; } else if (copy_mode==2)//CTRL-X, cut { - clipboard_data=build_save(&clipboard_length, save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL, bmap, fvx, fvy, signs, parts, decorations); + clipboard_data=build_save(&clipboard_length, save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL, bmap, fvx, fvy, signs, parts); clipboard_ready = 1; save_mode = 0; copy_mode = 0; @@ -2866,7 +2865,7 @@ int main(int argc, char *argv[]) } if (x>=19 && x<=35 && svf_last && svf_open && !bq) { //int tpval = sys_pause; - parse_save(svf_last, svf_lsize, 1, 0, 0, bmap, fvx, fvy, signs, parts, pmap, decorations); + parse_save(svf_last, svf_lsize, 1, 0, 0, bmap, fvx, fvy, signs, parts, pmap); //sys_pause = tpval; } if (x>=(XRES+BARSIZE-(510-476)) && x<=(XRES+BARSIZE-(510-491)) && !bq) diff --git a/src/powder.c b/src/powder.c index 34328f3f2..fcb76b388 100644 --- a/src/powder.c +++ b/src/powder.c @@ -2587,14 +2587,11 @@ void *transform_save(void *odata, int *size, matrix2d transform, vector2d transl float (*fvyo)[XRES/CELL] = calloc((YRES/CELL)*(XRES/CELL), sizeof(float)); float (*fvxn)[XRES/CELL] = calloc((YRES/CELL)*(XRES/CELL), sizeof(float)); float (*fvyn)[XRES/CELL] = calloc((YRES/CELL)*(XRES/CELL), sizeof(float)); - pixel *decorationso = calloc((XRES+BARSIZE)*YRES, PIXELSIZE); - pixel *decorationsn = calloc((XRES+BARSIZE)*YRES, PIXELSIZE); int i, x, y, nx, ny, w, h, nw, nh; - pixel px; vector2d pos, tmp, ctl, cbr; vector2d cornerso[4]; unsigned char *odatac = odata; - if (parse_save(odata, *size, 0, 0, 0, bmapo, fvxo, fvyo, signst, partst, pmapt, decorationso)) + if (parse_save(odata, *size, 0, 0, 0, bmapo, fvxo, fvyo, signst, partst, pmapt)) { free(bmapo); free(bmapn); @@ -2605,8 +2602,6 @@ void *transform_save(void *odata, int *size, matrix2d transform, vector2d transl free(fvyo); free(fvxn); free(fvyn); - free(decorationso); - free(decorationsn); return odata; } w = odatac[6]*CELL; @@ -2663,21 +2658,26 @@ void *transform_save(void *odata, int *size, matrix2d transform, vector2d transl partst[i].x = nx; partst[i].y = ny; } - for (y=0; y=nw || ny<0 || ny>=nh) continue; - decorationsn[ny*(XRES+BARSIZE)+nx] = px; + if (bmapo[y][x]) + { + bmapn[ny][nx] = bmapo[y][x]; + if (bmapo[y][x]==WL_FAN) + { + fvxn[ny][nx] = fvxo[y][x]; + fvyn[ny][nx] = fvyo[y][x]; + } + } } - ndata = build_save(size,0,0,nw,nh,bmapn,fvxn,fvyn,signst,partst,decorationsn); + ndata = build_save(size,0,0,nw,nh,bmapn,fvxn,fvyn,signst,partst); free(bmapo); free(bmapn); free(partst); @@ -2687,8 +2687,6 @@ void *transform_save(void *odata, int *size, matrix2d transform, vector2d transl free(fvyo); free(fvxn); free(fvyn); - free(decorationso); - free(decorationsn); return ndata; }