foxygit / doom Log in
commit fdcd8dda0935403185ba307304028d3a682297a9
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Sat Jan 30 16:14:04 2010 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Sat Jan 30 16:14:04 2010 +0000

    Change directory to home directory before launching the game, so that
    recorded demos go somewhere sensible.

    Subversion-branch: /trunk/chocolate-doom
    Subversion-revision: 1835
---
 NEWS              |  3 ++-
 pkg/osx/Execute.m | 11 +++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index ba7c81b1..ac12bded 100644
--- a/NEWS
+++ b/NEWS
@@ -9,7 +9,8 @@
        no longer necessary to compile binaries for this system by
        hand.  The package includes a simple graphical launcher
        program and can be installed simply by dragging the "Chocolate
-       Doom" icon to the Applications folder.
+       Doom" icon to the Applications folder. (thanks to Rikard Lang
+       for extensive testing and feedback)
      * The video mode auto-adjust code will automatically choose
        windowed mode if no fullscreen video modes are available.
      * The zone memory size is automatically reduced on systems with
diff --git a/pkg/osx/Execute.m b/pkg/osx/Execute.m
index bb4eed45..608443e2 100644
--- a/pkg/osx/Execute.m
+++ b/pkg/osx/Execute.m
@@ -100,6 +100,7 @@ static void DoExec(const char *executable, const char *iwad, const char *args)
 void ExecuteProgram(const char *executable, const char *iwad, const char *args)
 {
     pid_t childpid;
+    char *homedir;

     childpid = fork();

@@ -107,6 +108,16 @@ void ExecuteProgram(const char *executable, const char *iwad, const char *args)
     {
         signal(SIGCHLD, SIG_DFL);

+        // Change directory to home dir before launch, so that any demos
+        // are saved somewhere sensible.
+
+        homedir = getenv("HOME");
+
+        if (homedir != NULL)
+        {
+            chdir(homedir);
+        }
+
         DoExec(executable, iwad, args);
     }
     else