diff --git a/include/QF/quakefs.h b/include/QF/quakefs.h index 9ee60c9df..dee718373 100644 --- a/include/QF/quakefs.h +++ b/include/QF/quakefs.h @@ -217,7 +217,6 @@ void QFS_WriteFile (const char *filename, const void *data, int len); \param filename The name of the file to open. \param gzfile Address of file handle pointer. - \param foundname If not NULL, will be set to the real name of the file. \param zip If true and the file has been compressed with gzip, the file will be opened such that it decompresses on the fly. Otherwise, the file will be read as-is. @@ -227,8 +226,7 @@ void QFS_WriteFile (const char *filename, const void *data, int len); occurs while opening the file, this will be -1 and \a *gzfile will be set to NULL. */ -int _QFS_FOpenFile (const char *filename, QFile **gzfile, - struct dstring_s *foundname, int zip); +int _QFS_FOpenFile (const char *filename, QFile **gzfile, int zip); /** Open a file for reading. diff --git a/libs/audio/renderer/snd_mem.c b/libs/audio/renderer/snd_mem.c index dd8b09b0e..13c460cf7 100644 --- a/libs/audio/renderer/snd_mem.c +++ b/libs/audio/renderer/snd_mem.c @@ -293,7 +293,6 @@ SND_StreamAdvance (sfxbuffer_t *buffer, unsigned int count) int SND_Load (sfx_t *sfx) { - dstring_t *foundname = dstring_new (); char *realname; char buf[4]; QFile *file; @@ -303,16 +302,14 @@ SND_Load (sfx_t *sfx) sfx->close = snd_noop; sfx->open = snd_open_fail; - _QFS_FOpenFile (sfx->name, &file, foundname, 1); + QFS_FOpenFile (sfx->name, &file); if (!file) { Sys_Printf ("Couldn't load %s\n", sfx->name); - dstring_delete (foundname); return -1; } sfx->open = snd_open; - if (!strequal (foundname->str, sfx->name)) { - realname = foundname->str; - free (foundname); + if (!strequal (qfs_foundfile.realname, sfx->name)) { + realname = strdup (qfs_foundfile.realname); } else { realname = (char *) sfx->name; // won't free if realname == sfx->name } diff --git a/libs/util/quakefs.c b/libs/util/quakefs.c index 0c14ae6a5..3e4076c85 100644 --- a/libs/util/quakefs.c +++ b/libs/util/quakefs.c @@ -1020,13 +1020,9 @@ VISIBLE findfile_t qfs_foundfile; */ static void -open_file (int_findfile_t *found, QFile **gzfile, dstring_t *foundname, - int zip) +open_file (int_findfile_t *found, QFile **gzfile, int zip) { qfs_foundfile = found->ff; - if (foundname) { - dstring_copystr (foundname, found->ff.realname); - } if (found->ff.in_pak) { *gzfile = qfs_openread (found->pack->filename, found->packfile->filepos, @@ -1037,8 +1033,7 @@ open_file (int_findfile_t *found, QFile **gzfile, dstring_t *foundname, } VISIBLE int -_QFS_FOpenFile (const char *filename, QFile **gzfile, - dstring_t *foundname, int zip) +_QFS_FOpenFile (const char *filename, QFile **gzfile, int zip) { int_findfile_t *found; char *path; @@ -1088,7 +1083,7 @@ _QFS_FOpenFile (const char *filename, QFile **gzfile, found = qfs_findfile (fnames, 0, 0); if (found) { - open_file (found, gzfile, foundname, zip_flags[found->fname_index]); + open_file (found, gzfile, zip_flags[found->fname_index]); free(path); return qfs_filesize; } @@ -1104,7 +1099,7 @@ error: VISIBLE int QFS_FOpenFile (const char *filename, QFile **gzfile) { - return _QFS_FOpenFile (filename, gzfile, 0, 1); + return _QFS_FOpenFile (filename, gzfile, 1); } cache_user_t *loadcache; diff --git a/qw/source/sv_user.c b/qw/source/sv_user.c index 95f8213ce..5a063b6b7 100644 --- a/qw/source/sv_user.c +++ b/qw/source/sv_user.c @@ -717,7 +717,6 @@ static void SV_BeginDownload_f (void *unused) { const char *name; - dstring_t *realname; int http, size, zip; QFile *file; @@ -754,8 +753,7 @@ SV_BeginDownload_f (void *unused) http = sv_http_url_base->string[0] && strchr (Info_ValueForKey (host_client->userinfo, "*cap"), 'h'); - realname = dstring_newstr (); - size = _QFS_FOpenFile (name, &file, realname, !zip); + size = _QFS_FOpenFile (name, &file, !zip); host_client->download = file; host_client->downloadsize = size; @@ -774,41 +772,40 @@ SV_BeginDownload_f (void *unused) MSG_ReliableWrite_Begin (&host_client->backbuf, svc_download, 4); MSG_ReliableWrite_Short (&host_client->backbuf, DL_NOFILE); MSG_ReliableWrite_Byte (&host_client->backbuf, 0); - dstring_delete (realname); return; } if (http) { int size; - int ren = zip && strcmp (realname->str, name); + int ren = zip && strcmp (qfs_foundfile.realname, name); SV_Printf ("http redirect: %s/%s\n", sv_http_url_base->string, - realname->str); - size = ren ? strlen (realname->str) * 2 : strlen (name); + qfs_foundfile.realname); + size = ren ? strlen (qfs_foundfile.realname) * 2 : strlen (name); size += strlen (sv_http_url_base->string) + 7; MSG_ReliableWrite_Begin (&host_client->backbuf, svc_download, size); MSG_ReliableWrite_Short (&host_client->backbuf, DL_HTTP); MSG_ReliableWrite_Byte (&host_client->backbuf, 0); MSG_ReliableWrite_String (&host_client->backbuf, va ("%s/%s", sv_http_url_base->string, - ren ? realname->str : name)); + ren ? qfs_foundfile.realname : name)); MSG_ReliableWrite_String (&host_client->backbuf, - ren ? realname->str : ""); + ren ? qfs_foundfile.realname : ""); if (host_client->download) { Qclose (host_client->download); host_client->download = NULL; } } else { - if (zip && strcmp (realname->str, name)) { - SV_Printf ("download renamed to %s\n", realname->str); + if (zip && strcmp (qfs_foundfile.realname, name)) { + SV_Printf ("download renamed to %s\n", qfs_foundfile.realname); MSG_ReliableWrite_Begin (&host_client->backbuf, svc_download, - strlen (realname->str) + 5); + strlen (qfs_foundfile.realname) + 5); MSG_ReliableWrite_Short (&host_client->backbuf, DL_RENAME); MSG_ReliableWrite_Byte (&host_client->backbuf, 0); - MSG_ReliableWrite_String (&host_client->backbuf, realname->str); + MSG_ReliableWrite_String (&host_client->backbuf, + qfs_foundfile.realname); MSG_Reliable_FinishWrite (&host_client->backbuf); } } - dstring_delete (realname); SV_NextDownload_f (0); SV_Printf ("Downloading %s to %s\n", name, host_client->name);