[Tool] ftldat r7

Discuss and distribute tools and methods for modding. Moderator - Grognak
MrAdam
Posts: 7
Joined: Mon Oct 08, 2012 12:56 pm

Re: [Tool] ftldat r7

Postby MrAdam » Mon Oct 08, 2012 6:33 pm

Icehawk78 wrote:
MrAdam wrote:Why? Well, I was thinking about making a mod manager with a bit more features than the existing one.

Im an Android developer and I don't have much experience with Java desktop development (started programming Java when I started working with Android), so my skillset is mostly for mobile stuff. Anyways, for what I can see, the .dat files are just binary encoded C objects? I would just like to know the basic structure of those objects, as it would make it much easier for me to work with :)
EDIT: Right now Im trying to get the data reading to work using a library called Preon, which enables be to define the structure of the byte-data, and it can then map it to java classes to make it easier to work with, like this:

Code: Select all

public class FTLData {
    @BoundNumber(byteOrder = ByteOrder.LittleEndian, size = "32")
    public long indexSize;
}

Ah, gotcha. That makes sense (I'm looking into doing something similar with Ruby), then.

From what I can gather, the file format looks to just be this:

Code: Select all

4: Index Size
4*Index Size: Indices
Files: (For each Index)
    4: File Size
    4: Filename Size
    Filename Size: Filename
    File Size: File


Looking up Preon, I'd think you'd want something like this:

Code: Select all

public class BinFile {
    @BoundNumber(size="32", byteOrder=LittleEndian) Integer index_size
    @BoundList(type=Integer.class, size="index_size", byteOrder=LittleEndian)
    @BoundList(type=DataFile.class, size="index_size", byteOrder=LittleEndian)

    public class DataFile {
        @BoundNumber(size="32", byteOrder=LittleEndian) Integer file_size
        @BoundNumber(size="32", byteOrder=LittleEndian) Integer filename_size
        @BoundString(size="filename_size", byteOrder=LittleEndian) String filename
        //@Bound(size="file_size", byteOrder=LittleEndian) ChunkOfData file - not sure offhand how you'd populate this
    }
}


Note: None of this is tested, it's just what I gleaned from the python.

Wow, thanks for the info ;-) Ill test it when I get home in a few hours :)
Icehawk78
Posts: 230
Joined: Tue Sep 18, 2012 4:55 pm

Re: [Tool] ftldat r7

Postby Icehawk78 » Mon Oct 08, 2012 6:43 pm

MrAdam wrote:Wow, thanks for the info ;-) Ill test it when I get home in a few hours :)

No problem, let me know if it works for you.
MrAdam
Posts: 7
Joined: Mon Oct 08, 2012 12:56 pm

Re: [Tool] ftldat r7

Postby MrAdam » Mon Oct 08, 2012 9:25 pm

Icehawk78 wrote:
MrAdam wrote:Wow, thanks for the info ;-) Ill test it when I get home in a few hours :)

No problem, let me know if it works for you.

Well, it kinda works ^_^

Code: Select all

public class BinaryFile {
    @BoundNumber() public int indexSize;
    @BoundList(size = "indexSize") public int[] indexes;
    @BoundList(size = "10") public DataFile[] files;

    public class DataFile {       
        @BoundNumber() public int size;
        @BoundNumber() public int filenameSize;
        @BoundString(size = "filenameSize") public String filename;
        @BoundString(size = "size") public String data;
    }
}

and

Code: Select all

File file = new File("/Users/adam/Desktop/data.dat");
        Codec<BinaryFile> codec = Codecs.create(BinaryFile.class);
        BinaryFile binaryFile = Codecs.decode(codec, file);
        System.out.println(binaryFile.files[0].filename);

gives

Code: Select all

data/achievements.xml

The problem right now is that it fails if the number of files is not the same as the index size, as it will then try to load empty files.. I will have to find out a way for it to only load if the corresponding file index is not 0, thats why the 10 is hardcoded right now

this is what I need for the size parameter of the file array, but haven't figured out how yet.

Code: Select all

public int indexUsed() {
        int n = 0;
        for (int i = 0; i < indexSize; i++)
            if (index[i] != 0) n++;
        return n;
    }
Icehawk78
Posts: 230
Joined: Tue Sep 18, 2012 4:55 pm

Re: [Tool] ftldat r7

Postby Icehawk78 » Mon Oct 08, 2012 11:43 pm

(Slightly modified - sorry, but arrays just bug me because you can't properly loop over them)

Code: Select all

public class BinaryFile {
    @BoundNumber() public Integer indexSize;
    @BoundList(size = "indexSize") public List<Integer> indexes;
    @BoundList(size = "indexUsed()") public List<DataFile> files;

    public int indexUsed() {
        int i = 0;
        for (Integer index : indexes) {
            if (index != 0) {
                i += 1;
            }
        return i;
    }

    public class DataFile {       
        @BoundNumber() public int size;
        @BoundNumber() public int filenameSize;
        @BoundString(size = "filenameSize") public String filename;
        @BoundString(size = "size") public String data;
    }
}


Maybe this will work?
MrAdam
Posts: 7
Joined: Mon Oct 08, 2012 12:56 pm

Re: [Tool] ftldat r7

Postby MrAdam » Mon Oct 08, 2012 11:48 pm

Icehawk78 wrote:(Slightly modified - sorry, but arrays just bug me because you can't properly loop over them)

Code: Select all

public class BinaryFile {
    @BoundNumber() public Integer indexSize;
    @BoundList(size = "indexSize") public List<Integer> indexes;
    @BoundList(size = "indexUsed()") public List<DataFile> files;

    public int indexUsed() {
        int i = 0;
        for (Integer index : indexes) {
            if (index != 0) {
                i += 1;
            }
        return i;
    }

    public class DataFile {       
        @BoundNumber() public int size;
        @BoundNumber() public int filenameSize;
        @BoundString(size = "filenameSize") public String filename;
        @BoundString(size = "size") public String data;
    }
}


Maybe this will work?

You cant reference a function in the size parametre, already tried it :-)
Icehawk78
Posts: 230
Joined: Tue Sep 18, 2012 4:55 pm

Re: [Tool] ftldat r7

Postby Icehawk78 » Tue Oct 09, 2012 12:02 am

MrAdam wrote:You cant reference a function in the size parametre, already tried it :-)

Ah. That sucks.

Maybe if you have some other way of setting a local variable to the output of a function? I'm not certain, I've never worked with that package.
MrAdam
Posts: 7
Joined: Mon Oct 08, 2012 12:56 pm

Re: [Tool] ftldat r7

Postby MrAdam » Tue Oct 09, 2012 9:57 am

Icehawk78 wrote:
MrAdam wrote:You cant reference a function in the size parametre, already tried it :-)

Ah. That sucks.

Maybe if you have some other way of setting a local variable to the output of a function? I'm not certain, I've never worked with that package.

Ill just keep trying and report back ^_^
xXSoulSlayerXx
Posts: 15
Joined: Sun Oct 07, 2012 8:57 am
Location: Flying around the galaxy and pwning rebels...
Contact:

Re: [Tool] ftldat r7

Postby xXSoulSlayerXx » Wed Oct 10, 2012 6:58 am

Your python version is working perfectly! Text based is always the way to go! Hooray to ftldat!!!
Ahhhhhh!!! Not the ion cannons!!!
LordValgor
Posts: 3
Joined: Sun Oct 07, 2012 6:09 pm

Re: [Tool] ftldat r7

Postby LordValgor » Thu Oct 11, 2012 5:57 pm

hmm... the exe version is labled as a trojan by kaspersky, and I can't get the python version to work for the life of me...

I think I will just go the easy route and disable Kaspersky for a bit...
Coolguybest
Posts: 5
Joined: Fri Oct 05, 2012 10:03 pm

Re: [Tool] ftldat r7

Postby Coolguybest » Mon Oct 15, 2012 10:36 pm

Can someone help me (again)?
I tried editing the file myself... I get a window to pop up for a split second (it has writing, at least!)
Here's what I have on the unpack_data:

@ECHO OFF
ftldat unpack C:/Program Files(x86)/Steam/steamapps/common/FTL Faster Than Light/resources

Is this right, or am I completely wrong again?

Who is online

Users browsing this forum: No registered users and 7 guests