Refactor: Logic Rewrite #35

Merged
nwesterhausen merged 93 commits from dev into main 2023-10-24 15:32:28 +00:00
nwesterhausen commented 2023-09-27 19:19:18 +00:00 (Migrated from github.com)

Rewrite of parsing logic.

This was to simplify the parsing from a massive match statement to having each type of raw handle parsing itself. Additionally, instead of a match with strings, this uses a perfect hash table for the strings of the tokens. That gets turned into an enum value which is then matched. It isn't clear if this actually is faster, but it is much much simpler to maintain.

Another change was removing the "conversion" stuff that was handwritten (because I wasn't sure how to use serde_json without caring about the underlying type.. i.e. with Box<dyn trait> situations. However with the typetag library, serde_json actually does all the work and with the generated bindings its very simple to work with the JSON output.

To keep the serialized file size down, any default values are skipped during the serialization step. This makes a huge difference, cutting the size down an order of magnitude. This lets some raws be super specific while others can be fairly plain.

Resolves #4 by letting the program handle COPY_TAGS_FROM tags.

Resolves #20 by letting the lib functions return Vec<Box<dyn RawObject>>

List of features:

  • auto-generate typescript bindings with rs-ts
  • no more custom conversion step, serde handles all serialization
  • adds an Options struct which specifies options for parsing
  • parse creatures
  • parse creature castes
  • parse plants
  • parse plant growths
  • parse tree information
  • parse crop information
  • parse materials
  • parse inorganics
  • parse material templates
  • parse syndromes
  • parse module info files
Rewrite of parsing logic. This was to simplify the parsing from a massive match statement to having each type of raw handle parsing itself. Additionally, instead of a match with strings, this uses a perfect hash table for the strings of the tokens. That gets turned into an `enum` value which is then matched. It isn't clear if this actually is faster, but it is much much simpler to maintain. Another change was removing the "conversion" stuff that was handwritten (because I wasn't sure how to use `serde_json` without caring about the underlying type.. i.e. with `Box<dyn trait>` situations. However with the `typetag` library, `serde_json` actually does all the work and with the generated bindings its very simple to work with the JSON output. To keep the serialized file size down, any default values are skipped during the serialization step. This makes a huge difference, cutting the size down an order of magnitude. This lets some raws be super specific while others can be fairly plain. Resolves #4 by letting the program handle COPY_TAGS_FROM tags. Resolves #20 by letting the lib functions return `Vec<Box<dyn RawObject>>` List of features: - auto-generate typescript bindings with `rs-ts` - no more custom conversion step, `serde` handles all serialization - adds an Options struct which specifies options for parsing - parse creatures - parse creature castes - parse plants - parse plant growths - parse tree information - parse crop information - parse materials - parse inorganics - parse material templates - parse syndromes - parse module info files
Sign in to join this conversation.
No description provided.