]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - fs.c
fixed several warnings that appear with -std=gnu99 -pedantic
[xonotic/darkplaces.git] / fs.c
diff --git a/fs.c b/fs.c
index 119499f9b445d62c5723aac1a8bca8590863bd4a..0dfc6eaa7b62e087251c4f4a3e947ac4b0e52edb 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -285,6 +285,7 @@ FUNCTION PROTOTYPES
 
 void FS_Dir_f(void);
 void FS_Ls_f(void);
+void FS_Which_f(void);
 
 static searchpath_t *FS_FindFile (const char *name, int* index, qboolean quiet);
 static packfile_t* FS_AddFileToPack (const char* name, pack_t* pack,
@@ -313,7 +314,7 @@ char fs_basedir[MAX_OSPATH];
 int fs_numgamedirs = 0;
 char fs_gamedirs[MAX_GAMEDIRS][MAX_QPATH];
 
-cvar_t scr_screenshot_name = {0, "scr_screenshot_name","dp", "prefix name for saved screenshots (changes based on -game commandline, as well as which game mode is running)"};
+cvar_t scr_screenshot_name = {0, "scr_screenshot_name","dp", "prefix name for saved screenshots (changes based on -game commandline, as well as which game mode is running; the date is encoded using strftime escapes)"};
 cvar_t fs_empty_files_in_pack_mark_deletions = {0, "fs_empty_files_in_pack_mark_deletions", "0", "if enabled, empty files in a pak/pk3 count as not existing but cancel the search in further packs, effectively allowing patch pak/pk3 files to 'delete' files"};
 
 
@@ -1567,6 +1568,7 @@ void FS_Init_Commands(void)
        Cmd_AddCommand ("path", FS_Path_f, "print searchpath (game directories and archives)");
        Cmd_AddCommand ("dir", FS_Dir_f, "list files in searchpath matching an * filename pattern, one per line");
        Cmd_AddCommand ("ls", FS_Ls_f, "list files in searchpath matching an * filename pattern, multiple per line");
+       Cmd_AddCommand ("which", FS_Which_f, "accepts a file name as argument and reports where the file is taken from");
 }
 
 /*
@@ -3101,6 +3103,29 @@ void FS_Ls_f(void)
        FS_ListDirectoryCmd("ls", false);
 }
 
+void FS_Which_f(void)
+{
+       const char *filename;
+       int index;
+       searchpath_t *sp;
+       if (Cmd_Argc() != 2)
+       {
+               Con_Printf("usage:\n%s <file>\n", Cmd_Argv(0));
+               return;
+       }  
+       filename = Cmd_Argv(1);
+       sp = FS_FindFile(filename, &index, true);
+       if (!sp) {
+               Con_Printf("%s isn't anywhere\n", filename);
+               return;
+       }
+       if (sp->pack)
+               Con_Printf("%s is in package %s\n", filename, sp->pack->shortname);
+       else
+               Con_Printf("%s is file %s%s\n", filename, sp->filename, filename);
+}
+
+
 const char *FS_WhichPack(const char *filename)
 {
        int index;
@@ -3208,7 +3233,7 @@ unsigned char *FS_Deflate(const unsigned char *data, size_t size, size_t *deflat
        strm.next_in = (unsigned char*)data;
        strm.avail_in = size;
 
-       tmp = Mem_Alloc(tempmempool, size);
+       tmp = (unsigned char *) Mem_Alloc(tempmempool, size);
        if(!tmp)
        {
                Con_Printf("FS_Deflate: not enough memory in tempmempool!\n");
@@ -3241,7 +3266,7 @@ unsigned char *FS_Deflate(const unsigned char *data, size_t size, size_t *deflat
                return NULL;
        }
 
-       out = Mem_Alloc(mempool, strm.total_out);
+       out = (unsigned char *) Mem_Alloc(mempool, strm.total_out);
        if(!out)
        {
                Con_Printf("FS_Deflate: not enough memory in target mempool!\n");
@@ -3266,7 +3291,7 @@ static void AssertBufsize(sizebuf_t *buf, int length)
                unsigned char *olddata;
                olddata = buf->data;
                buf->maxsize += length;
-               buf->data = Mem_Alloc(tempmempool, buf->maxsize);
+               buf->data = (unsigned char *) Mem_Alloc(tempmempool, buf->maxsize);
                if(olddata)
                {
                        memcpy(buf->data, olddata, oldsize);
@@ -3285,7 +3310,7 @@ unsigned char *FS_Inflate(const unsigned char *data, size_t size, size_t *inflat
        sizebuf_t outbuf;
 
        memset(&outbuf, 0, sizeof(outbuf));
-       outbuf.data = Mem_Alloc(tempmempool, sizeof(tmp));
+       outbuf.data = (unsigned char *) Mem_Alloc(tempmempool, sizeof(tmp));
        outbuf.maxsize = sizeof(tmp);
 
        memset(&strm, 0, sizeof(strm));
@@ -3347,7 +3372,7 @@ unsigned char *FS_Inflate(const unsigned char *data, size_t size, size_t *inflat
 
        qz_inflateEnd(&strm);
 
-       out = Mem_Alloc(mempool, outbuf.cursize);
+       out = (unsigned char *) Mem_Alloc(mempool, outbuf.cursize);
        if(!out)
        {
                Con_Printf("FS_Inflate: not enough memory in target mempool!\n");