]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - fs.c
sv_public now defaults to 0 except on dedicated servers
[xonotic/darkplaces.git] / fs.c
diff --git a/fs.c b/fs.c
index 39a5aecadd1a68ed823dba01022c27540505f162..0b72b4d125200fc3d0fdb8609dd35764f4f987f2 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -853,8 +853,6 @@ void FS_AddGameHierarchy (const char *dir)
        const char *homedir;
 #endif
 
-       strlcpy (com_modname, dir, sizeof (com_modname));
-
        // Add the common game directory
        FS_AddGameDirectory (va("%s/%s", fs_basedir, dir));
 
@@ -904,14 +902,22 @@ void FS_Init (void)
 
        fs_mempool = Mem_AllocPool("file management", 0, NULL);
 
-       Cvar_RegisterVariable (&scr_screenshot_name);
-
-       Cmd_AddCommand ("path", FS_Path_f);
-       Cmd_AddCommand ("dir", FS_Dir_f);
-       Cmd_AddCommand ("ls", FS_Ls_f);
-
        strcpy(fs_basedir, ".");
-       strcpy(fs_gamedir, ".");
+       strcpy(fs_gamedir, "");
+
+#ifdef MACOSX
+       // FIXME: is there a better way to find the directory outside the .app?
+       if (strstr(com_argv[0], ".app/"))
+       {
+               char *split;
+               char temp[4096];
+               split = strstr(com_argv[0], ".app/");
+               while (split > com_argv[0] && *split != '/')
+                       split--;
+               strlcpy(fs_basedir, com_argv[0], sizeof(fs_basedir));
+               fs_basedir[split - com_argv[0]] = 0;
+       }
+#endif
 
        PK3_OpenLibrary ();
 
@@ -963,7 +969,6 @@ void FS_Init (void)
        // add the game-specific paths
        // gamedirname1 (typically id1)
        FS_AddGameHierarchy (gamedirname1);
-       Cvar_SetQuick (&scr_screenshot_name, gamescreenshotname);
 
        // add the game-specific path, if any
        if (gamedirname2)
@@ -972,6 +977,9 @@ void FS_Init (void)
                FS_AddGameHierarchy (gamedirname2);
        }
 
+       // set the com_modname (reported in server info)
+       strlcpy(com_modname, gamedirname1, sizeof(com_modname));
+
        // -game <gamedir>
        // Adds basedir/gamedir as an override game
        // LordHavoc: now supports multiple -game directories
@@ -984,7 +992,8 @@ void FS_Init (void)
                        i++;
                        fs_modified = true;
                        FS_AddGameHierarchy (com_argv[i]);
-                       Cvar_SetQuick (&scr_screenshot_name, com_modname);
+                       // update the com_modname
+                       strlcpy (com_modname, com_argv[i], sizeof (com_modname));
                }
        }
 
@@ -993,6 +1002,22 @@ void FS_Init (void)
                unlink (va("%s/qconsole.log", fs_gamedir));
 }
 
+void FS_Init_Commands(void)
+{
+       Cvar_RegisterVariable (&scr_screenshot_name);
+
+       Cmd_AddCommand ("path", FS_Path_f);
+       Cmd_AddCommand ("dir", FS_Dir_f);
+       Cmd_AddCommand ("ls", FS_Ls_f);
+
+       // set the default screenshot name to either the mod name or the
+       // gamemode screenshot name
+       if (fs_modified)
+               Cvar_SetQuick (&scr_screenshot_name, com_modname);
+       else
+               Cvar_SetQuick (&scr_screenshot_name, gamescreenshotname);
+}
+
 /*
 ================
 FS_Shutdown