diff --git a/includes/interface.h b/includes/interface.h index 7ed4f8c48..57a643236 100644 --- a/includes/interface.h +++ b/includes/interface.h @@ -138,6 +138,9 @@ extern char svf_pass[64]; extern char svf_user_id[64]; extern char svf_session_id[64]; + +extern char svf_filename[255]; +extern int svf_fileopen; extern int svf_open; extern int svf_own; extern int svf_myvote; diff --git a/src/interface.c b/src/interface.c index a85ea1f0c..f67bfe6f0 100644 --- a/src/interface.c +++ b/src/interface.c @@ -41,6 +41,8 @@ int svf_open = 0; int svf_own = 0; int svf_myvote = 0; int svf_publish = 0; +char svf_filename[255] = ""; +int svf_fileopen = 0; char svf_id[16] = ""; char svf_name[64] = ""; char svf_description[255] = ""; @@ -636,16 +638,19 @@ void draw_svf_ui(pixel *vid_buf, int alternate)// all the buttons at the bottom } // the reload button - c = svf_open ? 255 : 128; + c = (svf_open || svf_fileopen) ? 255 : 128; drawtext(vid_buf, 23, YRES+(MENUSIZE-14), "\x91", c, c, c, 255); drawrect(vid_buf, 19, YRES+(MENUSIZE-16), 16, 14, c, c, c, 255); // the save sim button - if(alternate) + if(alternate || svf_fileopen) { fillrect(vid_buf, 36, YRES+(MENUSIZE-16)-1, 152, 16, 255, 255, 255, 255); drawtext(vid_buf, 40, YRES+(MENUSIZE-14), "\x82", 0, 0, 0, 255); - drawtext(vid_buf, 58, YRES+(MENUSIZE-12), "[save to disk]", 0, 0, 0, 255); + if(svf_fileopen) + drawtext(vid_buf, 58, YRES+(MENUSIZE-12), svf_filename, 0, 0, 0, 255); + else + drawtext(vid_buf, 58, YRES+(MENUSIZE-12), "[save to disk]", 0, 0, 0, 255); } else { c = svf_login ? 255 : 128; drawtext(vid_buf, 40, YRES+(MENUSIZE-14), "\x82", c, c, c, 255); @@ -1666,6 +1671,8 @@ int save_name_ui(pixel *vid_buf) svf_open = 1; svf_own = 1; svf_publish = cb.checked; + svf_filename[0] = 0; + svf_fileopen = 0; free(old_vid); return nd+1; } @@ -3628,12 +3635,16 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date) svf_tags[0] = 0; } svf_myvote = info->myvote; + svf_filename[0] = 0; + svf_fileopen = 0; retval = 1; break; } else { queue_open = 0; svf_open = 0; + svf_filename[0] = 0; + svf_fileopen = 0; svf_publish = 0; svf_own = 0; svf_myvote = 0; @@ -5219,6 +5230,11 @@ int save_filename_ui(pixel *vid_buf) ed.cursor = 0; ed.multiline = 0; ed.str[0] = 0; + + if(svf_fileopen){ + strncpy(ed.str, svf_filename, 255); + ed.cursor = strlen(ed.str); + } while (!sdl_poll()) { @@ -5264,8 +5280,10 @@ int save_filename_ui(pixel *vid_buf) if(b && !bq) { FILE *f = NULL; + char *savefname = malloc(strlen(ed.str)+5); char *filename = malloc(strlen(LOCAL_SAVE_DIR)+strlen(PATH_SEP)+strlen(ed.str)+5); sprintf(filename, "%s%s%s.cps", LOCAL_SAVE_DIR, PATH_SEP, ed.str); + sprintf(savefname, "%s.cps", ed.str); #ifdef WIN32 _mkdir(LOCAL_SAVE_DIR); @@ -5285,6 +5303,11 @@ int save_filename_ui(pixel *vid_buf) { fwrite(save_data, save_size, 1, f); fclose(f); + if(svf_fileopen) + { + strncpy(svf_filename, savefname, 255); + svf_fileopen = 1; + } break; } else { error_ui(vid_buf, 0, "Unable to write to save file."); @@ -5448,6 +5471,9 @@ void catalogue_ui(pixel * vid_buf) status = parse_save(data, size, 1, 0, 0, bmap, fvx, fvy, signs, parts, pmap); if(!status) { + //svf_filename[0] = 0; + strncpy(svf_filename, csave->name, 255); + svf_fileopen = 1; svf_open = 0; svf_publish = 0; svf_own = 0; @@ -5456,9 +5482,13 @@ void catalogue_ui(pixel * vid_buf) svf_name[0] = 0; svf_description[0] = 0; svf_tags[0] = 0; + svf_last = data; + data = NULL; + svf_lsize = size; goto openfin; } else { error_ui(vid_buf, 0, "Save data corrupt"); + free(data); } } else { error_ui(vid_buf, 0, "Unable to read save file"); diff --git a/src/main.c b/src/main.c index bb3e56f3c..bcb524a81 100644 --- a/src/main.c +++ b/src/main.c @@ -567,7 +567,7 @@ int parse_save(void *save, int size, int replace, int x0, int y0, unsigned char airMode = ((c[3]>>4)&0x07);// | ((c[3]>>4)&0x02) | ((c[3]>>4)&0x01); } if (ver>=49 && replace) { - tempGrav = ((c[3]>>7)&0x01); + tempGrav = ((c[3]>>7)&0x01); } } else { if (c[3]==1||c[3]==0) { @@ -2875,6 +2875,8 @@ int main(int argc, char *argv[]) pfree = 0; legacy_enable = 0; + svf_filename[0] = 0; + svf_fileopen = 0; svf_myvote = 0; svf_open = 0; svf_publish = 0; @@ -2940,7 +2942,7 @@ int main(int argc, char *argv[]) memset(fire_b, 0, sizeof(fire_b)); } } - if (x>=19 && x<=35 && svf_last && svf_open && !bq) { + if (x>=19 && x<=35 && svf_last && (svf_open || svf_fileopen) && !bq) { //int tpval = sys_pause; parse_save(svf_last, svf_lsize, 1, 0, 0, bmap, fvx, fvy, signs, parts, pmap); //sys_pause = tpval;