summaryrefslogtreecommitdiff
path: root/src/common/files.c
diff options
context:
space:
mode:
authorAndrey Nazarov <skuller@skuller.net>2013-02-03 22:03:28 +0400
committerAndrey Nazarov <skuller@skuller.net>2013-02-03 22:12:21 +0400
commitd47a61ab6b83377705e11f725e7a7b4e527be5e9 (patch)
treefbd61edf8b023b32a9876bb20259a9875b291ecd /src/common/files.c
parent8b05e7f3a9972da520eff04e0af36e19ed0eb6d4 (diff)
Support reading raw deflated data from *.pkz files.
Diffstat (limited to 'src/common/files.c')
-rw-r--r--src/common/files.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/common/files.c b/src/common/files.c
index ecb759a..d0a5f4c 100644
--- a/src/common/files.c
+++ b/src/common/files.c
@@ -1229,7 +1229,12 @@ static ssize_t open_from_pak(file_t *file, pack_t *pack, packfile_t *entry, qboo
#if USE_ZLIB
if (pack->type == FS_ZIP) {
- if (entry->compmtd) {
+ if (file->mode & FS_FLAG_DEFLATE) {
+ // server wants raw deflated data for downloads
+ file->type = FS_PAK;
+ file->rest_out = entry->complen;
+ file->length = entry->complen;
+ } else if (entry->compmtd) {
open_zip_file(file);
} else {
// stored, just pretend it's a packfile
@@ -1244,9 +1249,9 @@ static ssize_t open_from_pak(file_t *file, pack_t *pack, packfile_t *entry, qboo
}
FS_DPrintf("%s: %s/%s: %"PRIz" bytes\n",
- __func__, pack->filename, entry->name, entry->filelen);
+ __func__, pack->filename, entry->name, file->length);
- return entry->filelen;
+ return file->length;
fail2:
if (unique) {
@@ -1328,13 +1333,23 @@ static ssize_t open_file_read(file_t *file, const char *normalized, size_t namel
if (namelen >= MAX_QPATH) {
continue;
}
- // look through all the pak file elements
pak = search->pack;
+#if USE_ZLIB
+ if ((file->mode & FS_FLAG_DEFLATE) && pak->type != FS_ZIP) {
+ continue;
+ }
+#endif
+ // look through all the pak file elements
entry = pak->file_hash[hash & (pak->hash_size - 1)];
for (; entry; entry = entry->hash_next) {
if (entry->namelen != namelen) {
continue;
}
+#if USE_ZLIB
+ if ((file->mode & FS_FLAG_DEFLATE) && entry->compmtd != Z_DEFLATED) {
+ continue;
+ }
+#endif
FS_COUNT_STRCMP;
if (!FS_pathcmp(entry->name, normalized)) {
// found it!
@@ -1345,6 +1360,11 @@ static ssize_t open_file_read(file_t *file, const char *normalized, size_t namel
if ((file->mode & FS_TYPE_MASK) == FS_TYPE_PAK) {
continue;
}
+#if USE_ZLIB
+ if (file->mode & FS_FLAG_DEFLATE) {
+ continue;
+ }
+#endif
// don't error out immediately if the path is found to be invalid,
// just stop looking for it in directory tree but continue to search
// for it in packs, to give broken maps or mods a chance to work