[SOLVED] How does the decompression of files within pk3s work? - Printable Version +- Xonotic Forums (https://forums.xonotic.org) +-- Forum: Creating & Contributing (https://forums.xonotic.org/forumdisplay.php?fid=10) +--- Forum: Xonotic - Development (https://forums.xonotic.org/forumdisplay.php?fid=12) +--- Thread: [SOLVED] How does the decompression of files within pk3s work? (/showthread.php?tid=2202) |
[SOLVED] How does the decompression of files within pk3s work? - joshbeck - 09-29-2011 So I'm trying to read the darkplaces/fs.c code but it's sort of hard to understand. The big thing that I don't get is where decompression happens. Does it happen all at once for each pk3, and then the decompressed pk3 is stored in RAM/virtual memory, or does decompression happen as-needed for each requested file? I suspect it's the latter. However what I don't get is where this happens, unless inflateInit2 decompresses files (but the zlib manual says it doesn't). You'd expect that fs.c would work in such a way such that when an already-decompressed file is requested, the address to its location in RAM would be provided, and if the file requested isn't already decompressed, then fs.c would decompress it and return its address. I don't see where this is going on. In fact, there's only one place in the Darkplaces engine where an actual inflate() call is made, and the function that contains it is only called once in cl_parse.c for decompressing files downloaded from a server. So can someone explain how fs.c handles decompressing files within pak3 files? RE: How does the decompression of files within pk3s work? - Halogene - 09-29-2011 Welcome to Xonotic! May I recommend to you: Xonotic development IRC channel #xonotic on freenode. I am sure that this channel would be a valuable medium for information exchange for you. You will probably receive an answer on this forum, too, but this sounds just like a question someone like divVerent would be able to answer to you within minutes via IRC (no warranty tho). I for one can identify myself only with your first sentence except that I don't try to read the code. Edit: Just for the avoidance of doubts: I didn't mean to tell you this forum is wrong for asking such specific questions, just wanted to point you to an additional communication channel that might prove effevtive. RE: How does the decompression of files within pk3s work? - divVerent - 09-29-2011 It is happening on FS_Read() in fs.c, which calls qz_Inflate, which points to zlib's inflate function. RE: How does the decompression of files within pk3s work? - joshbeck - 09-29-2011 Thanks! |