A more or less complete set of hacks. nwn-expansion-packs
authorRyan C. Gordon <icculus@icculus.org>
Wed, 02 Jun 2004 06:39:14 +0000
branchnwn-expansion-packs
changeset 55 9a0e5eb2024d
parent 54 c00701d24133
child 56 b44830f1fdee
A more or less complete set of hacks.
Makefile
MojoPatch.app/Contents/Resources/mojopatch.icns
build-patchfile.sh
mojopatch.c
platform_unix.c
ui_carbon.c
--- a/Makefile	Sun May 30 19:47:59 2004 +0000
+++ b/Makefile	Wed Jun 02 06:39:14 2004 +0000
@@ -25,7 +25,7 @@
 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
Binary file MojoPatch.app/Contents/Resources/mojopatch.icns has changed
--- a/build-patchfile.sh	Sun May 30 19:47:59 2004 +0000
+++ b/build-patchfile.sh	Wed Jun 02 06:39:14 2004 +0000
@@ -3,35 +3,56 @@
 # Just die if anything fails.
 set -e
 
-rm -f ~/Desktop/nwn.mojopatch
-
-./MojoPatch.app/Contents/MacOS/mojopatch  --create --alwaysadd --zliblevel 1 \
---product "Neverwinter Nights Dedicated Server" --identifier "nwserver.icns" \
---version "0.0.1d1" --newversion "1.62" --replace --append --quietonsuccess \
---titlebar "Neverwinter Nights Dedicated Server 1.62 patch" \
-"/Users/icculus/Desktop/nwn.mojopatch" \
-"/Users/icculus/Desktop/Neverwinter Nights orig/Dedicated Server.app" \
-"/Users/icculus/Desktop/nwn162/Dedicated Server.app"
-
-./MojoPatch.app/Contents/MacOS/mojopatch  --create --alwaysadd --zliblevel 1 \
---product "Neverwinter Nights Main Game Icon" --identifier "nwmain.icns" \
---version "0.0.1d1" --newversion "1.62" --replace --append --quietonsuccess \
---titlebar "Neverwinter Nights 1.62 patch" \
-"/Users/icculus/Desktop/nwn.mojopatch" \
-"/Users/icculus/Desktop/Neverwinter Nights orig/Neverwinter Nights.app" \
-"/Users/icculus/Desktop/nwn162/Neverwinter Nights.app"
+# revert everything to a sane state.
+make
+strip -S ./bin/mojopatch
+mv ./bin/mojopatch ./MojoPatch.app/Contents/MacOS/
+rm -rf ./MojoPatch.app/default.mojopatch
+rm -rf "/Users/icculus/Desktop/Shadows of Undrentide Installer.app"
+rm -rf "/Users/icculus/Desktop/Hordes of the Underdark Installer.app"
 
 # Just a blank dir, so everything in the patch dir is added in the patch...
 mkdir -p tmp
 
+# Put the 1.62 patch together...
 ./MojoPatch.app/Contents/MacOS/mojopatch  --create --alwaysadd --zliblevel 1 \
---product "Neverwinter Nights base folder" \
---version "Neverwinter Nights.app" --replace --append \
+--product "Neverwinter Nights" \
+--identifier "nwmain.icns" \
+--version "0.0.1d1" --newversion "1.62" --replace --append --quietonsuccess \
+--titlebar "Neverwinter Nights 1.62 patch" \
+"./MojoPatch.app/default.mojopatch" \
+"./tmp" \
+"/Users/icculus/Desktop/nwn162"
+
+# Copy initial patchfile to seperate expansion pack installers...
+echo "copying initial patch to SoU branch..."
+cp -R MojoPatch.app "/Users/icculus/Desktop/Shadows of Undrentide Installer.app"
+rm -f "/Users/icculus/Desktop/Shadows of Undrentide Installer.app/Contents/MacOS/xdelta"
+
+echo "copying initial patch to HotU branch..."
+cp -R MojoPatch.app "/Users/icculus/Desktop/Hordes of the Underdark Installer.app"
+rm -f "/Users/icculus/Desktop/Hordes of the Underdark Installer.app/Contents/MacOS/xdelta"
+
+# Add XP1 data to patchfile...
+./MojoPatch.app/Contents/MacOS/mojopatch  --create --alwaysadd --zliblevel 1 \
+--product "Neverwinter Nights" \
+--identifier "SoU" \
+--version "a" --newversion "b" --replace --append --quietonsuccess \
 --titlebar "NWN Shadows of Undrentide Expansion Pack" \
-"/Users/icculus/Desktop/nwn.mojopatch" \
+"/Users/icculus/Desktop/Shadows of Undrentide Installer.app/default.mojopatch" \
 "./tmp" \
 "/Users/icculus/Desktop/XP1/XP1-1.62.8047e"
 
+# Add XP2 data to the other patchfile...
+./MojoPatch.app/Contents/MacOS/mojopatch  --create --alwaysadd --zliblevel 1 \
+--product "Neverwinter Nights" \
+--identifier "HotU" \
+--version "a" --newversion "b" --replace --append \
+--titlebar "NWN Hordes of the Underdark Expansion Pack" \
+"/Users/icculus/Desktop/Hordes of the Underdark Installer.app/default.mojopatch" \
+"./tmp" \
+"/Users/icculus/Desktop/XP2/XP2-1.62.8047e"
+
 rmdir tmp
 
 exit 0;
--- a/mojopatch.c	Sun May 30 19:47:59 2004 +0000
+++ b/mojopatch.c	Wed Jun 02 06:39:14 2004 +0000
@@ -1,7 +1,7 @@
 /*
  *----------------------------------------------------------------------------
  *
- * mojopatch
+ * mojopatch : nwn expansion pack branch
  * Copyright (C) 2003  Ryan C. Gordon.
  *
  *----------------------------------------------------------------------------
@@ -43,7 +43,7 @@
 #define VER_EXT_ZLIB " (w/zlib)"
 #endif
 
-#define VERSION "0.0.5" VER_EXT_ZLIB
+#define VERSION "0.0.5nwnxp" VER_EXT_ZLIB
 
 #define DEFAULT_PATCHFILENAME "default.mojopatch"
 
@@ -165,9 +165,6 @@
     ZLIB_UNCOMPRESS
 } ZlibOptions;
 
-/* This is a hack. */
-static int must_prompt_for_location = 1;
-
 static int debug = 0;
 static int interactive = 0;
 static int replace = 0;
@@ -577,25 +574,7 @@
 /* don't taunt this function. */
 int version_ok(const char *ver, const char *allowed_ver)
 {
-    char *ptr;
-    char *buf;
-
-    if (*allowed_ver == '\0')
-        return 1;  /* No specified version? Anything is okay, then. */
-
-    buf = (char *) alloca(strlen(allowed_ver) + 1);
-    strcpy(buf, allowed_ver);
-
-    while ((ptr = strstr(buf, " or ")) != NULL)
-    {
-        *ptr = '\0';
-        if (strcmp(ver, buf) == 0)
-            return(1);
-
-        buf = ptr + 4;
-    } /* while */
-
-    return(strcmp(ver, buf) == 0);
+    return(strcmp(ver, "0.0.1d1") == 0);
 } /* version_ok */
 
 
@@ -1118,8 +1097,7 @@
     struct stat statbuf;
     int retval = PATCHERROR;
 
-    _current_operation("%s %s", (replace) ? "ADDORREPLACE" : "ADD",
-                        final_path_element(fname));
+    _current_operation("Installing file %s ...", final_path_element(fname));
     _log("%s %s", (replace) ? "ADDORREPLACE" : "ADD", fname);
 
     if (!confirm())
@@ -1175,8 +1153,7 @@
     FILE *io = NULL;
     int rc;
 
-    _current_operation("%s %s", (replace_ok) ? "ADDORREPLACE" : "ADD",
-                          final_path_element(add->fname));
+    _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 @@
             } /* 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 @@
 
     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 @@
 
     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 @@
         else if (rc == -1)
             skip_patch = 1;
     } /* if */
+#endif
 
     if (*h->readmefname)
     {
@@ -2027,6 +2006,55 @@
     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 @@
     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 @@
         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;
 
--- a/platform_unix.c	Sun May 30 19:47:59 2004 +0000
+++ b/platform_unix.c	Wed Jun 02 06:39:14 2004 +0000
@@ -293,9 +293,9 @@
 } /* 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 @@
             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 @@
 
 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 @@
 
     if (!retval) _fatal("Can't update product's installed version.");
     return(retval);
+#endif
 } /* update_version */
 
 
--- a/ui_carbon.c	Sun May 30 19:47:59 2004 +0000
+++ b/ui_carbon.c	Wed Jun 02 06:39:14 2004 +0000
@@ -176,7 +176,7 @@
     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);