Jump to content






Now This is a Strange File...

Posted by pepoluan, in SW:KotOR, SW:TSL 02 July 2016 · 614 views

swike toolsuite tools GFF

BioWare's GFF files are simply... uhh... perplexing.

 

I had... quite an interesting time trying to grasp my head around the ideas.

 

So this post is kind-of a self-note for me.

 

So, we have "Structs". Inside a Struct, there's a property "FieldCount"

 

A Struct can have one "Field", in which case the "DataOrDataOffset" property contains an index to the "Fields Array", pointing directly to the lone field definition of that Struct.

 

So far so good.

 

But what's interesting is if a Struct has more than one Fields. In this case, the DataOrDataOffset property points to -- here's the key -- somewhere within the "Field Indices" section of the file. Then you get N elements from the Field Indices starting from the location that DataOrDataOffset pointed to (where N is = FieldCount above).

 

In other words, the "Field Indices" list is an "unlabeled" set of Fields. It's a looooong list formed from the list of Fields used by Structs.

 

Illustration:

 

Let's say Struct 1 uses fields 1, 4, 5. Struct 2 uses fields 1, 2, 5, 6. Struct 3 uses fields 3, 4, 5, 6, 7.

 

The content of "Field Indices" will be:

 

1, 4, 5, 1, 2, 5, 6, 3, 4, 5, 6, 7

 

 

Struct_1.FieldCount == 3

Struct_1.DataOrDataOffset == 0 (numbering begins from 0)

Struct_2.FieldCount == 4

Struct_2.DataOrDataOffset == 3

Struct_3.FieldCount == 5

Struct_3.DataOrDataOffset == 7

 

WHew. Now, that's not difficult, isn't it?

 

Now that I can (kinda) grasp the "major structure" and ERD of the GFF file, I should be able to parse dem files...

 

And with this understanding, I also realize that I have to totally rewrite the logic of the current parser, to make things efficient and to enable a file validity checker.

 

Huh.

 

I need some rest.






Self notes save so much time, if only I did this more.... D:

October 2017

S M T W T F S
1234567
891011121314
15161718 19 2021
22232425262728
293031    

Recent Entries

Recent Comments