raduprv / Eternal-Lands

http://www.eternal-lands.com
Other
158 stars 57 forks source link

Replace binary format files for counters, recipies, spells and the el.cfg with text versions. #71

Closed pjbroad closed 2 years ago

pjbroad commented 4 years ago

Several user configuration files use binary formats, basically, dumping and restoring the raw C structure to and from disk. This is a really back idea as it is so fragile. If the structure is modified, the saved file will no longer be read back properly. It will also potentially break if you switch between 32 and 64 bit version of the client, or copy your files between different endianness CPUs.

We should replace these formats with text versions that can adapt more easily to change.

pjbroad commented 4 years ago

This looks like a good choice: https://github.com/hyperrealm/libconfig

gvissers commented 4 years ago

I fully agree with the goals, but how about using a more standardised format, like JSON?

pjbroad commented 4 years ago

I did consider json and would do so again, I use it all the time elsewhere but not with C/C++ code. Do you have any recommended libraries. I've had a play with nlohmann/json which is really nice. Its available as a package on Linux and the mingw environment I use to build on windows.

pjbroad commented 4 years ago

I have a working version saving and loading the recipes using the nlohmann/json code.

gvissers commented 4 years ago

I did consider json and would do so again, I use it all the time elsewhere but not with C/C++ code.

TBH, neither have I. I mostly use Rust nowadays.

Do you have any recommended libraries. I've had a play with nlohmann/json which is really nice. Its available as a package on Linux and the mingw environment I use to build on windows.

Sorry, no recommendations. I just happen to like JSON for its conciseness and because there's broad support for it everywhere. I took a quick look at the project you mentioned, and it looks impressive. If the code is as good as the feature set and documentation promises, I'd certainly have no problem using it.

But, as I'm not the one that's going to implement this, I'll leave the decision up to you. I just thought that a format with broad support in the wider programming world might be better. I'm going back to beating the font handling code into shape. I think I may need a bigger hammer...

pjbroad commented 4 years ago

Well you successfully helped me change my mind. I've done the recipe file using json and I'll commit the changes in a bit. I'd be interested to hear what you're planning for the font handing. Perhaps raise an issue? :)

pjbroad commented 2 years ago

Item Lists remain but at least its already a text file. Closing.