shithub: choc

Download patch

ref: 62df1ab1dd5bd04c5e6228cea09442c5177a955e
parent: d03dd75b5c4098f1fa59a4a0074b4770e73d835b
author: Simon Howard <[email protected]>
date: Thu Jul 9 16:08:20 EDT 2009

Select the game to configure automatically if the game name is found
inside the name of the executable. Rename the executable for the Windows
CE install packages.

Subversion-branch: /branches/raven-branch
Subversion-revision: 1612

--- a/pkg/wince/doom-cab.cfg
+++ b/pkg/wince/doom-cab.cfg
@@ -12,8 +12,8 @@
 src = "../../src/"
 
 files = {
-    d+"chocolate-doom.exe":    src+"chocolate-doom.exe",
-    d+"chocolate-setup.exe":   src+"chocolate-setup.exe",
+    d+"chocolate-doom.exe":        src+"chocolate-doom.exe",
+    d+"chocolate-doom-setup.exe":  src+"chocolate-setup.exe",
 }
 
 add_libraries(d, files)
@@ -22,6 +22,6 @@
 
 links = {
     s+"Chocolate Doom.lnk":       d+"chocolate-doom.exe",
-    s+"Chocolate Doom Setup.lnk": d+"chocolate-setup.exe"
+    s+"Chocolate Doom Setup.lnk": d+"chocolate-doom-setup.exe"
 }
 
--- a/pkg/wince/heretic-cab.cfg
+++ b/pkg/wince/heretic-cab.cfg
@@ -12,8 +12,8 @@
 src = "../../src/"
 
 files = {
-    d+"chocolate-heretic.exe": src+"chocolate-heretic.exe",
-    d+"chocolate-setup.exe":   src+"chocolate-setup.exe",
+    d+"chocolate-heretic.exe":       src+"chocolate-heretic.exe",
+    d+"chocolate-heretic-setup.exe": src+"chocolate-setup.exe",
 }
 
 add_libraries(d, files)
@@ -22,6 +22,6 @@
 
 links = {
     s+"Chocolate Heretic.lnk":       d+"chocolate-heretic.exe",
-    s+"Chocolate Heretic Setup.lnk": d+"chocolate-setup.exe"
+    s+"Chocolate Heretic Setup.lnk": d+"chocolate-heretic-setup.exe"
 }
 
--- a/pkg/wince/hexen-cab.cfg
+++ b/pkg/wince/hexen-cab.cfg
@@ -12,8 +12,8 @@
 src = "../../src/"
 
 files = {
-    d+"chocolate-hexen.exe":   src+"chocolate-hexen.exe",
-    d+"chocolate-setup.exe":   src+"chocolate-setup.exe",
+    d+"chocolate-hexen.exe":       src+"chocolate-hexen.exe",
+    d+"chocolate-hexen-setup.exe": src+"chocolate-setup.exe",
 }
 
 add_libraries(d, files)
@@ -22,6 +22,6 @@
 
 links = {
     s+"Chocolate Hexen.lnk":       d+"chocolate-hexen.exe",
-    s+"Chocolate Hexen Setup.lnk": d+"chocolate-setup.exe"
+    s+"Chocolate Hexen Setup.lnk": d+"chocolate-hexen-setup.exe"
 }
 
--- a/src/m_argv.c
+++ b/src/m_argv.c
@@ -243,3 +243,21 @@
     }
 }
 
+// Return the name of the executable used to start the program:
+
+char *M_GetExecutableName(void)
+{
+    char *sep;
+
+    sep = strrchr(myargv[0], DIR_SEPARATOR);
+
+    if (sep == NULL)
+    {
+        return myargv[0];
+    }
+    else
+    {
+        return sep + 1;
+    }
+}
+
--- a/src/m_argv.h
+++ b/src/m_argv.h
@@ -46,4 +46,8 @@
 
 boolean M_ParmExists(char *check);
 
+// Get name of executable used to run this program:
+
+char *M_GetExecutableName(void);
+
 #endif
--- a/src/setup/mode.c
+++ b/src/setup/mode.c
@@ -197,6 +197,32 @@
     return NULL;
 }
 
+// Check the name of the executable.  If it contains one of the game
+// names (eg. chocolate-hexen-setup.exe) then use that game.
+
+static boolean CheckExecutableName(GameSelectCallback callback)
+{
+    mission_config_t *config;
+    char *exe_name;
+    int i;
+
+    exe_name = M_GetExecutableName();
+
+    for (i=0; i<arrlen(mission_configs); ++i)
+    {
+        config = &mission_configs[i];
+
+        if (strstr(exe_name, config->name) != NULL)
+        {
+            SetMission(config);
+            callback();
+            return true;
+        }
+    }
+
+    return false;
+}
+
 static void GameSelected(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(config))
 {
     TXT_CAST_ARG(mission_config_t, config);
@@ -293,7 +319,7 @@
         SetMission(config);
         callback();
     }
-    else
+    else if (!CheckExecutableName(callback))
     {
         OpenGameSelectDialog(callback);
     }