units::volume and units::mass readers for mandatory and optional #36354
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
SUMMARY: Infrastructure "implement volume_reader and mass_reader for read and write"
Purpose of change
The purpose of this is to make it simple to read and write various units using optional and mandatory from generic_factory, and also able to serialize easily. The usage for this is pretty straightforward: just add one of the readers as a parameter to optional or mandatory. this will avoid seg faults and having to re implement reading json. The reader does not support legacy units, and we should eventually get away from using legacy 1 = 250 anyway.
Describe alternatives you've considered
writing some kind of helper funciton i suppose? that's basically what this is though
Testing
Ran the game in vanilla, found some errors. talked to anothersimulacrum about it and he PRed several changes already. This needs to have tests run to make sure that in-repo mods are all prepared for it, as I changed one of the loading functions to use this new reader as a proof of concept.
It would be cool to use this for items and monsters, but those have their own specialized classes rather than using generic_factory.