]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - fs.c
upgraded network protocol to DP5, now sends precise entity angles (except for EF_LOWP...
[xonotic/darkplaces.git] / fs.c
diff --git a/fs.c b/fs.c
index 8ba6759bbc5051ab3c297bbfd80995ec673673a2..2a5ea5a867f3cdbcc5fd4456ba42a42ef3a42593 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -679,7 +679,7 @@ static packfile_t* FS_AddFileToPack (const char* name, pack_t* pack,
 ============
 FS_CreatePath
 
-Only used for FS_WriteFile.
+Only used for FS_Open.
 ============
 */
 void FS_CreatePath (char *path)
@@ -1103,9 +1103,8 @@ static searchpath_t *FS_FindFile (const char *name, int* index, qboolean quiet)
                }
                else
                {
-                       char* netpath;
-
-                       netpath = va ("%s/%s", search->filename, name);
+                       char netpath[MAX_OSPATH];
+                       snprintf(netpath, sizeof(netpath), "%s/%s", search->filename, name);
                        if (FS_SysFileExists (netpath))
                        {
                                if (!quiet)
@@ -1155,7 +1154,11 @@ qfile_t *FS_FOpenFile (const char *filename, qboolean quiet)
 
        // Found in the filesystem?
        if (i < 0)
-               return FS_OpenRead (va ("%s/%s", search->filename, filename), -1, -1);
+       {
+               char netpath[MAX_OSPATH];
+               snprintf(netpath, sizeof(netpath), "%s/%s", search->filename, filename);
+               return FS_OpenRead(netpath, -1, -1);
+       }
 
        // So, we found it in a package...
        packfile = &search->pack->files[i];
@@ -1341,12 +1344,13 @@ size_t FS_Read (qfile_t* file, void* buffer, size_t buffersize)
                // If "input" is also empty, we need to fill it
                if (ztk->in_ind == ztk->in_max)
                {
-                       size_t remain = file->length - ztk->in_position;
+                       size_t remain;
 
                        // If we are at the end of the file
-                       if (!remain)
+                       if (ztk->out_position == ztk->real_length)
                                return nb;
 
+                       remain = file->length - ztk->in_position;
                        count = (remain > sizeof (ztk->input)) ? sizeof (ztk->input) : remain;
                        fread (ztk->input, 1, count, file->stream);