anno-mods / FileDBReader

A command line tool for working with a proprietary bluebyte file compression used in Anno 2205 and 1800.
15 stars 4 forks source link

Fix and Finish new Deserializers #25

Closed Shad0wlife closed 1 year ago

Shad0wlife commented 1 year ago

The first 3 commits are some design fixes, which later affected the Deserializer Implementations as I wrote them.

ReferenceArray Deserialization Handler now checks that the Tag given to it contains a <size> tag, and that the <size> tag is in first position. It also checks that the count of the remaining children after the <size> tag is equal to the value inside the <size> tag. It then iterates over the remaining children and calls their respective handler to create the resulting array. In case of the item type being a Tuple, it also unpacks the Tuple-Wrapping tags, and feeds their content to the Tuple handler.

ListHandler iterates over its children and adds them to a newly created List object (that gets created via reflection from the target type). Special Case: The List handler correctly strides over Tuple-Typed content, to correctly feed the Tuple handler the correct amount of items.

TupleHandler takes a Collection of FileDBNodes and constructs a tuple from them. It correctly unpacks nested Tuples that are surrounded by an extra tag.

FlatArrayHandler is effectively just a ListHandler except that it does not get a tag with the List items in it, but instead gets the Collection of List items directly.

The Test Class for the Unit Test "NewDeserializerTest" has been extended to test all above cases.