• util.Compress/Decompress - What algorithm is it using?
    7 replies, posted
I want to work with compressed data outside of GMod. In the older days, I had remembered it used "FastLZ", but last night I went to check up the docs: [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/util/Compress]util.Compress[/url] It now says "LZMA", and points to the wikipedia page. Reading down the wikipedia page, I found a link to a .NET library "Noemax" which offers a bunch of compression factories. But, as I have just tested a same input on all algorithms and all compression levels, I found no match against what's returned by the game Compress function... Ok, compression didn't turn positive for any of the algorithms provided by said library. I then tested a decompression of all factories on the compressed test file produced by gmod (compressed.txt). A program threw an exception on all factories... I was stumped. Soo, what is the algorithm behind ingame de/compression function?? Is it FastLZ? If so, then why the **** did you change it? Here is a pointer to a history where it had been changed off: util.Compress ~ CaptainPRICE
Last I checked gmod was using Garry's bootil library for compression. You can see how he does this here https://github.com/garrynewman/bootil/blob/master/src/Bootil/Utility/CompressionLZMA.cpp Garry's Mod is most definitely using LZMA for compressing lua files shared between client & server.
The question is, how bootil's LZMA different from standard LZMA? (Soo much that any .NET library I have tried, couldn't decompress a test file.)
Bootil is using the standard LZMA. They are using the SDK from 7z. https://github.com/garrynewman/bootil/blob/1d3e321fc2be359e2350205b8c7f1cad2164ee0b/src/3rdParty/lzma/lzma.txt#L597
But, I have already confirmed that these 2 functions aren't using standard LZMA. Could you provide me some .NET library which can successfully decompress a test file produced by GMod util.Compress?
They are most definitely LZMA, but the contents may not be in compliance with the library you are using. The headers are all different in different LZMA implementations.
I confirmed it by reversing, right before your post... Anyways, I have finally got to Bootil... Here it is, compiled for all happy Windows users (I had to export FastLZ manually tho): bootil.zip Pick it up, and P/Invoking!
I had the best luck in Linux by using LZMA Utils, it produces a compressed file with compatible headers for Garry's Mod and is really easy to build.
Sorry, you need to Log In to post a reply to this thread.