GothicKit / ZenKit

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

MDS file parsing stops early #50

Closed thokkat closed 1 year ago

thokkat commented 1 year ago

In OpenGothic the size of p.animations is smaller for some mds files than if using a pre-phoenix build. E.g. for HumanS.mds only the first 279 of 864 entries are loaded resulting in stuck npc behavior.

This is only a issue for G1, in G2 there's no difference.

Animation::Animation(phoenix::model_script &p, std::string_view name, const bool ignoreErrChunks) {
  ref = std::move(p.aliases);

  for(auto& ani : p.animations) {

https://github.com/Try/OpenGothic/blob/fc1c1343028fb92dbb7b5c1f7ed67b4294b800b3/game/graphics/mesh/animation.cpp#L33

lmichaelis commented 1 year ago

Hey @thokkat, thanks for the report! I did find something while pre-merge testing that is probably this exact issue though I wasn't able to find the cause. I'll look into it :)

zdump output before fix: HUMANS.MDS.txt

lmichaelis commented 1 year ago

Preliminary fix is now available. Changes made are detailed in the commit message :)

thokkat commented 1 year ago

Got this error message while parsing Lurker.mds

error: while parsing mds::dsl_integer
     │
 336 │ ⇨⇨⇨⇨*eventTag⇨("DEF_HIT_LIMB"⇨⇨"BIP01 L PONYTAIL1")
     │                ^ peek failure
error: while parsing mds::dsl_integer
     │
 336 │ ⇨⇨⇨⇨*eventTag⇨("DEF_HIT_LIMB"⇨⇨"BIP01 L PONYTAIL1")
     │                ^ expected digit.decimal

loading error: failed parsing resource of type syntax error
lmichaelis commented 1 year ago

I've checked all vanilla MDS files manually to make sure they are fully parsed. Trough that I've found two more quirks which are now fixed. This is just a temporary solution while I'm implementing a parser that does not use lexy.

There are just too many quirks and programming errors in the source files to keep the current parser around for long. It's already horrible to work with.

thokkat commented 1 year ago

Works, thanks for the quick fix.