carmineos / rage-toolkit

Other
19 stars 6 forks source link

Either Importing/Exporting ytd not working correctly? #35

Open xZToxicZx opened 1 year ago

xZToxicZx commented 1 year ago

I load the TXD like so:

        var ytd = new TextureDictionaryFileWrapper_GTA5_pc();
        ytd.Load(file.FullName);
        Console.WriteLine(file.FullName);

Then export again doing nothing in between the last line and this line:

        var output = Path.Join(file.Directory.FullName, "[done]", file.Name);
        Console.WriteLine(output);
        ytd.Save(output);

The input file size is 4,699kb output is 5,201kb. When attempting to load into game some of the textures dont load and some do? Digging into it further OpenIV when attempting to import the original dds files it duplicates them? Not sure if this could be an issue with naming or something else but thought I'd try be in depth since I've been at this for about 5 hours now. Please let me know if I'm being dumb or this is a bug because I cant seem to figure it out.

xZToxicZx commented 1 year ago

Issue is when importing. Stream still includes header here:

            var deflateStream = new DeflateStream(stream, CompressionMode.Decompress, true);
            deflateStream.ReadExactly(VirtualData, 0, (int)virtualSize);
            deflateStream.ReadExactly(PhysicalData, 0, (int)physicalSize);
            deflateStream.Close();

I've fixed locally will do a pull request if this repo is even still active.

xZToxicZx commented 1 year ago

The above is incorrect, issue is to do with UpdateClass in TextureDictionaryWrapper_GTA5_pc Have just commented locally and seems to have fixed, it only affects textures that have any transparency to them

carmineos commented 1 year ago

It is possible that ResourceWrappers have bugs, specially those related to textures. Note that resource wrappers are still old code from original gta-toolkit, they should be a way to expose high level API to handle resources but they are far from ready as even low level API aren't complete.