df-structures icon indicating copy to clipboard operation
df-structures copied to clipboard

Idea: Standard attributes for "variable" size arrays determined by known field(s)

Open PatrikLundell opened this issue 5 years ago • 4 comments

One important example would be df.global.world.world_data.region_map, where the size of the array is based on the width of the world, a value that can be found in world_width in the parent struct, with the elements themselves being (pointers to) arrays of a size determined by the world height element.

A trickier case would be the very next element, currently called unk_1c4, which is a 2D matrix with dimensions controlled by the same parameters.

The immediate purpose of the suggestion would be to provide writers/readers of the XML with a standardized method for describing these relations, while the longer term objective would be to allow code and scripts to access the info (imagine gui/gm-editor being able to show the region_map elements for all the world tiles, for instance).

Possible names for such attributes might be ref-count, ref-count1, ref-count2, ref_count3 (taking cues from "ref-target", and "count" for static arrays, for the respective parts). ref-count and ref-count1 would be identical in function, with the difference being that the "1" version would imply to a reader that there are more than 1 dimensions.

The presence of one or more ref-count attributes implies the "is-array='true'" attribute functionality, and thus ought to be mutually exclusive in the .xsd file.

PatrikLundell avatar May 14 '20 09:05 PatrikLundell

Please don't use "ref-count" if this is not about reference counting. This abbreviation is too common to be misused.

cvuchener avatar May 14 '20 10:05 cvuchener

Good point. What about "ref-size"?

PatrikLundell avatar May 14 '20 10:05 PatrikLundell

I feel like we only need one ref-size attribute, and we can just put ref-size on the inner pointer if we need to specify multiple dimensions

BenLubar avatar May 14 '20 19:05 BenLubar

Hm, so the second example would be split into an array of arrays (there's no pointer available)? That ought to work.

PatrikLundell avatar May 14 '20 19:05 PatrikLundell