- Cmd_AddCommand(&cmd_client, "gamedir", FS_GameDir_f, "changes active gamedir list (can take multiple arguments), not including base directory (example usage: gamedir ctf)");
- Cmd_AddCommand(&cmd_client, "fs_rescan", FS_Rescan_f, "rescans filesystem for new pack archives and any other changes");
- Cmd_AddCommand(&cmd_client, "path", FS_Path_f, "print searchpath (game directories and archives)");
- Cmd_AddCommand(&cmd_client, "dir", FS_Dir_f, "list files in searchpath matching an * filename pattern, one per line");
- Cmd_AddCommand(&cmd_client, "ls", FS_Ls_f, "list files in searchpath matching an * filename pattern, multiple per line");
- Cmd_AddCommand(&cmd_client, "which", FS_Which_f, "accepts a file name as argument and reports where the file is taken from");
-
- Cmd_AddCommand(&cmd_server, "gamedir", FS_GameDir_f, "changes active gamedir list (can take multiple arguments), not including base directory (example usage: gamedir ctf)");
- Cmd_AddCommand(&cmd_server, "fs_rescan", FS_Rescan_f, "rescans filesystem for new pack archives and any other changes");
- Cmd_AddCommand(&cmd_server, "path", FS_Path_f, "print searchpath (game directories and archives)");
- Cmd_AddCommand(&cmd_server, "dir", FS_Dir_f, "list files in searchpath matching an * filename pattern, one per line");
- Cmd_AddCommand(&cmd_server, "ls", FS_Ls_f, "list files in searchpath matching an * filename pattern, multiple per line");
- Cmd_AddCommand(&cmd_server, "which", FS_Which_f, "accepts a file name as argument and reports where the file is taken from");
+ // Load darkplaces.opt from the FS.
+ if (!Sys_CheckParm("-noopt"))
+ {
+ buf = (char *) FS_SysLoadFile("darkplaces.opt", tempmempool, true, NULL);
+ if(buf)
+ {
+ COM_InsertFlags(buf);
+ Mem_Free(buf);
+ }
+ }
+
+#ifndef USE_RWOPS
+ // Provide the SelfPack.
+ if (!Sys_CheckParm("-noselfpack") && sys.selffd >= 0)
+ {
+ fs_selfpack = FS_LoadPackPK3FromFD(sys.argv[0], sys.selffd, true);
+ if(fs_selfpack)
+ {
+ FS_AddSelfPack();
+ if (!Sys_CheckParm("-noopt"))
+ {
+ buf = (char *) FS_LoadFile("darkplaces.opt", tempmempool, true, NULL);
+ if(buf)
+ {
+ COM_InsertFlags(buf);
+ Mem_Free(buf);
+ }
+ }
+ }
+ }
+#endif
+}
+
+/*
+================
+FS_Init
+================
+*/
+
+void FS_Init(void)
+{
+ fs_mempool = Mem_AllocPool("file management", 0, NULL);
+
+ FS_Init_Commands();
+
+ PK3_OpenLibrary ();
+
+ // initialize the self-pack (must be before COM_InitGameType as it may add command line options)
+ FS_Init_SelfPack();
+
+ // detect gamemode from commandline options or executable name
+ COM_InitGameType();
+
+ FS_Init_Dir();