Sign in to follow this  
  • entries
    3
  • comments
    2
  • views
    5,488

Now This is a Strange File...

pepoluan

1,815 views

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.



1 Comment


Recommended Comments

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.