From dd2077451f8100952f366eb66ba4d6088d71291f Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 2 Jun 2004 06:39:14 +0000 Subject: [PATCH] A more or less complete set of hacks. --- Makefile | 2 +- .../Contents/Resources/mojopatch.icns | Bin 53954 -> 53954 bytes build-patchfile.sh | 55 ++++++--- mojopatch.c | 108 +++++++++++------- platform_unix.c | 29 ++--- ui_carbon.c | 2 +- 6 files changed, 123 insertions(+), 73 deletions(-) diff --git a/Makefile b/Makefile index 03003c5..34bdb4e 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ PLATFORMDEF := -DPLATFORM_UNIX PLATFORMSRCS := platform_unix.c ui_stdio.c endif -CFLAGS := $(PLATFORMDEF) -Wall -g -fsigned-char -fno-omit-frame-pointer -O0 +CFLAGS := $(PLATFORMDEF) -Wall -g -fsigned-char -fno-omit-frame-pointer -Os ifeq ($(strip $(use_zlib)),true) CFLAGS += -DUSE_ZLIB diff --git a/MojoPatch.app/Contents/Resources/mojopatch.icns b/MojoPatch.app/Contents/Resources/mojopatch.icns index a5be679cf974bac35476448a295c47b9a3fad2dd..2734926d6899e22d007ed7edc257bac5354f8e48 100644 GIT binary patch delta 1823 zcmaJ=ZD?Cn7=CYWx@1ezG)>ZWOhQ;`D|8t_S>AwAe1-I5NwQXNwwm4QX*Z4n$I(oSbfKhok5w$h~q8LJX=eBOI+LmI&Y@B6&p z=bm$(J3Fq^~eVzuw14+kG~b^da7qiN^VqDRWh>h#vL%ImKgHA~l%%JQ2;Xa6SZx=ysbMASD( z^za3uhVO~Oy+pM+oyZX_;cGQr7009cVbc&S#&8&mBO(I@=ht& zSyU+v7Lt-!6e*J|rmvTXVnw1z!w!*eo5;Cte+1EFz4C!q%nrSAB9*c}Cxw+T&D{t) z%CM9&4#N$U->5`!;IP6uUYwTka4NOJhP;wWab6CKnXfdF%Q%&jX@9fxq*)tH`&*Q# zc=yM4MNj)%9k`YSpt2z5M>UpOluh48gX{LR+0g;}K!<5UrPBVO$NpN5v9F}W%vc0F zdGsFMc<<`jZME>*y;*HIn97>@ZZRGjN3uw7(SDcsN|NIQ9@FG}@cCB!0)K_2)o*5C z^D=EHae5>;H0SkNQ9CS7UkZu2oYQ_kJ7+hEqgR3=d(j0#2gD)6DJDkh#EWAc%uyTN zB9jTEwE#lCE68-QGA>LqP0N4t@5y)d&fQ=Q{48O(BGd96*1|GEQ z!oVQ>hky;h2(TX52CNgEnRcK@9J$m1bc<^j9|5|=7bA}i%^ij55aUxvM9uuM?t#QP zaFn|F+Wi+|=bxE+|GleU#?FTq8*{aBcdj<6Xx7vDZ^VjvNiXrG>!nyRvg6xkajvU| zlAJu%byvlk2BQ2_D1qXcY?fD*%SEEz2#L+<7W2V2r(Mhs(U%QB&AnK=y_Q#Y%RH&d zGjB4XM!VXAa;@l&X*yBpj&%$^gmnZyz(C^clc+yaZvDw{${<+6fygz@p!bqz(O&|}ZDKvQ} HwlwrF!0i_$ delta 274 zcmX@Kl=;w7W`WG)ykZ81ONTt2{gfFP7&#^fuFRX9urhw~hk3@E1sE%N;Q}B*eE7pW zYmUt144^4Y9+MRr6&7z4Vw~*1C=H@%MfB#2B5pE7n}*LOd~y$rIDxJx2D*a5WAej! o4x8hxUNXaN1$t_-hrPn&i$)SaRkfname)); + _current_operation("Installing file %s ...", final_path_element(add->fname)); _log("%s %s", (replace_ok) ? "ADDORREPLACE" : "ADD", add->fname); if ( (info_only()) || (!confirm()) || (in_ignore_list(add->fname)) ) @@ -1206,7 +1183,7 @@ static int handle_add_op(SerialArchive *ar, OperationType op, void *d) } /* if */ _log("[%s] already exists...looking at md5sum...", add->fname); - _current_operation("VERIFY %s", final_path_element(add->fname)); + _current_operation("Verifying %s ...", final_path_element(add->fname)); io = fopen(add->fname, "rb"); if (io == NULL) { @@ -1249,7 +1226,7 @@ static int handle_add_op(SerialArchive *ar, OperationType op, void *d) chmod(add->fname, add->mode); /* !!! FIXME: Should this be an error condition? */ - _current_operation("VERIFY %s", final_path_element(add->fname)); + _current_operation("Verifying %s ...", final_path_element(add->fname)); io = fopen(add->fname, "rb"); if (io == NULL) { @@ -2005,7 +1982,8 @@ static int process_patch_header(SerialArchive *ar, PatchHeader *h) ui_title(h->titlebar); - if ( (!info_only()) && (must_prompt_for_location) ) +#if 0 + if ( (!info_only()) ) { int rc = chdir_by_identifier(h->product, h->identifier, h->version, h->newversion); @@ -2014,6 +1992,7 @@ static int process_patch_header(SerialArchive *ar, PatchHeader *h) else if (rc == -1) skip_patch = 1; } /* if */ +#endif if (*h->readmefname) { @@ -2027,6 +2006,55 @@ static int process_patch_header(SerialArchive *ar, PatchHeader *h) return(retval); } /* process_patch_header */ +int manually_locate_product(const char *name, char *buf, size_t bufsize); +int parse_info_dot_plist(const char *ident, + const char *version, + const char *newversion); + +static char nwnbase[MAXPATHLEN]; + +static int nwn_patch_start(void) +{ + int rc = 0; + ui_msgbox("Welcome to the Neverwinter Nights expansion pack installer!" + " Before installing the expansion pack, we need to make sure" + " the game is patched up to an acceptable version."); + + while (1) + { + if (!manually_locate_product("Neverwinter Nights", nwnbase, sizeof (nwnbase))) + { + _fatal("We can't patch the product if we can't find it!"); + return(0); + } /* if */ + + if (chdir(nwnbase) != 0) + { + _fatal("Failed to change to product's installation directory."); + return(0); + } /* if */ + + if (file_exists("./Neverwinter Nights.app")) + break; + + ui_msgbox("This doesn't appear to be the right directory!"); + } /* while */ + + if (chdir("./Neverwinter Nights.app") != 0) + { + _fatal("Failed to change to product's installation directory."); + return(0); + } /* if */ + + rc = parse_info_dot_plist("nwmain.icns", "0.0.1d1", "1.62"); + if (!rc) + return(0); + else if (rc == -1) + skip_patch = 1; + + return(1); +} /* nwn_patch_start */ + static int do_patching(void) { @@ -2045,11 +2073,8 @@ static int do_patching(void) if (file_size == 0) do_progress = 0; /* prevent a division by zero. */ - ui_msgbox("Welcome to the Neverwinter Nights expansion pack installer!" - " Before installing the expansion pack, we need to make sure" - " the game is patched up to an acceptable version. You may be" - " prompted to show us where some icons in your original game " - " installation reside."); + if (!nwn_patch_start()) + return(PATCHERROR); while (1) { @@ -2060,18 +2085,19 @@ static int do_patching(void) if (legitEOF) /* actually end of file, so bail. */ break; + if (chdir(nwnbase) != 0) + { + _fatal("Failed to change to product's installation directory."); + return(0); + } /* if */ + /* if there's no identifier, then we're past the game patches. */ if (*header.identifier == '\0') { ui_msgbox("Now we're ready to install the expansion pack.\n" " This will take around 5 to 10 minutes."); - - chdir(".."); /* presumably, this is the base of the install. */ - if (file_exists("./nwn.ini")) - must_prompt_for_location = 0; } /* if */ - if (process_patch_header(&ar, &header) == PATCHERROR) goto do_patching_done; diff --git a/platform_unix.c b/platform_unix.c index 40e1259..09e2a8d 100644 --- a/platform_unix.c +++ b/platform_unix.c @@ -293,9 +293,9 @@ static char *find_info_plist_bundle_id(char *ptr) } /* find_info_plist_version */ -static int parse_info_dot_plist(const char *ident, - const char *version, - const char *newversion) +int parse_info_dot_plist(const char *ident, + const char *version, + const char *newversion) { const char *fname = "Contents/Info.plist"; /* already chdir'd for this. */ char *mem = NULL; @@ -337,17 +337,17 @@ static int parse_info_dot_plist(const char *ident, retval = 1; else { - if (strcmp(ptr, newversion) == 0) - { - _fatal("You seem to be all patched up already!"); +// if (strcmp(ptr, newversion) == 0) +// { + _fatal("You seem to have the required %s patch already!", newversion); retval = -1; - } /* if */ - else - { - _fatal("This patch applies to version '%s', but you have '%s'.", - version, ptr); - retval = 0; - } /* else */ +// } /* if */ +// else +// { +// _fatal("This patch applies to version '%s', but you have '%s'.", +// version, ptr); +// retval = 0; +// } /* else */ } /* else */ } /* if */ @@ -363,6 +363,8 @@ static int parse_info_dot_plist(const char *ident, int update_version(const char *ver) { +return 1; +#if 0 const char *fname = "Contents/Info.plist"; /* already chdir'd for this. */ char *mem = NULL; char *ptr; @@ -400,6 +402,7 @@ int update_version(const char *ver) if (!retval) _fatal("Can't update product's installed version."); return(retval); +#endif } /* update_version */ diff --git a/ui_carbon.c b/ui_carbon.c index c76caff..37d3bdb 100644 --- a/ui_carbon.c +++ b/ui_carbon.c @@ -176,7 +176,7 @@ int manually_locate_product(const char *name, char *buf, size_t bufsize) OSStatus rc; int retval = 0; int yn; - const char *promptfmt = "We can't find your \"%s\" installation." + const char *promptfmt = "We can't find your %s installation." " Would you like to show us where it is?"; char *promptstr = alloca(strlen(name) + strlen(promptfmt) + 1);