From 4514c5e61969f4187706545cb769981d6adae15e Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Sat, 24 Sep 2011 17:13:28 +0100 Subject: [PATCH] Make changes to prefs file regarding build_num and updated --- includes/defines.h | 2 +- src/main.c | 2 +- src/misc.c | 23 +++++++++++++++++------ 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/includes/defines.h b/includes/defines.h index 17cf1118e..1efa916f9 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -224,7 +224,7 @@ extern int legacy_enable; //Used to disable new features such as heat, will be s extern int framerender; extern pixel *vid_buf; -extern unsigned char last_major, last_minor, update_flag; +extern unsigned char last_major, last_minor, update_flag, last_build; extern char http_proxy_string[256]; diff --git a/src/main.c b/src/main.c index a67836b20..4abf2ef1c 100644 --- a/src/main.c +++ b/src/main.c @@ -2657,7 +2657,7 @@ int main(int argc, char *argv[]) if (update_flag) { info_box(vid_buf, "Finalizing update..."); - if (last_major>SAVE_VERSION || (last_major==SAVE_VERSION && last_minor>=MINOR_VERSION) || last_build>BUILD_NUM) + if (last_build>BUILD_NUM) { update_cleanup(); error_ui(vid_buf, 0, "Update failed - try downloading a new version."); diff --git a/src/misc.c b/src/misc.c index 6739624cf..25594ea1e 100644 --- a/src/misc.c +++ b/src/misc.c @@ -120,7 +120,7 @@ void clean_text(char *text, int vwidth) void save_presets(int do_update) { FILE *f=fopen("powder.def", "wb"); - unsigned char sig[4] = {0x50, 0x44, 0x65, 0x67}; + unsigned char sig[4] = {0x50, 0x44, 0x65, 0x68}; unsigned char tmp = sdl_scale; if (!f) return; @@ -137,10 +137,12 @@ void save_presets(int do_update) tmp = svf_mod; fwrite(&tmp, 1, 1, f); save_string(f, http_proxy_string); - tmp = SAVE_VERSION; + tmp = MAJOR_VERSION; fwrite(&tmp, 1, 1, f); tmp = MINOR_VERSION; fwrite(&tmp, 1, 1, f); + tmp = BUILD_NUM; + fwrite(&tmp, 1, 1, f); tmp = do_update; fwrite(&tmp, 1, 1, f); fclose(f); @@ -178,8 +180,9 @@ void load_presets(void) remove("powder.def"); goto fail; } - last_major = sig[0]; - last_minor = sig[1]; + //last_major = sig[0]; + //last_minor = sig[1]; + last_build = 0; update_flag = sig[2]; } fclose(f); @@ -214,8 +217,16 @@ void load_presets(void) svf_mod = tmp; if (load_string(f, http_proxy_string, 255)) goto fail; - if (fread(sig, 1, 3, f) != 3) - goto fail; + + if (sig[3]!=0x68) { //Pre v64 format + if (fread(sig, 1, 3, f) != 3) + goto fail; + last_build = 0; + } else { + if (fread(sig, 1, 4, f) != 4) + goto fail; + last_build = sig[3]; + } last_major = sig[0]; last_minor = sig[1]; update_flag = sig[2];