Originally posted by Kazan
yes - there are compiler portability issues, severe performance issues and it's impossible to debug into the STL and see anything useful
however coding to standards for the sake of coding to standards is inherently stupid - VPs are NOT anything like ANY of your standard streams - trying to treat them as if they were is inefficient at best
Oki, actually at work we use STL on large projects (projects which handle tens of megabytes per second file processing and many clients at a time, so I'm not speaking about GUIs or something heh) and I wouldnt say it's impossible to debug...
But anyway, I cant really prove this with words unless talking on a specific example as such I willl let my codes speak for themselves as I do make use of STL and the rest of the standard C++ library where that usage is good. Also about portability, I don't think FS2 being a C++ program should try to support systems that are not fully ANSI C+98 compliant, otherwise why don't we switch FS2 on C89 or something...
Writing a class that treats a file in a manner that is SANE to it's internal formatting is not "reininventing the wheel" - attempting to treat a VP like it could be class vp : public fstream is making a square wheel and calling it perfect
I wouldnt use "perfect" for any codes in the real world
Also, I very much agree with your point, if this is the case here, which is why I'm trying to discuss about this, I would expect great chances to be wrong because I don't have much FS2 codes experience.
the file listing in a VP is structured in a specific manner - files are sorted alphabetically (case sensative) inside their folders - and i believe folders are sorted alphabetically as well, i can go back and check this.
Is this sorting some mandatory requirement ? Why ?
(please bare with me...)
A) you have no way to sort that block in the VP - there is NO ROOM for it in the FAT - we would have to either break support or calculate the block and seek to it's beginning instead of know the position of the file and seek to it to read
B) You have to DECOMPRESS the bloody file
Here you got me lost... By FAT you meand the index in the VP file ? Presuming that you talk about the index and it really needs to be sorted I don't understand how sorting the index has anything to do with how the files are stored (compressed or not). In the end sorting the index just means reordering of the index entries but their values (like the offset to the compressed block that contains the beginning of the file) remains the same. You mean to have the contents of the file also sorted in the order found in the index ? What whould be the purpose of this ?
You seem to be blissfully ignorant of the CPU costs of decompression, the delacacy of the filesystem module in fs2_open, the purpose of VP files.
Well I've been saying that all along, no need for 3 replies to realise that
Yes, I am TOTALLY ignorant of FS2 needs of VP files which probably means the main USE for them their main REASON to exist. As such I am arguing here so someone clearifies this for me.
Reading from a VP:
* Open File, Seek to fat, bitblt fat to memory
* (Close file if you wish)
* Find file in FAT
* (Open File if you closed it)
*Seek to File's offset
*Read File (open i just bitblt small files like textures into a memory block and do everything in ram)
Ok, this doesn't sound too far away of what I had in mind for FS2 usage even not reading those codes...
Reading from a theoretical compressed VP
* Open File, Read Header, Seek FIRST BLOCK that contains fat, decompress it: find the beginning of the FAT in that block, start reading it - decompress any more blocks you need
* Store fat in memory
* (Close file if you wish)
* File file in FAT
* (Open file if you closed it)
* Seek to first compression block, decompress it, find beginning of file, read on decompressing any additional blocks you need
Actually, compressing of the index (if that is what you mean by FAT) was just an option. My last proposal of compressed VP file didn't had such an option. So the index is still stored uncompressed. So the flow becomes:
* Open File, Read Header, read FAT in memory (if that is what you mean by bitblt)
*(Close file if you wish)
* Find file in index (or FAT)
*(Open file if you closed it)
* Seek to first compression block (offset to this is already in the index, so is just an I/O seek), decompress it (OK, some CPU load), find beginning of the file (the block has been decompressed at the previous step IN MEMORY (where else) as such "finding the beginning of the block" just means returning the data that starts there, and you don't need to "seek" it, you have the offset in the decompressed block stored in the index too)
So again, the only overhead I see here is the CPU involved by decompression. Because you still think that this is a huge overhead and I don't think so, I already started working on my own VP library that WILL have this kind of compression support and you could expect some benchmark numbers really soon
Let the numbers speak for themselves...
Compression VASTLY increases EVERY form of overhead, breaks compatability, serves no real purpose
About breaking of compatibility I think Taylor's idea to have these files with their own extension (.cvp) whould solve that because people will see that either their tools has support for .vp only or also for .cvp.
About purpuse, well, can't say I see one big either... not like disk usage is much of an issue and as you also said many files are already compressed. However, there are a lot of "large" files in VPs that do compress a lot, people that distribute uncompressed vp files (ie non-zipped) should be hunted and killed
oh.. and most of the file put in VPs isn't compressable because the file type itself is compressed data (.dds, .jpg,. png) or is uncompressable data (POFs aren't really very compressable.. )
uncompressable/already compressed data accounts for probably about 80% of the data in a VP
Again I don't have much experience but take fsport VP files but for example fsport:
-rw-r--r-- 1 dizzy users 82120116 Aug 29 11:45 tango_fs1.zip
-rw-r--r-- 1 dizzy users 159327089 Aug 29 00:57 tango_fs1.vp
I would say that is a huge difference
(happens on some other fsport VP files too).
In conclusion (if I'm allowed to do that
), let's see how my VP lib project develops and wait for the benchmark numbers. Doesn't seem to be much in purpose for compressed VP files because their only purpose whould be to reduce used disk space AFTER INSTALLATION (that is, people who DISTRIBUTE uncompressed VP files should be killed as stated, this is different from the VP files you keep then in your FS2 dir which can be uncompressed) and I don't think there are many games out there doing that right now as disk space is very cheap. About unification of VP codes, I still think is something that proves good in time but if someone as experienced and influental as Kazan says that it's stupid then I'll drop it (for the moment:)).