GothicKit / ZenKit

A re-implementation of file formats used by the early 2000's ZenGin
http://zk.gothickit.dev/
MIT License
44 stars 10 forks source link

[v2.0.0] Uniform parse syntax #11

Closed lmichaelis closed 8 months ago

lmichaelis commented 1 year ago

Instead of defining a parse static member function for each entity, there should instead be a uniform

namespace phoenix {
    template <typename T>
    T parse(buffer&);

    template <typename T>
    T parse(buffer&&);

    template <typename T>
    T parse(archive_reader&);
}

This can only be implemented if a heuristic for detecting the Gothic version within worlds can be found. One idea would be to search through the archive's key-map to find object keys only present in Gothic 2 VObs, like visualAniMode (probably unlikely to yield good results since it's in the base zCVob which is most likely packed), canMove or fadeOutSky. It might still be a good idea, however, to keep the explicit version around somehow, so consumers of the library can prevent loading the wrong version anyways.

This alteration should also apply to dumping function (if implemented):

namespace phoenix {
    template <typename T>
    buffer dump(const T&);
}
lmichaelis commented 1 year ago

Still to convert: