Twelvesky2 script invalid for reimporting

Doubts, help and support about QuickBMS and other game research tools
silvershadow
Posts: 3
Joined: Tue Jan 11, 2022 3:10 pm

Twelvesky2 script invalid for reimporting

Post by silvershadow »

Hi,
I was using your script to extract some *.dds files from GIMAGE2D files of the twelvesky2 and it worked fine. But when I try to reimport the file using reimporter I'm getting this error.
Image
Even if I don't change the file at all just try to reimport the same dds file it gives me the same error.
I tried adding -. to the reimporter and this time it didn't give any error but it also didn't import anything to the file.
Image
How can I fix this problem?
Thanks for your time.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Twelvesky2 script invalid for reimporting

Post by aluigi »

For that format the decompressed data contains a DDS at offset 0x24, therefore the script decompresses the data in memory and then dumps the dds from that offset.
That's the reason why reimport can't work.

There are a couple of work-arounds but they require some manual work which is obviously impossible if you have many edited dds.
Additionally I don't know/remember what's the content of those 0x24 bytes and if the edited dds may work or something must be edited in that small header too.
silvershadow
Posts: 3
Joined: Tue Jan 11, 2022 3:10 pm

Re: Twelvesky2 script invalid for reimporting

Post by silvershadow »

I have uploaded some IMG files as examples in case you would like to take a look.
I have also uploaded some DDS Header file examples too.
I am completely fine with leaving the header as-is since unless you change the dimensions or file save format of the dds (like DXT3), the header file remains the same.
I just couldn't figure out how to reimport the changed file after the header offset. How can I tinker with the script to repack the new dds file and write it after the offset?
Thanks for your help.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Twelvesky2 script invalid for reimporting

Post by aluigi »

Ok so the following script should do the two jobs:

Code: Select all

get MYSIZE asize
get NAME basename
get EXT extension

if EXT == "IMG"

    get SIZE long
    get ZSIZE long
    if ZSIZE > MYSIZE
        # skip
    else
        savepos OFFSET
        string NAME + ".IMG2"
        clog NAME OFFSET ZSIZE SIZE
    endif

else if EXT == "IMG2"

    math OFFSET = 0x24
    math MYSIZE - OFFSET
    string NAME + ".dds"
    log NAME OFFSET MYSIZE

endif

001_00676.IMG -> 001_00676.IMG2 (a temporary extension I assigned)
001_00676.IMG2 -> 001_00676.dds

It works also in reimport* mode as I just tested:
reimport: 001_00676.dds -> 001_00676.IMG2
reimport2: 001_00676.IMG2 -> 001_00676.IMG

Yeah, the only requirement is using reimport.bat for dds->img2 and reimport2 for img2->img because reimport2 refuses to corrupt the data in the first step.

Note: both reimport.bat and reimpor3 work in the first step, the difference is that reimport3 puts the new data in place of the old one shrinking/enlarging the original content, but this is not the case since the dds is at the end of img2 so there is no data at the end to preserve.
silvershadow
Posts: 3
Joined: Tue Jan 11, 2022 3:10 pm

Re: Twelvesky2 script invalid for reimporting

Post by silvershadow »

Hi,
I have tested the modifications you provided and they worked like a magic. I was confused as to why the script refuses to reimport but now it all makes sense.

Thank you very much and have a nice day. :)