]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - common.c
added cl_avidemo cvar (saves a series of tga images named gamedir/dpavi000000.tga...
[xonotic/darkplaces.git] / common.c
index bc7cfea3efd076519b1b3cce5d49e4d0820da6cb..80a7389fc3b1e372a7e6d7a731e802e4f7991583 100644 (file)
--- a/common.c
+++ b/common.c
@@ -841,8 +841,8 @@ void COM_StripExtension (char *in, char *out)
        while (*in)
        {
                if (*in == '.')
-                       last = in;
-               if ((*in == '/') || (*in == '\\') || (*in == ':'))
+                       last = out;
+               else if (*in == '/' || *in == '\\' || *in == ':')
                        last = NULL;
                *out++ = *in++;
        }
@@ -1126,14 +1126,18 @@ void COM_InitArgv (int argc, char **argv)
        largv[com_argc] = argvdummy;
        com_argv = largv;
 
-#if ZYMOTIC
+#if BLOODBATH
+       gamemode = GAME_BLOODBATH;
+#elif ZYMOTIC
        gamemode = GAME_ZYMOTIC;
 #elif FIENDARENA
        gamemode = GAME_FIENDARENA;
 #elif NEHAHRA
        gamemode = GAME_NEHAHRA;
 #else
-       if (COM_CheckParm ("-zymotic"))
+       if (COM_CheckParm ("-bloodbath"))
+               gamemode = GAME_BLOODBATH;
+       else if (COM_CheckParm ("-zymotic"))
                gamemode = GAME_ZYMOTIC;
        else if (COM_CheckParm ("-fiendarena"))
                gamemode = GAME_FIENDARENA;
@@ -1164,6 +1168,9 @@ void COM_InitArgv (int argc, char **argv)
        case GAME_ZYMOTIC:
                gamename = "Zymotic";
                break;
+       case GAME_BLOODBATH:
+               gamename = "BloodBath";
+               break;
        default:
                Sys_Error("COM_InitArgv: unknown gamemode %i\n", gamemode);
                break;
@@ -1355,8 +1362,9 @@ void    COM_CreatePath (char *path)
 
        for (ofs = path+1 ; *ofs ; ofs++)
        {
-               if (*ofs == '/' || *ofs == '\\' || *ofs == ':')
-               {       // create the directory
+               if (*ofs == '/' || *ofs == '\\')
+               {
+                       // create the directory
                        save = *ofs;
                        *ofs = 0;
                        Sys_mkdir (path);
@@ -1373,7 +1381,7 @@ COM_WriteFile
 The filename will be prefixed by the current game directory
 ============
 */
-void COM_WriteFile (char *filename, void *data, int len)
+qboolean COM_WriteFile (char *filename, void *data, int len)
 {
        int             handle;
        char    name[MAX_OSPATH];
@@ -1386,13 +1394,14 @@ void COM_WriteFile (char *filename, void *data, int len)
        handle = Sys_FileOpenWrite (name);
        if (handle == -1)
        {
-               Sys_Printf ("COM_WriteFile: failed on %s\n", name);
-               return;
+               Con_Printf ("COM_WriteFile: failed on %s\n", name);
+               return false;
        }
 
-       Con_Printf ("COM_WriteFile: %s\n", name);
+       Con_DPrintf ("COM_WriteFile: %s\n", name);
        Sys_FileWrite (handle, data, len);
        Sys_FileClose (handle);
+       return true;
 }
 
 
@@ -1720,10 +1729,11 @@ then loads and adds pak1.pak pak2.pak ...
 */
 void COM_AddGameDirectory (char *dir)
 {
-       int                             i;
-       searchpath_t    *search;
-       pack_t                  *pak;
-       char                    pakfile[MAX_OSPATH];
+       //int i;
+       stringlist_t *list, *current;
+       searchpath_t *search;
+       pack_t *pak;
+       char pakfile[MAX_OSPATH];
 
        strcpy (com_gamedir, dir);
 
@@ -1735,6 +1745,28 @@ void COM_AddGameDirectory (char *dir)
        search->next = com_searchpaths;
        com_searchpaths = search;
 
+       // add any paks in the directory
+       list = listdirectory(dir);
+       for (current = list;current;current = current->next)
+       {
+               if (matchpattern(current->text, "*.pak"))
+               {
+                       sprintf (pakfile, "%s/%s", dir, current->text);
+                       pak = COM_LoadPackFile (pakfile);
+                       if (pak)
+                       {
+                               search = Mem_Alloc(pak_mempool, sizeof(searchpath_t));
+                               search->pack = pak;
+                               search->next = com_searchpaths;
+                               com_searchpaths = search;
+                       }
+                       else
+                               Con_Printf("unable to load pak \"%s\"\n", pakfile);
+               }
+       }
+       freedirectory(list);
+
+       /*
 //
 // add any pak files in the format pak0.pak pak1.pak, ...
 //
@@ -1749,6 +1781,7 @@ void COM_AddGameDirectory (char *dir)
                search->next = com_searchpaths;
                com_searchpaths = search;
        }
+       */
 
 //
 // add the contents of the parms.txt file to the end of the command line
@@ -1827,6 +1860,9 @@ void COM_InitFilesystem (void)
        case GAME_ZYMOTIC:
                COM_AddGameDirectory (va("%s/zymotic", basedir) );
                break;
+       case GAME_BLOODBATH:
+               COM_AddGameDirectory (va("%s/bb", basedir) );
+               break;
        default:
                Sys_Error("COM_InitFilesystem: unknown gamemode %i\n", gamemode);
                break;